Vendor github.com/jhowardmsft/opengcs v0.0.7

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2017-06-26 21:22:50 -07:00
Родитель 8f3c526e78
Коммит 3f14e25a7f
5 изменённых файлов: 34 добавлений и 33 удалений

Просмотреть файл

@ -8,7 +8,7 @@ github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
github.com/gorilla/context v1.1
github.com/gorilla/mux v1.1
github.com/jhowardmsft/opengcs v0.0.4
github.com/jhowardmsft/opengcs v0.0.7
github.com/kr/pty 5cf931ef8f
github.com/mattn/go-shellwords v1.0.3
github.com/tchap/go-patricia v2.2.6

42
vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go сгенерированный поставляемый
Просмотреть файл

@ -52,19 +52,20 @@ const (
//
// VHD is the priority.
type Config struct {
KirdPath string // Path to where kernel/initrd are found (defaults to c:\program files\lcow)
KernelFile string // Kernel for Utility VM (embedded in a UEFI bootloader) - does NOT include full path, just filename
InitrdFile string // Initrd image for Utility VM - does NOT include full path, just filename
Vhdx string // VHD for booting the utility VM - is a full path
Name string // Name of the utility VM
RequestedMode Mode // What mode is preferred when validating
ActualMode Mode // What mode was obtained during validation
UvmTimeoutSeconds int // How long to wait for the utility VM to respond in seconds
Uvm hcsshim.Container // The actual container
KirdPath string // Path to where kernel/initrd are found (defaults to c:\program files\Linux Containers)
KernelFile string // Kernel for Utility VM (embedded in a UEFI bootloader) - does NOT include full path, just filename
InitrdFile string // Initrd image for Utility VM - does NOT include full path, just filename
Vhdx string // VHD for booting the utility VM - is a full path
Name string // Name of the utility VM
RequestedMode Mode // What mode is preferred when validating
ActualMode Mode // What mode was obtained during validation
UvmTimeoutSeconds int // How long to wait for the utility VM to respond in seconds
Uvm hcsshim.Container // The actual container
MappedVirtualDisks []hcsshim.MappedVirtualDisk // Data-disks to be attached
}
// GenerateDefault generates a default config from a set of options
// If baseDir is not supplied, defaults to $env:ProgramFiles\lcow
// If baseDir is not supplied, defaults to $env:ProgramFiles\Linux Containers
func (config *Config) GenerateDefault(options []string) error {
if config.UvmTimeoutSeconds < 0 {
return fmt.Errorf("opengcs: cannot generate a config when supplied a negative utility VM timeout")
@ -111,7 +112,7 @@ func (config *Config) GenerateDefault(options []string) error {
}
if config.KirdPath == "" {
config.KirdPath = filepath.Join(os.Getenv("ProgramFiles"), "lcow")
config.KirdPath = filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers")
}
if config.Vhdx == "" {
@ -138,6 +139,8 @@ func (config *Config) GenerateDefault(options []string) error {
}
}
config.MappedVirtualDisks = nil
return nil
}
@ -172,11 +175,6 @@ func (config *Config) validate() error {
return fmt.Errorf("opengcs: configuration is invalid")
}
// Move to validation
//if _, err := os.Stat(baseDir); os.IsNotExist(err) {
// return fmt.Errorf("opengcs: cannot create default utility VM configuration as directory '%s' was not found", baseDir)
//}
if _, err := os.Stat(filepath.Join(config.KirdPath, config.KernelFile)); os.IsNotExist(err) {
return fmt.Errorf("opengcs: kernel '%s' was not found", filepath.Join(config.KirdPath, config.KernelFile))
}
@ -185,6 +183,17 @@ func (config *Config) validate() error {
}
config.ActualMode = ModeActualKernelInitrd
// Ensure all the MappedVirtualDisks exist on the host
for _, mvd := range config.MappedVirtualDisks {
if _, err := os.Stat(mvd.HostPath); err != nil {
return fmt.Errorf("opengcs: MappedVirtualDisk '%s' was not found", mvd.HostPath)
}
if mvd.ContainerPath == "" {
return fmt.Errorf("opengcs: MappedVirtualDisk '%s' has no container path", mvd.HostPath)
}
}
return nil
}
@ -202,6 +211,7 @@ func (config *Config) Create() error {
SystemType: "container",
ContainerType: "linux",
TerminateOnLastHandleClosed: true,
MappedVirtualDisks: config.MappedVirtualDisks,
}
if config.ActualMode == ModeActualVhdx {

4
vendor/github.com/jhowardmsft/opengcs/gogcs/client/createsandbox.go сгенерированный поставляемый
Просмотреть файл

@ -25,7 +25,7 @@ func (config *Config) CreateSandbox(destFile string, maxSizeInMB uint32, cacheFi
logrus.Debugf("opengcs: CreateSandbox: %s size:%dMB cache:%s", destFile, maxSizeInMB, cacheFile)
// Retrieve from cache if the default size and already on disk
if maxSizeInMB == DefaultSandboxSizeMB {
if cacheFile != "" && maxSizeInMB == DefaultSandboxSizeMB {
sandboxCacheLock.Lock()
if _, err := os.Stat(cacheFile); err == nil {
if err := copyFile(cacheFile, destFile); err != nil {
@ -61,7 +61,7 @@ func (config *Config) CreateSandbox(destFile string, maxSizeInMB uint32, cacheFi
}
// Populate the cache
if maxSizeInMB == DefaultSandboxSizeMB {
if cacheFile != "" && maxSizeInMB == DefaultSandboxSizeMB {
sandboxCacheLock.Lock()
// It may already exist due to being created on another thread, in which case no copy back needed.
if _, err := os.Stat(cacheFile); os.IsNotExist(err) {

4
vendor/github.com/jhowardmsft/opengcs/gogcs/client/tartovhd.go сгенерированный поставляемый
Просмотреть файл

@ -31,7 +31,9 @@ func (config *Config) TarToVhd(targetVHDFile string, reader io.Reader) (int64, e
}
// Don't need stdin now we've sent everything. This signals GCS that we are finished sending data.
process.Process.CloseStdin()
if err := process.Process.CloseStdin(); err != nil {
return 0, fmt.Errorf("opengcs: TarToVhd: %s: failed closing stdin handle: %s", targetVHDFile, err)
}
// Write stdout contents of `tar2vhd` to the VHD file
payloadSize, err := writeFileFromReader(targetVHDFile, process.Stdout, config.UvmTimeoutSeconds, fmt.Sprintf("output of tar2vhd to %s", targetVHDFile))

15
vendor/github.com/jhowardmsft/opengcs/gogcs/client/utilities.go сгенерированный поставляемый
Просмотреть файл

@ -41,20 +41,9 @@ func copyWithTimeout(dst io.Writer, src io.Reader, size int64, timeoutSeconds in
done := make(chan resultType, 1)
go func() {
// TODO @jhowardmsft. Needs platform fix. Improve reliability by
// chunking the data. Ultimately can just use io.Copy instead with no loop
result := resultType{}
var copied int64
for {
copied, result.err = io.CopyN(dst, src, 1024)
result.bytes += copied
if copied == 0 {
done <- result
break
}
// TODO @jhowardmsft - next line is debugging only. Remove
//logrus.Debugf("%s: copied so far %d\n", context, result.bytes)
}
result.bytes, result.err = io.Copy(dst, src)
done <- result
}()
var result resultType