id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
143,600
Microsoft/hcsshim
ext4/tar2ext4/tar2ext4.go
MaximumDiskSize
func MaximumDiskSize(size int64) Option { return func(p *params) { p.ext4opts = append(p.ext4opts, compactext4.MaximumDiskSize(size)) } }
go
func MaximumDiskSize(size int64) Option { return func(p *params) { p.ext4opts = append(p.ext4opts, compactext4.MaximumDiskSize(size)) } }
[ "func", "MaximumDiskSize", "(", "size", "int64", ")", "Option", "{", "return", "func", "(", "p", "*", "params", ")", "{", "p", ".", "ext4opts", "=", "append", "(", "p", ".", "ext4opts", ",", "compactext4", ".", "MaximumDiskSize", "(", "size", ")", ")", "\n", "}", "\n", "}" ]
// MaximumDiskSize instructs the writer to limit the disk size to the specified // value. This also reserves enough metadata space for the specified disk size. // If not provided, then 16GB is the default.
[ "MaximumDiskSize", "instructs", "the", "writer", "to", "limit", "the", "disk", "size", "to", "the", "specified", "value", ".", "This", "also", "reserves", "enough", "metadata", "space", "for", "the", "specified", "disk", "size", ".", "If", "not", "provided", "then", "16GB", "is", "the", "default", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/ext4/tar2ext4/tar2ext4.go#L45-L49
143,601
Microsoft/hcsshim
internal/hcs/system.go
CreateComputeSystem
func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System, err error) { operation := "hcsshim::CreateComputeSystem" computeSystem := newSystem(id) computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() hcsDocumentB, err := json.Marshal(hcsDocumentInterface) if err != nil { return nil, err } hcsDocument := string(hcsDocumentB) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, hcsDocument). Debug("HCS ComputeSystem Document") var ( resultp *uint16 identity syscall.Handle createError error ) syscallWatcher(computeSystem.logctx, func() { createError = hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp) }) if createError == nil || IsPending(createError) { if err = computeSystem.registerCallback(); err != nil { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. computeSystem.Terminate() return nil, makeSystemError(computeSystem, operation, "", err, nil) } } events, err := processAsyncHcsResult(createError, resultp, computeSystem.callbackNumber, hcsNotificationSystemCreateCompleted, &timeout.SystemCreate) if err != nil { if err == ErrTimeout { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. computeSystem.Terminate() } return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) } go computeSystem.waitBackground() return computeSystem, nil }
go
func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System, err error) { operation := "hcsshim::CreateComputeSystem" computeSystem := newSystem(id) computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() hcsDocumentB, err := json.Marshal(hcsDocumentInterface) if err != nil { return nil, err } hcsDocument := string(hcsDocumentB) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, hcsDocument). Debug("HCS ComputeSystem Document") var ( resultp *uint16 identity syscall.Handle createError error ) syscallWatcher(computeSystem.logctx, func() { createError = hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp) }) if createError == nil || IsPending(createError) { if err = computeSystem.registerCallback(); err != nil { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. computeSystem.Terminate() return nil, makeSystemError(computeSystem, operation, "", err, nil) } } events, err := processAsyncHcsResult(createError, resultp, computeSystem.callbackNumber, hcsNotificationSystemCreateCompleted, &timeout.SystemCreate) if err != nil { if err == ErrTimeout { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. computeSystem.Terminate() } return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) } go computeSystem.waitBackground() return computeSystem, nil }
[ "func", "CreateComputeSystem", "(", "id", "string", ",", "hcsDocumentInterface", "interface", "{", "}", ")", "(", "_", "*", "System", ",", "err", "error", ")", "{", "operation", ":=", "\"", "\"", "\n\n", "computeSystem", ":=", "newSystem", "(", "id", ")", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "hcsDocumentB", ",", "err", ":=", "json", ".", "Marshal", "(", "hcsDocumentInterface", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "hcsDocument", ":=", "string", "(", "hcsDocumentB", ")", "\n\n", "logrus", ".", "WithFields", "(", "computeSystem", ".", "logctx", ")", ".", "WithField", "(", "logfields", ".", "JSON", ",", "hcsDocument", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "var", "(", "resultp", "*", "uint16", "\n", "identity", "syscall", ".", "Handle", "\n", "createError", "error", "\n", ")", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "createError", "=", "hcsCreateComputeSystem", "(", "id", ",", "hcsDocument", ",", "identity", ",", "&", "computeSystem", ".", "handle", ",", "&", "resultp", ")", "\n", "}", ")", "\n\n", "if", "createError", "==", "nil", "||", "IsPending", "(", "createError", ")", "{", "if", "err", "=", "computeSystem", ".", "registerCallback", "(", ")", ";", "err", "!=", "nil", "{", "// Terminate the compute system if it still exists. We're okay to", "// ignore a failure here.", "computeSystem", ".", "Terminate", "(", ")", "\n", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "operation", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n", "}", "\n\n", "events", ",", "err", ":=", "processAsyncHcsResult", "(", "createError", ",", "resultp", ",", "computeSystem", ".", "callbackNumber", ",", "hcsNotificationSystemCreateCompleted", ",", "&", "timeout", ".", "SystemCreate", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "ErrTimeout", "{", "// Terminate the compute system if it still exists. We're okay to", "// ignore a failure here.", "computeSystem", ".", "Terminate", "(", ")", "\n", "}", "\n", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "operation", ",", "hcsDocument", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "go", "computeSystem", ".", "waitBackground", "(", ")", "\n\n", "return", "computeSystem", ",", "nil", "\n", "}" ]
// CreateComputeSystem creates a new compute system with the given configuration but does not start it.
[ "CreateComputeSystem", "creates", "a", "new", "compute", "system", "with", "the", "given", "configuration", "but", "does", "not", "start", "it", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L79-L128
143,602
Microsoft/hcsshim
internal/hcs/system.go
OpenComputeSystem
func OpenComputeSystem(id string) (_ *System, err error) { operation := "hcsshim::OpenComputeSystem" computeSystem := newSystem(id) computeSystem.logOperationBegin(operation) defer func() { if IsNotExist(err) { computeSystem.logOperationEnd(operation, nil) } else { computeSystem.logOperationEnd(operation, err) } }() var ( handle hcsSystem resultp *uint16 ) err = hcsOpenComputeSystem(id, &handle, &resultp) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, operation, "", err, events) } computeSystem.handle = handle if err = computeSystem.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, operation, "", err, nil) } go computeSystem.waitBackground() return computeSystem, nil }
go
func OpenComputeSystem(id string) (_ *System, err error) { operation := "hcsshim::OpenComputeSystem" computeSystem := newSystem(id) computeSystem.logOperationBegin(operation) defer func() { if IsNotExist(err) { computeSystem.logOperationEnd(operation, nil) } else { computeSystem.logOperationEnd(operation, err) } }() var ( handle hcsSystem resultp *uint16 ) err = hcsOpenComputeSystem(id, &handle, &resultp) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, operation, "", err, events) } computeSystem.handle = handle if err = computeSystem.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, operation, "", err, nil) } go computeSystem.waitBackground() return computeSystem, nil }
[ "func", "OpenComputeSystem", "(", "id", "string", ")", "(", "_", "*", "System", ",", "err", "error", ")", "{", "operation", ":=", "\"", "\"", "\n\n", "computeSystem", ":=", "newSystem", "(", "id", ")", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "if", "IsNotExist", "(", "err", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "nil", ")", "\n", "}", "else", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "var", "(", "handle", "hcsSystem", "\n", "resultp", "*", "uint16", "\n", ")", "\n", "err", "=", "hcsOpenComputeSystem", "(", "id", ",", "&", "handle", ",", "&", "resultp", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "operation", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "computeSystem", ".", "handle", "=", "handle", "\n\n", "if", "err", "=", "computeSystem", ".", "registerCallback", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "operation", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n", "go", "computeSystem", ".", "waitBackground", "(", ")", "\n\n", "return", "computeSystem", ",", "nil", "\n", "}" ]
// OpenComputeSystem opens an existing compute system by ID.
[ "OpenComputeSystem", "opens", "an", "existing", "compute", "system", "by", "ID", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L131-L162
143,603
Microsoft/hcsshim
internal/hcs/system.go
GetComputeSystems
func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) { operation := "hcsshim::GetComputeSystems" fields := logrus.Fields{} logOperationBegin( fields, operation+" - Begin Operation") defer func() { var result string if err == nil { result = "Success" } else { result = "Error" } logOperationEnd( fields, operation+" - End Operation - "+result, err) }() queryb, err := json.Marshal(q) if err != nil { return nil, err } query := string(queryb) logrus.WithFields(fields). WithField(logfields.JSON, query). Debug("HCS ComputeSystem Query") var ( resultp *uint16 computeSystemsp *uint16 ) syscallWatcher(fields, func() { err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, &HcsError{Op: operation, Err: err, Events: events} } if computeSystemsp == nil { return nil, ErrUnexpectedValue } computeSystemsRaw := interop.ConvertAndFreeCoTaskMemBytes(computeSystemsp) computeSystems := []schema1.ContainerProperties{} if err = json.Unmarshal(computeSystemsRaw, &computeSystems); err != nil { return nil, err } return computeSystems, nil }
go
func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) { operation := "hcsshim::GetComputeSystems" fields := logrus.Fields{} logOperationBegin( fields, operation+" - Begin Operation") defer func() { var result string if err == nil { result = "Success" } else { result = "Error" } logOperationEnd( fields, operation+" - End Operation - "+result, err) }() queryb, err := json.Marshal(q) if err != nil { return nil, err } query := string(queryb) logrus.WithFields(fields). WithField(logfields.JSON, query). Debug("HCS ComputeSystem Query") var ( resultp *uint16 computeSystemsp *uint16 ) syscallWatcher(fields, func() { err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, &HcsError{Op: operation, Err: err, Events: events} } if computeSystemsp == nil { return nil, ErrUnexpectedValue } computeSystemsRaw := interop.ConvertAndFreeCoTaskMemBytes(computeSystemsp) computeSystems := []schema1.ContainerProperties{} if err = json.Unmarshal(computeSystemsRaw, &computeSystems); err != nil { return nil, err } return computeSystems, nil }
[ "func", "GetComputeSystems", "(", "q", "schema1", ".", "ComputeSystemQuery", ")", "(", "_", "[", "]", "schema1", ".", "ContainerProperties", ",", "err", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "}", "\n", "logOperationBegin", "(", "fields", ",", "operation", "+", "\"", "\"", ")", "\n\n", "defer", "func", "(", ")", "{", "var", "result", "string", "\n", "if", "err", "==", "nil", "{", "result", "=", "\"", "\"", "\n", "}", "else", "{", "result", "=", "\"", "\"", "\n", "}", "\n\n", "logOperationEnd", "(", "fields", ",", "operation", "+", "\"", "\"", "+", "result", ",", "err", ")", "\n", "}", "(", ")", "\n\n", "queryb", ",", "err", ":=", "json", ".", "Marshal", "(", "q", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "query", ":=", "string", "(", "queryb", ")", "\n\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "WithField", "(", "logfields", ".", "JSON", ",", "query", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "var", "(", "resultp", "*", "uint16", "\n", "computeSystemsp", "*", "uint16", "\n", ")", "\n\n", "syscallWatcher", "(", "fields", ",", "func", "(", ")", "{", "err", "=", "hcsEnumerateComputeSystems", "(", "query", ",", "&", "computeSystemsp", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "&", "HcsError", "{", "Op", ":", "operation", ",", "Err", ":", "err", ",", "Events", ":", "events", "}", "\n", "}", "\n\n", "if", "computeSystemsp", "==", "nil", "{", "return", "nil", ",", "ErrUnexpectedValue", "\n", "}", "\n", "computeSystemsRaw", ":=", "interop", ".", "ConvertAndFreeCoTaskMemBytes", "(", "computeSystemsp", ")", "\n", "computeSystems", ":=", "[", "]", "schema1", ".", "ContainerProperties", "{", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "computeSystemsRaw", ",", "&", "computeSystems", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "computeSystems", ",", "nil", "\n", "}" ]
// GetComputeSystems gets a list of the compute systems on the system that match the query
[ "GetComputeSystems", "gets", "a", "list", "of", "the", "compute", "systems", "on", "the", "system", "that", "match", "the", "query" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L165-L220
143,604
Microsoft/hcsshim
internal/hcs/system.go
Start
func (computeSystem *System) Start() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Start" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil) } // This is a very simple backoff-retry loop to limit the number // of parallel container starts if environment variable // HCSSHIM_MAX_PARALLEL_START is set to a positive integer. // It should generally only be used as a workaround to various // platform issues that exist between RS1 and RS4 as of Aug 2018 if currentContainerStarts.maxParallel > 0 { for { currentContainerStarts.Lock() if currentContainerStarts.inProgress < currentContainerStarts.maxParallel { currentContainerStarts.inProgress++ currentContainerStarts.Unlock() break } if currentContainerStarts.inProgress == currentContainerStarts.maxParallel { currentContainerStarts.Unlock() time.Sleep(100 * time.Millisecond) } } // Make sure we decrement the count when we are done. defer func() { currentContainerStarts.Lock() currentContainerStarts.inProgress-- currentContainerStarts.Unlock() }() } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsStartComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart) if err != nil { return makeSystemError(computeSystem, "Start", "", err, events) } return nil }
go
func (computeSystem *System) Start() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Start" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil) } // This is a very simple backoff-retry loop to limit the number // of parallel container starts if environment variable // HCSSHIM_MAX_PARALLEL_START is set to a positive integer. // It should generally only be used as a workaround to various // platform issues that exist between RS1 and RS4 as of Aug 2018 if currentContainerStarts.maxParallel > 0 { for { currentContainerStarts.Lock() if currentContainerStarts.inProgress < currentContainerStarts.maxParallel { currentContainerStarts.inProgress++ currentContainerStarts.Unlock() break } if currentContainerStarts.inProgress == currentContainerStarts.maxParallel { currentContainerStarts.Unlock() time.Sleep(100 * time.Millisecond) } } // Make sure we decrement the count when we are done. defer func() { currentContainerStarts.Lock() currentContainerStarts.inProgress-- currentContainerStarts.Unlock() }() } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsStartComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart) if err != nil { return makeSystemError(computeSystem, "Start", "", err, events) } return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Start", "(", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "// This is a very simple backoff-retry loop to limit the number", "// of parallel container starts if environment variable", "// HCSSHIM_MAX_PARALLEL_START is set to a positive integer.", "// It should generally only be used as a workaround to various", "// platform issues that exist between RS1 and RS4 as of Aug 2018", "if", "currentContainerStarts", ".", "maxParallel", ">", "0", "{", "for", "{", "currentContainerStarts", ".", "Lock", "(", ")", "\n", "if", "currentContainerStarts", ".", "inProgress", "<", "currentContainerStarts", ".", "maxParallel", "{", "currentContainerStarts", ".", "inProgress", "++", "\n", "currentContainerStarts", ".", "Unlock", "(", ")", "\n", "break", "\n", "}", "\n", "if", "currentContainerStarts", ".", "inProgress", "==", "currentContainerStarts", ".", "maxParallel", "{", "currentContainerStarts", ".", "Unlock", "(", ")", "\n", "time", ".", "Sleep", "(", "100", "*", "time", ".", "Millisecond", ")", "\n", "}", "\n", "}", "\n", "// Make sure we decrement the count when we are done.", "defer", "func", "(", ")", "{", "currentContainerStarts", ".", "Lock", "(", ")", "\n", "currentContainerStarts", ".", "inProgress", "--", "\n", "currentContainerStarts", ".", "Unlock", "(", ")", "\n", "}", "(", ")", "\n", "}", "\n\n", "var", "resultp", "*", "uint16", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsStartComputeSystem", "(", "computeSystem", ".", "handle", ",", "\"", "\"", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ",", "err", ":=", "processAsyncHcsResult", "(", "err", ",", "resultp", ",", "computeSystem", ".", "callbackNumber", ",", "hcsNotificationSystemStartCompleted", ",", "&", "timeout", ".", "SystemStart", ")", "\n", "if", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Start synchronously starts the computeSystem.
[ "Start", "synchronously", "starts", "the", "computeSystem", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L223-L271
143,605
Microsoft/hcsshim
internal/hcs/system.go
Shutdown
func (computeSystem *System) Shutdown() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Shutdown" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return nil } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp) }) events := processHcsResult(resultp) switch err { case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending: default: return makeSystemError(computeSystem, "Shutdown", "", err, events) } return nil }
go
func (computeSystem *System) Shutdown() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Shutdown" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return nil } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp) }) events := processHcsResult(resultp) switch err { case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending: default: return makeSystemError(computeSystem, "Shutdown", "", err, events) } return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Shutdown", "(", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "\n", "}", "(", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "var", "resultp", "*", "uint16", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsShutdownComputeSystem", "(", "computeSystem", ".", "handle", ",", "\"", "\"", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "switch", "err", "{", "case", "nil", ",", "ErrVmcomputeAlreadyStopped", ",", "ErrComputeSystemDoesNotExist", ",", "ErrVmcomputeOperationPending", ":", "default", ":", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Shutdown requests a compute system shutdown.
[ "Shutdown", "requests", "a", "compute", "system", "shutdown", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L279-L304
143,606
Microsoft/hcsshim
internal/hcs/system.go
ExitError
func (computeSystem *System) ExitError() (err error) { select { case <-computeSystem.waitBlock: if computeSystem.waitError != nil { return computeSystem.waitError } return computeSystem.exitError default: return errors.New("container not exited") } }
go
func (computeSystem *System) ExitError() (err error) { select { case <-computeSystem.waitBlock: if computeSystem.waitError != nil { return computeSystem.waitError } return computeSystem.exitError default: return errors.New("container not exited") } }
[ "func", "(", "computeSystem", "*", "System", ")", "ExitError", "(", ")", "(", "err", "error", ")", "{", "select", "{", "case", "<-", "computeSystem", ".", "waitBlock", ":", "if", "computeSystem", ".", "waitError", "!=", "nil", "{", "return", "computeSystem", ".", "waitError", "\n", "}", "\n", "return", "computeSystem", ".", "exitError", "\n", "default", ":", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// ExitError returns an error describing the reason the compute system terminated.
[ "ExitError", "returns", "an", "error", "describing", "the", "reason", "the", "compute", "system", "terminated", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L367-L377
143,607
Microsoft/hcsshim
internal/hcs/system.go
Pause
func (computeSystem *System) Pause() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Pause" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil) } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause) if err != nil { return makeSystemError(computeSystem, "Pause", "", err, events) } return nil }
go
func (computeSystem *System) Pause() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Pause" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil) } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause) if err != nil { return makeSystemError(computeSystem, "Pause", "", err, events) } return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Pause", "(", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "var", "resultp", "*", "uint16", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsPauseComputeSystem", "(", "computeSystem", ".", "handle", ",", "\"", "\"", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ",", "err", ":=", "processAsyncHcsResult", "(", "err", ",", "resultp", ",", "computeSystem", ".", "callbackNumber", ",", "hcsNotificationSystemPauseCompleted", ",", "&", "timeout", ".", "SystemPause", ")", "\n", "if", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Pause pauses the execution of the computeSystem. This feature is not enabled in TP5.
[ "Pause", "pauses", "the", "execution", "of", "the", "computeSystem", ".", "This", "feature", "is", "not", "enabled", "in", "TP5", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L419-L441
143,608
Microsoft/hcsshim
internal/hcs/system.go
Resume
func (computeSystem *System) Resume() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Resume" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil) } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume) if err != nil { return makeSystemError(computeSystem, "Resume", "", err, events) } return nil }
go
func (computeSystem *System) Resume() (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Resume" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil) } var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp) }) events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume) if err != nil { return makeSystemError(computeSystem, "Resume", "", err, events) } return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Resume", "(", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "var", "resultp", "*", "uint16", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsResumeComputeSystem", "(", "computeSystem", ".", "handle", ",", "\"", "\"", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ",", "err", ":=", "processAsyncHcsResult", "(", "err", ",", "resultp", ",", "computeSystem", ".", "callbackNumber", ",", "hcsNotificationSystemResumeCompleted", ",", "&", "timeout", ".", "SystemResume", ")", "\n", "if", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Resume resumes the execution of the computeSystem. This feature is not enabled in TP5.
[ "Resume", "resumes", "the", "execution", "of", "the", "computeSystem", ".", "This", "feature", "is", "not", "enabled", "in", "TP5", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L444-L466
143,609
Microsoft/hcsshim
internal/hcs/system.go
CreateProcess
func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::CreateProcess" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() var ( processInfo hcsProcessInformation processHandle hcsProcess resultp *uint16 ) if computeSystem.handle == 0 { return nil, makeSystemError(computeSystem, "CreateProcess", "", ErrAlreadyClosed, nil) } configurationb, err := json.Marshal(c) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } configuration := string(configurationb) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, configuration). Debug("HCS ComputeSystem Process Document") syscallWatcher(computeSystem.logctx, func() { err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events) } logrus.WithFields(computeSystem.logctx). WithField(logfields.ProcessID, processInfo.ProcessId). Debug("HCS ComputeSystem CreateProcess PID") process := newProcess(processHandle, int(processInfo.ProcessId), computeSystem) defer func() { if err != nil { process.Close() } }() pipes, err := makeOpenFiles([]syscall.Handle{processInfo.StdInput, processInfo.StdOutput, processInfo.StdError}) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } process.stdin = pipes[0] process.stdout = pipes[1] process.stderr = pipes[2] if err = process.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } go process.waitBackground() return process, nil }
go
func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::CreateProcess" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() var ( processInfo hcsProcessInformation processHandle hcsProcess resultp *uint16 ) if computeSystem.handle == 0 { return nil, makeSystemError(computeSystem, "CreateProcess", "", ErrAlreadyClosed, nil) } configurationb, err := json.Marshal(c) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } configuration := string(configurationb) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, configuration). Debug("HCS ComputeSystem Process Document") syscallWatcher(computeSystem.logctx, func() { err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events) } logrus.WithFields(computeSystem.logctx). WithField(logfields.ProcessID, processInfo.ProcessId). Debug("HCS ComputeSystem CreateProcess PID") process := newProcess(processHandle, int(processInfo.ProcessId), computeSystem) defer func() { if err != nil { process.Close() } }() pipes, err := makeOpenFiles([]syscall.Handle{processInfo.StdInput, processInfo.StdOutput, processInfo.StdError}) if err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } process.stdin = pipes[0] process.stdout = pipes[1] process.stderr = pipes[2] if err = process.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) } go process.waitBackground() return process, nil }
[ "func", "(", "computeSystem", "*", "System", ")", "CreateProcess", "(", "c", "interface", "{", "}", ")", "(", "_", "*", "Process", ",", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "var", "(", "processInfo", "hcsProcessInformation", "\n", "processHandle", "hcsProcess", "\n", "resultp", "*", "uint16", "\n", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "configurationb", ",", "err", ":=", "json", ".", "Marshal", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n\n", "configuration", ":=", "string", "(", "configurationb", ")", "\n\n", "logrus", ".", "WithFields", "(", "computeSystem", ".", "logctx", ")", ".", "WithField", "(", "logfields", ".", "JSON", ",", "configuration", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsCreateProcess", "(", "computeSystem", ".", "handle", ",", "configuration", ",", "&", "processInfo", ",", "&", "processHandle", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "configuration", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "logrus", ".", "WithFields", "(", "computeSystem", ".", "logctx", ")", ".", "WithField", "(", "logfields", ".", "ProcessID", ",", "processInfo", ".", "ProcessId", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "process", ":=", "newProcess", "(", "processHandle", ",", "int", "(", "processInfo", ".", "ProcessId", ")", ",", "computeSystem", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "process", ".", "Close", "(", ")", "\n", "}", "\n", "}", "(", ")", "\n", "pipes", ",", "err", ":=", "makeOpenFiles", "(", "[", "]", "syscall", ".", "Handle", "{", "processInfo", ".", "StdInput", ",", "processInfo", ".", "StdOutput", ",", "processInfo", ".", "StdError", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n", "process", ".", "stdin", "=", "pipes", "[", "0", "]", "\n", "process", ".", "stdout", "=", "pipes", "[", "1", "]", "\n", "process", ".", "stderr", "=", "pipes", "[", "2", "]", "\n", "if", "err", "=", "process", ".", "registerCallback", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n", "go", "process", ".", "waitBackground", "(", ")", "\n\n", "return", "process", ",", "nil", "\n", "}" ]
// CreateProcess launches a new process within the computeSystem.
[ "CreateProcess", "launches", "a", "new", "process", "within", "the", "computeSystem", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L469-L529
143,610
Microsoft/hcsshim
internal/hcs/system.go
OpenProcess
func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() // Add PID for the context of this operation computeSystem.logctx[logfields.ProcessID] = pid defer delete(computeSystem.logctx, logfields.ProcessID) operation := "hcsshim::ComputeSystem::OpenProcess" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() var ( processHandle hcsProcess resultp *uint16 ) if computeSystem.handle == 0 { return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil) } syscallWatcher(computeSystem.logctx, func() { err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events) } process := newProcess(processHandle, pid, computeSystem) if err = process.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, "OpenProcess", "", err, nil) } go process.waitBackground() return process, nil }
go
func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() // Add PID for the context of this operation computeSystem.logctx[logfields.ProcessID] = pid defer delete(computeSystem.logctx, logfields.ProcessID) operation := "hcsshim::ComputeSystem::OpenProcess" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() var ( processHandle hcsProcess resultp *uint16 ) if computeSystem.handle == 0 { return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil) } syscallWatcher(computeSystem.logctx, func() { err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp) }) events := processHcsResult(resultp) if err != nil { return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events) } process := newProcess(processHandle, pid, computeSystem) if err = process.registerCallback(); err != nil { return nil, makeSystemError(computeSystem, "OpenProcess", "", err, nil) } go process.waitBackground() return process, nil }
[ "func", "(", "computeSystem", "*", "System", ")", "OpenProcess", "(", "pid", "int", ")", "(", "_", "*", "Process", ",", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "// Add PID for the context of this operation", "computeSystem", ".", "logctx", "[", "logfields", ".", "ProcessID", "]", "=", "pid", "\n", "defer", "delete", "(", "computeSystem", ".", "logctx", ",", "logfields", ".", "ProcessID", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "var", "(", "processHandle", "hcsProcess", "\n", "resultp", "*", "uint16", "\n", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsOpenProcess", "(", "computeSystem", ".", "handle", ",", "uint32", "(", "pid", ")", ",", "&", "processHandle", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "process", ":=", "newProcess", "(", "processHandle", ",", "pid", ",", "computeSystem", ")", "\n", "if", "err", "=", "process", ".", "registerCallback", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n", "go", "process", ".", "waitBackground", "(", ")", "\n\n", "return", "process", ",", "nil", "\n", "}" ]
// OpenProcess gets an interface to an existing process within the computeSystem.
[ "OpenProcess", "gets", "an", "interface", "to", "an", "existing", "process", "within", "the", "computeSystem", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L532-L568
143,611
Microsoft/hcsshim
internal/hcs/system.go
Close
func (computeSystem *System) Close() (err error) { computeSystem.handleLock.Lock() defer computeSystem.handleLock.Unlock() operation := "hcsshim::ComputeSystem::Close" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() // Don't double free this if computeSystem.handle == 0 { return nil } if err = computeSystem.unregisterCallback(); err != nil { return makeSystemError(computeSystem, "Close", "", err, nil) } syscallWatcher(computeSystem.logctx, func() { err = hcsCloseComputeSystem(computeSystem.handle) }) if err != nil { return makeSystemError(computeSystem, "Close", "", err, nil) } computeSystem.handle = 0 computeSystem.closedWaitOnce.Do(func() { computeSystem.waitError = ErrAlreadyClosed close(computeSystem.waitBlock) }) return nil }
go
func (computeSystem *System) Close() (err error) { computeSystem.handleLock.Lock() defer computeSystem.handleLock.Unlock() operation := "hcsshim::ComputeSystem::Close" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() // Don't double free this if computeSystem.handle == 0 { return nil } if err = computeSystem.unregisterCallback(); err != nil { return makeSystemError(computeSystem, "Close", "", err, nil) } syscallWatcher(computeSystem.logctx, func() { err = hcsCloseComputeSystem(computeSystem.handle) }) if err != nil { return makeSystemError(computeSystem, "Close", "", err, nil) } computeSystem.handle = 0 computeSystem.closedWaitOnce.Do(func() { computeSystem.waitError = ErrAlreadyClosed close(computeSystem.waitBlock) }) return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "Lock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "Unlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "// Don't double free this", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "if", "err", "=", "computeSystem", ".", "unregisterCallback", "(", ")", ";", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsCloseComputeSystem", "(", "computeSystem", ".", "handle", ")", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ",", "nil", ")", "\n", "}", "\n\n", "computeSystem", ".", "handle", "=", "0", "\n", "computeSystem", ".", "closedWaitOnce", ".", "Do", "(", "func", "(", ")", "{", "computeSystem", ".", "waitError", "=", "ErrAlreadyClosed", "\n", "close", "(", "computeSystem", ".", "waitBlock", ")", "\n", "}", ")", "\n\n", "return", "nil", "\n", "}" ]
// Close cleans up any state associated with the compute system but does not terminate or wait for it.
[ "Close", "cleans", "up", "any", "state", "associated", "with", "the", "compute", "system", "but", "does", "not", "terminate", "or", "wait", "for", "it", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L571-L602
143,612
Microsoft/hcsshim
internal/hcs/system.go
Modify
func (computeSystem *System) Modify(config interface{}) (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Modify" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil) } requestJSON, err := json.Marshal(config) if err != nil { return err } requestString := string(requestJSON) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, requestString). Debug("HCS ComputeSystem Modify Document") var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp) }) events := processHcsResult(resultp) if err != nil { return makeSystemError(computeSystem, "Modify", requestString, err, events) } return nil }
go
func (computeSystem *System) Modify(config interface{}) (err error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() operation := "hcsshim::ComputeSystem::Modify" computeSystem.logOperationBegin(operation) defer func() { computeSystem.logOperationEnd(operation, err) }() if computeSystem.handle == 0 { return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil) } requestJSON, err := json.Marshal(config) if err != nil { return err } requestString := string(requestJSON) logrus.WithFields(computeSystem.logctx). WithField(logfields.JSON, requestString). Debug("HCS ComputeSystem Modify Document") var resultp *uint16 syscallWatcher(computeSystem.logctx, func() { err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp) }) events := processHcsResult(resultp) if err != nil { return makeSystemError(computeSystem, "Modify", requestString, err, events) } return nil }
[ "func", "(", "computeSystem", "*", "System", ")", "Modify", "(", "config", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "computeSystem", ".", "handleLock", ".", "RLock", "(", ")", "\n", "defer", "computeSystem", ".", "handleLock", ".", "RUnlock", "(", ")", "\n\n", "operation", ":=", "\"", "\"", "\n", "computeSystem", ".", "logOperationBegin", "(", "operation", ")", "\n", "defer", "func", "(", ")", "{", "computeSystem", ".", "logOperationEnd", "(", "operation", ",", "err", ")", "}", "(", ")", "\n\n", "if", "computeSystem", ".", "handle", "==", "0", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "\"", "\"", ",", "ErrAlreadyClosed", ",", "nil", ")", "\n", "}", "\n\n", "requestJSON", ",", "err", ":=", "json", ".", "Marshal", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "requestString", ":=", "string", "(", "requestJSON", ")", "\n\n", "logrus", ".", "WithFields", "(", "computeSystem", ".", "logctx", ")", ".", "WithField", "(", "logfields", ".", "JSON", ",", "requestString", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "var", "resultp", "*", "uint16", "\n", "syscallWatcher", "(", "computeSystem", ".", "logctx", ",", "func", "(", ")", "{", "err", "=", "hcsModifyComputeSystem", "(", "computeSystem", ".", "handle", ",", "requestString", ",", "&", "resultp", ")", "\n", "}", ")", "\n", "events", ":=", "processHcsResult", "(", "resultp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "makeSystemError", "(", "computeSystem", ",", "\"", "\"", ",", "requestString", ",", "err", ",", "events", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Modify the System by sending a request to HCS
[ "Modify", "the", "System", "by", "sending", "a", "request", "to", "HCS" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/system.go#L663-L696
143,613
Microsoft/hcsshim
internal/wclayer/expandscratchsize.go
ExpandScratchSize
func ExpandScratchSize(path string, size uint64) (err error) { title := "hcsshim::ExpandScratchSize" fields := logrus.Fields{ "path": path, "size": size, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = expandSandboxSize(&stdDriverInfo, path, size) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
go
func ExpandScratchSize(path string, size uint64) (err error) { title := "hcsshim::ExpandScratchSize" fields := logrus.Fields{ "path": path, "size": size, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = expandSandboxSize(&stdDriverInfo, path, size) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
[ "func", "ExpandScratchSize", "(", "path", "string", ",", "size", "uint64", ")", "(", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "path", ",", "\"", "\"", ":", "size", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "err", "=", "expandSandboxSize", "(", "&", "stdDriverInfo", ",", "path", ",", "size", ")", "\n", "if", "err", "!=", "nil", "{", "return", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ExpandScratchSize expands the size of a layer to at least size bytes.
[ "ExpandScratchSize", "expands", "the", "size", "of", "a", "layer", "to", "at", "least", "size", "bytes", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/expandscratchsize.go#L9-L30
143,614
Microsoft/hcsshim
hcn/hcnloadbalancer.go
ListLoadBalancers
func ListLoadBalancers() ([]HostComputeLoadBalancer, error) { hcnQuery := defaultQuery() loadBalancers, err := ListLoadBalancersQuery(hcnQuery) if err != nil { return nil, err } return loadBalancers, nil }
go
func ListLoadBalancers() ([]HostComputeLoadBalancer, error) { hcnQuery := defaultQuery() loadBalancers, err := ListLoadBalancersQuery(hcnQuery) if err != nil { return nil, err } return loadBalancers, nil }
[ "func", "ListLoadBalancers", "(", ")", "(", "[", "]", "HostComputeLoadBalancer", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "loadBalancers", ",", "err", ":=", "ListLoadBalancersQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "loadBalancers", ",", "nil", "\n", "}" ]
// ListLoadBalancers makes a call to list all available loadBalancers.
[ "ListLoadBalancers", "makes", "a", "call", "to", "list", "all", "available", "loadBalancers", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L202-L209
143,615
Microsoft/hcsshim
hcn/hcnloadbalancer.go
ListLoadBalancersQuery
func ListLoadBalancersQuery(query HostComputeQuery) ([]HostComputeLoadBalancer, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } loadBalancers, err := enumerateLoadBalancers(string(queryJson)) if err != nil { return nil, err } return loadBalancers, nil }
go
func ListLoadBalancersQuery(query HostComputeQuery) ([]HostComputeLoadBalancer, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } loadBalancers, err := enumerateLoadBalancers(string(queryJson)) if err != nil { return nil, err } return loadBalancers, nil }
[ "func", "ListLoadBalancersQuery", "(", "query", "HostComputeQuery", ")", "(", "[", "]", "HostComputeLoadBalancer", ",", "error", ")", "{", "queryJson", ",", "err", ":=", "json", ".", "Marshal", "(", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "loadBalancers", ",", "err", ":=", "enumerateLoadBalancers", "(", "string", "(", "queryJson", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "loadBalancers", ",", "nil", "\n", "}" ]
// ListLoadBalancersQuery makes a call to query the list of available loadBalancers.
[ "ListLoadBalancersQuery", "makes", "a", "call", "to", "query", "the", "list", "of", "available", "loadBalancers", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L212-L223
143,616
Microsoft/hcsshim
hcn/hcnloadbalancer.go
GetLoadBalancerByID
func GetLoadBalancerByID(loadBalancerId string) (*HostComputeLoadBalancer, error) { hcnQuery := defaultQuery() mapA := map[string]string{"ID": loadBalancerId} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) loadBalancers, err := ListLoadBalancersQuery(hcnQuery) if err != nil { return nil, err } if len(loadBalancers) == 0 { return nil, LoadBalancerNotFoundError{LoadBalancerId: loadBalancerId} } return &loadBalancers[0], err }
go
func GetLoadBalancerByID(loadBalancerId string) (*HostComputeLoadBalancer, error) { hcnQuery := defaultQuery() mapA := map[string]string{"ID": loadBalancerId} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) loadBalancers, err := ListLoadBalancersQuery(hcnQuery) if err != nil { return nil, err } if len(loadBalancers) == 0 { return nil, LoadBalancerNotFoundError{LoadBalancerId: loadBalancerId} } return &loadBalancers[0], err }
[ "func", "GetLoadBalancerByID", "(", "loadBalancerId", "string", ")", "(", "*", "HostComputeLoadBalancer", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "mapA", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "loadBalancerId", "}", "\n", "filter", ",", "err", ":=", "json", ".", "Marshal", "(", "mapA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "hcnQuery", ".", "Filter", "=", "string", "(", "filter", ")", "\n\n", "loadBalancers", ",", "err", ":=", "ListLoadBalancersQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "loadBalancers", ")", "==", "0", "{", "return", "nil", ",", "LoadBalancerNotFoundError", "{", "LoadBalancerId", ":", "loadBalancerId", "}", "\n", "}", "\n", "return", "&", "loadBalancers", "[", "0", "]", ",", "err", "\n", "}" ]
// GetLoadBalancerByID returns the LoadBalancer specified by Id.
[ "GetLoadBalancerByID", "returns", "the", "LoadBalancer", "specified", "by", "Id", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L226-L243
143,617
Microsoft/hcsshim
hcn/hcnloadbalancer.go
Create
func (loadBalancer *HostComputeLoadBalancer) Create() (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::Create id=%s", loadBalancer.Id) jsonString, err := json.Marshal(loadBalancer) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeLoadBalancer::Create JSON: %s", jsonString) loadBalancer, hcnErr := createLoadBalancer(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return loadBalancer, nil }
go
func (loadBalancer *HostComputeLoadBalancer) Create() (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::Create id=%s", loadBalancer.Id) jsonString, err := json.Marshal(loadBalancer) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeLoadBalancer::Create JSON: %s", jsonString) loadBalancer, hcnErr := createLoadBalancer(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return loadBalancer, nil }
[ "func", "(", "loadBalancer", "*", "HostComputeLoadBalancer", ")", "Create", "(", ")", "(", "*", "HostComputeLoadBalancer", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "loadBalancer", ".", "Id", ")", "\n\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "loadBalancer", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "jsonString", ")", "\n", "loadBalancer", ",", "hcnErr", ":=", "createLoadBalancer", "(", "string", "(", "jsonString", ")", ")", "\n", "if", "hcnErr", "!=", "nil", "{", "return", "nil", ",", "hcnErr", "\n", "}", "\n", "return", "loadBalancer", ",", "nil", "\n", "}" ]
// Create LoadBalancer.
[ "Create", "LoadBalancer", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L246-L260
143,618
Microsoft/hcsshim
hcn/hcnloadbalancer.go
Delete
func (loadBalancer *HostComputeLoadBalancer) Delete() error { logrus.Debugf("hcn::HostComputeLoadBalancer::Delete id=%s", loadBalancer.Id) if err := deleteLoadBalancer(loadBalancer.Id); err != nil { return err } return nil }
go
func (loadBalancer *HostComputeLoadBalancer) Delete() error { logrus.Debugf("hcn::HostComputeLoadBalancer::Delete id=%s", loadBalancer.Id) if err := deleteLoadBalancer(loadBalancer.Id); err != nil { return err } return nil }
[ "func", "(", "loadBalancer", "*", "HostComputeLoadBalancer", ")", "Delete", "(", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "loadBalancer", ".", "Id", ")", "\n\n", "if", "err", ":=", "deleteLoadBalancer", "(", "loadBalancer", ".", "Id", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Delete LoadBalancer.
[ "Delete", "LoadBalancer", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L263-L270
143,619
Microsoft/hcsshim
hcn/hcnloadbalancer.go
AddEndpoint
func (loadBalancer *HostComputeLoadBalancer) AddEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::AddEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id) err := loadBalancer.Delete() if err != nil { return nil, err } // Add Endpoint to the Existing List loadBalancer.HostComputeEndpoints = append(loadBalancer.HostComputeEndpoints, endpoint.Id) return loadBalancer.Create() }
go
func (loadBalancer *HostComputeLoadBalancer) AddEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::AddEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id) err := loadBalancer.Delete() if err != nil { return nil, err } // Add Endpoint to the Existing List loadBalancer.HostComputeEndpoints = append(loadBalancer.HostComputeEndpoints, endpoint.Id) return loadBalancer.Create() }
[ "func", "(", "loadBalancer", "*", "HostComputeLoadBalancer", ")", "AddEndpoint", "(", "endpoint", "*", "HostComputeEndpoint", ")", "(", "*", "HostComputeLoadBalancer", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "loadBalancer", ".", "Id", ",", "endpoint", ".", "Id", ")", "\n\n", "err", ":=", "loadBalancer", ".", "Delete", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Add Endpoint to the Existing List", "loadBalancer", ".", "HostComputeEndpoints", "=", "append", "(", "loadBalancer", ".", "HostComputeEndpoints", ",", "endpoint", ".", "Id", ")", "\n\n", "return", "loadBalancer", ".", "Create", "(", ")", "\n", "}" ]
// AddEndpoint add an endpoint to a LoadBalancer
[ "AddEndpoint", "add", "an", "endpoint", "to", "a", "LoadBalancer" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L273-L285
143,620
Microsoft/hcsshim
hcn/hcnloadbalancer.go
RemoveEndpoint
func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::RemoveEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id) err := loadBalancer.Delete() if err != nil { return nil, err } // Create a list of all the endpoints besides the one being removed var endpoints []string for _, endpointReference := range loadBalancer.HostComputeEndpoints { if endpointReference == endpoint.Id { continue } endpoints = append(endpoints, endpointReference) } loadBalancer.HostComputeEndpoints = endpoints return loadBalancer.Create() }
go
func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::RemoveEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id) err := loadBalancer.Delete() if err != nil { return nil, err } // Create a list of all the endpoints besides the one being removed var endpoints []string for _, endpointReference := range loadBalancer.HostComputeEndpoints { if endpointReference == endpoint.Id { continue } endpoints = append(endpoints, endpointReference) } loadBalancer.HostComputeEndpoints = endpoints return loadBalancer.Create() }
[ "func", "(", "loadBalancer", "*", "HostComputeLoadBalancer", ")", "RemoveEndpoint", "(", "endpoint", "*", "HostComputeEndpoint", ")", "(", "*", "HostComputeLoadBalancer", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "loadBalancer", ".", "Id", ",", "endpoint", ".", "Id", ")", "\n\n", "err", ":=", "loadBalancer", ".", "Delete", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Create a list of all the endpoints besides the one being removed", "var", "endpoints", "[", "]", "string", "\n", "for", "_", ",", "endpointReference", ":=", "range", "loadBalancer", ".", "HostComputeEndpoints", "{", "if", "endpointReference", "==", "endpoint", ".", "Id", "{", "continue", "\n", "}", "\n", "endpoints", "=", "append", "(", "endpoints", ",", "endpointReference", ")", "\n", "}", "\n", "loadBalancer", ".", "HostComputeEndpoints", "=", "endpoints", "\n", "return", "loadBalancer", ".", "Create", "(", ")", "\n", "}" ]
// RemoveEndpoint removes an endpoint from a LoadBalancer
[ "RemoveEndpoint", "removes", "an", "endpoint", "from", "a", "LoadBalancer" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L288-L306
143,621
Microsoft/hcsshim
hcn/hcnloadbalancer.go
AddLoadBalancer
func AddLoadBalancer(endpoints []HostComputeEndpoint, flags LoadBalancerFlags, portMappingFlags LoadBalancerPortMappingFlags, sourceVIP string, frontendVIPs []string, protocol uint16, internalPort uint16, externalPort uint16) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::AddLoadBalancer endpointId=%v, LoadBalancerFlags=%v, LoadBalancerPortMappingFlags=%v, sourceVIP=%s, frontendVIPs=%v, protocol=%v, internalPort=%v, externalPort=%v", endpoints, flags, portMappingFlags, sourceVIP, frontendVIPs, protocol, internalPort, externalPort) loadBalancer := &HostComputeLoadBalancer{ SourceVIP: sourceVIP, PortMappings: []LoadBalancerPortMapping{ { Protocol: uint32(protocol), InternalPort: internalPort, ExternalPort: externalPort, Flags: portMappingFlags, }, }, FrontendVIPs: frontendVIPs, SchemaVersion: SchemaVersion{ Major: 2, Minor: 0, }, Flags: flags, } for _, endpoint := range endpoints { loadBalancer.HostComputeEndpoints = append(loadBalancer.HostComputeEndpoints, endpoint.Id) } return loadBalancer.Create() }
go
func AddLoadBalancer(endpoints []HostComputeEndpoint, flags LoadBalancerFlags, portMappingFlags LoadBalancerPortMappingFlags, sourceVIP string, frontendVIPs []string, protocol uint16, internalPort uint16, externalPort uint16) (*HostComputeLoadBalancer, error) { logrus.Debugf("hcn::HostComputeLoadBalancer::AddLoadBalancer endpointId=%v, LoadBalancerFlags=%v, LoadBalancerPortMappingFlags=%v, sourceVIP=%s, frontendVIPs=%v, protocol=%v, internalPort=%v, externalPort=%v", endpoints, flags, portMappingFlags, sourceVIP, frontendVIPs, protocol, internalPort, externalPort) loadBalancer := &HostComputeLoadBalancer{ SourceVIP: sourceVIP, PortMappings: []LoadBalancerPortMapping{ { Protocol: uint32(protocol), InternalPort: internalPort, ExternalPort: externalPort, Flags: portMappingFlags, }, }, FrontendVIPs: frontendVIPs, SchemaVersion: SchemaVersion{ Major: 2, Minor: 0, }, Flags: flags, } for _, endpoint := range endpoints { loadBalancer.HostComputeEndpoints = append(loadBalancer.HostComputeEndpoints, endpoint.Id) } return loadBalancer.Create() }
[ "func", "AddLoadBalancer", "(", "endpoints", "[", "]", "HostComputeEndpoint", ",", "flags", "LoadBalancerFlags", ",", "portMappingFlags", "LoadBalancerPortMappingFlags", ",", "sourceVIP", "string", ",", "frontendVIPs", "[", "]", "string", ",", "protocol", "uint16", ",", "internalPort", "uint16", ",", "externalPort", "uint16", ")", "(", "*", "HostComputeLoadBalancer", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "endpoints", ",", "flags", ",", "portMappingFlags", ",", "sourceVIP", ",", "frontendVIPs", ",", "protocol", ",", "internalPort", ",", "externalPort", ")", "\n\n", "loadBalancer", ":=", "&", "HostComputeLoadBalancer", "{", "SourceVIP", ":", "sourceVIP", ",", "PortMappings", ":", "[", "]", "LoadBalancerPortMapping", "{", "{", "Protocol", ":", "uint32", "(", "protocol", ")", ",", "InternalPort", ":", "internalPort", ",", "ExternalPort", ":", "externalPort", ",", "Flags", ":", "portMappingFlags", ",", "}", ",", "}", ",", "FrontendVIPs", ":", "frontendVIPs", ",", "SchemaVersion", ":", "SchemaVersion", "{", "Major", ":", "2", ",", "Minor", ":", "0", ",", "}", ",", "Flags", ":", "flags", ",", "}", "\n\n", "for", "_", ",", "endpoint", ":=", "range", "endpoints", "{", "loadBalancer", ".", "HostComputeEndpoints", "=", "append", "(", "loadBalancer", ".", "HostComputeEndpoints", ",", "endpoint", ".", "Id", ")", "\n", "}", "\n\n", "return", "loadBalancer", ".", "Create", "(", ")", "\n", "}" ]
// AddLoadBalancer for the specified endpoints
[ "AddLoadBalancer", "for", "the", "specified", "endpoints" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnloadbalancer.go#L309-L335
143,622
Microsoft/hcsshim
layer.go
CreateSandboxLayer
func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error { return wclayer.CreateScratchLayer(layerPath(&info, layerId), parentLayerPaths) }
go
func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error { return wclayer.CreateScratchLayer(layerPath(&info, layerId), parentLayerPaths) }
[ "func", "CreateSandboxLayer", "(", "info", "DriverInfo", ",", "layerId", ",", "parentId", "string", ",", "parentLayerPaths", "[", "]", "string", ")", "error", "{", "return", "wclayer", ".", "CreateScratchLayer", "(", "layerPath", "(", "&", "info", ",", "layerId", ")", ",", "parentLayerPaths", ")", "\n", "}" ]
// New clients should use CreateScratchLayer instead. Kept in to preserve API compatibility.
[ "New", "clients", "should", "use", "CreateScratchLayer", "instead", ".", "Kept", "in", "to", "preserve", "API", "compatibility", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/layer.go#L23-L25
143,623
Microsoft/hcsshim
layer.go
ExpandSandboxSize
func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error { return wclayer.ExpandScratchSize(layerPath(&info, layerId), size) }
go
func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error { return wclayer.ExpandScratchSize(layerPath(&info, layerId), size) }
[ "func", "ExpandSandboxSize", "(", "info", "DriverInfo", ",", "layerId", "string", ",", "size", "uint64", ")", "error", "{", "return", "wclayer", ".", "ExpandScratchSize", "(", "layerPath", "(", "&", "info", ",", "layerId", ")", ",", "size", ")", "\n", "}" ]
// New clients should use ExpandScratchSize instead. Kept in to preserve API compatibility.
[ "New", "clients", "should", "use", "ExpandScratchSize", "instead", ".", "Kept", "in", "to", "preserve", "API", "compatibility", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/layer.go#L37-L39
143,624
Microsoft/hcsshim
hcn/hcnnamespace.go
ListNamespaces
func ListNamespaces() ([]HostComputeNamespace, error) { hcnQuery := defaultQuery() namespaces, err := ListNamespacesQuery(hcnQuery) if err != nil { return nil, err } return namespaces, nil }
go
func ListNamespaces() ([]HostComputeNamespace, error) { hcnQuery := defaultQuery() namespaces, err := ListNamespacesQuery(hcnQuery) if err != nil { return nil, err } return namespaces, nil }
[ "func", "ListNamespaces", "(", ")", "(", "[", "]", "HostComputeNamespace", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "namespaces", ",", "err", ":=", "ListNamespacesQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "namespaces", ",", "nil", "\n", "}" ]
// ListNamespaces makes a call to list all available namespaces.
[ "ListNamespaces", "makes", "a", "call", "to", "list", "all", "available", "namespaces", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L219-L226
143,625
Microsoft/hcsshim
hcn/hcnnamespace.go
ListNamespacesQuery
func ListNamespacesQuery(query HostComputeQuery) ([]HostComputeNamespace, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } namespaces, err := enumerateNamespaces(string(queryJson)) if err != nil { return nil, err } return namespaces, nil }
go
func ListNamespacesQuery(query HostComputeQuery) ([]HostComputeNamespace, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } namespaces, err := enumerateNamespaces(string(queryJson)) if err != nil { return nil, err } return namespaces, nil }
[ "func", "ListNamespacesQuery", "(", "query", "HostComputeQuery", ")", "(", "[", "]", "HostComputeNamespace", ",", "error", ")", "{", "queryJson", ",", "err", ":=", "json", ".", "Marshal", "(", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "namespaces", ",", "err", ":=", "enumerateNamespaces", "(", "string", "(", "queryJson", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "namespaces", ",", "nil", "\n", "}" ]
// ListNamespacesQuery makes a call to query the list of available namespaces.
[ "ListNamespacesQuery", "makes", "a", "call", "to", "query", "the", "list", "of", "available", "namespaces", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L229-L240
143,626
Microsoft/hcsshim
hcn/hcnnamespace.go
GetNamespaceByID
func GetNamespaceByID(namespaceId string) (*HostComputeNamespace, error) { return getNamespace(guid.FromString(namespaceId), defaultQueryJson()) }
go
func GetNamespaceByID(namespaceId string) (*HostComputeNamespace, error) { return getNamespace(guid.FromString(namespaceId), defaultQueryJson()) }
[ "func", "GetNamespaceByID", "(", "namespaceId", "string", ")", "(", "*", "HostComputeNamespace", ",", "error", ")", "{", "return", "getNamespace", "(", "guid", ".", "FromString", "(", "namespaceId", ")", ",", "defaultQueryJson", "(", ")", ")", "\n", "}" ]
// GetNamespaceByID returns the Namespace specified by Id.
[ "GetNamespaceByID", "returns", "the", "Namespace", "specified", "by", "Id", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L243-L245
143,627
Microsoft/hcsshim
hcn/hcnnamespace.go
GetNamespaceEndpointIds
func GetNamespaceEndpointIds(namespaceId string) ([]string, error) { namespace, err := GetNamespaceByID(namespaceId) if err != nil { return nil, err } var endpointsIds []string for _, resource := range namespace.Resources { if resource.Type == "Endpoint" { var endpointResource NamespaceResourceEndpoint if err := json.Unmarshal([]byte(resource.Data), &endpointResource); err != nil { return nil, err } endpointsIds = append(endpointsIds, endpointResource.Id) } } return endpointsIds, nil }
go
func GetNamespaceEndpointIds(namespaceId string) ([]string, error) { namespace, err := GetNamespaceByID(namespaceId) if err != nil { return nil, err } var endpointsIds []string for _, resource := range namespace.Resources { if resource.Type == "Endpoint" { var endpointResource NamespaceResourceEndpoint if err := json.Unmarshal([]byte(resource.Data), &endpointResource); err != nil { return nil, err } endpointsIds = append(endpointsIds, endpointResource.Id) } } return endpointsIds, nil }
[ "func", "GetNamespaceEndpointIds", "(", "namespaceId", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "namespace", ",", "err", ":=", "GetNamespaceByID", "(", "namespaceId", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "endpointsIds", "[", "]", "string", "\n", "for", "_", ",", "resource", ":=", "range", "namespace", ".", "Resources", "{", "if", "resource", ".", "Type", "==", "\"", "\"", "{", "var", "endpointResource", "NamespaceResourceEndpoint", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "resource", ".", "Data", ")", ",", "&", "endpointResource", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "endpointsIds", "=", "append", "(", "endpointsIds", ",", "endpointResource", ".", "Id", ")", "\n", "}", "\n", "}", "\n", "return", "endpointsIds", ",", "nil", "\n", "}" ]
// GetNamespaceEndpointIds returns the endpoints of the Namespace specified by Id.
[ "GetNamespaceEndpointIds", "returns", "the", "endpoints", "of", "the", "Namespace", "specified", "by", "Id", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L248-L264
143,628
Microsoft/hcsshim
hcn/hcnnamespace.go
GetNamespaceContainerIds
func GetNamespaceContainerIds(namespaceId string) ([]string, error) { namespace, err := GetNamespaceByID(namespaceId) if err != nil { return nil, err } var containerIds []string for _, resource := range namespace.Resources { if resource.Type == "Container" { var contaienrResource NamespaceResourceContainer if err := json.Unmarshal([]byte(resource.Data), &contaienrResource); err != nil { return nil, err } containerIds = append(containerIds, contaienrResource.Id) } } return containerIds, nil }
go
func GetNamespaceContainerIds(namespaceId string) ([]string, error) { namespace, err := GetNamespaceByID(namespaceId) if err != nil { return nil, err } var containerIds []string for _, resource := range namespace.Resources { if resource.Type == "Container" { var contaienrResource NamespaceResourceContainer if err := json.Unmarshal([]byte(resource.Data), &contaienrResource); err != nil { return nil, err } containerIds = append(containerIds, contaienrResource.Id) } } return containerIds, nil }
[ "func", "GetNamespaceContainerIds", "(", "namespaceId", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "namespace", ",", "err", ":=", "GetNamespaceByID", "(", "namespaceId", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "containerIds", "[", "]", "string", "\n", "for", "_", ",", "resource", ":=", "range", "namespace", ".", "Resources", "{", "if", "resource", ".", "Type", "==", "\"", "\"", "{", "var", "contaienrResource", "NamespaceResourceContainer", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "resource", ".", "Data", ")", ",", "&", "contaienrResource", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "containerIds", "=", "append", "(", "containerIds", ",", "contaienrResource", ".", "Id", ")", "\n", "}", "\n", "}", "\n", "return", "containerIds", ",", "nil", "\n", "}" ]
// GetNamespaceContainerIds returns the containers of the Namespace specified by Id.
[ "GetNamespaceContainerIds", "returns", "the", "containers", "of", "the", "Namespace", "specified", "by", "Id", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L267-L283
143,629
Microsoft/hcsshim
hcn/hcnnamespace.go
Create
func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) { logrus.Debugf("hcn::HostComputeNamespace::Create id=%s", namespace.Id) jsonString, err := json.Marshal(namespace) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeNamespace::Create JSON: %s", jsonString) namespace, hcnErr := createNamespace(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return namespace, nil }
go
func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) { logrus.Debugf("hcn::HostComputeNamespace::Create id=%s", namespace.Id) jsonString, err := json.Marshal(namespace) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeNamespace::Create JSON: %s", jsonString) namespace, hcnErr := createNamespace(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return namespace, nil }
[ "func", "(", "namespace", "*", "HostComputeNamespace", ")", "Create", "(", ")", "(", "*", "HostComputeNamespace", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "namespace", ".", "Id", ")", "\n\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "namespace", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "jsonString", ")", "\n", "namespace", ",", "hcnErr", ":=", "createNamespace", "(", "string", "(", "jsonString", ")", ")", "\n", "if", "hcnErr", "!=", "nil", "{", "return", "nil", ",", "hcnErr", "\n", "}", "\n", "return", "namespace", ",", "nil", "\n", "}" ]
// Create Namespace.
[ "Create", "Namespace", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L294-L308
143,630
Microsoft/hcsshim
hcn/hcnnamespace.go
Delete
func (namespace *HostComputeNamespace) Delete() error { logrus.Debugf("hcn::HostComputeNamespace::Delete id=%s", namespace.Id) if err := deleteNamespace(namespace.Id); err != nil { return err } return nil }
go
func (namespace *HostComputeNamespace) Delete() error { logrus.Debugf("hcn::HostComputeNamespace::Delete id=%s", namespace.Id) if err := deleteNamespace(namespace.Id); err != nil { return err } return nil }
[ "func", "(", "namespace", "*", "HostComputeNamespace", ")", "Delete", "(", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "namespace", ".", "Id", ")", "\n\n", "if", "err", ":=", "deleteNamespace", "(", "namespace", ".", "Id", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Delete Namespace.
[ "Delete", "Namespace", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L311-L318
143,631
Microsoft/hcsshim
hcn/hcnnamespace.go
AddNamespaceEndpoint
func AddNamespaceEndpoint(namespaceId string, endpointId string) error { logrus.Debugf("hcn::HostComputeEndpoint::AddNamespaceEndpoint id=%s", endpointId) mapA := map[string]string{"EndpointId": endpointId} settingsJson, err := json.Marshal(mapA) if err != nil { return err } requestMessage := &ModifyNamespaceSettingRequest{ ResourceType: NamespaceResourceTypeEndpoint, RequestType: RequestTypeAdd, Settings: settingsJson, } return ModifyNamespaceSettings(namespaceId, requestMessage) }
go
func AddNamespaceEndpoint(namespaceId string, endpointId string) error { logrus.Debugf("hcn::HostComputeEndpoint::AddNamespaceEndpoint id=%s", endpointId) mapA := map[string]string{"EndpointId": endpointId} settingsJson, err := json.Marshal(mapA) if err != nil { return err } requestMessage := &ModifyNamespaceSettingRequest{ ResourceType: NamespaceResourceTypeEndpoint, RequestType: RequestTypeAdd, Settings: settingsJson, } return ModifyNamespaceSettings(namespaceId, requestMessage) }
[ "func", "AddNamespaceEndpoint", "(", "namespaceId", "string", ",", "endpointId", "string", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "endpointId", ")", "\n\n", "mapA", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "endpointId", "}", "\n", "settingsJson", ",", "err", ":=", "json", ".", "Marshal", "(", "mapA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "requestMessage", ":=", "&", "ModifyNamespaceSettingRequest", "{", "ResourceType", ":", "NamespaceResourceTypeEndpoint", ",", "RequestType", ":", "RequestTypeAdd", ",", "Settings", ":", "settingsJson", ",", "}", "\n\n", "return", "ModifyNamespaceSettings", "(", "namespaceId", ",", "requestMessage", ")", "\n", "}" ]
// AddNamespaceEndpoint adds an endpoint to a Namespace.
[ "AddNamespaceEndpoint", "adds", "an", "endpoint", "to", "a", "Namespace", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnamespace.go#L391-L406
143,632
Microsoft/hcsshim
internal/oci/util.go
IsIsolated
func IsIsolated(s *specs.Spec) bool { return IsLCOW(s) || (s.Windows != nil && s.Windows.HyperV != nil) }
go
func IsIsolated(s *specs.Spec) bool { return IsLCOW(s) || (s.Windows != nil && s.Windows.HyperV != nil) }
[ "func", "IsIsolated", "(", "s", "*", "specs", ".", "Spec", ")", "bool", "{", "return", "IsLCOW", "(", "s", ")", "||", "(", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "HyperV", "!=", "nil", ")", "\n", "}" ]
// IsIsolated checks if `s` is hypervisor isolated.
[ "IsIsolated", "checks", "if", "s", "is", "hypervisor", "isolated", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/util.go#L16-L18
143,633
Microsoft/hcsshim
internal/ociwclayer/import.go
ImportLayer
func ImportLayer(r io.Reader, path string, parentLayerPaths []string) (int64, error) { err := os.MkdirAll(path, 0) if err != nil { return 0, err } w, err := hcsshim.NewLayerWriter(hcsshim.DriverInfo{}, path, parentLayerPaths) if err != nil { return 0, err } n, err := writeLayerFromTar(r, w, path) cerr := w.Close() if err != nil { return 0, err } if cerr != nil { return 0, cerr } return n, nil }
go
func ImportLayer(r io.Reader, path string, parentLayerPaths []string) (int64, error) { err := os.MkdirAll(path, 0) if err != nil { return 0, err } w, err := hcsshim.NewLayerWriter(hcsshim.DriverInfo{}, path, parentLayerPaths) if err != nil { return 0, err } n, err := writeLayerFromTar(r, w, path) cerr := w.Close() if err != nil { return 0, err } if cerr != nil { return 0, cerr } return n, nil }
[ "func", "ImportLayer", "(", "r", "io", ".", "Reader", ",", "path", "string", ",", "parentLayerPaths", "[", "]", "string", ")", "(", "int64", ",", "error", ")", "{", "err", ":=", "os", ".", "MkdirAll", "(", "path", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "w", ",", "err", ":=", "hcsshim", ".", "NewLayerWriter", "(", "hcsshim", ".", "DriverInfo", "{", "}", ",", "path", ",", "parentLayerPaths", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "n", ",", "err", ":=", "writeLayerFromTar", "(", "r", ",", "w", ",", "path", ")", "\n", "cerr", ":=", "w", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "cerr", "!=", "nil", "{", "return", "0", ",", "cerr", "\n", "}", "\n", "return", "n", ",", "nil", "\n", "}" ]
// ImportLayer reads a layer from an OCI layer tar stream and extracts it to the // specified path. The caller must specify the parent layers, if any, ordered // from lowest to highest layer. // // The caller must ensure that the thread or process has acquired backup and // restore privileges. // // This function returns the total size of the layer's files, in bytes.
[ "ImportLayer", "reads", "a", "layer", "from", "an", "OCI", "layer", "tar", "stream", "and", "extracts", "it", "to", "the", "specified", "path", ".", "The", "caller", "must", "specify", "the", "parent", "layers", "if", "any", "ordered", "from", "lowest", "to", "highest", "layer", ".", "The", "caller", "must", "ensure", "that", "the", "thread", "or", "process", "has", "acquired", "backup", "and", "restore", "privileges", ".", "This", "function", "returns", "the", "total", "size", "of", "the", "layer", "s", "files", "in", "bytes", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/ociwclayer/import.go#L38-L56
143,634
Microsoft/hcsshim
internal/lcow/tar2vhd.go
TarToVhd
func TarToVhd(lcowUVM *uvm.UtilityVM, targetVHDFile string, reader io.Reader) (int64, error) { logrus.Debugf("hcsshim: TarToVhd: %s", targetVHDFile) if lcowUVM == nil { return 0, fmt.Errorf("no utility VM passed") } //defer uvm.DebugLCOWGCS() outFile, err := os.Create(targetVHDFile) if err != nil { return 0, fmt.Errorf("tar2vhd failed to create %s: %s", targetVHDFile, err) } defer outFile.Close() // BUGBUG Delete the file on failure tar2vhd, byteCounts, err := CreateProcess(&ProcessOptions{ HCSSystem: lcowUVM.ComputeSystem(), Process: &specs.Process{Args: []string{"tar2vhd"}}, CreateInUtilityVm: true, Stdin: reader, Stdout: outFile, CopyTimeout: 2 * time.Minute, }) if err != nil { return 0, fmt.Errorf("failed to start tar2vhd for %s: %s", targetVHDFile, err) } defer tar2vhd.Close() logrus.Debugf("hcsshim: TarToVhd: %s created, %d bytes", targetVHDFile, byteCounts.Out) return byteCounts.Out, err }
go
func TarToVhd(lcowUVM *uvm.UtilityVM, targetVHDFile string, reader io.Reader) (int64, error) { logrus.Debugf("hcsshim: TarToVhd: %s", targetVHDFile) if lcowUVM == nil { return 0, fmt.Errorf("no utility VM passed") } //defer uvm.DebugLCOWGCS() outFile, err := os.Create(targetVHDFile) if err != nil { return 0, fmt.Errorf("tar2vhd failed to create %s: %s", targetVHDFile, err) } defer outFile.Close() // BUGBUG Delete the file on failure tar2vhd, byteCounts, err := CreateProcess(&ProcessOptions{ HCSSystem: lcowUVM.ComputeSystem(), Process: &specs.Process{Args: []string{"tar2vhd"}}, CreateInUtilityVm: true, Stdin: reader, Stdout: outFile, CopyTimeout: 2 * time.Minute, }) if err != nil { return 0, fmt.Errorf("failed to start tar2vhd for %s: %s", targetVHDFile, err) } defer tar2vhd.Close() logrus.Debugf("hcsshim: TarToVhd: %s created, %d bytes", targetVHDFile, byteCounts.Out) return byteCounts.Out, err }
[ "func", "TarToVhd", "(", "lcowUVM", "*", "uvm", ".", "UtilityVM", ",", "targetVHDFile", "string", ",", "reader", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "targetVHDFile", ")", "\n\n", "if", "lcowUVM", "==", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "//defer uvm.DebugLCOWGCS()", "outFile", ",", "err", ":=", "os", ".", "Create", "(", "targetVHDFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "targetVHDFile", ",", "err", ")", "\n", "}", "\n", "defer", "outFile", ".", "Close", "(", ")", "\n", "// BUGBUG Delete the file on failure", "tar2vhd", ",", "byteCounts", ",", "err", ":=", "CreateProcess", "(", "&", "ProcessOptions", "{", "HCSSystem", ":", "lcowUVM", ".", "ComputeSystem", "(", ")", ",", "Process", ":", "&", "specs", ".", "Process", "{", "Args", ":", "[", "]", "string", "{", "\"", "\"", "}", "}", ",", "CreateInUtilityVm", ":", "true", ",", "Stdin", ":", "reader", ",", "Stdout", ":", "outFile", ",", "CopyTimeout", ":", "2", "*", "time", ".", "Minute", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "targetVHDFile", ",", "err", ")", "\n", "}", "\n", "defer", "tar2vhd", ".", "Close", "(", ")", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "targetVHDFile", ",", "byteCounts", ".", "Out", ")", "\n", "return", "byteCounts", ".", "Out", ",", "err", "\n", "}" ]
// TarToVhd streams a tarstream contained in an io.Reader to a fixed vhd file
[ "TarToVhd", "streams", "a", "tarstream", "contained", "in", "an", "io", ".", "Reader", "to", "a", "fixed", "vhd", "file" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/lcow/tar2vhd.go#L15-L46
143,635
Microsoft/hcsshim
internal/uvm/network.go
AddNetNS
func (uvm *UtilityVM) AddNetNS(id string) (err error) { op := "uvm::AddNetNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() if _, ok := uvm.namespaces[id]; ok { return ErrNetNSAlreadyAttached } if uvm.isNetworkNamespaceSupported() { // Add a Guest Network namespace. On LCOW we add the adapters // dynamically. if uvm.operatingSystem == "windows" { hcnNamespace, err := hcn.GetNamespaceByID(id) if err != nil { return err } guestNamespace := hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeNetworkNamespace, RequestType: requesttype.Add, Settings: hcnNamespace, }, } if err := uvm.Modify(&guestNamespace); err != nil { return err } } } if uvm.namespaces == nil { uvm.namespaces = make(map[string]*namespaceInfo) } uvm.namespaces[id] = &namespaceInfo{ nics: make(map[string]*nicInfo), } return nil }
go
func (uvm *UtilityVM) AddNetNS(id string) (err error) { op := "uvm::AddNetNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() if _, ok := uvm.namespaces[id]; ok { return ErrNetNSAlreadyAttached } if uvm.isNetworkNamespaceSupported() { // Add a Guest Network namespace. On LCOW we add the adapters // dynamically. if uvm.operatingSystem == "windows" { hcnNamespace, err := hcn.GetNamespaceByID(id) if err != nil { return err } guestNamespace := hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeNetworkNamespace, RequestType: requesttype.Add, Settings: hcnNamespace, }, } if err := uvm.Modify(&guestNamespace); err != nil { return err } } } if uvm.namespaces == nil { uvm.namespaces = make(map[string]*namespaceInfo) } uvm.namespaces[id] = &namespaceInfo{ nics: make(map[string]*nicInfo), } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "AddNetNS", "(", "id", "string", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "uvm", ".", "namespaces", "[", "id", "]", ";", "ok", "{", "return", "ErrNetNSAlreadyAttached", "\n", "}", "\n\n", "if", "uvm", ".", "isNetworkNamespaceSupported", "(", ")", "{", "// Add a Guest Network namespace. On LCOW we add the adapters", "// dynamically.", "if", "uvm", ".", "operatingSystem", "==", "\"", "\"", "{", "hcnNamespace", ",", "err", ":=", "hcn", ".", "GetNamespaceByID", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "guestNamespace", ":=", "hcsschema", ".", "ModifySettingRequest", "{", "GuestRequest", ":", "guestrequest", ".", "GuestRequest", "{", "ResourceType", ":", "guestrequest", ".", "ResourceTypeNetworkNamespace", ",", "RequestType", ":", "requesttype", ".", "Add", ",", "Settings", ":", "hcnNamespace", ",", "}", ",", "}", "\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "&", "guestNamespace", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "uvm", ".", "namespaces", "==", "nil", "{", "uvm", ".", "namespaces", "=", "make", "(", "map", "[", "string", "]", "*", "namespaceInfo", ")", "\n", "}", "\n", "uvm", ".", "namespaces", "[", "id", "]", "=", "&", "namespaceInfo", "{", "nics", ":", "make", "(", "map", "[", "string", "]", "*", "nicInfo", ")", ",", "}", "\n", "return", "nil", "\n", "}" ]
// AddNetNS adds network namespace inside the guest. // // If a namespace with `id` already exists returns `ErrNetNSAlreadyAttached`.
[ "AddNetNS", "adds", "network", "namespace", "inside", "the", "guest", ".", "If", "a", "namespace", "with", "id", "already", "exists", "returns", "ErrNetNSAlreadyAttached", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/network.go#L32-L82
143,636
Microsoft/hcsshim
internal/uvm/network.go
AddEndpointsToNS
func (uvm *UtilityVM) AddEndpointsToNS(id string, endpoints []*hns.HNSEndpoint) (err error) { op := "uvm::AddEndpointsToNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() ns, ok := uvm.namespaces[id] if !ok { return ErrNetNSNotFound } for _, endpoint := range endpoints { if _, ok := ns.nics[endpoint.Id]; !ok { nicID := guid.New() if err := uvm.addNIC(nicID, endpoint); err != nil { return err } ns.nics[endpoint.Id] = &nicInfo{ ID: nicID, Endpoint: endpoint, } } } return nil }
go
func (uvm *UtilityVM) AddEndpointsToNS(id string, endpoints []*hns.HNSEndpoint) (err error) { op := "uvm::AddEndpointsToNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() ns, ok := uvm.namespaces[id] if !ok { return ErrNetNSNotFound } for _, endpoint := range endpoints { if _, ok := ns.nics[endpoint.Id]; !ok { nicID := guid.New() if err := uvm.addNIC(nicID, endpoint); err != nil { return err } ns.nics[endpoint.Id] = &nicInfo{ ID: nicID, Endpoint: endpoint, } } } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "AddEndpointsToNS", "(", "id", "string", ",", "endpoints", "[", "]", "*", "hns", ".", "HNSEndpoint", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n\n", "ns", ",", "ok", ":=", "uvm", ".", "namespaces", "[", "id", "]", "\n", "if", "!", "ok", "{", "return", "ErrNetNSNotFound", "\n", "}", "\n\n", "for", "_", ",", "endpoint", ":=", "range", "endpoints", "{", "if", "_", ",", "ok", ":=", "ns", ".", "nics", "[", "endpoint", ".", "Id", "]", ";", "!", "ok", "{", "nicID", ":=", "guid", ".", "New", "(", ")", "\n", "if", "err", ":=", "uvm", ".", "addNIC", "(", "nicID", ",", "endpoint", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "ns", ".", "nics", "[", "endpoint", ".", "Id", "]", "=", "&", "nicInfo", "{", "ID", ":", "nicID", ",", "Endpoint", ":", "endpoint", ",", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// AddEndpointsToNS adds all unique `endpoints` to the network namespace // matching `id`. On failure does not roll back any previously successfully // added endpoints. // // If no network namespace matches `id` returns `ErrNetNSNotFound`.
[ "AddEndpointsToNS", "adds", "all", "unique", "endpoints", "to", "the", "network", "namespace", "matching", "id", ".", "On", "failure", "does", "not", "roll", "back", "any", "previously", "successfully", "added", "endpoints", ".", "If", "no", "network", "namespace", "matches", "id", "returns", "ErrNetNSNotFound", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/network.go#L89-L126
143,637
Microsoft/hcsshim
internal/uvm/network.go
RemoveNetNS
func (uvm *UtilityVM) RemoveNetNS(id string) (err error) { op := "uvm::RemoveNetNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() if ns, ok := uvm.namespaces[id]; ok { for _, ninfo := range ns.nics { if err := uvm.removeNIC(ninfo.ID, ninfo.Endpoint); err != nil { return err } ns.nics[ninfo.Endpoint.Id] = nil } // Remove the Guest Network namespace if uvm.isNetworkNamespaceSupported() { if uvm.operatingSystem == "windows" { hcnNamespace, err := hcn.GetNamespaceByID(id) if err != nil { return err } guestNamespace := hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeNetworkNamespace, RequestType: requesttype.Remove, Settings: hcnNamespace, }, } if err := uvm.Modify(&guestNamespace); err != nil { return err } } } delete(uvm.namespaces, id) } return nil }
go
func (uvm *UtilityVM) RemoveNetNS(id string) (err error) { op := "uvm::RemoveNetNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() if ns, ok := uvm.namespaces[id]; ok { for _, ninfo := range ns.nics { if err := uvm.removeNIC(ninfo.ID, ninfo.Endpoint); err != nil { return err } ns.nics[ninfo.Endpoint.Id] = nil } // Remove the Guest Network namespace if uvm.isNetworkNamespaceSupported() { if uvm.operatingSystem == "windows" { hcnNamespace, err := hcn.GetNamespaceByID(id) if err != nil { return err } guestNamespace := hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeNetworkNamespace, RequestType: requesttype.Remove, Settings: hcnNamespace, }, } if err := uvm.Modify(&guestNamespace); err != nil { return err } } } delete(uvm.namespaces, id) } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "RemoveNetNS", "(", "id", "string", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "if", "ns", ",", "ok", ":=", "uvm", ".", "namespaces", "[", "id", "]", ";", "ok", "{", "for", "_", ",", "ninfo", ":=", "range", "ns", ".", "nics", "{", "if", "err", ":=", "uvm", ".", "removeNIC", "(", "ninfo", ".", "ID", ",", "ninfo", ".", "Endpoint", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "ns", ".", "nics", "[", "ninfo", ".", "Endpoint", ".", "Id", "]", "=", "nil", "\n", "}", "\n", "// Remove the Guest Network namespace", "if", "uvm", ".", "isNetworkNamespaceSupported", "(", ")", "{", "if", "uvm", ".", "operatingSystem", "==", "\"", "\"", "{", "hcnNamespace", ",", "err", ":=", "hcn", ".", "GetNamespaceByID", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "guestNamespace", ":=", "hcsschema", ".", "ModifySettingRequest", "{", "GuestRequest", ":", "guestrequest", ".", "GuestRequest", "{", "ResourceType", ":", "guestrequest", ".", "ResourceTypeNetworkNamespace", ",", "RequestType", ":", "requesttype", ".", "Remove", ",", "Settings", ":", "hcnNamespace", ",", "}", ",", "}", "\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "&", "guestNamespace", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "delete", "(", "uvm", ".", "namespaces", ",", "id", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemoveNetNS removes the namespace from the uvm and all remaining endpoints in // the namespace. // // If a namespace matching `id` is not found this command silently succeeds.
[ "RemoveNetNS", "removes", "the", "namespace", "from", "the", "uvm", "and", "all", "remaining", "endpoints", "in", "the", "namespace", ".", "If", "a", "namespace", "matching", "id", "is", "not", "found", "this", "command", "silently", "succeeds", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/network.go#L132-L179
143,638
Microsoft/hcsshim
internal/uvm/network.go
RemoveEndpointsFromNS
func (uvm *UtilityVM) RemoveEndpointsFromNS(id string, endpoints []*hns.HNSEndpoint) (err error) { op := "uvm::RemoveEndpointsFromNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() ns, ok := uvm.namespaces[id] if !ok { return ErrNetNSNotFound } for _, endpoint := range endpoints { if ninfo, ok := ns.nics[endpoint.Id]; ok && ninfo != nil { if err := uvm.removeNIC(ninfo.ID, ninfo.Endpoint); err != nil { return err } delete(ns.nics, endpoint.Id) } } return nil }
go
func (uvm *UtilityVM) RemoveEndpointsFromNS(id string, endpoints []*hns.HNSEndpoint) (err error) { op := "uvm::RemoveEndpointsFromNS" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "netns-id": id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.m.Lock() defer uvm.m.Unlock() ns, ok := uvm.namespaces[id] if !ok { return ErrNetNSNotFound } for _, endpoint := range endpoints { if ninfo, ok := ns.nics[endpoint.Id]; ok && ninfo != nil { if err := uvm.removeNIC(ninfo.ID, ninfo.Endpoint); err != nil { return err } delete(ns.nics, endpoint.Id) } } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "RemoveEndpointsFromNS", "(", "id", "string", ",", "endpoints", "[", "]", "*", "hns", ".", "HNSEndpoint", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n\n", "ns", ",", "ok", ":=", "uvm", ".", "namespaces", "[", "id", "]", "\n", "if", "!", "ok", "{", "return", "ErrNetNSNotFound", "\n", "}", "\n\n", "for", "_", ",", "endpoint", ":=", "range", "endpoints", "{", "if", "ninfo", ",", "ok", ":=", "ns", ".", "nics", "[", "endpoint", ".", "Id", "]", ";", "ok", "&&", "ninfo", "!=", "nil", "{", "if", "err", ":=", "uvm", ".", "removeNIC", "(", "ninfo", ".", "ID", ",", "ninfo", ".", "Endpoint", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "delete", "(", "ns", ".", "nics", ",", "endpoint", ".", "Id", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemoveEndpointsFromNS removes all matching `endpoints` in the network // namespace matching `id`. If no endpoint matching `endpoint.Id` is found in // the network namespace this command silently succeeds. // // If no network namespace matches `id` returns `ErrNetNSNotFound`.
[ "RemoveEndpointsFromNS", "removes", "all", "matching", "endpoints", "in", "the", "network", "namespace", "matching", "id", ".", "If", "no", "endpoint", "matching", "endpoint", ".", "Id", "is", "found", "in", "the", "network", "namespace", "this", "command", "silently", "succeeds", ".", "If", "no", "network", "namespace", "matches", "id", "returns", "ErrNetNSNotFound", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/network.go#L186-L219
143,639
Microsoft/hcsshim
internal/uvm/network.go
isNetworkNamespaceSupported
func (uvm *UtilityVM) isNetworkNamespaceSupported() bool { p, err := uvm.ComputeSystem().Properties(schema1.PropertyTypeGuestConnection) if err == nil { return p.GuestConnectionInfo.GuestDefinedCapabilities.NamespaceAddRequestSupported } return false }
go
func (uvm *UtilityVM) isNetworkNamespaceSupported() bool { p, err := uvm.ComputeSystem().Properties(schema1.PropertyTypeGuestConnection) if err == nil { return p.GuestConnectionInfo.GuestDefinedCapabilities.NamespaceAddRequestSupported } return false }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "isNetworkNamespaceSupported", "(", ")", "bool", "{", "p", ",", "err", ":=", "uvm", ".", "ComputeSystem", "(", ")", ".", "Properties", "(", "schema1", ".", "PropertyTypeGuestConnection", ")", "\n", "if", "err", "==", "nil", "{", "return", "p", ".", "GuestConnectionInfo", ".", "GuestDefinedCapabilities", ".", "NamespaceAddRequestSupported", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// IsNetworkNamespaceSupported returns bool value specifying if network namespace is supported inside the guest
[ "IsNetworkNamespaceSupported", "returns", "bool", "value", "specifying", "if", "network", "namespace", "is", "supported", "inside", "the", "guest" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/network.go#L222-L229
143,640
Microsoft/hcsshim
internal/hcs/utils.go
makeOpenFiles
func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) { fs := make([]io.ReadWriteCloser, len(hs)) for i, h := range hs { if h != syscall.Handle(0) { if err == nil { fs[i], err = winio.MakeOpenFile(h) } if err != nil { syscall.Close(h) } } } if err != nil { for _, f := range fs { if f != nil { f.Close() } } return nil, err } return fs, nil }
go
func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) { fs := make([]io.ReadWriteCloser, len(hs)) for i, h := range hs { if h != syscall.Handle(0) { if err == nil { fs[i], err = winio.MakeOpenFile(h) } if err != nil { syscall.Close(h) } } } if err != nil { for _, f := range fs { if f != nil { f.Close() } } return nil, err } return fs, nil }
[ "func", "makeOpenFiles", "(", "hs", "[", "]", "syscall", ".", "Handle", ")", "(", "_", "[", "]", "io", ".", "ReadWriteCloser", ",", "err", "error", ")", "{", "fs", ":=", "make", "(", "[", "]", "io", ".", "ReadWriteCloser", ",", "len", "(", "hs", ")", ")", "\n", "for", "i", ",", "h", ":=", "range", "hs", "{", "if", "h", "!=", "syscall", ".", "Handle", "(", "0", ")", "{", "if", "err", "==", "nil", "{", "fs", "[", "i", "]", ",", "err", "=", "winio", ".", "MakeOpenFile", "(", "h", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "syscall", ".", "Close", "(", "h", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "for", "_", ",", "f", ":=", "range", "fs", "{", "if", "f", "!=", "nil", "{", "f", ".", "Close", "(", ")", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "fs", ",", "nil", "\n", "}" ]
// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles // if there is an error.
[ "makeOpenFiles", "calls", "winio", ".", "MakeOpenFile", "for", "each", "handle", "in", "a", "slice", "but", "closes", "all", "the", "handles", "if", "there", "is", "an", "error", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/utils.go#L12-L33
143,641
Microsoft/hcsshim
internal/uvm/plan9.go
AddPlan9
func (uvm *UtilityVM) AddPlan9(hostPath string, uvmPath string, readOnly bool, restrict bool, allowedNames []string) (_ *Plan9Share, err error) { op := "uvm::AddPlan9" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, "uvm-path": uvmPath, "readOnly": readOnly, "restrict": restrict, "allowedNames": allowedNames, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return nil, errNotSupported } if restrict && osversion.Get().Build < 18328 { return nil, errors.New("single-file mappings are not supported on this build of Windows") } if uvmPath == "" { return nil, fmt.Errorf("uvmPath must be passed to AddPlan9") } // TODO: JTERRY75 - These are marked private in the schema. For now use them // but when there are public variants we need to switch to them. const ( shareFlagsReadOnly int32 = 0x00000001 shareFlagsLinuxMetadata int32 = 0x00000004 shareFlagsCaseSensitive int32 = 0x00000008 shareFlagsRestrictFileAccess int32 = 0x00000080 ) // TODO: JTERRY75 - `shareFlagsCaseSensitive` only works if the Windows // `hostPath` supports case sensitivity. We need to detect this case before // forwarding this flag in all cases. flags := shareFlagsLinuxMetadata // | shareFlagsCaseSensitive if readOnly { flags |= shareFlagsReadOnly } if restrict { flags |= shareFlagsRestrictFileAccess } uvm.m.Lock() index := uvm.plan9Counter uvm.plan9Counter++ uvm.m.Unlock() name := strconv.FormatUint(index, 10) modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Add, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, Path: hostPath, Port: plan9Port, Flags: flags, AllowedFiles: allowedNames, }, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/Plan9/Shares"), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeMappedDirectory, RequestType: requesttype.Add, Settings: guestrequest.LCOWMappedDirectory{ MountPath: uvmPath, ShareName: name, Port: plan9Port, ReadOnly: readOnly, }, }, } if err := uvm.Modify(modification); err != nil { return nil, err } share := &Plan9Share{name: name, uvmPath: uvmPath} return share, nil }
go
func (uvm *UtilityVM) AddPlan9(hostPath string, uvmPath string, readOnly bool, restrict bool, allowedNames []string) (_ *Plan9Share, err error) { op := "uvm::AddPlan9" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, "uvm-path": uvmPath, "readOnly": readOnly, "restrict": restrict, "allowedNames": allowedNames, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return nil, errNotSupported } if restrict && osversion.Get().Build < 18328 { return nil, errors.New("single-file mappings are not supported on this build of Windows") } if uvmPath == "" { return nil, fmt.Errorf("uvmPath must be passed to AddPlan9") } // TODO: JTERRY75 - These are marked private in the schema. For now use them // but when there are public variants we need to switch to them. const ( shareFlagsReadOnly int32 = 0x00000001 shareFlagsLinuxMetadata int32 = 0x00000004 shareFlagsCaseSensitive int32 = 0x00000008 shareFlagsRestrictFileAccess int32 = 0x00000080 ) // TODO: JTERRY75 - `shareFlagsCaseSensitive` only works if the Windows // `hostPath` supports case sensitivity. We need to detect this case before // forwarding this flag in all cases. flags := shareFlagsLinuxMetadata // | shareFlagsCaseSensitive if readOnly { flags |= shareFlagsReadOnly } if restrict { flags |= shareFlagsRestrictFileAccess } uvm.m.Lock() index := uvm.plan9Counter uvm.plan9Counter++ uvm.m.Unlock() name := strconv.FormatUint(index, 10) modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Add, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, Path: hostPath, Port: plan9Port, Flags: flags, AllowedFiles: allowedNames, }, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/Plan9/Shares"), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeMappedDirectory, RequestType: requesttype.Add, Settings: guestrequest.LCOWMappedDirectory{ MountPath: uvmPath, ShareName: name, Port: plan9Port, ReadOnly: readOnly, }, }, } if err := uvm.Modify(modification); err != nil { return nil, err } share := &Plan9Share{name: name, uvmPath: uvmPath} return share, nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "AddPlan9", "(", "hostPath", "string", ",", "uvmPath", "string", ",", "readOnly", "bool", ",", "restrict", "bool", ",", "allowedNames", "[", "]", "string", ")", "(", "_", "*", "Plan9Share", ",", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "\"", "\"", ":", "uvmPath", ",", "\"", "\"", ":", "readOnly", ",", "\"", "\"", ":", "restrict", ",", "\"", "\"", ":", "allowedNames", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "operatingSystem", "!=", "\"", "\"", "{", "return", "nil", ",", "errNotSupported", "\n", "}", "\n", "if", "restrict", "&&", "osversion", ".", "Get", "(", ")", ".", "Build", "<", "18328", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "uvmPath", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// TODO: JTERRY75 - These are marked private in the schema. For now use them", "// but when there are public variants we need to switch to them.", "const", "(", "shareFlagsReadOnly", "int32", "=", "0x00000001", "\n", "shareFlagsLinuxMetadata", "int32", "=", "0x00000004", "\n", "shareFlagsCaseSensitive", "int32", "=", "0x00000008", "\n", "shareFlagsRestrictFileAccess", "int32", "=", "0x00000080", "\n", ")", "\n\n", "// TODO: JTERRY75 - `shareFlagsCaseSensitive` only works if the Windows", "// `hostPath` supports case sensitivity. We need to detect this case before", "// forwarding this flag in all cases.", "flags", ":=", "shareFlagsLinuxMetadata", "// | shareFlagsCaseSensitive", "\n", "if", "readOnly", "{", "flags", "|=", "shareFlagsReadOnly", "\n", "}", "\n", "if", "restrict", "{", "flags", "|=", "shareFlagsRestrictFileAccess", "\n", "}", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "index", ":=", "uvm", ".", "plan9Counter", "\n", "uvm", ".", "plan9Counter", "++", "\n", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "name", ":=", "strconv", ".", "FormatUint", "(", "index", ",", "10", ")", "\n\n", "modification", ":=", "&", "hcsschema", ".", "ModifySettingRequest", "{", "RequestType", ":", "requesttype", ".", "Add", ",", "Settings", ":", "hcsschema", ".", "Plan9Share", "{", "Name", ":", "name", ",", "AccessName", ":", "name", ",", "Path", ":", "hostPath", ",", "Port", ":", "plan9Port", ",", "Flags", ":", "flags", ",", "AllowedFiles", ":", "allowedNames", ",", "}", ",", "ResourcePath", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", ",", "GuestRequest", ":", "guestrequest", ".", "GuestRequest", "{", "ResourceType", ":", "guestrequest", ".", "ResourceTypeMappedDirectory", ",", "RequestType", ":", "requesttype", ".", "Add", ",", "Settings", ":", "guestrequest", ".", "LCOWMappedDirectory", "{", "MountPath", ":", "uvmPath", ",", "ShareName", ":", "name", ",", "Port", ":", "plan9Port", ",", "ReadOnly", ":", "readOnly", ",", "}", ",", "}", ",", "}", "\n\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "modification", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "share", ":=", "&", "Plan9Share", "{", "name", ":", "name", ",", "uvmPath", ":", "uvmPath", "}", "\n", "return", "share", ",", "nil", "\n", "}" ]
// AddPlan9 adds a Plan9 share to a utility VM.
[ "AddPlan9", "adds", "a", "Plan9", "share", "to", "a", "utility", "VM", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/plan9.go#L23-L108
143,642
Microsoft/hcsshim
internal/uvm/plan9.go
RemovePlan9
func (uvm *UtilityVM) RemovePlan9(share *Plan9Share) (err error) { op := "uvm::RemovePlan9" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "name": share.name, "uvm-path": share.uvmPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return errNotSupported } modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, Settings: hcsschema.Plan9Share{ Name: share.name, AccessName: share.name, Port: plan9Port, }, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/Plan9/Shares"), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeMappedDirectory, RequestType: requesttype.Remove, Settings: guestrequest.LCOWMappedDirectory{ MountPath: share.uvmPath, ShareName: share.name, Port: plan9Port, }, }, } if err := uvm.Modify(modification); err != nil { return fmt.Errorf("failed to remove plan9 share %s from %s: %+v: %s", share.name, uvm.id, modification, err) } return nil }
go
func (uvm *UtilityVM) RemovePlan9(share *Plan9Share) (err error) { op := "uvm::RemovePlan9" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "name": share.name, "uvm-path": share.uvmPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return errNotSupported } modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, Settings: hcsschema.Plan9Share{ Name: share.name, AccessName: share.name, Port: plan9Port, }, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/Plan9/Shares"), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeMappedDirectory, RequestType: requesttype.Remove, Settings: guestrequest.LCOWMappedDirectory{ MountPath: share.uvmPath, ShareName: share.name, Port: plan9Port, }, }, } if err := uvm.Modify(modification); err != nil { return fmt.Errorf("failed to remove plan9 share %s from %s: %+v: %s", share.name, uvm.id, modification, err) } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "RemovePlan9", "(", "share", "*", "Plan9Share", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "share", ".", "name", ",", "\"", "\"", ":", "share", ".", "uvmPath", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "operatingSystem", "!=", "\"", "\"", "{", "return", "errNotSupported", "\n", "}", "\n\n", "modification", ":=", "&", "hcsschema", ".", "ModifySettingRequest", "{", "RequestType", ":", "requesttype", ".", "Remove", ",", "Settings", ":", "hcsschema", ".", "Plan9Share", "{", "Name", ":", "share", ".", "name", ",", "AccessName", ":", "share", ".", "name", ",", "Port", ":", "plan9Port", ",", "}", ",", "ResourcePath", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", ",", "GuestRequest", ":", "guestrequest", ".", "GuestRequest", "{", "ResourceType", ":", "guestrequest", ".", "ResourceTypeMappedDirectory", ",", "RequestType", ":", "requesttype", ".", "Remove", ",", "Settings", ":", "guestrequest", ".", "LCOWMappedDirectory", "{", "MountPath", ":", "share", ".", "uvmPath", ",", "ShareName", ":", "share", ".", "name", ",", "Port", ":", "plan9Port", ",", "}", ",", "}", ",", "}", "\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "modification", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "share", ".", "name", ",", "uvm", ".", "id", ",", "modification", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemovePlan9 removes a Plan9 share from a utility VM. Each Plan9 share is ref-counted // and only actually removed when the ref-count drops to zero.
[ "RemovePlan9", "removes", "a", "Plan9", "share", "from", "a", "utility", "VM", ".", "Each", "Plan9", "share", "is", "ref", "-", "counted", "and", "only", "actually", "removed", "when", "the", "ref", "-", "count", "drops", "to", "zero", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/plan9.go#L112-L155
143,643
Microsoft/hcsshim
internal/hns/hnsnetwork.go
GetHNSNetworkByName
func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) { hsnnetworks, err := HNSListNetworkRequest("GET", "", "") if err != nil { return nil, err } for _, hnsnetwork := range hsnnetworks { if hnsnetwork.Name == networkName { return &hnsnetwork, nil } } return nil, NetworkNotFoundError{NetworkName: networkName} }
go
func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) { hsnnetworks, err := HNSListNetworkRequest("GET", "", "") if err != nil { return nil, err } for _, hnsnetwork := range hsnnetworks { if hnsnetwork.Name == networkName { return &hnsnetwork, nil } } return nil, NetworkNotFoundError{NetworkName: networkName} }
[ "func", "GetHNSNetworkByName", "(", "networkName", "string", ")", "(", "*", "HNSNetwork", ",", "error", ")", "{", "hsnnetworks", ",", "err", ":=", "HNSListNetworkRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "hnsnetwork", ":=", "range", "hsnnetworks", "{", "if", "hnsnetwork", ".", "Name", "==", "networkName", "{", "return", "&", "hnsnetwork", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "NetworkNotFoundError", "{", "NetworkName", ":", "networkName", "}", "\n", "}" ]
// GetHNSNetworkName filtered by Name
[ "GetHNSNetworkName", "filtered", "by", "Name" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsnetwork.go#L82-L93
143,644
Microsoft/hcsshim
internal/hns/hnsnetwork.go
Create
func (network *HNSNetwork) Create() (*HNSNetwork, error) { operation := "Create" title := "hcsshim::HNSNetwork::" + operation logrus.Debugf(title+" id=%s", network.Id) for _, subnet := range network.Subnets { if (subnet.AddressPrefix != "") && (subnet.GatewayAddress == "") { return nil, errors.New("network create error, subnet has address prefix but no gateway specified") } } jsonString, err := json.Marshal(network) if err != nil { return nil, err } return HNSNetworkRequest("POST", "", string(jsonString)) }
go
func (network *HNSNetwork) Create() (*HNSNetwork, error) { operation := "Create" title := "hcsshim::HNSNetwork::" + operation logrus.Debugf(title+" id=%s", network.Id) for _, subnet := range network.Subnets { if (subnet.AddressPrefix != "") && (subnet.GatewayAddress == "") { return nil, errors.New("network create error, subnet has address prefix but no gateway specified") } } jsonString, err := json.Marshal(network) if err != nil { return nil, err } return HNSNetworkRequest("POST", "", string(jsonString)) }
[ "func", "(", "network", "*", "HNSNetwork", ")", "Create", "(", ")", "(", "*", "HNSNetwork", ",", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "network", ".", "Id", ")", "\n\n", "for", "_", ",", "subnet", ":=", "range", "network", ".", "Subnets", "{", "if", "(", "subnet", ".", "AddressPrefix", "!=", "\"", "\"", ")", "&&", "(", "subnet", ".", "GatewayAddress", "==", "\"", "\"", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "network", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "HNSNetworkRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "string", "(", "jsonString", ")", ")", "\n", "}" ]
// Create Network by sending NetworkRequest to HNS.
[ "Create", "Network", "by", "sending", "NetworkRequest", "to", "HNS", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsnetwork.go#L96-L112
143,645
Microsoft/hcsshim
internal/hns/hnsnetwork.go
Delete
func (network *HNSNetwork) Delete() (*HNSNetwork, error) { operation := "Delete" title := "hcsshim::HNSNetwork::" + operation logrus.Debugf(title+" id=%s", network.Id) return HNSNetworkRequest("DELETE", network.Id, "") }
go
func (network *HNSNetwork) Delete() (*HNSNetwork, error) { operation := "Delete" title := "hcsshim::HNSNetwork::" + operation logrus.Debugf(title+" id=%s", network.Id) return HNSNetworkRequest("DELETE", network.Id, "") }
[ "func", "(", "network", "*", "HNSNetwork", ")", "Delete", "(", ")", "(", "*", "HNSNetwork", ",", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "network", ".", "Id", ")", "\n\n", "return", "HNSNetworkRequest", "(", "\"", "\"", ",", "network", ".", "Id", ",", "\"", "\"", ")", "\n", "}" ]
// Delete Network by sending NetworkRequest to HNS
[ "Delete", "Network", "by", "sending", "NetworkRequest", "to", "HNS" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsnetwork.go#L115-L121
143,646
Microsoft/hcsshim
internal/hns/hnsnetwork.go
NewEndpoint
func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint { return &HNSEndpoint{ VirtualNetwork: network.Id, IPAddress: ipAddress, MacAddress: string(macAddress), } }
go
func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint { return &HNSEndpoint{ VirtualNetwork: network.Id, IPAddress: ipAddress, MacAddress: string(macAddress), } }
[ "func", "(", "network", "*", "HNSNetwork", ")", "NewEndpoint", "(", "ipAddress", "net", ".", "IP", ",", "macAddress", "net", ".", "HardwareAddr", ")", "*", "HNSEndpoint", "{", "return", "&", "HNSEndpoint", "{", "VirtualNetwork", ":", "network", ".", "Id", ",", "IPAddress", ":", "ipAddress", ",", "MacAddress", ":", "string", "(", "macAddress", ")", ",", "}", "\n", "}" ]
// Creates an endpoint on the Network.
[ "Creates", "an", "endpoint", "on", "the", "Network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsnetwork.go#L124-L130
143,647
Microsoft/hcsshim
internal/runhcs/container.go
GetErrorFromPipe
func GetErrorFromPipe(pipe io.Reader, p *os.Process) error { serr, err := ioutil.ReadAll(pipe) if err != nil { return err } if bytes.Equal(serr, ShimSuccess) { return nil } extra := "" if p != nil { p.Kill() state, err := p.Wait() if err != nil { panic(err) } extra = fmt.Sprintf(", exit code %d", state.Sys().(syscall.WaitStatus).ExitCode) } if len(serr) == 0 { return fmt.Errorf("unknown shim failure%s", extra) } return errors.New(string(serr)) }
go
func GetErrorFromPipe(pipe io.Reader, p *os.Process) error { serr, err := ioutil.ReadAll(pipe) if err != nil { return err } if bytes.Equal(serr, ShimSuccess) { return nil } extra := "" if p != nil { p.Kill() state, err := p.Wait() if err != nil { panic(err) } extra = fmt.Sprintf(", exit code %d", state.Sys().(syscall.WaitStatus).ExitCode) } if len(serr) == 0 { return fmt.Errorf("unknown shim failure%s", extra) } return errors.New(string(serr)) }
[ "func", "GetErrorFromPipe", "(", "pipe", "io", ".", "Reader", ",", "p", "*", "os", ".", "Process", ")", "error", "{", "serr", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "pipe", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "bytes", ".", "Equal", "(", "serr", ",", "ShimSuccess", ")", "{", "return", "nil", "\n", "}", "\n\n", "extra", ":=", "\"", "\"", "\n", "if", "p", "!=", "nil", "{", "p", ".", "Kill", "(", ")", "\n", "state", ",", "err", ":=", "p", ".", "Wait", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "extra", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "state", ".", "Sys", "(", ")", ".", "(", "syscall", ".", "WaitStatus", ")", ".", "ExitCode", ")", "\n", "}", "\n", "if", "len", "(", "serr", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "extra", ")", "\n", "}", "\n\n", "return", "errors", ".", "New", "(", "string", "(", "serr", ")", ")", "\n", "}" ]
// GetErrorFromPipe returns reads from `pipe` and verifies if the operation // returned success or error. If error converts that to an error and returns. If // `p` is not nill will issue a `Kill` and `Wait` for exit.
[ "GetErrorFromPipe", "returns", "reads", "from", "pipe", "and", "verifies", "if", "the", "operation", "returned", "success", "or", "error", ".", "If", "error", "converts", "that", "to", "an", "error", "and", "returns", ".", "If", "p", "is", "not", "nill", "will", "issue", "a", "Kill", "and", "Wait", "for", "exit", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/runhcs/container.go#L42-L66
143,648
Microsoft/hcsshim
internal/hcsoci/network.go
GetNamespaceEndpoints
func GetNamespaceEndpoints(netNS string) ([]*hns.HNSEndpoint, error) { op := "hcsoci::GetNamespaceEndpoints" log := logrus.WithField("netns-id", netNS) log.Debug(op + " - Begin") defer func() { log.Debug(op + " - End") }() ids, err := hns.GetNamespaceEndpoints(netNS) if err != nil { return nil, err } var endpoints []*hns.HNSEndpoint for _, id := range ids { endpoint, err := hns.GetHNSEndpointByID(id) if err != nil { return nil, err } endpoints = append(endpoints, endpoint) } return endpoints, nil }
go
func GetNamespaceEndpoints(netNS string) ([]*hns.HNSEndpoint, error) { op := "hcsoci::GetNamespaceEndpoints" log := logrus.WithField("netns-id", netNS) log.Debug(op + " - Begin") defer func() { log.Debug(op + " - End") }() ids, err := hns.GetNamespaceEndpoints(netNS) if err != nil { return nil, err } var endpoints []*hns.HNSEndpoint for _, id := range ids { endpoint, err := hns.GetHNSEndpointByID(id) if err != nil { return nil, err } endpoints = append(endpoints, endpoint) } return endpoints, nil }
[ "func", "GetNamespaceEndpoints", "(", "netNS", "string", ")", "(", "[", "]", "*", "hns", ".", "HNSEndpoint", ",", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithField", "(", "\"", "\"", ",", "netNS", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "(", ")", "\n\n", "ids", ",", "err", ":=", "hns", ".", "GetNamespaceEndpoints", "(", "netNS", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "endpoints", "[", "]", "*", "hns", ".", "HNSEndpoint", "\n", "for", "_", ",", "id", ":=", "range", "ids", "{", "endpoint", ",", "err", ":=", "hns", ".", "GetHNSEndpointByID", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "endpoints", "=", "append", "(", "endpoints", ",", "endpoint", ")", "\n", "}", "\n", "return", "endpoints", ",", "nil", "\n", "}" ]
// GetNamespaceEndpoints gets all endpoints in `netNS`
[ "GetNamespaceEndpoints", "gets", "all", "endpoints", "in", "netNS" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcsoci/network.go#L36-L57
143,649
Microsoft/hcsshim
hcn/hcnerrors.go
IsNotFoundError
func IsNotFoundError(err error) bool { switch err.(type) { case NetworkNotFoundError: return true case EndpointNotFoundError: return true case NamespaceNotFoundError: return true case LoadBalancerNotFoundError: return true } return false }
go
func IsNotFoundError(err error) bool { switch err.(type) { case NetworkNotFoundError: return true case EndpointNotFoundError: return true case NamespaceNotFoundError: return true case LoadBalancerNotFoundError: return true } return false }
[ "func", "IsNotFoundError", "(", "err", "error", ")", "bool", "{", "switch", "err", ".", "(", "type", ")", "{", "case", "NetworkNotFoundError", ":", "return", "true", "\n", "case", "EndpointNotFoundError", ":", "return", "true", "\n", "case", "NamespaceNotFoundError", ":", "return", "true", "\n", "case", "LoadBalancerNotFoundError", ":", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsNotFoundError returns a boolean indicating whether the error was caused by // a resource not being found.
[ "IsNotFoundError", "returns", "a", "boolean", "indicating", "whether", "the", "error", "was", "caused", "by", "a", "resource", "not", "being", "found", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnerrors.go#L83-L95
143,650
Microsoft/hcsshim
pkg/go-runhcs/runhcs_delete.go
Delete
func (r *Runhcs) Delete(context context.Context, id string, opts *DeleteOpts) error { args := []string{"delete"} if opts != nil { oargs, err := opts.args() if err != nil { return err } args = append(args, oargs...) } return r.runOrError(r.command(context, append(args, id)...)) }
go
func (r *Runhcs) Delete(context context.Context, id string, opts *DeleteOpts) error { args := []string{"delete"} if opts != nil { oargs, err := opts.args() if err != nil { return err } args = append(args, oargs...) } return r.runOrError(r.command(context, append(args, id)...)) }
[ "func", "(", "r", "*", "Runhcs", ")", "Delete", "(", "context", "context", ".", "Context", ",", "id", "string", ",", "opts", "*", "DeleteOpts", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "if", "opts", "!=", "nil", "{", "oargs", ",", "err", ":=", "opts", ".", "args", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "args", "=", "append", "(", "args", ",", "oargs", "...", ")", "\n", "}", "\n", "return", "r", ".", "runOrError", "(", "r", ".", "command", "(", "context", ",", "append", "(", "args", ",", "id", ")", "...", ")", ")", "\n", "}" ]
// Delete any resources held by the container often used with detached // containers.
[ "Delete", "any", "resources", "held", "by", "the", "container", "often", "used", "with", "detached", "containers", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/pkg/go-runhcs/runhcs_delete.go#L23-L33
143,651
Microsoft/hcsshim
internal/wclayer/baselayer.go
reapplyDirectoryTimes
func reapplyDirectoryTimes(root *os.File, dis []dirInfo) error { for i := range dis { di := &dis[len(dis)-i-1] // reverse order: process child directories first f, err := safefile.OpenRelative(di.path, root, syscall.GENERIC_READ|syscall.GENERIC_WRITE, syscall.FILE_SHARE_READ, safefile.FILE_OPEN, safefile.FILE_DIRECTORY_FILE) if err != nil { return err } err = winio.SetFileBasicInfo(f, &di.fileInfo) f.Close() if err != nil { return err } } return nil }
go
func reapplyDirectoryTimes(root *os.File, dis []dirInfo) error { for i := range dis { di := &dis[len(dis)-i-1] // reverse order: process child directories first f, err := safefile.OpenRelative(di.path, root, syscall.GENERIC_READ|syscall.GENERIC_WRITE, syscall.FILE_SHARE_READ, safefile.FILE_OPEN, safefile.FILE_DIRECTORY_FILE) if err != nil { return err } err = winio.SetFileBasicInfo(f, &di.fileInfo) f.Close() if err != nil { return err } } return nil }
[ "func", "reapplyDirectoryTimes", "(", "root", "*", "os", ".", "File", ",", "dis", "[", "]", "dirInfo", ")", "error", "{", "for", "i", ":=", "range", "dis", "{", "di", ":=", "&", "dis", "[", "len", "(", "dis", ")", "-", "i", "-", "1", "]", "// reverse order: process child directories first", "\n", "f", ",", "err", ":=", "safefile", ".", "OpenRelative", "(", "di", ".", "path", ",", "root", ",", "syscall", ".", "GENERIC_READ", "|", "syscall", ".", "GENERIC_WRITE", ",", "syscall", ".", "FILE_SHARE_READ", ",", "safefile", ".", "FILE_OPEN", ",", "safefile", ".", "FILE_DIRECTORY_FILE", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "winio", ".", "SetFileBasicInfo", "(", "f", ",", "&", "di", ".", "fileInfo", ")", "\n", "f", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// reapplyDirectoryTimes reapplies directory modification, creation, etc. times // after processing of the directory tree has completed. The times are expected // to be ordered such that parent directories come before child directories.
[ "reapplyDirectoryTimes", "reapplies", "directory", "modification", "creation", "etc", ".", "times", "after", "processing", "of", "the", "directory", "tree", "has", "completed", ".", "The", "times", "are", "expected", "to", "be", "ordered", "such", "that", "parent", "directories", "come", "before", "child", "directories", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/baselayer.go#L31-L46
143,652
Microsoft/hcsshim
internal/uvm/create.go
newDefaultOptions
func newDefaultOptions(id, owner string) *Options { opts := &Options{ ID: id, Owner: owner, MemorySizeInMB: 1024, AllowOvercommit: true, EnableDeferredCommit: false, ProcessorCount: defaultProcessorCount(), } if opts.ID == "" { opts.ID = guid.New().String() } if opts.Owner == "" { opts.Owner = filepath.Base(os.Args[0]) } return opts }
go
func newDefaultOptions(id, owner string) *Options { opts := &Options{ ID: id, Owner: owner, MemorySizeInMB: 1024, AllowOvercommit: true, EnableDeferredCommit: false, ProcessorCount: defaultProcessorCount(), } if opts.ID == "" { opts.ID = guid.New().String() } if opts.Owner == "" { opts.Owner = filepath.Base(os.Args[0]) } return opts }
[ "func", "newDefaultOptions", "(", "id", ",", "owner", "string", ")", "*", "Options", "{", "opts", ":=", "&", "Options", "{", "ID", ":", "id", ",", "Owner", ":", "owner", ",", "MemorySizeInMB", ":", "1024", ",", "AllowOvercommit", ":", "true", ",", "EnableDeferredCommit", ":", "false", ",", "ProcessorCount", ":", "defaultProcessorCount", "(", ")", ",", "}", "\n\n", "if", "opts", ".", "ID", "==", "\"", "\"", "{", "opts", ".", "ID", "=", "guid", ".", "New", "(", ")", ".", "String", "(", ")", "\n", "}", "\n", "if", "opts", ".", "Owner", "==", "\"", "\"", "{", "opts", ".", "Owner", "=", "filepath", ".", "Base", "(", "os", ".", "Args", "[", "0", "]", ")", "\n", "}", "\n\n", "return", "opts", "\n", "}" ]
// newDefaultOptions returns the default base options for WCOW and LCOW. // // If `id` is empty it will be generated. // // If `owner` is empty it will be set to the calling executables name.
[ "newDefaultOptions", "returns", "the", "default", "base", "options", "for", "WCOW", "and", "LCOW", ".", "If", "id", "is", "empty", "it", "will", "be", "generated", ".", "If", "owner", "is", "empty", "it", "will", "be", "set", "to", "the", "calling", "executables", "name", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/create.go#L57-L75
143,653
Microsoft/hcsshim
internal/uvm/create.go
Close
func (uvm *UtilityVM) Close() (err error) { op := "uvm::Close" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.hcsSystem.Terminate() uvm.Wait() // outputListener will only be nil for a Create -> Stop without a Start. In // this case we have no goroutine processing output so its safe to close the // channel here. if uvm.outputListener != nil { close(uvm.outputProcessingDone) uvm.outputListener.Close() uvm.outputListener = nil } return uvm.hcsSystem.Close() }
go
func (uvm *UtilityVM) Close() (err error) { op := "uvm::Close" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() uvm.hcsSystem.Terminate() uvm.Wait() // outputListener will only be nil for a Create -> Stop without a Start. In // this case we have no goroutine processing output so its safe to close the // channel here. if uvm.outputListener != nil { close(uvm.outputProcessingDone) uvm.outputListener.Close() uvm.outputListener = nil } return uvm.hcsSystem.Close() }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "uvm", ".", "hcsSystem", ".", "Terminate", "(", ")", "\n", "uvm", ".", "Wait", "(", ")", "\n\n", "// outputListener will only be nil for a Create -> Stop without a Start. In", "// this case we have no goroutine processing output so its safe to close the", "// channel here.", "if", "uvm", ".", "outputListener", "!=", "nil", "{", "close", "(", "uvm", ".", "outputProcessingDone", ")", "\n", "uvm", ".", "outputListener", ".", "Close", "(", ")", "\n", "uvm", ".", "outputListener", "=", "nil", "\n", "}", "\n", "return", "uvm", ".", "hcsSystem", ".", "Close", "(", ")", "\n", "}" ]
// Close terminates and releases resources associated with the utility VM.
[ "Close", "terminates", "and", "releases", "resources", "associated", "with", "the", "utility", "VM", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/create.go#L88-L115
143,654
Microsoft/hcsshim
internal/longpath/longpath.go
LongAbs
func LongAbs(path string) (string, error) { if strings.HasPrefix(path, `\\?\`) || strings.HasPrefix(path, `\\.\`) { return path, nil } if !filepath.IsAbs(path) { absPath, err := filepath.Abs(path) if err != nil { return "", err } path = absPath } if strings.HasPrefix(path, `\\`) { return `\\?\UNC\` + path[2:], nil } return `\\?\` + path, nil }
go
func LongAbs(path string) (string, error) { if strings.HasPrefix(path, `\\?\`) || strings.HasPrefix(path, `\\.\`) { return path, nil } if !filepath.IsAbs(path) { absPath, err := filepath.Abs(path) if err != nil { return "", err } path = absPath } if strings.HasPrefix(path, `\\`) { return `\\?\UNC\` + path[2:], nil } return `\\?\` + path, nil }
[ "func", "LongAbs", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "if", "strings", ".", "HasPrefix", "(", "path", ",", "`\\\\?\\`", ")", "||", "strings", ".", "HasPrefix", "(", "path", ",", "`\\\\.\\`", ")", "{", "return", "path", ",", "nil", "\n", "}", "\n", "if", "!", "filepath", ".", "IsAbs", "(", "path", ")", "{", "absPath", ",", "err", ":=", "filepath", ".", "Abs", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "path", "=", "absPath", "\n", "}", "\n", "if", "strings", ".", "HasPrefix", "(", "path", ",", "`\\\\`", ")", "{", "return", "`\\\\?\\UNC\\`", "+", "path", "[", "2", ":", "]", ",", "nil", "\n", "}", "\n", "return", "`\\\\?\\`", "+", "path", ",", "nil", "\n", "}" ]
// LongAbs makes a path absolute and returns it in NT long path form.
[ "LongAbs", "makes", "a", "path", "absolute", "and", "returns", "it", "in", "NT", "long", "path", "form", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/longpath/longpath.go#L9-L24
143,655
Microsoft/hcsshim
internal/wclayer/grantvmaccess.go
GrantVmAccess
func GrantVmAccess(vmid string, filepath string) (err error) { title := "hcsshim::GrantVmAccess" fields := logrus.Fields{ "vm-id": vmid, "path": filepath, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = grantVmAccess(vmid, filepath) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
go
func GrantVmAccess(vmid string, filepath string) (err error) { title := "hcsshim::GrantVmAccess" fields := logrus.Fields{ "vm-id": vmid, "path": filepath, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = grantVmAccess(vmid, filepath) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
[ "func", "GrantVmAccess", "(", "vmid", "string", ",", "filepath", "string", ")", "(", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "vmid", ",", "\"", "\"", ":", "filepath", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "err", "=", "grantVmAccess", "(", "vmid", ",", "filepath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// GrantVmAccess adds access to a file for a given VM
[ "GrantVmAccess", "adds", "access", "to", "a", "file", "for", "a", "given", "VM" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/grantvmaccess.go#L9-L30
143,656
Microsoft/hcsshim
internal/uvm/start.go
Start
func (uvm *UtilityVM) Start() (err error) { op := "uvm::Start" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.outputListener != nil { ctx, cancel := context.WithCancel(context.Background()) go processOutput(ctx, uvm.outputListener, uvm.outputProcessingDone, uvm.outputHandler) uvm.outputProcessingCancel = cancel uvm.outputListener = nil } return uvm.hcsSystem.Start() }
go
func (uvm *UtilityVM) Start() (err error) { op := "uvm::Start" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.outputListener != nil { ctx, cancel := context.WithCancel(context.Background()) go processOutput(ctx, uvm.outputListener, uvm.outputProcessingDone, uvm.outputHandler) uvm.outputProcessingCancel = cancel uvm.outputListener = nil } return uvm.hcsSystem.Start() }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "Start", "(", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "outputListener", "!=", "nil", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "go", "processOutput", "(", "ctx", ",", "uvm", ".", "outputListener", ",", "uvm", ".", "outputProcessingDone", ",", "uvm", ".", "outputHandler", ")", "\n", "uvm", ".", "outputProcessingCancel", "=", "cancel", "\n", "uvm", ".", "outputListener", "=", "nil", "\n", "}", "\n", "return", "uvm", ".", "hcsSystem", ".", "Start", "(", ")", "\n", "}" ]
// Start synchronously starts the utility VM.
[ "Start", "synchronously", "starts", "the", "utility", "VM", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/start.go#L135-L157
143,657
Microsoft/hcsshim
hcn/hcnnetwork.go
ListNetworks
func ListNetworks() ([]HostComputeNetwork, error) { hcnQuery := defaultQuery() networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } return networks, nil }
go
func ListNetworks() ([]HostComputeNetwork, error) { hcnQuery := defaultQuery() networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } return networks, nil }
[ "func", "ListNetworks", "(", ")", "(", "[", "]", "HostComputeNetwork", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "networks", ",", "err", ":=", "ListNetworksQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "networks", ",", "nil", "\n", "}" ]
// ListNetworks makes a call to list all available networks.
[ "ListNetworks", "makes", "a", "call", "to", "list", "all", "available", "networks", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L257-L264
143,658
Microsoft/hcsshim
hcn/hcnnetwork.go
ListNetworksQuery
func ListNetworksQuery(query HostComputeQuery) ([]HostComputeNetwork, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } networks, err := enumerateNetworks(string(queryJson)) if err != nil { return nil, err } return networks, nil }
go
func ListNetworksQuery(query HostComputeQuery) ([]HostComputeNetwork, error) { queryJson, err := json.Marshal(query) if err != nil { return nil, err } networks, err := enumerateNetworks(string(queryJson)) if err != nil { return nil, err } return networks, nil }
[ "func", "ListNetworksQuery", "(", "query", "HostComputeQuery", ")", "(", "[", "]", "HostComputeNetwork", ",", "error", ")", "{", "queryJson", ",", "err", ":=", "json", ".", "Marshal", "(", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "networks", ",", "err", ":=", "enumerateNetworks", "(", "string", "(", "queryJson", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "networks", ",", "nil", "\n", "}" ]
// ListNetworksQuery makes a call to query the list of available networks.
[ "ListNetworksQuery", "makes", "a", "call", "to", "query", "the", "list", "of", "available", "networks", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L267-L278
143,659
Microsoft/hcsshim
hcn/hcnnetwork.go
GetNetworkByID
func GetNetworkByID(networkID string) (*HostComputeNetwork, error) { hcnQuery := defaultQuery() mapA := map[string]string{"ID": networkID} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } if len(networks) == 0 { return nil, NetworkNotFoundError{NetworkID: networkID} } return &networks[0], err }
go
func GetNetworkByID(networkID string) (*HostComputeNetwork, error) { hcnQuery := defaultQuery() mapA := map[string]string{"ID": networkID} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } if len(networks) == 0 { return nil, NetworkNotFoundError{NetworkID: networkID} } return &networks[0], err }
[ "func", "GetNetworkByID", "(", "networkID", "string", ")", "(", "*", "HostComputeNetwork", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "mapA", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "networkID", "}", "\n", "filter", ",", "err", ":=", "json", ".", "Marshal", "(", "mapA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "hcnQuery", ".", "Filter", "=", "string", "(", "filter", ")", "\n\n", "networks", ",", "err", ":=", "ListNetworksQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "networks", ")", "==", "0", "{", "return", "nil", ",", "NetworkNotFoundError", "{", "NetworkID", ":", "networkID", "}", "\n", "}", "\n", "return", "&", "networks", "[", "0", "]", ",", "err", "\n", "}" ]
// GetNetworkByID returns the network specified by Id.
[ "GetNetworkByID", "returns", "the", "network", "specified", "by", "Id", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L281-L298
143,660
Microsoft/hcsshim
hcn/hcnnetwork.go
GetNetworkByName
func GetNetworkByName(networkName string) (*HostComputeNetwork, error) { hcnQuery := defaultQuery() mapA := map[string]string{"Name": networkName} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } if len(networks) == 0 { return nil, NetworkNotFoundError{NetworkName: networkName} } return &networks[0], err }
go
func GetNetworkByName(networkName string) (*HostComputeNetwork, error) { hcnQuery := defaultQuery() mapA := map[string]string{"Name": networkName} filter, err := json.Marshal(mapA) if err != nil { return nil, err } hcnQuery.Filter = string(filter) networks, err := ListNetworksQuery(hcnQuery) if err != nil { return nil, err } if len(networks) == 0 { return nil, NetworkNotFoundError{NetworkName: networkName} } return &networks[0], err }
[ "func", "GetNetworkByName", "(", "networkName", "string", ")", "(", "*", "HostComputeNetwork", ",", "error", ")", "{", "hcnQuery", ":=", "defaultQuery", "(", ")", "\n", "mapA", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "networkName", "}", "\n", "filter", ",", "err", ":=", "json", ".", "Marshal", "(", "mapA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "hcnQuery", ".", "Filter", "=", "string", "(", "filter", ")", "\n\n", "networks", ",", "err", ":=", "ListNetworksQuery", "(", "hcnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "networks", ")", "==", "0", "{", "return", "nil", ",", "NetworkNotFoundError", "{", "NetworkName", ":", "networkName", "}", "\n", "}", "\n", "return", "&", "networks", "[", "0", "]", ",", "err", "\n", "}" ]
// GetNetworkByName returns the network specified by Name.
[ "GetNetworkByName", "returns", "the", "network", "specified", "by", "Name", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L301-L318
143,661
Microsoft/hcsshim
hcn/hcnnetwork.go
Create
func (network *HostComputeNetwork) Create() (*HostComputeNetwork, error) { logrus.Debugf("hcn::HostComputeNetwork::Create id=%s", network.Id) for _, ipam := range network.Ipams { for _, subnet := range ipam.Subnets { if subnet.IpAddressPrefix != "" { hasDefault := false for _, route := range subnet.Routes { if route.NextHop == "" { return nil, errors.New("network create error, subnet has address prefix but no gateway specified") } if route.DestinationPrefix == "0.0.0.0/0" || route.DestinationPrefix == "::/0" { hasDefault = true } } if !hasDefault { return nil, errors.New("network create error, no default gateway") } } } } jsonString, err := json.Marshal(network) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeNetwork::Create JSON: %s", jsonString) network, hcnErr := createNetwork(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return network, nil }
go
func (network *HostComputeNetwork) Create() (*HostComputeNetwork, error) { logrus.Debugf("hcn::HostComputeNetwork::Create id=%s", network.Id) for _, ipam := range network.Ipams { for _, subnet := range ipam.Subnets { if subnet.IpAddressPrefix != "" { hasDefault := false for _, route := range subnet.Routes { if route.NextHop == "" { return nil, errors.New("network create error, subnet has address prefix but no gateway specified") } if route.DestinationPrefix == "0.0.0.0/0" || route.DestinationPrefix == "::/0" { hasDefault = true } } if !hasDefault { return nil, errors.New("network create error, no default gateway") } } } } jsonString, err := json.Marshal(network) if err != nil { return nil, err } logrus.Debugf("hcn::HostComputeNetwork::Create JSON: %s", jsonString) network, hcnErr := createNetwork(string(jsonString)) if hcnErr != nil { return nil, hcnErr } return network, nil }
[ "func", "(", "network", "*", "HostComputeNetwork", ")", "Create", "(", ")", "(", "*", "HostComputeNetwork", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "network", ".", "Id", ")", "\n", "for", "_", ",", "ipam", ":=", "range", "network", ".", "Ipams", "{", "for", "_", ",", "subnet", ":=", "range", "ipam", ".", "Subnets", "{", "if", "subnet", ".", "IpAddressPrefix", "!=", "\"", "\"", "{", "hasDefault", ":=", "false", "\n", "for", "_", ",", "route", ":=", "range", "subnet", ".", "Routes", "{", "if", "route", ".", "NextHop", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "route", ".", "DestinationPrefix", "==", "\"", "\"", "||", "route", ".", "DestinationPrefix", "==", "\"", "\"", "{", "hasDefault", "=", "true", "\n", "}", "\n", "}", "\n", "if", "!", "hasDefault", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "network", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "jsonString", ")", "\n", "network", ",", "hcnErr", ":=", "createNetwork", "(", "string", "(", "jsonString", ")", ")", "\n", "if", "hcnErr", "!=", "nil", "{", "return", "nil", ",", "hcnErr", "\n", "}", "\n", "return", "network", ",", "nil", "\n", "}" ]
// Create Network.
[ "Create", "Network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L321-L353
143,662
Microsoft/hcsshim
hcn/hcnnetwork.go
Delete
func (network *HostComputeNetwork) Delete() error { logrus.Debugf("hcn::HostComputeNetwork::Delete id=%s", network.Id) if err := deleteNetwork(network.Id); err != nil { return err } return nil }
go
func (network *HostComputeNetwork) Delete() error { logrus.Debugf("hcn::HostComputeNetwork::Delete id=%s", network.Id) if err := deleteNetwork(network.Id); err != nil { return err } return nil }
[ "func", "(", "network", "*", "HostComputeNetwork", ")", "Delete", "(", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "network", ".", "Id", ")", "\n\n", "if", "err", ":=", "deleteNetwork", "(", "network", ".", "Id", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Delete Network.
[ "Delete", "Network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L356-L363
143,663
Microsoft/hcsshim
hcn/hcnnetwork.go
ModifyNetworkSettings
func (network *HostComputeNetwork) ModifyNetworkSettings(request *ModifyNetworkSettingRequest) error { logrus.Debugf("hcn::HostComputeNetwork::ModifyNetworkSettings id=%s", network.Id) networkSettingsRequest, err := json.Marshal(request) if err != nil { return err } _, err = modifyNetwork(network.Id, string(networkSettingsRequest)) if err != nil { return err } return nil }
go
func (network *HostComputeNetwork) ModifyNetworkSettings(request *ModifyNetworkSettingRequest) error { logrus.Debugf("hcn::HostComputeNetwork::ModifyNetworkSettings id=%s", network.Id) networkSettingsRequest, err := json.Marshal(request) if err != nil { return err } _, err = modifyNetwork(network.Id, string(networkSettingsRequest)) if err != nil { return err } return nil }
[ "func", "(", "network", "*", "HostComputeNetwork", ")", "ModifyNetworkSettings", "(", "request", "*", "ModifyNetworkSettingRequest", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "network", ".", "Id", ")", "\n\n", "networkSettingsRequest", ",", "err", ":=", "json", ".", "Marshal", "(", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "_", ",", "err", "=", "modifyNetwork", "(", "network", ".", "Id", ",", "string", "(", "networkSettingsRequest", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ModifyNetworkSettings updates the Policy for a network.
[ "ModifyNetworkSettings", "updates", "the", "Policy", "for", "a", "network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L366-L379
143,664
Microsoft/hcsshim
hcn/hcnnetwork.go
CreateEndpoint
func (network *HostComputeNetwork) CreateEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error) { isRemote := endpoint.Flags&EndpointFlagsRemoteEndpoint != 0 logrus.Debugf("hcn::HostComputeNetwork::CreatEndpoint, networkId=%s remote=%t", network.Id, isRemote) endpoint.HostComputeNetwork = network.Id endpointSettings, err := json.Marshal(endpoint) if err != nil { return nil, err } newEndpoint, err := createEndpoint(network.Id, string(endpointSettings)) if err != nil { return nil, err } return newEndpoint, nil }
go
func (network *HostComputeNetwork) CreateEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error) { isRemote := endpoint.Flags&EndpointFlagsRemoteEndpoint != 0 logrus.Debugf("hcn::HostComputeNetwork::CreatEndpoint, networkId=%s remote=%t", network.Id, isRemote) endpoint.HostComputeNetwork = network.Id endpointSettings, err := json.Marshal(endpoint) if err != nil { return nil, err } newEndpoint, err := createEndpoint(network.Id, string(endpointSettings)) if err != nil { return nil, err } return newEndpoint, nil }
[ "func", "(", "network", "*", "HostComputeNetwork", ")", "CreateEndpoint", "(", "endpoint", "*", "HostComputeEndpoint", ")", "(", "*", "HostComputeEndpoint", ",", "error", ")", "{", "isRemote", ":=", "endpoint", ".", "Flags", "&", "EndpointFlagsRemoteEndpoint", "!=", "0", "\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "network", ".", "Id", ",", "isRemote", ")", "\n\n", "endpoint", ".", "HostComputeNetwork", "=", "network", ".", "Id", "\n", "endpointSettings", ",", "err", ":=", "json", ".", "Marshal", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "newEndpoint", ",", "err", ":=", "createEndpoint", "(", "network", ".", "Id", ",", "string", "(", "endpointSettings", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newEndpoint", ",", "nil", "\n", "}" ]
// CreateEndpoint creates an endpoint on the Network.
[ "CreateEndpoint", "creates", "an", "endpoint", "on", "the", "Network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L416-L430
143,665
Microsoft/hcsshim
hcn/hcnnetwork.go
CreateRemoteEndpoint
func (network *HostComputeNetwork) CreateRemoteEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error) { endpoint.Flags = EndpointFlagsRemoteEndpoint | endpoint.Flags return network.CreateEndpoint(endpoint) }
go
func (network *HostComputeNetwork) CreateRemoteEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error) { endpoint.Flags = EndpointFlagsRemoteEndpoint | endpoint.Flags return network.CreateEndpoint(endpoint) }
[ "func", "(", "network", "*", "HostComputeNetwork", ")", "CreateRemoteEndpoint", "(", "endpoint", "*", "HostComputeEndpoint", ")", "(", "*", "HostComputeEndpoint", ",", "error", ")", "{", "endpoint", ".", "Flags", "=", "EndpointFlagsRemoteEndpoint", "|", "endpoint", ".", "Flags", "\n", "return", "network", ".", "CreateEndpoint", "(", "endpoint", ")", "\n", "}" ]
// CreateRemoteEndpoint creates a remote endpoint on the Network.
[ "CreateRemoteEndpoint", "creates", "a", "remote", "endpoint", "on", "the", "Network", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnnetwork.go#L433-L436
143,666
Microsoft/hcsshim
internal/uvm/vpmem.go
allocateVPMEM
func (uvm *UtilityVM) allocateVPMEM(hostPath string) (uint32, error) { for index, vi := range uvm.vpmemDevices { if vi.hostPath == "" { vi.hostPath = hostPath logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": vi.hostPath, "uvm-path": vi.uvmPath, "refCount": vi.refCount, "deviceNumber": uint32(index), }).Debug("uvm::allocateVPMEM") return uint32(index), nil } } return 0, fmt.Errorf("no free VPMEM locations") }
go
func (uvm *UtilityVM) allocateVPMEM(hostPath string) (uint32, error) { for index, vi := range uvm.vpmemDevices { if vi.hostPath == "" { vi.hostPath = hostPath logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": vi.hostPath, "uvm-path": vi.uvmPath, "refCount": vi.refCount, "deviceNumber": uint32(index), }).Debug("uvm::allocateVPMEM") return uint32(index), nil } } return 0, fmt.Errorf("no free VPMEM locations") }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "allocateVPMEM", "(", "hostPath", "string", ")", "(", "uint32", ",", "error", ")", "{", "for", "index", ",", "vi", ":=", "range", "uvm", ".", "vpmemDevices", "{", "if", "vi", ".", "hostPath", "==", "\"", "\"", "{", "vi", ".", "hostPath", "=", "hostPath", "\n", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "vi", ".", "hostPath", ",", "\"", "\"", ":", "vi", ".", "uvmPath", ",", "\"", "\"", ":", "vi", ".", "refCount", ",", "\"", "\"", ":", "uint32", "(", "index", ")", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "uint32", "(", "index", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// allocateVPMEM finds the next available VPMem slot. The lock MUST be held // when calling this function.
[ "allocateVPMEM", "finds", "the", "next", "available", "VPMem", "slot", ".", "The", "lock", "MUST", "be", "held", "when", "calling", "this", "function", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vpmem.go#L15-L30
143,667
Microsoft/hcsshim
internal/uvm/vpmem.go
findVPMEMDevice
func (uvm *UtilityVM) findVPMEMDevice(findThisHostPath string) (uint32, string, error) { for deviceNumber, vi := range uvm.vpmemDevices { if vi.hostPath == findThisHostPath { logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": findThisHostPath, "uvm-path": vi.uvmPath, "refCount": vi.refCount, "deviceNumber": uint32(deviceNumber), }).Debug("uvm::findVPMEMDevice") return uint32(deviceNumber), vi.uvmPath, nil } } return 0, "", fmt.Errorf("%s is not attached to VPMEM", findThisHostPath) }
go
func (uvm *UtilityVM) findVPMEMDevice(findThisHostPath string) (uint32, string, error) { for deviceNumber, vi := range uvm.vpmemDevices { if vi.hostPath == findThisHostPath { logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": findThisHostPath, "uvm-path": vi.uvmPath, "refCount": vi.refCount, "deviceNumber": uint32(deviceNumber), }).Debug("uvm::findVPMEMDevice") return uint32(deviceNumber), vi.uvmPath, nil } } return 0, "", fmt.Errorf("%s is not attached to VPMEM", findThisHostPath) }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "findVPMEMDevice", "(", "findThisHostPath", "string", ")", "(", "uint32", ",", "string", ",", "error", ")", "{", "for", "deviceNumber", ",", "vi", ":=", "range", "uvm", ".", "vpmemDevices", "{", "if", "vi", ".", "hostPath", "==", "findThisHostPath", "{", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "findThisHostPath", ",", "\"", "\"", ":", "vi", ".", "uvmPath", ",", "\"", "\"", ":", "vi", ".", "refCount", ",", "\"", "\"", ":", "uint32", "(", "deviceNumber", ")", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "uint32", "(", "deviceNumber", ")", ",", "vi", ".", "uvmPath", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "0", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "findThisHostPath", ")", "\n", "}" ]
// Lock must be held when calling this function
[ "Lock", "must", "be", "held", "when", "calling", "this", "function" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vpmem.go#L51-L65
143,668
Microsoft/hcsshim
internal/uvm/vpmem.go
RemoveVPMEM
func (uvm *UtilityVM) RemoveVPMEM(hostPath string) (err error) { op := "uvm::RemoveVPMEM" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() // Make sure is actually attached deviceNumber, uvmPath, err := uvm.findVPMEMDevice(hostPath) if err != nil { return fmt.Errorf("cannot remove VPMEM %s as it is not attached to utility VM %s: %s", hostPath, uvm.id, err) } if err := uvm.removeVPMEM(hostPath, uvmPath, deviceNumber); err != nil { return fmt.Errorf("failed to remove VPMEM %s from utility VM %s: %s", hostPath, uvm.id, err) } return nil }
go
func (uvm *UtilityVM) RemoveVPMEM(hostPath string) (err error) { op := "uvm::RemoveVPMEM" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "linux" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() // Make sure is actually attached deviceNumber, uvmPath, err := uvm.findVPMEMDevice(hostPath) if err != nil { return fmt.Errorf("cannot remove VPMEM %s as it is not attached to utility VM %s: %s", hostPath, uvm.id, err) } if err := uvm.removeVPMEM(hostPath, uvmPath, deviceNumber); err != nil { return fmt.Errorf("failed to remove VPMEM %s from utility VM %s: %s", hostPath, uvm.id, err) } return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "RemoveVPMEM", "(", "hostPath", "string", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "operatingSystem", "!=", "\"", "\"", "{", "return", "errNotSupported", "\n", "}", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n\n", "// Make sure is actually attached", "deviceNumber", ",", "uvmPath", ",", "err", ":=", "uvm", ".", "findVPMEMDevice", "(", "hostPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostPath", ",", "uvm", ".", "id", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "uvm", ".", "removeVPMEM", "(", "hostPath", ",", "uvmPath", ",", "deviceNumber", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostPath", ",", "uvm", ".", "id", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemoveVPMEM removes a VPMEM disk from a utility VM. As an external API, it // is "safe". Internal use can call removeVPMEM.
[ "RemoveVPMEM", "removes", "a", "VPMEM", "disk", "from", "a", "utility", "VM", ".", "As", "an", "external", "API", "it", "is", "safe", ".", "Internal", "use", "can", "call", "removeVPMEM", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vpmem.go#L151-L184
143,669
Microsoft/hcsshim
internal/uvm/vpmem.go
removeVPMEM
func (uvm *UtilityVM) removeVPMEM(hostPath string, uvmPath string, deviceNumber uint32) error { if uvm.vpmemDevices[deviceNumber].refCount == 1 { modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/VirtualPMem/Devices/%d", deviceNumber), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeVPMemDevice, RequestType: requesttype.Remove, Settings: guestrequest.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: uvmPath, }, }, } if err := uvm.Modify(modification); err != nil { return err } uvm.vpmemDevices[deviceNumber] = vpmemInfo{} return nil } uvm.vpmemDevices[deviceNumber].refCount-- return nil }
go
func (uvm *UtilityVM) removeVPMEM(hostPath string, uvmPath string, deviceNumber uint32) error { if uvm.vpmemDevices[deviceNumber].refCount == 1 { modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, ResourcePath: fmt.Sprintf("VirtualMachine/Devices/VirtualPMem/Devices/%d", deviceNumber), GuestRequest: guestrequest.GuestRequest{ ResourceType: guestrequest.ResourceTypeVPMemDevice, RequestType: requesttype.Remove, Settings: guestrequest.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: uvmPath, }, }, } if err := uvm.Modify(modification); err != nil { return err } uvm.vpmemDevices[deviceNumber] = vpmemInfo{} return nil } uvm.vpmemDevices[deviceNumber].refCount-- return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "removeVPMEM", "(", "hostPath", "string", ",", "uvmPath", "string", ",", "deviceNumber", "uint32", ")", "error", "{", "if", "uvm", ".", "vpmemDevices", "[", "deviceNumber", "]", ".", "refCount", "==", "1", "{", "modification", ":=", "&", "hcsschema", ".", "ModifySettingRequest", "{", "RequestType", ":", "requesttype", ".", "Remove", ",", "ResourcePath", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "deviceNumber", ")", ",", "GuestRequest", ":", "guestrequest", ".", "GuestRequest", "{", "ResourceType", ":", "guestrequest", ".", "ResourceTypeVPMemDevice", ",", "RequestType", ":", "requesttype", ".", "Remove", ",", "Settings", ":", "guestrequest", ".", "LCOWMappedVPMemDevice", "{", "DeviceNumber", ":", "deviceNumber", ",", "MountPath", ":", "uvmPath", ",", "}", ",", "}", ",", "}", "\n\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "modification", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "uvm", ".", "vpmemDevices", "[", "deviceNumber", "]", "=", "vpmemInfo", "{", "}", "\n", "return", "nil", "\n", "}", "\n", "uvm", ".", "vpmemDevices", "[", "deviceNumber", "]", ".", "refCount", "--", "\n", "return", "nil", "\n\n", "}" ]
// removeVPMEM is the internally callable "unsafe" version of RemoveVPMEM. The mutex // MUST be held when calling this function.
[ "removeVPMEM", "is", "the", "internally", "callable", "unsafe", "version", "of", "RemoveVPMEM", ".", "The", "mutex", "MUST", "be", "held", "when", "calling", "this", "function", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vpmem.go#L188-L212
143,670
Microsoft/hcsshim
internal/ociwclayer/export.go
ExportLayer
func ExportLayer(w io.Writer, path string, parentLayerPaths []string) error { err := hcsshim.ActivateLayer(driverInfo, path) if err != nil { return err } defer hcsshim.DeactivateLayer(driverInfo, path) // Prepare and unprepare the layer to ensure that it has been initialized. err = hcsshim.PrepareLayer(driverInfo, path, parentLayerPaths) if err != nil { return err } err = hcsshim.UnprepareLayer(driverInfo, path) if err != nil { return err } r, err := hcsshim.NewLayerReader(driverInfo, path, parentLayerPaths) if err != nil { return err } err = writeTarFromLayer(r, w) cerr := r.Close() if err != nil { return err } return cerr }
go
func ExportLayer(w io.Writer, path string, parentLayerPaths []string) error { err := hcsshim.ActivateLayer(driverInfo, path) if err != nil { return err } defer hcsshim.DeactivateLayer(driverInfo, path) // Prepare and unprepare the layer to ensure that it has been initialized. err = hcsshim.PrepareLayer(driverInfo, path, parentLayerPaths) if err != nil { return err } err = hcsshim.UnprepareLayer(driverInfo, path) if err != nil { return err } r, err := hcsshim.NewLayerReader(driverInfo, path, parentLayerPaths) if err != nil { return err } err = writeTarFromLayer(r, w) cerr := r.Close() if err != nil { return err } return cerr }
[ "func", "ExportLayer", "(", "w", "io", ".", "Writer", ",", "path", "string", ",", "parentLayerPaths", "[", "]", "string", ")", "error", "{", "err", ":=", "hcsshim", ".", "ActivateLayer", "(", "driverInfo", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "hcsshim", ".", "DeactivateLayer", "(", "driverInfo", ",", "path", ")", "\n\n", "// Prepare and unprepare the layer to ensure that it has been initialized.", "err", "=", "hcsshim", ".", "PrepareLayer", "(", "driverInfo", ",", "path", ",", "parentLayerPaths", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "hcsshim", ".", "UnprepareLayer", "(", "driverInfo", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ",", "err", ":=", "hcsshim", ".", "NewLayerReader", "(", "driverInfo", ",", "path", ",", "parentLayerPaths", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "writeTarFromLayer", "(", "r", ",", "w", ")", "\n", "cerr", ":=", "r", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "cerr", "\n", "}" ]
// ExportLayer writes an OCI layer tar stream from the provided on-disk layer. // The caller must specify the parent layers, if any, ordered from lowest to // highest layer. // // The layer will be mounted for this process, so the caller should ensure that // it is not currently mounted.
[ "ExportLayer", "writes", "an", "OCI", "layer", "tar", "stream", "from", "the", "provided", "on", "-", "disk", "layer", ".", "The", "caller", "must", "specify", "the", "parent", "layers", "if", "any", "ordered", "from", "lowest", "to", "highest", "layer", ".", "The", "layer", "will", "be", "mounted", "for", "this", "process", "so", "the", "caller", "should", "ensure", "that", "it", "is", "not", "currently", "mounted", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/ociwclayer/export.go#L22-L50
143,671
Microsoft/hcsshim
internal/uvm/modify.go
Modify
func (uvm *UtilityVM) Modify(hcsModificationDocument interface{}) (err error) { op := "uvm::Modify" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() return uvm.hcsSystem.Modify(hcsModificationDocument) }
go
func (uvm *UtilityVM) Modify(hcsModificationDocument interface{}) (err error) { op := "uvm::Modify" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() return uvm.hcsSystem.Modify(hcsModificationDocument) }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "Modify", "(", "hcsModificationDocument", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "return", "uvm", ".", "hcsSystem", ".", "Modify", "(", "hcsModificationDocument", ")", "\n", "}" ]
// Modify modifies the compute system by sending a request to HCS.
[ "Modify", "modifies", "the", "compute", "system", "by", "sending", "a", "request", "to", "HCS", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/modify.go#L9-L25
143,672
Microsoft/hcsshim
internal/uvm/wait.go
Wait
func (uvm *UtilityVM) Wait() error { err := uvm.hcsSystem.Wait() // outputProcessingCancel will only cancel waiting for the vsockexec // connection, it won't stop output processing once the connection is // established. if uvm.outputProcessingCancel != nil { uvm.outputProcessingCancel() } uvm.waitForOutput() return err }
go
func (uvm *UtilityVM) Wait() error { err := uvm.hcsSystem.Wait() // outputProcessingCancel will only cancel waiting for the vsockexec // connection, it won't stop output processing once the connection is // established. if uvm.outputProcessingCancel != nil { uvm.outputProcessingCancel() } uvm.waitForOutput() return err }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "Wait", "(", ")", "error", "{", "err", ":=", "uvm", ".", "hcsSystem", ".", "Wait", "(", ")", "\n\n", "// outputProcessingCancel will only cancel waiting for the vsockexec", "// connection, it won't stop output processing once the connection is", "// established.", "if", "uvm", ".", "outputProcessingCancel", "!=", "nil", "{", "uvm", ".", "outputProcessingCancel", "(", ")", "\n", "}", "\n", "uvm", ".", "waitForOutput", "(", ")", "\n\n", "return", "err", "\n", "}" ]
// Wait waits synchronously for a utility VM to terminate.
[ "Wait", "waits", "synchronously", "for", "a", "utility", "VM", "to", "terminate", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/wait.go#L17-L29
143,673
Microsoft/hcsshim
internal/oci/uvm.go
parseAnnotationsBool
func parseAnnotationsBool(a map[string]string, key string, def bool) bool { if v, ok := a[key]; ok { switch strings.ToLower(v) { case "true": return true case "false": return false default: logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Bool, }).Warning("annotation could not be parsed") } } return def }
go
func parseAnnotationsBool(a map[string]string, key string, def bool) bool { if v, ok := a[key]; ok { switch strings.ToLower(v) { case "true": return true case "false": return false default: logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Bool, }).Warning("annotation could not be parsed") } } return def }
[ "func", "parseAnnotationsBool", "(", "a", "map", "[", "string", "]", "string", ",", "key", "string", ",", "def", "bool", ")", "bool", "{", "if", "v", ",", "ok", ":=", "a", "[", "key", "]", ";", "ok", "{", "switch", "strings", ".", "ToLower", "(", "v", ")", "{", "case", "\"", "\"", ":", "return", "true", "\n", "case", "\"", "\"", ":", "return", "false", "\n", "default", ":", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "OCIAnnotation", ":", "key", ",", "logfields", ".", "Value", ":", "v", ",", "logfields", ".", "ExpectedType", ":", "logfields", ".", "Bool", ",", "}", ")", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "def", "\n", "}" ]
// parseAnnotationsBool searches `a` for `key` and if found verifies that the // value is `true` or `false` in any case. If `key` is not found returns `def`.
[ "parseAnnotationsBool", "searches", "a", "for", "key", "and", "if", "found", "verifies", "that", "the", "value", "is", "true", "or", "false", "in", "any", "case", ".", "If", "key", "is", "not", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L120-L136
143,674
Microsoft/hcsshim
internal/oci/uvm.go
ParseAnnotationsCPUCount
func ParseAnnotationsCPUCount(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Count != nil && *s.Windows.Resources.CPU.Count > 0 { return int32(*s.Windows.Resources.CPU.Count) } return def }
go
func ParseAnnotationsCPUCount(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Count != nil && *s.Windows.Resources.CPU.Count > 0 { return int32(*s.Windows.Resources.CPU.Count) } return def }
[ "func", "ParseAnnotationsCPUCount", "(", "s", "*", "specs", ".", "Spec", ",", "annotation", "string", ",", "def", "int32", ")", "int32", "{", "if", "m", ":=", "parseAnnotationsUint64", "(", "s", ".", "Annotations", ",", "annotation", ",", "0", ")", ";", "m", "!=", "0", "{", "return", "int32", "(", "m", ")", "\n", "}", "\n", "if", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Count", "!=", "nil", "&&", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Count", ">", "0", "{", "return", "int32", "(", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Count", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// ParseAnnotationsCPUCount searches `s.Annotations` for the CPU annotation. If // not found searches `s` for the Windows CPU section. If neither are found // returns `def`.
[ "ParseAnnotationsCPUCount", "searches", "s", ".", "Annotations", "for", "the", "CPU", "annotation", ".", "If", "not", "found", "searches", "s", "for", "the", "Windows", "CPU", "section", ".", "If", "neither", "are", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L141-L153
143,675
Microsoft/hcsshim
internal/oci/uvm.go
ParseAnnotationsCPULimit
func ParseAnnotationsCPULimit(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Maximum != nil && *s.Windows.Resources.CPU.Maximum > 0 { return int32(*s.Windows.Resources.CPU.Maximum) } return def }
go
func ParseAnnotationsCPULimit(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Maximum != nil && *s.Windows.Resources.CPU.Maximum > 0 { return int32(*s.Windows.Resources.CPU.Maximum) } return def }
[ "func", "ParseAnnotationsCPULimit", "(", "s", "*", "specs", ".", "Spec", ",", "annotation", "string", ",", "def", "int32", ")", "int32", "{", "if", "m", ":=", "parseAnnotationsUint64", "(", "s", ".", "Annotations", ",", "annotation", ",", "0", ")", ";", "m", "!=", "0", "{", "return", "int32", "(", "m", ")", "\n", "}", "\n", "if", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Maximum", "!=", "nil", "&&", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Maximum", ">", "0", "{", "return", "int32", "(", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Maximum", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// ParseAnnotationsCPULimit searches `s.Annotations` for the CPU annotation. If // not found searches `s` for the Windows CPU section. If neither are found // returns `def`.
[ "ParseAnnotationsCPULimit", "searches", "s", ".", "Annotations", "for", "the", "CPU", "annotation", ".", "If", "not", "found", "searches", "s", "for", "the", "Windows", "CPU", "section", ".", "If", "neither", "are", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L158-L170
143,676
Microsoft/hcsshim
internal/oci/uvm.go
ParseAnnotationsCPUWeight
func ParseAnnotationsCPUWeight(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Shares != nil && *s.Windows.Resources.CPU.Shares > 0 { return int32(*s.Windows.Resources.CPU.Shares) } return def }
go
func ParseAnnotationsCPUWeight(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.CPU != nil && s.Windows.Resources.CPU.Shares != nil && *s.Windows.Resources.CPU.Shares > 0 { return int32(*s.Windows.Resources.CPU.Shares) } return def }
[ "func", "ParseAnnotationsCPUWeight", "(", "s", "*", "specs", ".", "Spec", ",", "annotation", "string", ",", "def", "int32", ")", "int32", "{", "if", "m", ":=", "parseAnnotationsUint64", "(", "s", ".", "Annotations", ",", "annotation", ",", "0", ")", ";", "m", "!=", "0", "{", "return", "int32", "(", "m", ")", "\n", "}", "\n", "if", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Shares", "!=", "nil", "&&", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Shares", ">", "0", "{", "return", "int32", "(", "*", "s", ".", "Windows", ".", "Resources", ".", "CPU", ".", "Shares", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// ParseAnnotationsCPUWeight searches `s.Annotations` for the CPU annotation. If // not found searches `s` for the Windows CPU section. If neither are found // returns `def`.
[ "ParseAnnotationsCPUWeight", "searches", "s", ".", "Annotations", "for", "the", "CPU", "annotation", ".", "If", "not", "found", "searches", "s", "for", "the", "Windows", "CPU", "section", ".", "If", "neither", "are", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L175-L187
143,677
Microsoft/hcsshim
internal/oci/uvm.go
ParseAnnotationsStorageIops
func ParseAnnotationsStorageIops(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.Storage != nil && s.Windows.Resources.Storage.Iops != nil && *s.Windows.Resources.Storage.Iops > 0 { return int32(*s.Windows.Resources.Storage.Iops) } return def }
go
func ParseAnnotationsStorageIops(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.Storage != nil && s.Windows.Resources.Storage.Iops != nil && *s.Windows.Resources.Storage.Iops > 0 { return int32(*s.Windows.Resources.Storage.Iops) } return def }
[ "func", "ParseAnnotationsStorageIops", "(", "s", "*", "specs", ".", "Spec", ",", "annotation", "string", ",", "def", "int32", ")", "int32", "{", "if", "m", ":=", "parseAnnotationsUint64", "(", "s", ".", "Annotations", ",", "annotation", ",", "0", ")", ";", "m", "!=", "0", "{", "return", "int32", "(", "m", ")", "\n", "}", "\n", "if", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "Storage", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Iops", "!=", "nil", "&&", "*", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Iops", ">", "0", "{", "return", "int32", "(", "*", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Iops", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// ParseAnnotationsStorageIops searches `s.Annotations` for the `Iops` // annotation. If not found searches `s` for the Windows Storage section. If // neither are found returns `def`.
[ "ParseAnnotationsStorageIops", "searches", "s", ".", "Annotations", "for", "the", "Iops", "annotation", ".", "If", "not", "found", "searches", "s", "for", "the", "Windows", "Storage", "section", ".", "If", "neither", "are", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L192-L204
143,678
Microsoft/hcsshim
internal/oci/uvm.go
ParseAnnotationsStorageBps
func ParseAnnotationsStorageBps(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.Storage != nil && s.Windows.Resources.Storage.Bps != nil && *s.Windows.Resources.Storage.Bps > 0 { return int32(*s.Windows.Resources.Storage.Bps) } return def }
go
func ParseAnnotationsStorageBps(s *specs.Spec, annotation string, def int32) int32 { if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 { return int32(m) } if s.Windows != nil && s.Windows.Resources != nil && s.Windows.Resources.Storage != nil && s.Windows.Resources.Storage.Bps != nil && *s.Windows.Resources.Storage.Bps > 0 { return int32(*s.Windows.Resources.Storage.Bps) } return def }
[ "func", "ParseAnnotationsStorageBps", "(", "s", "*", "specs", ".", "Spec", ",", "annotation", "string", ",", "def", "int32", ")", "int32", "{", "if", "m", ":=", "parseAnnotationsUint64", "(", "s", ".", "Annotations", ",", "annotation", ",", "0", ")", ";", "m", "!=", "0", "{", "return", "int32", "(", "m", ")", "\n", "}", "\n", "if", "s", ".", "Windows", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "Storage", "!=", "nil", "&&", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Bps", "!=", "nil", "&&", "*", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Bps", ">", "0", "{", "return", "int32", "(", "*", "s", ".", "Windows", ".", "Resources", ".", "Storage", ".", "Bps", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// ParseAnnotationsStorageBps searches `s.Annotations` for the `Bps` annotation. // If not found searches `s` for the Windows Storage section. If neither are // found returns `def`.
[ "ParseAnnotationsStorageBps", "searches", "s", ".", "Annotations", "for", "the", "Bps", "annotation", ".", "If", "not", "found", "searches", "s", "for", "the", "Windows", "Storage", "section", ".", "If", "neither", "are", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L209-L221
143,679
Microsoft/hcsshim
internal/oci/uvm.go
parseAnnotationsPreferredRootFSType
func parseAnnotationsPreferredRootFSType(a map[string]string, key string, def uvm.PreferredRootFSType) uvm.PreferredRootFSType { if v, ok := a[key]; ok { switch v { case "initrd": return uvm.PreferredRootFSTypeInitRd case "vhd": return uvm.PreferredRootFSTypeVHD default: logrus.Warningf("annotation: '%s', with value: '%s' must be 'initrd' or 'vhd'", key, v) } } return def }
go
func parseAnnotationsPreferredRootFSType(a map[string]string, key string, def uvm.PreferredRootFSType) uvm.PreferredRootFSType { if v, ok := a[key]; ok { switch v { case "initrd": return uvm.PreferredRootFSTypeInitRd case "vhd": return uvm.PreferredRootFSTypeVHD default: logrus.Warningf("annotation: '%s', with value: '%s' must be 'initrd' or 'vhd'", key, v) } } return def }
[ "func", "parseAnnotationsPreferredRootFSType", "(", "a", "map", "[", "string", "]", "string", ",", "key", "string", ",", "def", "uvm", ".", "PreferredRootFSType", ")", "uvm", ".", "PreferredRootFSType", "{", "if", "v", ",", "ok", ":=", "a", "[", "key", "]", ";", "ok", "{", "switch", "v", "{", "case", "\"", "\"", ":", "return", "uvm", ".", "PreferredRootFSTypeInitRd", "\n", "case", "\"", "\"", ":", "return", "uvm", ".", "PreferredRootFSTypeVHD", "\n", "default", ":", "logrus", ".", "Warningf", "(", "\"", "\"", ",", "key", ",", "v", ")", "\n", "}", "\n", "}", "\n", "return", "def", "\n", "}" ]
// parseAnnotationsPreferredRootFSType searches `a` for `key` and verifies that the // value is in the set of allowed values. If `key` is not found returns `def`.
[ "parseAnnotationsPreferredRootFSType", "searches", "a", "for", "key", "and", "verifies", "that", "the", "value", "is", "in", "the", "set", "of", "allowed", "values", ".", "If", "key", "is", "not", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L244-L256
143,680
Microsoft/hcsshim
internal/oci/uvm.go
parseAnnotationsUint32
func parseAnnotationsUint32(a map[string]string, key string, def uint32) uint32 { if v, ok := a[key]; ok { countu, err := strconv.ParseUint(v, 10, 32) if err == nil { v := uint32(countu) return v } logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Uint32, logrus.ErrorKey: err, }).Warning("annotation could not be parsed") } return def }
go
func parseAnnotationsUint32(a map[string]string, key string, def uint32) uint32 { if v, ok := a[key]; ok { countu, err := strconv.ParseUint(v, 10, 32) if err == nil { v := uint32(countu) return v } logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Uint32, logrus.ErrorKey: err, }).Warning("annotation could not be parsed") } return def }
[ "func", "parseAnnotationsUint32", "(", "a", "map", "[", "string", "]", "string", ",", "key", "string", ",", "def", "uint32", ")", "uint32", "{", "if", "v", ",", "ok", ":=", "a", "[", "key", "]", ";", "ok", "{", "countu", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "v", ",", "10", ",", "32", ")", "\n", "if", "err", "==", "nil", "{", "v", ":=", "uint32", "(", "countu", ")", "\n", "return", "v", "\n", "}", "\n", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "OCIAnnotation", ":", "key", ",", "logfields", ".", "Value", ":", "v", ",", "logfields", ".", "ExpectedType", ":", "logfields", ".", "Uint32", ",", "logrus", ".", "ErrorKey", ":", "err", ",", "}", ")", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// parseAnnotationsUint32 searches `a` for `key` and if found verifies that the // value is a 32 bit unsigned integer. If `key` is not found returns `def`.
[ "parseAnnotationsUint32", "searches", "a", "for", "key", "and", "if", "found", "verifies", "that", "the", "value", "is", "a", "32", "bit", "unsigned", "integer", ".", "If", "key", "is", "not", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L260-L275
143,681
Microsoft/hcsshim
internal/oci/uvm.go
parseAnnotationsUint64
func parseAnnotationsUint64(a map[string]string, key string, def uint64) uint64 { if v, ok := a[key]; ok { countu, err := strconv.ParseUint(v, 10, 64) if err == nil { return countu } logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Uint64, logrus.ErrorKey: err, }).Warning("annotation could not be parsed") } return def }
go
func parseAnnotationsUint64(a map[string]string, key string, def uint64) uint64 { if v, ok := a[key]; ok { countu, err := strconv.ParseUint(v, 10, 64) if err == nil { return countu } logrus.WithFields(logrus.Fields{ logfields.OCIAnnotation: key, logfields.Value: v, logfields.ExpectedType: logfields.Uint64, logrus.ErrorKey: err, }).Warning("annotation could not be parsed") } return def }
[ "func", "parseAnnotationsUint64", "(", "a", "map", "[", "string", "]", "string", ",", "key", "string", ",", "def", "uint64", ")", "uint64", "{", "if", "v", ",", "ok", ":=", "a", "[", "key", "]", ";", "ok", "{", "countu", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "v", ",", "10", ",", "64", ")", "\n", "if", "err", "==", "nil", "{", "return", "countu", "\n", "}", "\n", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "OCIAnnotation", ":", "key", ",", "logfields", ".", "Value", ":", "v", ",", "logfields", ".", "ExpectedType", ":", "logfields", ".", "Uint64", ",", "logrus", ".", "ErrorKey", ":", "err", ",", "}", ")", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "def", "\n", "}" ]
// parseAnnotationsUint64 searches `a` for `key` and if found verifies that the // value is a 64 bit unsigned integer. If `key` is not found returns `def`.
[ "parseAnnotationsUint64", "searches", "a", "for", "key", "and", "if", "found", "verifies", "that", "the", "value", "is", "a", "64", "bit", "unsigned", "integer", ".", "If", "key", "is", "not", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L279-L293
143,682
Microsoft/hcsshim
internal/oci/uvm.go
parseAnnotationsString
func parseAnnotationsString(a map[string]string, key string, def string) string { if v, ok := a[key]; ok { return v } return def }
go
func parseAnnotationsString(a map[string]string, key string, def string) string { if v, ok := a[key]; ok { return v } return def }
[ "func", "parseAnnotationsString", "(", "a", "map", "[", "string", "]", "string", ",", "key", "string", ",", "def", "string", ")", "string", "{", "if", "v", ",", "ok", ":=", "a", "[", "key", "]", ";", "ok", "{", "return", "v", "\n", "}", "\n", "return", "def", "\n", "}" ]
// parseAnnotationsString searches `a` for `key`. If `key` is not found returns `def`.
[ "parseAnnotationsString", "searches", "a", "for", "key", ".", "If", "key", "is", "not", "found", "returns", "def", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L296-L301
143,683
Microsoft/hcsshim
internal/oci/uvm.go
UpdateSpecFromOptions
func UpdateSpecFromOptions(s specs.Spec, opts *runhcsopts.Options) specs.Spec { if opts != nil && opts.BootFilesRootPath != "" { s.Annotations[annotationBootFilesRootPath] = opts.BootFilesRootPath } return s }
go
func UpdateSpecFromOptions(s specs.Spec, opts *runhcsopts.Options) specs.Spec { if opts != nil && opts.BootFilesRootPath != "" { s.Annotations[annotationBootFilesRootPath] = opts.BootFilesRootPath } return s }
[ "func", "UpdateSpecFromOptions", "(", "s", "specs", ".", "Spec", ",", "opts", "*", "runhcsopts", ".", "Options", ")", "specs", ".", "Spec", "{", "if", "opts", "!=", "nil", "&&", "opts", ".", "BootFilesRootPath", "!=", "\"", "\"", "{", "s", ".", "Annotations", "[", "annotationBootFilesRootPath", "]", "=", "opts", ".", "BootFilesRootPath", "\n", "}", "\n\n", "return", "s", "\n", "}" ]
// UpdateSpecFromOptions sets extra annotations on the OCI spec based on the // `opts` struct.
[ "UpdateSpecFromOptions", "sets", "extra", "annotations", "on", "the", "OCI", "spec", "based", "on", "the", "opts", "struct", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/oci/uvm.go#L347-L353
143,684
Microsoft/hcsshim
internal/uvm/create_lcow.go
defaultLCOWOSBootFilesPath
func defaultLCOWOSBootFilesPath() string { localDirPath := filepath.Join(filepath.Dir(os.Args[0]), "LinuxBootFiles") if _, err := os.Stat(localDirPath); err == nil { return localDirPath } return filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers") }
go
func defaultLCOWOSBootFilesPath() string { localDirPath := filepath.Join(filepath.Dir(os.Args[0]), "LinuxBootFiles") if _, err := os.Stat(localDirPath); err == nil { return localDirPath } return filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers") }
[ "func", "defaultLCOWOSBootFilesPath", "(", ")", "string", "{", "localDirPath", ":=", "filepath", ".", "Join", "(", "filepath", ".", "Dir", "(", "os", ".", "Args", "[", "0", "]", ")", ",", "\"", "\"", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "localDirPath", ")", ";", "err", "==", "nil", "{", "return", "localDirPath", "\n", "}", "\n", "return", "filepath", ".", "Join", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "\n", "}" ]
// defaultLCOWOSBootFilesPath returns the default path used to locate the LCOW // OS kernel and root FS files. This default is the subdirectory // `LinuxBootFiles` in the directory of the executable that started the current // process; or, if it does not exist, `%ProgramFiles%\Linux Containers`.
[ "defaultLCOWOSBootFilesPath", "returns", "the", "default", "path", "used", "to", "locate", "the", "LCOW", "OS", "kernel", "and", "root", "FS", "files", ".", "This", "default", "is", "the", "subdirectory", "LinuxBootFiles", "in", "the", "directory", "of", "the", "executable", "that", "started", "the", "current", "process", ";", "or", "if", "it", "does", "not", "exist", "%ProgramFiles%", "\\", "Linux", "Containers", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/create_lcow.go#L69-L75
143,685
Microsoft/hcsshim
internal/uvm/create_lcow.go
NewDefaultOptionsLCOW
func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW { // Use KernelDirect boot by default on all builds that support it. kernelDirectSupported := osversion.Get().Build >= 18286 opts := &OptionsLCOW{ Options: newDefaultOptions(id, owner), BootFilesPath: defaultLCOWOSBootFilesPath(), KernelFile: KernelFile, KernelDirect: kernelDirectSupported, RootFSFile: InitrdFile, KernelBootOptions: "", EnableGraphicsConsole: false, ConsolePipe: "", SCSIControllerCount: 1, UseGuestConnection: true, ExecCommandLine: fmt.Sprintf("/bin/gcs -log-format json -loglevel %s", logrus.StandardLogger().Level.String()), ForwardStdout: false, ForwardStderr: true, OutputHandler: parseLogrus(id), VPMemDeviceCount: DefaultVPMEMCount, VPMemSizeBytes: DefaultVPMemSizeBytes, PreferredRootFSType: PreferredRootFSTypeInitRd, } if _, err := os.Stat(filepath.Join(opts.BootFilesPath, VhdFile)); err == nil { // We have a rootfs.vhd in the boot files path. Use it over an initrd.img opts.RootFSFile = VhdFile opts.PreferredRootFSType = PreferredRootFSTypeVHD } if kernelDirectSupported { // KernelDirect supports uncompressed kernel if the kernel is present. // Default to uncompressed if on box. NOTE: If `kernel` is already // uncompressed and simply named 'kernel' it will still be used // uncompressed automatically. if _, err := os.Stat(filepath.Join(opts.BootFilesPath, UncompressedKernelFile)); err == nil { opts.KernelFile = UncompressedKernelFile } } return opts }
go
func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW { // Use KernelDirect boot by default on all builds that support it. kernelDirectSupported := osversion.Get().Build >= 18286 opts := &OptionsLCOW{ Options: newDefaultOptions(id, owner), BootFilesPath: defaultLCOWOSBootFilesPath(), KernelFile: KernelFile, KernelDirect: kernelDirectSupported, RootFSFile: InitrdFile, KernelBootOptions: "", EnableGraphicsConsole: false, ConsolePipe: "", SCSIControllerCount: 1, UseGuestConnection: true, ExecCommandLine: fmt.Sprintf("/bin/gcs -log-format json -loglevel %s", logrus.StandardLogger().Level.String()), ForwardStdout: false, ForwardStderr: true, OutputHandler: parseLogrus(id), VPMemDeviceCount: DefaultVPMEMCount, VPMemSizeBytes: DefaultVPMemSizeBytes, PreferredRootFSType: PreferredRootFSTypeInitRd, } if _, err := os.Stat(filepath.Join(opts.BootFilesPath, VhdFile)); err == nil { // We have a rootfs.vhd in the boot files path. Use it over an initrd.img opts.RootFSFile = VhdFile opts.PreferredRootFSType = PreferredRootFSTypeVHD } if kernelDirectSupported { // KernelDirect supports uncompressed kernel if the kernel is present. // Default to uncompressed if on box. NOTE: If `kernel` is already // uncompressed and simply named 'kernel' it will still be used // uncompressed automatically. if _, err := os.Stat(filepath.Join(opts.BootFilesPath, UncompressedKernelFile)); err == nil { opts.KernelFile = UncompressedKernelFile } } return opts }
[ "func", "NewDefaultOptionsLCOW", "(", "id", ",", "owner", "string", ")", "*", "OptionsLCOW", "{", "// Use KernelDirect boot by default on all builds that support it.", "kernelDirectSupported", ":=", "osversion", ".", "Get", "(", ")", ".", "Build", ">=", "18286", "\n", "opts", ":=", "&", "OptionsLCOW", "{", "Options", ":", "newDefaultOptions", "(", "id", ",", "owner", ")", ",", "BootFilesPath", ":", "defaultLCOWOSBootFilesPath", "(", ")", ",", "KernelFile", ":", "KernelFile", ",", "KernelDirect", ":", "kernelDirectSupported", ",", "RootFSFile", ":", "InitrdFile", ",", "KernelBootOptions", ":", "\"", "\"", ",", "EnableGraphicsConsole", ":", "false", ",", "ConsolePipe", ":", "\"", "\"", ",", "SCSIControllerCount", ":", "1", ",", "UseGuestConnection", ":", "true", ",", "ExecCommandLine", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "logrus", ".", "StandardLogger", "(", ")", ".", "Level", ".", "String", "(", ")", ")", ",", "ForwardStdout", ":", "false", ",", "ForwardStderr", ":", "true", ",", "OutputHandler", ":", "parseLogrus", "(", "id", ")", ",", "VPMemDeviceCount", ":", "DefaultVPMEMCount", ",", "VPMemSizeBytes", ":", "DefaultVPMemSizeBytes", ",", "PreferredRootFSType", ":", "PreferredRootFSTypeInitRd", ",", "}", "\n\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filepath", ".", "Join", "(", "opts", ".", "BootFilesPath", ",", "VhdFile", ")", ")", ";", "err", "==", "nil", "{", "// We have a rootfs.vhd in the boot files path. Use it over an initrd.img", "opts", ".", "RootFSFile", "=", "VhdFile", "\n", "opts", ".", "PreferredRootFSType", "=", "PreferredRootFSTypeVHD", "\n", "}", "\n\n", "if", "kernelDirectSupported", "{", "// KernelDirect supports uncompressed kernel if the kernel is present.", "// Default to uncompressed if on box. NOTE: If `kernel` is already", "// uncompressed and simply named 'kernel' it will still be used", "// uncompressed automatically.", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filepath", ".", "Join", "(", "opts", ".", "BootFilesPath", ",", "UncompressedKernelFile", ")", ")", ";", "err", "==", "nil", "{", "opts", ".", "KernelFile", "=", "UncompressedKernelFile", "\n", "}", "\n", "}", "\n", "return", "opts", "\n", "}" ]
// NewDefaultOptionsLCOW creates the default options for a bootable version of // LCOW. // // `id` the ID of the compute system. If not passed will generate a new GUID. // // `owner` the owner of the compute system. If not passed will use the // executable files name.
[ "NewDefaultOptionsLCOW", "creates", "the", "default", "options", "for", "a", "bootable", "version", "of", "LCOW", ".", "id", "the", "ID", "of", "the", "compute", "system", ".", "If", "not", "passed", "will", "generate", "a", "new", "GUID", ".", "owner", "the", "owner", "of", "the", "compute", "system", ".", "If", "not", "passed", "will", "use", "the", "executable", "files", "name", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/create_lcow.go#L84-L123
143,686
Microsoft/hcsshim
internal/wclayer/legacy.go
newLegacyLayerReader
func newLegacyLayerReader(root string) *legacyLayerReader { r := &legacyLayerReader{ root: root, result: make(chan *fileEntry), proceed: make(chan bool), } go r.walk() return r }
go
func newLegacyLayerReader(root string) *legacyLayerReader { r := &legacyLayerReader{ root: root, result: make(chan *fileEntry), proceed: make(chan bool), } go r.walk() return r }
[ "func", "newLegacyLayerReader", "(", "root", "string", ")", "*", "legacyLayerReader", "{", "r", ":=", "&", "legacyLayerReader", "{", "root", ":", "root", ",", "result", ":", "make", "(", "chan", "*", "fileEntry", ")", ",", "proceed", ":", "make", "(", "chan", "bool", ")", ",", "}", "\n", "go", "r", ".", "walk", "(", ")", "\n", "return", "r", "\n", "}" ]
// newLegacyLayerReader returns a new LayerReader that can read the Windows // container layer transport format from disk.
[ "newLegacyLayerReader", "returns", "a", "new", "LayerReader", "that", "can", "read", "the", "Windows", "container", "layer", "transport", "format", "from", "disk", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/legacy.go#L60-L68
143,687
Microsoft/hcsshim
internal/wclayer/legacy.go
newLegacyLayerWriter
func newLegacyLayerWriter(root string, parentRoots []string, destRoot string) (w *legacyLayerWriter, err error) { w = &legacyLayerWriter{ addedFiles: make(map[string]bool), } defer func() { if err != nil { w.CloseRoots() w = nil } }() w.root, err = safefile.OpenRoot(root) if err != nil { return } w.destRoot, err = safefile.OpenRoot(destRoot) if err != nil { return } for _, r := range parentRoots { f, err := safefile.OpenRoot(r) if err != nil { return w, err } w.parentRoots = append(w.parentRoots, f) } w.bufWriter = bufio.NewWriterSize(ioutil.Discard, 65536) return }
go
func newLegacyLayerWriter(root string, parentRoots []string, destRoot string) (w *legacyLayerWriter, err error) { w = &legacyLayerWriter{ addedFiles: make(map[string]bool), } defer func() { if err != nil { w.CloseRoots() w = nil } }() w.root, err = safefile.OpenRoot(root) if err != nil { return } w.destRoot, err = safefile.OpenRoot(destRoot) if err != nil { return } for _, r := range parentRoots { f, err := safefile.OpenRoot(r) if err != nil { return w, err } w.parentRoots = append(w.parentRoots, f) } w.bufWriter = bufio.NewWriterSize(ioutil.Discard, 65536) return }
[ "func", "newLegacyLayerWriter", "(", "root", "string", ",", "parentRoots", "[", "]", "string", ",", "destRoot", "string", ")", "(", "w", "*", "legacyLayerWriter", ",", "err", "error", ")", "{", "w", "=", "&", "legacyLayerWriter", "{", "addedFiles", ":", "make", "(", "map", "[", "string", "]", "bool", ")", ",", "}", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "w", ".", "CloseRoots", "(", ")", "\n", "w", "=", "nil", "\n", "}", "\n", "}", "(", ")", "\n", "w", ".", "root", ",", "err", "=", "safefile", ".", "OpenRoot", "(", "root", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "w", ".", "destRoot", ",", "err", "=", "safefile", ".", "OpenRoot", "(", "destRoot", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "for", "_", ",", "r", ":=", "range", "parentRoots", "{", "f", ",", "err", ":=", "safefile", ".", "OpenRoot", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "w", ",", "err", "\n", "}", "\n", "w", ".", "parentRoots", "=", "append", "(", "w", ".", "parentRoots", ",", "f", ")", "\n", "}", "\n", "w", ".", "bufWriter", "=", "bufio", ".", "NewWriterSize", "(", "ioutil", ".", "Discard", ",", "65536", ")", "\n", "return", "\n", "}" ]
// newLegacyLayerWriter returns a LayerWriter that can write the contaler layer // transport format to disk.
[ "newLegacyLayerWriter", "returns", "a", "LayerWriter", "that", "can", "write", "the", "contaler", "layer", "transport", "format", "to", "disk", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/legacy.go#L353-L380
143,688
Microsoft/hcsshim
internal/wclayer/legacy.go
cloneTree
func cloneTree(srcRoot *os.File, destRoot *os.File, subPath string, mutatedFiles map[string]bool) error { var di []dirInfo err := safefile.EnsureNotReparsePointRelative(subPath, srcRoot) if err != nil { return err } err = filepath.Walk(filepath.Join(srcRoot.Name(), subPath), func(srcFilePath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(srcRoot.Name(), srcFilePath) if err != nil { return err } fileAttributes := info.Sys().(*syscall.Win32FileAttributeData).FileAttributes // Directories, reparse points, and files that will be mutated during // utility VM import must be copied. All other files can be hard linked. isReparsePoint := fileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 // In go1.9, FileInfo.IsDir() returns false if the directory is also a symlink. // See: https://github.com/golang/go/commit/1989921aef60c83e6f9127a8448fb5ede10e9acc // Fixes the problem by checking syscall.FILE_ATTRIBUTE_DIRECTORY directly isDir := fileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 if isDir || isReparsePoint || mutatedFiles[relPath] { fi, err := copyFileWithMetadata(srcRoot, destRoot, relPath, isDir) if err != nil { return err } if isDir && !isReparsePoint { di = append(di, dirInfo{path: relPath, fileInfo: *fi}) } } else { err = safefile.LinkRelative(relPath, srcRoot, relPath, destRoot) if err != nil { return err } } return nil }) if err != nil { return err } return reapplyDirectoryTimes(destRoot, di) }
go
func cloneTree(srcRoot *os.File, destRoot *os.File, subPath string, mutatedFiles map[string]bool) error { var di []dirInfo err := safefile.EnsureNotReparsePointRelative(subPath, srcRoot) if err != nil { return err } err = filepath.Walk(filepath.Join(srcRoot.Name(), subPath), func(srcFilePath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(srcRoot.Name(), srcFilePath) if err != nil { return err } fileAttributes := info.Sys().(*syscall.Win32FileAttributeData).FileAttributes // Directories, reparse points, and files that will be mutated during // utility VM import must be copied. All other files can be hard linked. isReparsePoint := fileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 // In go1.9, FileInfo.IsDir() returns false if the directory is also a symlink. // See: https://github.com/golang/go/commit/1989921aef60c83e6f9127a8448fb5ede10e9acc // Fixes the problem by checking syscall.FILE_ATTRIBUTE_DIRECTORY directly isDir := fileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 if isDir || isReparsePoint || mutatedFiles[relPath] { fi, err := copyFileWithMetadata(srcRoot, destRoot, relPath, isDir) if err != nil { return err } if isDir && !isReparsePoint { di = append(di, dirInfo{path: relPath, fileInfo: *fi}) } } else { err = safefile.LinkRelative(relPath, srcRoot, relPath, destRoot) if err != nil { return err } } return nil }) if err != nil { return err } return reapplyDirectoryTimes(destRoot, di) }
[ "func", "cloneTree", "(", "srcRoot", "*", "os", ".", "File", ",", "destRoot", "*", "os", ".", "File", ",", "subPath", "string", ",", "mutatedFiles", "map", "[", "string", "]", "bool", ")", "error", "{", "var", "di", "[", "]", "dirInfo", "\n", "err", ":=", "safefile", ".", "EnsureNotReparsePointRelative", "(", "subPath", ",", "srcRoot", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "filepath", ".", "Walk", "(", "filepath", ".", "Join", "(", "srcRoot", ".", "Name", "(", ")", ",", "subPath", ")", ",", "func", "(", "srcFilePath", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "relPath", ",", "err", ":=", "filepath", ".", "Rel", "(", "srcRoot", ".", "Name", "(", ")", ",", "srcFilePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fileAttributes", ":=", "info", ".", "Sys", "(", ")", ".", "(", "*", "syscall", ".", "Win32FileAttributeData", ")", ".", "FileAttributes", "\n", "// Directories, reparse points, and files that will be mutated during", "// utility VM import must be copied. All other files can be hard linked.", "isReparsePoint", ":=", "fileAttributes", "&", "syscall", ".", "FILE_ATTRIBUTE_REPARSE_POINT", "!=", "0", "\n", "// In go1.9, FileInfo.IsDir() returns false if the directory is also a symlink.", "// See: https://github.com/golang/go/commit/1989921aef60c83e6f9127a8448fb5ede10e9acc", "// Fixes the problem by checking syscall.FILE_ATTRIBUTE_DIRECTORY directly", "isDir", ":=", "fileAttributes", "&", "syscall", ".", "FILE_ATTRIBUTE_DIRECTORY", "!=", "0", "\n\n", "if", "isDir", "||", "isReparsePoint", "||", "mutatedFiles", "[", "relPath", "]", "{", "fi", ",", "err", ":=", "copyFileWithMetadata", "(", "srcRoot", ",", "destRoot", ",", "relPath", ",", "isDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "isDir", "&&", "!", "isReparsePoint", "{", "di", "=", "append", "(", "di", ",", "dirInfo", "{", "path", ":", "relPath", ",", "fileInfo", ":", "*", "fi", "}", ")", "\n", "}", "\n", "}", "else", "{", "err", "=", "safefile", ".", "LinkRelative", "(", "relPath", ",", "srcRoot", ",", "relPath", ",", "destRoot", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "reapplyDirectoryTimes", "(", "destRoot", ",", "di", ")", "\n", "}" ]
// cloneTree clones a directory tree using hard links. It skips hard links for // the file names in the provided map and just copies those files.
[ "cloneTree", "clones", "a", "directory", "tree", "using", "hard", "links", ".", "It", "skips", "hard", "links", "for", "the", "file", "names", "in", "the", "provided", "map", "and", "just", "copies", "those", "files", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/legacy.go#L528-L575
143,689
Microsoft/hcsshim
hcn/hcnglobals.go
GetGlobals
func GetGlobals() (*Globals, error) { var version Version err := hnsCall("GET", "/globals/version", "", &version) if err != nil { return nil, err } globals := &Globals{ Version: version, } return globals, nil }
go
func GetGlobals() (*Globals, error) { var version Version err := hnsCall("GET", "/globals/version", "", &version) if err != nil { return nil, err } globals := &Globals{ Version: version, } return globals, nil }
[ "func", "GetGlobals", "(", ")", "(", "*", "Globals", ",", "error", ")", "{", "var", "version", "Version", "\n", "err", ":=", "hnsCall", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "&", "version", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "globals", ":=", "&", "Globals", "{", "Version", ":", "version", ",", "}", "\n\n", "return", "globals", ",", "nil", "\n", "}" ]
// GetGlobals returns the global properties of the HCN Service.
[ "GetGlobals", "returns", "the", "global", "properties", "of", "the", "HCN", "Service", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnglobals.go#L37-L49
143,690
Microsoft/hcsshim
internal/hns/hnsendpoint.go
HNSListEndpointRequest
func HNSListEndpointRequest() ([]HNSEndpoint, error) { var endpoint []HNSEndpoint err := hnsCall("GET", "/endpoints/", "", &endpoint) if err != nil { return nil, err } return endpoint, nil }
go
func HNSListEndpointRequest() ([]HNSEndpoint, error) { var endpoint []HNSEndpoint err := hnsCall("GET", "/endpoints/", "", &endpoint) if err != nil { return nil, err } return endpoint, nil }
[ "func", "HNSListEndpointRequest", "(", ")", "(", "[", "]", "HNSEndpoint", ",", "error", ")", "{", "var", "endpoint", "[", "]", "HNSEndpoint", "\n", "err", ":=", "hnsCall", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "&", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "endpoint", ",", "nil", "\n", "}" ]
// HNSListEndpointRequest makes a HNS call to query the list of available endpoints
[ "HNSListEndpointRequest", "makes", "a", "HNS", "call", "to", "query", "the", "list", "of", "available", "endpoints" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L69-L77
143,691
Microsoft/hcsshim
internal/hns/hnsendpoint.go
GetHNSEndpointByName
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) { hnsResponse, err := HNSListEndpointRequest() if err != nil { return nil, err } for _, hnsEndpoint := range hnsResponse { if hnsEndpoint.Name == endpointName { return &hnsEndpoint, nil } } return nil, EndpointNotFoundError{EndpointName: endpointName} }
go
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) { hnsResponse, err := HNSListEndpointRequest() if err != nil { return nil, err } for _, hnsEndpoint := range hnsResponse { if hnsEndpoint.Name == endpointName { return &hnsEndpoint, nil } } return nil, EndpointNotFoundError{EndpointName: endpointName} }
[ "func", "GetHNSEndpointByName", "(", "endpointName", "string", ")", "(", "*", "HNSEndpoint", ",", "error", ")", "{", "hnsResponse", ",", "err", ":=", "HNSListEndpointRequest", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "hnsEndpoint", ":=", "range", "hnsResponse", "{", "if", "hnsEndpoint", ".", "Name", "==", "endpointName", "{", "return", "&", "hnsEndpoint", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "EndpointNotFoundError", "{", "EndpointName", ":", "endpointName", "}", "\n", "}" ]
// GetHNSEndpointByName gets the endpoint filtered by Name
[ "GetHNSEndpointByName", "gets", "the", "endpoint", "filtered", "by", "Name" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L85-L96
143,692
Microsoft/hcsshim
internal/hns/hnsendpoint.go
Delete
func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) { operation := "Delete" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) return HNSEndpointRequest("DELETE", endpoint.Id, "") }
go
func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) { operation := "Delete" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) return HNSEndpointRequest("DELETE", endpoint.Id, "") }
[ "func", "(", "endpoint", "*", "HNSEndpoint", ")", "Delete", "(", ")", "(", "*", "HNSEndpoint", ",", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "endpoint", ".", "Id", ")", "\n\n", "return", "HNSEndpointRequest", "(", "\"", "\"", ",", "endpoint", ".", "Id", ",", "\"", "\"", ")", "\n", "}" ]
// Delete Endpoint by sending EndpointRequest to HNS
[ "Delete", "Endpoint", "by", "sending", "EndpointRequest", "to", "HNS" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L133-L139
143,693
Microsoft/hcsshim
internal/hns/hnsendpoint.go
ApplyACLPolicy
func (endpoint *HNSEndpoint) ApplyACLPolicy(policies ...*ACLPolicy) error { operation := "ApplyACLPolicy" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) for _, policy := range policies { if policy == nil { continue } jsonString, err := json.Marshal(policy) if err != nil { return err } endpoint.Policies = append(endpoint.Policies, jsonString) } _, err := endpoint.Update() return err }
go
func (endpoint *HNSEndpoint) ApplyACLPolicy(policies ...*ACLPolicy) error { operation := "ApplyACLPolicy" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) for _, policy := range policies { if policy == nil { continue } jsonString, err := json.Marshal(policy) if err != nil { return err } endpoint.Policies = append(endpoint.Policies, jsonString) } _, err := endpoint.Update() return err }
[ "func", "(", "endpoint", "*", "HNSEndpoint", ")", "ApplyACLPolicy", "(", "policies", "...", "*", "ACLPolicy", ")", "error", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "endpoint", ".", "Id", ")", "\n\n", "for", "_", ",", "policy", ":=", "range", "policies", "{", "if", "policy", "==", "nil", "{", "continue", "\n", "}", "\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "policy", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "endpoint", ".", "Policies", "=", "append", "(", "endpoint", ".", "Policies", ",", "jsonString", ")", "\n", "}", "\n\n", "_", ",", "err", ":=", "endpoint", ".", "Update", "(", ")", "\n", "return", "err", "\n", "}" ]
// ApplyACLPolicy applies a set of ACL Policies on the Endpoint
[ "ApplyACLPolicy", "applies", "a", "set", "of", "ACL", "Policies", "on", "the", "Endpoint" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L156-L174
143,694
Microsoft/hcsshim
internal/hns/hnsendpoint.go
ContainerAttach
func (endpoint *HNSEndpoint) ContainerAttach(containerID string, compartmentID uint16) error { operation := "ContainerAttach" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) requestMessage := &EndpointAttachDetachRequest{ ContainerID: containerID, CompartmentID: compartmentID, SystemType: ContainerType, } response := &EndpointResquestResponse{} jsonString, err := json.Marshal(requestMessage) if err != nil { return err } return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response) }
go
func (endpoint *HNSEndpoint) ContainerAttach(containerID string, compartmentID uint16) error { operation := "ContainerAttach" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) requestMessage := &EndpointAttachDetachRequest{ ContainerID: containerID, CompartmentID: compartmentID, SystemType: ContainerType, } response := &EndpointResquestResponse{} jsonString, err := json.Marshal(requestMessage) if err != nil { return err } return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response) }
[ "func", "(", "endpoint", "*", "HNSEndpoint", ")", "ContainerAttach", "(", "containerID", "string", ",", "compartmentID", "uint16", ")", "error", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "endpoint", ".", "Id", ")", "\n\n", "requestMessage", ":=", "&", "EndpointAttachDetachRequest", "{", "ContainerID", ":", "containerID", ",", "CompartmentID", ":", "compartmentID", ",", "SystemType", ":", "ContainerType", ",", "}", "\n", "response", ":=", "&", "EndpointResquestResponse", "{", "}", "\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "requestMessage", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "hnsCall", "(", "\"", "\"", ",", "\"", "\"", "+", "endpoint", ".", "Id", "+", "\"", "\"", ",", "string", "(", "jsonString", ")", ",", "&", "response", ")", "\n", "}" ]
// ContainerAttach attaches an endpoint to container
[ "ContainerAttach", "attaches", "an", "endpoint", "to", "container" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L177-L193
143,695
Microsoft/hcsshim
internal/hns/hnsendpoint.go
HostAttach
func (endpoint *HNSEndpoint) HostAttach(compartmentID uint16) error { operation := "HostAttach" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) requestMessage := &EndpointAttachDetachRequest{ CompartmentID: compartmentID, SystemType: HostType, } response := &EndpointResquestResponse{} jsonString, err := json.Marshal(requestMessage) if err != nil { return err } return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response) }
go
func (endpoint *HNSEndpoint) HostAttach(compartmentID uint16) error { operation := "HostAttach" title := "hcsshim::HNSEndpoint::" + operation logrus.Debugf(title+" id=%s", endpoint.Id) requestMessage := &EndpointAttachDetachRequest{ CompartmentID: compartmentID, SystemType: HostType, } response := &EndpointResquestResponse{} jsonString, err := json.Marshal(requestMessage) if err != nil { return err } return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response) }
[ "func", "(", "endpoint", "*", "HNSEndpoint", ")", "HostAttach", "(", "compartmentID", "uint16", ")", "error", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "endpoint", ".", "Id", ")", "\n", "requestMessage", ":=", "&", "EndpointAttachDetachRequest", "{", "CompartmentID", ":", "compartmentID", ",", "SystemType", ":", "HostType", ",", "}", "\n", "response", ":=", "&", "EndpointResquestResponse", "{", "}", "\n\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "requestMessage", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "hnsCall", "(", "\"", "\"", ",", "\"", "\"", "+", "endpoint", ".", "Id", "+", "\"", "\"", ",", "string", "(", "jsonString", ")", ",", "&", "response", ")", "\n\n", "}" ]
// HostAttach attaches a nic on the host
[ "HostAttach", "attaches", "a", "nic", "on", "the", "host" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnsendpoint.go#L215-L231
143,696
Microsoft/hcsshim
hcn/hcnsupport.go
GetSupportedFeatures
func GetSupportedFeatures() SupportedFeatures { var features SupportedFeatures globals, err := GetGlobals() if err != nil { // Expected on pre-1803 builds, all features will be false/unsupported logrus.Debugf("Unable to obtain globals: %s", err) return features } features.Acl = AclFeatures{ AclAddressLists: isFeatureSupported(globals.Version, HNSVersion1803), AclNoHostRulePriority: isFeatureSupported(globals.Version, HNSVersion1803), AclPortRanges: isFeatureSupported(globals.Version, HNSVersion1803), AclRuleId: isFeatureSupported(globals.Version, HNSVersion1803), } features.Api = ApiSupport{ V2: isFeatureSupported(globals.Version, V2ApiSupport), V1: true, // HNSCall is still available. } features.RemoteSubnet = isFeatureSupported(globals.Version, RemoteSubnetVersion) features.HostRoute = isFeatureSupported(globals.Version, HostRouteVersion) features.DSR = isFeatureSupported(globals.Version, DSRVersion) return features }
go
func GetSupportedFeatures() SupportedFeatures { var features SupportedFeatures globals, err := GetGlobals() if err != nil { // Expected on pre-1803 builds, all features will be false/unsupported logrus.Debugf("Unable to obtain globals: %s", err) return features } features.Acl = AclFeatures{ AclAddressLists: isFeatureSupported(globals.Version, HNSVersion1803), AclNoHostRulePriority: isFeatureSupported(globals.Version, HNSVersion1803), AclPortRanges: isFeatureSupported(globals.Version, HNSVersion1803), AclRuleId: isFeatureSupported(globals.Version, HNSVersion1803), } features.Api = ApiSupport{ V2: isFeatureSupported(globals.Version, V2ApiSupport), V1: true, // HNSCall is still available. } features.RemoteSubnet = isFeatureSupported(globals.Version, RemoteSubnetVersion) features.HostRoute = isFeatureSupported(globals.Version, HostRouteVersion) features.DSR = isFeatureSupported(globals.Version, DSRVersion) return features }
[ "func", "GetSupportedFeatures", "(", ")", "SupportedFeatures", "{", "var", "features", "SupportedFeatures", "\n\n", "globals", ",", "err", ":=", "GetGlobals", "(", ")", "\n", "if", "err", "!=", "nil", "{", "// Expected on pre-1803 builds, all features will be false/unsupported", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "features", "\n", "}", "\n\n", "features", ".", "Acl", "=", "AclFeatures", "{", "AclAddressLists", ":", "isFeatureSupported", "(", "globals", ".", "Version", ",", "HNSVersion1803", ")", ",", "AclNoHostRulePriority", ":", "isFeatureSupported", "(", "globals", ".", "Version", ",", "HNSVersion1803", ")", ",", "AclPortRanges", ":", "isFeatureSupported", "(", "globals", ".", "Version", ",", "HNSVersion1803", ")", ",", "AclRuleId", ":", "isFeatureSupported", "(", "globals", ".", "Version", ",", "HNSVersion1803", ")", ",", "}", "\n\n", "features", ".", "Api", "=", "ApiSupport", "{", "V2", ":", "isFeatureSupported", "(", "globals", ".", "Version", ",", "V2ApiSupport", ")", ",", "V1", ":", "true", ",", "// HNSCall is still available.", "}", "\n\n", "features", ".", "RemoteSubnet", "=", "isFeatureSupported", "(", "globals", ".", "Version", ",", "RemoteSubnetVersion", ")", "\n", "features", ".", "HostRoute", "=", "isFeatureSupported", "(", "globals", ".", "Version", ",", "HostRouteVersion", ")", "\n", "features", ".", "DSR", "=", "isFeatureSupported", "(", "globals", ".", "Version", ",", "DSRVersion", ")", "\n\n", "return", "features", "\n", "}" ]
// GetSupportedFeatures returns the features supported by the Service.
[ "GetSupportedFeatures", "returns", "the", "features", "supported", "by", "the", "Service", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hcn/hcnsupport.go#L31-L58
143,697
Microsoft/hcsshim
cmd/runhcs/container.go
startVMShim
func (c *container) startVMShim(logFile string, opts interface{}) (*os.Process, error) { var os string if _, ok := opts.(*uvm.OptionsLCOW); ok { os = "linux" } else { os = "windows" } args := []string{"--os", os} if strings.HasPrefix(logFile, runhcs.SafePipePrefix) { args = append(args, "--log-pipe", logFile) } args = append(args, c.VMPipePath()) return launchShim("vmshim", "", logFile, args, opts) }
go
func (c *container) startVMShim(logFile string, opts interface{}) (*os.Process, error) { var os string if _, ok := opts.(*uvm.OptionsLCOW); ok { os = "linux" } else { os = "windows" } args := []string{"--os", os} if strings.HasPrefix(logFile, runhcs.SafePipePrefix) { args = append(args, "--log-pipe", logFile) } args = append(args, c.VMPipePath()) return launchShim("vmshim", "", logFile, args, opts) }
[ "func", "(", "c", "*", "container", ")", "startVMShim", "(", "logFile", "string", ",", "opts", "interface", "{", "}", ")", "(", "*", "os", ".", "Process", ",", "error", ")", "{", "var", "os", "string", "\n", "if", "_", ",", "ok", ":=", "opts", ".", "(", "*", "uvm", ".", "OptionsLCOW", ")", ";", "ok", "{", "os", "=", "\"", "\"", "\n", "}", "else", "{", "os", "=", "\"", "\"", "\n", "}", "\n", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "os", "}", "\n", "if", "strings", ".", "HasPrefix", "(", "logFile", ",", "runhcs", ".", "SafePipePrefix", ")", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ",", "logFile", ")", "\n", "}", "\n", "args", "=", "append", "(", "args", ",", "c", ".", "VMPipePath", "(", ")", ")", "\n", "return", "launchShim", "(", "\"", "\"", ",", "\"", "\"", ",", "logFile", ",", "args", ",", "opts", ")", "\n", "}" ]
// startVMShim starts a vm-shim command with the specified `opts`. `opts` can be `uvm.OptionsWCOW` or `uvm.OptionsLCOW`
[ "startVMShim", "starts", "a", "vm", "-", "shim", "command", "with", "the", "specified", "opts", ".", "opts", "can", "be", "uvm", ".", "OptionsWCOW", "or", "uvm", ".", "OptionsLCOW" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/runhcs/container.go#L229-L242
143,698
Microsoft/hcsshim
internal/appargs/appargs.go
Int
func Int(base int, min int, max int) Validator { return func(args []string) int { if len(args) == 0 { return -1 } i, err := strconv.ParseInt(args[0], base, 0) if err != nil || int(i) < min || int(i) > max { return -1 } return 1 } }
go
func Int(base int, min int, max int) Validator { return func(args []string) int { if len(args) == 0 { return -1 } i, err := strconv.ParseInt(args[0], base, 0) if err != nil || int(i) < min || int(i) > max { return -1 } return 1 } }
[ "func", "Int", "(", "base", "int", ",", "min", "int", ",", "max", "int", ")", "Validator", "{", "return", "func", "(", "args", "[", "]", "string", ")", "int", "{", "if", "len", "(", "args", ")", "==", "0", "{", "return", "-", "1", "\n", "}", "\n", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "args", "[", "0", "]", ",", "base", ",", "0", ")", "\n", "if", "err", "!=", "nil", "||", "int", "(", "i", ")", "<", "min", "||", "int", "(", "i", ")", ">", "max", "{", "return", "-", "1", "\n", "}", "\n", "return", "1", "\n", "}", "\n", "}" ]
// Int returns a validator for integers.
[ "Int", "returns", "a", "validator", "for", "integers", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/appargs/appargs.go#L33-L44
143,699
Microsoft/hcsshim
internal/appargs/appargs.go
Optional
func Optional(v Validator) Validator { return func(args []string) int { if len(args) == 0 { return 0 } return v(args) } }
go
func Optional(v Validator) Validator { return func(args []string) int { if len(args) == 0 { return 0 } return v(args) } }
[ "func", "Optional", "(", "v", "Validator", ")", "Validator", "{", "return", "func", "(", "args", "[", "]", "string", ")", "int", "{", "if", "len", "(", "args", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "v", "(", "args", ")", "\n", "}", "\n", "}" ]
// Optional returns a validator that treats an argument as optional.
[ "Optional", "returns", "a", "validator", "that", "treats", "an", "argument", "as", "optional", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/appargs/appargs.go#L47-L54