Container changes (#320)

Added container metrics
This commit is contained in:
Sachin Kumar
2019-03-13 13:31:29 -07:00
committed by Calle Pettersson
parent 517cd3b04b
commit 8841091f9c
388 changed files with 48899 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package wcow
import (
"os"
"path/filepath"
"github.com/Microsoft/hcsshim/internal/copyfile"
"github.com/Microsoft/hcsshim/internal/wclayer"
"github.com/sirupsen/logrus"
)
// CreateUVMScratch is a helper to create a scratch for a Windows utility VM
// with permissions to the specified VM ID in a specified directory
func CreateUVMScratch(imagePath, destDirectory, vmID string) error {
sourceScratch := filepath.Join(imagePath, `UtilityVM\SystemTemplate.vhdx`)
targetScratch := filepath.Join(destDirectory, "sandbox.vhdx")
logrus.Debugf("uvm::CreateUVMScratch %s from %s", targetScratch, sourceScratch)
if err := copyfile.CopyFile(sourceScratch, targetScratch, true); err != nil {
return err
}
if err := wclayer.GrantVmAccess(vmID, targetScratch); err != nil {
os.Remove(targetScratch)
return err
}
return nil
}