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
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
154,200
juju/juju
apiserver/facades/client/application/application.go
CharmConfig
func (api *APIv8) CharmConfig(args params.Entities) (params.ApplicationGetConfigResults, error) { return api.GetConfig(args) }
go
func (api *APIv8) CharmConfig(args params.Entities) (params.ApplicationGetConfigResults, error) { return api.GetConfig(args) }
[ "func", "(", "api", "*", "APIv8", ")", "CharmConfig", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "ApplicationGetConfigResults", ",", "error", ")", "{", "return", "api", ".", "GetConfig", "(", "args", ")", "\n", "}" ]
// CharmConfig is a shim to GetConfig on APIv5. It returns only charm config. // Version 8 and below accept params.Entities, where later versions must accept // a model generation
[ "CharmConfig", "is", "a", "shim", "to", "GetConfig", "on", "APIv5", ".", "It", "returns", "only", "charm", "config", ".", "Version", "8", "and", "below", "accept", "params", ".", "Entities", "where", "later", "versions", "must", "accept", "a", "model", "generation" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2032-L2034
154,201
juju/juju
apiserver/facades/client/application/application.go
CharmConfig
func (api *APIBase) CharmConfig(args params.ApplicationGetArgs) (params.ApplicationGetConfigResults, error) { if err := api.checkCanRead(); err != nil { return params.ApplicationGetConfigResults{}, err } results := params.ApplicationGetConfigResults{ Results: make([]params.ConfigResult, len(args.Args)), } for i, arg := range args.Args { config, err := api.getCharmConfig(arg.BranchName, arg.ApplicationName) results.Results[i].Config = config results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (api *APIBase) CharmConfig(args params.ApplicationGetArgs) (params.ApplicationGetConfigResults, error) { if err := api.checkCanRead(); err != nil { return params.ApplicationGetConfigResults{}, err } results := params.ApplicationGetConfigResults{ Results: make([]params.ConfigResult, len(args.Args)), } for i, arg := range args.Args { config, err := api.getCharmConfig(arg.BranchName, arg.ApplicationName) results.Results[i].Config = config results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "api", "*", "APIBase", ")", "CharmConfig", "(", "args", "params", ".", "ApplicationGetArgs", ")", "(", "params", ".", "ApplicationGetConfigResults", ",", "error", ")", "{", "if", "err", ":=", "api", ".", "checkCanRead", "(", ")", ";", "err", "!=", "nil", "{", "return", "params", ".", "ApplicationGetConfigResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "ApplicationGetConfigResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "ConfigResult", ",", "len", "(", "args", ".", "Args", ")", ")", ",", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Args", "{", "config", ",", "err", ":=", "api", ".", "getCharmConfig", "(", "arg", ".", "BranchName", ",", "arg", ".", "ApplicationName", ")", "\n", "results", ".", "Results", "[", "i", "]", ".", "Config", "=", "config", "\n", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// CharmConfig returns charm config for the input list of applications and // model generations.
[ "CharmConfig", "returns", "charm", "config", "for", "the", "input", "list", "of", "applications", "and", "model", "generations", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2038-L2051
154,202
juju/juju
apiserver/facades/client/application/application.go
GetConfig
func (api *APIBase) GetConfig(args params.Entities) (params.ApplicationGetConfigResults, error) { if err := api.checkCanRead(); err != nil { return params.ApplicationGetConfigResults{}, err } results := params.ApplicationGetConfigResults{ Results: make([]params.ConfigResult, len(args.Entities)), } for i, arg := range args.Entities { tag, err := names.ParseTag(arg.Tag) if err != nil { results.Results[i].Error = common.ServerError(err) continue } if tag.Kind() != names.ApplicationTagKind { results.Results[i].Error = common.ServerError( errors.Errorf("unexpected tag type, expected application, got %s", tag.Kind())) continue } // Always deal with the master branch version of config. config, err := api.getCharmConfig(model.GenerationMaster, tag.Id()) results.Results[i].Config = config results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (api *APIBase) GetConfig(args params.Entities) (params.ApplicationGetConfigResults, error) { if err := api.checkCanRead(); err != nil { return params.ApplicationGetConfigResults{}, err } results := params.ApplicationGetConfigResults{ Results: make([]params.ConfigResult, len(args.Entities)), } for i, arg := range args.Entities { tag, err := names.ParseTag(arg.Tag) if err != nil { results.Results[i].Error = common.ServerError(err) continue } if tag.Kind() != names.ApplicationTagKind { results.Results[i].Error = common.ServerError( errors.Errorf("unexpected tag type, expected application, got %s", tag.Kind())) continue } // Always deal with the master branch version of config. config, err := api.getCharmConfig(model.GenerationMaster, tag.Id()) results.Results[i].Config = config results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "api", "*", "APIBase", ")", "GetConfig", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "ApplicationGetConfigResults", ",", "error", ")", "{", "if", "err", ":=", "api", ".", "checkCanRead", "(", ")", ";", "err", "!=", "nil", "{", "return", "params", ".", "ApplicationGetConfigResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "ApplicationGetConfigResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "ConfigResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "tag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "if", "tag", ".", "Kind", "(", ")", "!=", "names", ".", "ApplicationTagKind", "{", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "errors", ".", "Errorf", "(", "\"", "\"", ",", "tag", ".", "Kind", "(", ")", ")", ")", "\n", "continue", "\n", "}", "\n\n", "// Always deal with the master branch version of config.", "config", ",", "err", ":=", "api", ".", "getCharmConfig", "(", "model", ".", "GenerationMaster", ",", "tag", ".", "Id", "(", ")", ")", "\n", "results", ".", "Results", "[", "i", "]", ".", "Config", "=", "config", "\n", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// GetConfig returns the charm config for each of the input applications.
[ "GetConfig", "returns", "the", "charm", "config", "for", "each", "of", "the", "input", "applications", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2054-L2079
154,203
juju/juju
apiserver/facades/client/application/application.go
SetApplicationsConfig
func (api *APIBase) SetApplicationsConfig(args params.ApplicationConfigSetArgs) (params.ErrorResults, error) { var result params.ErrorResults if err := api.checkCanWrite(); err != nil { return result, errors.Trace(err) } if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } result.Results = make([]params.ErrorResult, len(args.Args)) for i, arg := range args.Args { err := api.setApplicationConfig(arg) result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (api *APIBase) SetApplicationsConfig(args params.ApplicationConfigSetArgs) (params.ErrorResults, error) { var result params.ErrorResults if err := api.checkCanWrite(); err != nil { return result, errors.Trace(err) } if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } result.Results = make([]params.ErrorResult, len(args.Args)) for i, arg := range args.Args { err := api.setApplicationConfig(arg) result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "api", "*", "APIBase", ")", "SetApplicationsConfig", "(", "args", "params", ".", "ApplicationConfigSetArgs", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "var", "result", "params", ".", "ErrorResults", "\n", "if", "err", ":=", "api", ".", "checkCanWrite", "(", ")", ";", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "api", ".", "check", ".", "ChangeAllowed", "(", ")", ";", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "result", ".", "Results", "=", "make", "(", "[", "]", "params", ".", "ErrorResult", ",", "len", "(", "args", ".", "Args", ")", ")", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Args", "{", "err", ":=", "api", ".", "setApplicationConfig", "(", "arg", ")", "\n", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// SetApplicationsConfig implements the server side of Application.SetApplicationsConfig. // It does not unset values that are set to an empty string. // Unset should be used for that.
[ "SetApplicationsConfig", "implements", "the", "server", "side", "of", "Application", ".", "SetApplicationsConfig", ".", "It", "does", "not", "unset", "values", "that", "are", "set", "to", "an", "empty", "string", ".", "Unset", "should", "be", "used", "for", "that", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2103-L2117
154,204
juju/juju
apiserver/facades/client/application/application.go
ResolveUnitErrors
func (api *APIBase) ResolveUnitErrors(p params.UnitsResolved) (params.ErrorResults, error) { if p.All { unitsWithErrors, err := api.backend.UnitsInError() if err != nil { return params.ErrorResults{}, errors.Trace(err) } for _, u := range unitsWithErrors { if err := u.Resolve(p.Retry); err != nil { return params.ErrorResults{}, errors.Annotatef(err, "resolve error for unit %q", u.UnitTag().Id()) } } } var result params.ErrorResults if err := api.checkCanWrite(); err != nil { return result, errors.Trace(err) } if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } result.Results = make([]params.ErrorResult, len(p.Tags.Entities)) for i, entity := range p.Tags.Entities { tag, err := names.ParseUnitTag(entity.Tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } unit, err := api.backend.Unit(tag.Id()) if err != nil { result.Results[i].Error = common.ServerError(err) continue } err = unit.Resolve(p.Retry) result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (api *APIBase) ResolveUnitErrors(p params.UnitsResolved) (params.ErrorResults, error) { if p.All { unitsWithErrors, err := api.backend.UnitsInError() if err != nil { return params.ErrorResults{}, errors.Trace(err) } for _, u := range unitsWithErrors { if err := u.Resolve(p.Retry); err != nil { return params.ErrorResults{}, errors.Annotatef(err, "resolve error for unit %q", u.UnitTag().Id()) } } } var result params.ErrorResults if err := api.checkCanWrite(); err != nil { return result, errors.Trace(err) } if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } result.Results = make([]params.ErrorResult, len(p.Tags.Entities)) for i, entity := range p.Tags.Entities { tag, err := names.ParseUnitTag(entity.Tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } unit, err := api.backend.Unit(tag.Id()) if err != nil { result.Results[i].Error = common.ServerError(err) continue } err = unit.Resolve(p.Retry) result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "api", "*", "APIBase", ")", "ResolveUnitErrors", "(", "p", "params", ".", "UnitsResolved", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "if", "p", ".", "All", "{", "unitsWithErrors", ",", "err", ":=", "api", ".", "backend", ".", "UnitsInError", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "ErrorResults", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "for", "_", ",", "u", ":=", "range", "unitsWithErrors", "{", "if", "err", ":=", "u", ".", "Resolve", "(", "p", ".", "Retry", ")", ";", "err", "!=", "nil", "{", "return", "params", ".", "ErrorResults", "{", "}", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "u", ".", "UnitTag", "(", ")", ".", "Id", "(", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "var", "result", "params", ".", "ErrorResults", "\n", "if", "err", ":=", "api", ".", "checkCanWrite", "(", ")", ";", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "api", ".", "check", ".", "ChangeAllowed", "(", ")", ";", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "result", ".", "Results", "=", "make", "(", "[", "]", "params", ".", "ErrorResult", ",", "len", "(", "p", ".", "Tags", ".", "Entities", ")", ")", "\n", "for", "i", ",", "entity", ":=", "range", "p", ".", "Tags", ".", "Entities", "{", "tag", ",", "err", ":=", "names", ".", "ParseUnitTag", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "unit", ",", "err", ":=", "api", ".", "backend", ".", "Unit", "(", "tag", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "err", "=", "unit", ".", "Resolve", "(", "p", ".", "Retry", ")", "\n", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// ResolveUnitErrors marks errors on the specified units as resolved.
[ "ResolveUnitErrors", "marks", "errors", "on", "the", "specified", "units", "as", "resolved", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2235-L2272
154,205
juju/juju
apiserver/facades/client/application/application.go
ApplicationsInfo
func (api *APIBase) ApplicationsInfo(in params.Entities) (params.ApplicationInfoResults, error) { out := make([]params.ApplicationInfoResult, len(in.Entities)) for i, one := range in.Entities { tag, err := names.ParseApplicationTag(one.Tag) if err != nil { out[i].Error = common.ServerError(err) continue } app, err := api.backend.Application(tag.Name) if err != nil { out[i].Error = common.ServerError(err) continue } details, err := api.getConfig(params.ApplicationGet{ApplicationName: tag.Name}, describe) if err != nil { out[i].Error = common.ServerError(err) continue } bindings, err := app.EndpointBindings() if err != nil { out[i].Error = common.ServerError(err) continue } out[i].Result = &params.ApplicationInfo{ Tag: tag.String(), Charm: details.Charm, Series: details.Series, Channel: details.Channel, Constraints: details.Constraints, Principal: app.IsPrincipal(), Exposed: app.IsExposed(), Remote: app.IsRemote(), EndpointBindings: bindings, } } return params.ApplicationInfoResults{out}, nil }
go
func (api *APIBase) ApplicationsInfo(in params.Entities) (params.ApplicationInfoResults, error) { out := make([]params.ApplicationInfoResult, len(in.Entities)) for i, one := range in.Entities { tag, err := names.ParseApplicationTag(one.Tag) if err != nil { out[i].Error = common.ServerError(err) continue } app, err := api.backend.Application(tag.Name) if err != nil { out[i].Error = common.ServerError(err) continue } details, err := api.getConfig(params.ApplicationGet{ApplicationName: tag.Name}, describe) if err != nil { out[i].Error = common.ServerError(err) continue } bindings, err := app.EndpointBindings() if err != nil { out[i].Error = common.ServerError(err) continue } out[i].Result = &params.ApplicationInfo{ Tag: tag.String(), Charm: details.Charm, Series: details.Series, Channel: details.Channel, Constraints: details.Constraints, Principal: app.IsPrincipal(), Exposed: app.IsExposed(), Remote: app.IsRemote(), EndpointBindings: bindings, } } return params.ApplicationInfoResults{out}, nil }
[ "func", "(", "api", "*", "APIBase", ")", "ApplicationsInfo", "(", "in", "params", ".", "Entities", ")", "(", "params", ".", "ApplicationInfoResults", ",", "error", ")", "{", "out", ":=", "make", "(", "[", "]", "params", ".", "ApplicationInfoResult", ",", "len", "(", "in", ".", "Entities", ")", ")", "\n", "for", "i", ",", "one", ":=", "range", "in", ".", "Entities", "{", "tag", ",", "err", ":=", "names", ".", "ParseApplicationTag", "(", "one", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "out", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "app", ",", "err", ":=", "api", ".", "backend", ".", "Application", "(", "tag", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "out", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n\n", "details", ",", "err", ":=", "api", ".", "getConfig", "(", "params", ".", "ApplicationGet", "{", "ApplicationName", ":", "tag", ".", "Name", "}", ",", "describe", ")", "\n", "if", "err", "!=", "nil", "{", "out", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n\n", "bindings", ",", "err", ":=", "app", ".", "EndpointBindings", "(", ")", "\n", "if", "err", "!=", "nil", "{", "out", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n\n", "out", "[", "i", "]", ".", "Result", "=", "&", "params", ".", "ApplicationInfo", "{", "Tag", ":", "tag", ".", "String", "(", ")", ",", "Charm", ":", "details", ".", "Charm", ",", "Series", ":", "details", ".", "Series", ",", "Channel", ":", "details", ".", "Channel", ",", "Constraints", ":", "details", ".", "Constraints", ",", "Principal", ":", "app", ".", "IsPrincipal", "(", ")", ",", "Exposed", ":", "app", ".", "IsExposed", "(", ")", ",", "Remote", ":", "app", ".", "IsRemote", "(", ")", ",", "EndpointBindings", ":", "bindings", ",", "}", "\n", "}", "\n", "return", "params", ".", "ApplicationInfoResults", "{", "out", "}", ",", "nil", "\n", "}" ]
// ApplicationsInfo returns applications information.
[ "ApplicationsInfo", "returns", "applications", "information", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L2278-L2317
154,206
juju/juju
worker/actionpruner/worker.go
New
func New(conf pruner.Config) (worker.Worker, error) { if err := conf.Validate(); err != nil { return nil, errors.Trace(err) } w := &Worker{ pruner.New(conf), } err := catacomb.Invoke(catacomb.Plan{ Site: w.Catacomb(), Work: w.loop, }) return w, errors.Trace(err) }
go
func New(conf pruner.Config) (worker.Worker, error) { if err := conf.Validate(); err != nil { return nil, errors.Trace(err) } w := &Worker{ pruner.New(conf), } err := catacomb.Invoke(catacomb.Plan{ Site: w.Catacomb(), Work: w.loop, }) return w, errors.Trace(err) }
[ "func", "New", "(", "conf", "pruner", ".", "Config", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "conf", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "w", ":=", "&", "Worker", "{", "pruner", ".", "New", "(", "conf", ")", ",", "}", "\n\n", "err", ":=", "catacomb", ".", "Invoke", "(", "catacomb", ".", "Plan", "{", "Site", ":", "w", ".", "Catacomb", "(", ")", ",", "Work", ":", "w", ".", "loop", ",", "}", ")", "\n\n", "return", "w", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// New creates a new action pruner worker
[ "New", "creates", "a", "new", "action", "pruner", "worker" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/actionpruner/worker.go#L35-L50
154,207
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
WatchBlockDevices
func (s *StorageProvisionerAPIv3) WatchBlockDevices(args params.Entities) (params.NotifyWatchResults, error) { canAccess, err := s.getBlockDevicesAuthFunc() if err != nil { return params.NotifyWatchResults{}, common.ServerError(common.ErrPerm) } results := params.NotifyWatchResults{ Results: make([]params.NotifyWatchResult, len(args.Entities)), } one := func(arg params.Entity) (string, error) { machineTag, err := names.ParseMachineTag(arg.Tag) if err != nil { return "", err } if !canAccess(machineTag) { return "", common.ErrPerm } w := s.sb.WatchBlockDevices(machineTag) if _, ok := <-w.Changes(); ok { return s.resources.Register(w), nil } return "", watcher.EnsureErr(w) } for i, arg := range args.Entities { var result params.NotifyWatchResult id, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.NotifyWatcherId = id } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv3) WatchBlockDevices(args params.Entities) (params.NotifyWatchResults, error) { canAccess, err := s.getBlockDevicesAuthFunc() if err != nil { return params.NotifyWatchResults{}, common.ServerError(common.ErrPerm) } results := params.NotifyWatchResults{ Results: make([]params.NotifyWatchResult, len(args.Entities)), } one := func(arg params.Entity) (string, error) { machineTag, err := names.ParseMachineTag(arg.Tag) if err != nil { return "", err } if !canAccess(machineTag) { return "", common.ErrPerm } w := s.sb.WatchBlockDevices(machineTag) if _, ok := <-w.Changes(); ok { return s.resources.Register(w), nil } return "", watcher.EnsureErr(w) } for i, arg := range args.Entities { var result params.NotifyWatchResult id, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.NotifyWatcherId = id } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "WatchBlockDevices", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "NotifyWatchResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getBlockDevicesAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "NotifyWatchResults", "{", "}", ",", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "\n", "results", ":=", "params", ".", "NotifyWatchResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "NotifyWatchResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "(", "string", ",", "error", ")", "{", "machineTag", ",", "err", ":=", "names", ".", "ParseMachineTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "!", "canAccess", "(", "machineTag", ")", "{", "return", "\"", "\"", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "w", ":=", "s", ".", "sb", ".", "WatchBlockDevices", "(", "machineTag", ")", "\n", "if", "_", ",", "ok", ":=", "<-", "w", ".", "Changes", "(", ")", ";", "ok", "{", "return", "s", ".", "resources", ".", "Register", "(", "w", ")", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "watcher", ".", "EnsureErr", "(", "w", ")", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "var", "result", "params", ".", "NotifyWatchResult", "\n", "id", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "NotifyWatcherId", "=", "id", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// WatchBlockDevices watches for changes to the specified machines' block devices.
[ "WatchBlockDevices", "watches", "for", "changes", "to", "the", "specified", "machines", "block", "devices", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L242-L275
154,208
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
WatchVolumes
func (s *StorageProvisionerAPIv3) WatchVolumes(args params.Entities) (params.StringsWatchResults, error) { return s.watchStorageEntities(args, s.sb.WatchModelVolumes, s.sb.WatchMachineVolumes, nil) }
go
func (s *StorageProvisionerAPIv3) WatchVolumes(args params.Entities) (params.StringsWatchResults, error) { return s.watchStorageEntities(args, s.sb.WatchModelVolumes, s.sb.WatchMachineVolumes, nil) }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "WatchVolumes", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "StringsWatchResults", ",", "error", ")", "{", "return", "s", ".", "watchStorageEntities", "(", "args", ",", "s", ".", "sb", ".", "WatchModelVolumes", ",", "s", ".", "sb", ".", "WatchMachineVolumes", ",", "nil", ")", "\n", "}" ]
// WatchVolumes watches for changes to volumes scoped to the // entity with the tag passed to NewState.
[ "WatchVolumes", "watches", "for", "changes", "to", "volumes", "scoped", "to", "the", "entity", "with", "the", "tag", "passed", "to", "NewState", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L318-L320
154,209
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
WatchFilesystems
func (s *StorageProvisionerAPIv3) WatchFilesystems(args params.Entities) (params.StringsWatchResults, error) { w := filesystemwatcher.Watchers{s.sb} return s.watchStorageEntities(args, w.WatchModelManagedFilesystems, w.WatchMachineManagedFilesystems, w.WatchUnitManagedFilesystems) }
go
func (s *StorageProvisionerAPIv3) WatchFilesystems(args params.Entities) (params.StringsWatchResults, error) { w := filesystemwatcher.Watchers{s.sb} return s.watchStorageEntities(args, w.WatchModelManagedFilesystems, w.WatchMachineManagedFilesystems, w.WatchUnitManagedFilesystems) }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "WatchFilesystems", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "StringsWatchResults", ",", "error", ")", "{", "w", ":=", "filesystemwatcher", ".", "Watchers", "{", "s", ".", "sb", "}", "\n", "return", "s", ".", "watchStorageEntities", "(", "args", ",", "w", ".", "WatchModelManagedFilesystems", ",", "w", ".", "WatchMachineManagedFilesystems", ",", "w", ".", "WatchUnitManagedFilesystems", ")", "\n", "}" ]
// WatchFilesystems watches for changes to filesystems scoped // to the entity with the tag passed to NewState.
[ "WatchFilesystems", "watches", "for", "changes", "to", "filesystems", "scoped", "to", "the", "entity", "with", "the", "tag", "passed", "to", "NewState", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L324-L330
154,210
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
WatchVolumeAttachments
func (s *StorageProvisionerAPIv3) WatchVolumeAttachments(args params.Entities) (params.MachineStorageIdsWatchResults, error) { return s.watchAttachments( args, s.sb.WatchModelVolumeAttachments, s.sb.WatchMachineVolumeAttachments, s.sb.WatchUnitVolumeAttachments, storagecommon.ParseVolumeAttachmentIds, ) }
go
func (s *StorageProvisionerAPIv3) WatchVolumeAttachments(args params.Entities) (params.MachineStorageIdsWatchResults, error) { return s.watchAttachments( args, s.sb.WatchModelVolumeAttachments, s.sb.WatchMachineVolumeAttachments, s.sb.WatchUnitVolumeAttachments, storagecommon.ParseVolumeAttachmentIds, ) }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "WatchVolumeAttachments", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "MachineStorageIdsWatchResults", ",", "error", ")", "{", "return", "s", ".", "watchAttachments", "(", "args", ",", "s", ".", "sb", ".", "WatchModelVolumeAttachments", ",", "s", ".", "sb", ".", "WatchMachineVolumeAttachments", ",", "s", ".", "sb", ".", "WatchUnitVolumeAttachments", ",", "storagecommon", ".", "ParseVolumeAttachmentIds", ",", ")", "\n", "}" ]
// WatchVolumeAttachments watches for changes to volume attachments scoped to // the entity with the tag passed to NewState.
[ "WatchVolumeAttachments", "watches", "for", "changes", "to", "volume", "attachments", "scoped", "to", "the", "entity", "with", "the", "tag", "passed", "to", "NewState", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L383-L391
154,211
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
WatchFilesystemAttachments
func (s *StorageProvisionerAPIv3) WatchFilesystemAttachments(args params.Entities) (params.MachineStorageIdsWatchResults, error) { w := filesystemwatcher.Watchers{s.sb} return s.watchAttachments( args, w.WatchModelManagedFilesystemAttachments, w.WatchMachineManagedFilesystemAttachments, w.WatchUnitManagedFilesystemAttachments, storagecommon.ParseFilesystemAttachmentIds, ) }
go
func (s *StorageProvisionerAPIv3) WatchFilesystemAttachments(args params.Entities) (params.MachineStorageIdsWatchResults, error) { w := filesystemwatcher.Watchers{s.sb} return s.watchAttachments( args, w.WatchModelManagedFilesystemAttachments, w.WatchMachineManagedFilesystemAttachments, w.WatchUnitManagedFilesystemAttachments, storagecommon.ParseFilesystemAttachmentIds, ) }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "WatchFilesystemAttachments", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "MachineStorageIdsWatchResults", ",", "error", ")", "{", "w", ":=", "filesystemwatcher", ".", "Watchers", "{", "s", ".", "sb", "}", "\n", "return", "s", ".", "watchAttachments", "(", "args", ",", "w", ".", "WatchModelManagedFilesystemAttachments", ",", "w", ".", "WatchMachineManagedFilesystemAttachments", ",", "w", ".", "WatchUnitManagedFilesystemAttachments", ",", "storagecommon", ".", "ParseFilesystemAttachmentIds", ",", ")", "\n", "}" ]
// WatchFilesystemAttachments watches for changes to filesystem attachments // scoped to the entity with the tag passed to NewState.
[ "WatchFilesystemAttachments", "watches", "for", "changes", "to", "filesystem", "attachments", "scoped", "to", "the", "entity", "with", "the", "tag", "passed", "to", "NewState", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L395-L404
154,212
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
Volumes
func (s *StorageProvisionerAPIv3) Volumes(args params.Entities) (params.VolumeResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.VolumeResults{}, common.ServerError(common.ErrPerm) } results := params.VolumeResults{ Results: make([]params.VolumeResult, len(args.Entities)), } one := func(arg params.Entity) (params.Volume, error) { tag, err := names.ParseVolumeTag(arg.Tag) if err != nil || !canAccess(tag) { return params.Volume{}, common.ErrPerm } volume, err := s.sb.Volume(tag) if errors.IsNotFound(err) { return params.Volume{}, common.ErrPerm } else if err != nil { return params.Volume{}, err } return storagecommon.VolumeFromState(volume) } for i, arg := range args.Entities { var result params.VolumeResult volume, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volume } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv3) Volumes(args params.Entities) (params.VolumeResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.VolumeResults{}, common.ServerError(common.ErrPerm) } results := params.VolumeResults{ Results: make([]params.VolumeResult, len(args.Entities)), } one := func(arg params.Entity) (params.Volume, error) { tag, err := names.ParseVolumeTag(arg.Tag) if err != nil || !canAccess(tag) { return params.Volume{}, common.ErrPerm } volume, err := s.sb.Volume(tag) if errors.IsNotFound(err) { return params.Volume{}, common.ErrPerm } else if err != nil { return params.Volume{}, err } return storagecommon.VolumeFromState(volume) } for i, arg := range args.Entities { var result params.VolumeResult volume, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volume } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "Volumes", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "VolumeResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getStorageEntityAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "VolumeResults", "{", "}", ",", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "\n", "results", ":=", "params", ".", "VolumeResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "VolumeResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "(", "params", ".", "Volume", ",", "error", ")", "{", "tag", ",", "err", ":=", "names", ".", "ParseVolumeTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "||", "!", "canAccess", "(", "tag", ")", "{", "return", "params", ".", "Volume", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "volume", ",", "err", ":=", "s", ".", "sb", ".", "Volume", "(", "tag", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "params", ".", "Volume", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "params", ".", "Volume", "{", "}", ",", "err", "\n", "}", "\n", "return", "storagecommon", ".", "VolumeFromState", "(", "volume", ")", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "var", "result", "params", ".", "VolumeResult", "\n", "volume", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "volume", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// Volumes returns details of volumes with the specified tags.
[ "Volumes", "returns", "details", "of", "volumes", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L535-L567
154,213
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
VolumeAttachmentPlans
func (s *StorageProvisionerAPIv3) VolumeAttachmentPlans(args params.MachineStorageIds) (params.VolumeAttachmentPlanResults, error) { // NOTE(gsamfira): Containers will probably not be a concern for this at the moment // revisit this if containers should be treated canAccess, err := s.getMachineAuthFunc() if err != nil { return params.VolumeAttachmentPlanResults{}, common.ServerError(common.ErrPerm) } results := params.VolumeAttachmentPlanResults{ Results: make([]params.VolumeAttachmentPlanResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (params.VolumeAttachmentPlan, error) { volumeAttachmentPlan, err := s.oneVolumeAttachmentPlan(arg, canAccess) if err != nil { return params.VolumeAttachmentPlan{}, err } return storagecommon.VolumeAttachmentPlanFromState(volumeAttachmentPlan) } for i, arg := range args.Ids { var result params.VolumeAttachmentPlanResult volumeAttachmentPlan, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volumeAttachmentPlan } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv3) VolumeAttachmentPlans(args params.MachineStorageIds) (params.VolumeAttachmentPlanResults, error) { // NOTE(gsamfira): Containers will probably not be a concern for this at the moment // revisit this if containers should be treated canAccess, err := s.getMachineAuthFunc() if err != nil { return params.VolumeAttachmentPlanResults{}, common.ServerError(common.ErrPerm) } results := params.VolumeAttachmentPlanResults{ Results: make([]params.VolumeAttachmentPlanResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (params.VolumeAttachmentPlan, error) { volumeAttachmentPlan, err := s.oneVolumeAttachmentPlan(arg, canAccess) if err != nil { return params.VolumeAttachmentPlan{}, err } return storagecommon.VolumeAttachmentPlanFromState(volumeAttachmentPlan) } for i, arg := range args.Ids { var result params.VolumeAttachmentPlanResult volumeAttachmentPlan, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volumeAttachmentPlan } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "VolumeAttachmentPlans", "(", "args", "params", ".", "MachineStorageIds", ")", "(", "params", ".", "VolumeAttachmentPlanResults", ",", "error", ")", "{", "// NOTE(gsamfira): Containers will probably not be a concern for this at the moment", "// revisit this if containers should be treated", "canAccess", ",", "err", ":=", "s", ".", "getMachineAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "VolumeAttachmentPlanResults", "{", "}", ",", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "\n", "results", ":=", "params", ".", "VolumeAttachmentPlanResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "VolumeAttachmentPlanResult", ",", "len", "(", "args", ".", "Ids", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "MachineStorageId", ")", "(", "params", ".", "VolumeAttachmentPlan", ",", "error", ")", "{", "volumeAttachmentPlan", ",", "err", ":=", "s", ".", "oneVolumeAttachmentPlan", "(", "arg", ",", "canAccess", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "VolumeAttachmentPlan", "{", "}", ",", "err", "\n", "}", "\n", "return", "storagecommon", ".", "VolumeAttachmentPlanFromState", "(", "volumeAttachmentPlan", ")", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Ids", "{", "var", "result", "params", ".", "VolumeAttachmentPlanResult", "\n", "volumeAttachmentPlan", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "volumeAttachmentPlan", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// VolumeAttachmentPlans returns details of volume attachment plans with the specified IDs.
[ "VolumeAttachmentPlans", "returns", "details", "of", "volume", "attachment", "plans", "with", "the", "specified", "IDs", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L605-L633
154,214
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
VolumeBlockDevices
func (s *StorageProvisionerAPIv3) VolumeBlockDevices(args params.MachineStorageIds) (params.BlockDeviceResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.BlockDeviceResults{}, common.ServerError(common.ErrPerm) } results := params.BlockDeviceResults{ Results: make([]params.BlockDeviceResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (storage.BlockDevice, error) { stateBlockDevice, err := s.oneVolumeBlockDevice(arg, canAccess) if err != nil { return storage.BlockDevice{}, err } return storagecommon.BlockDeviceFromState(stateBlockDevice), nil } for i, arg := range args.Ids { var result params.BlockDeviceResult blockDevice, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = blockDevice } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv3) VolumeBlockDevices(args params.MachineStorageIds) (params.BlockDeviceResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.BlockDeviceResults{}, common.ServerError(common.ErrPerm) } results := params.BlockDeviceResults{ Results: make([]params.BlockDeviceResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (storage.BlockDevice, error) { stateBlockDevice, err := s.oneVolumeBlockDevice(arg, canAccess) if err != nil { return storage.BlockDevice{}, err } return storagecommon.BlockDeviceFromState(stateBlockDevice), nil } for i, arg := range args.Ids { var result params.BlockDeviceResult blockDevice, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = blockDevice } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "VolumeBlockDevices", "(", "args", "params", ".", "MachineStorageIds", ")", "(", "params", ".", "BlockDeviceResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getAttachmentAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "BlockDeviceResults", "{", "}", ",", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "\n", "results", ":=", "params", ".", "BlockDeviceResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "BlockDeviceResult", ",", "len", "(", "args", ".", "Ids", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "MachineStorageId", ")", "(", "storage", ".", "BlockDevice", ",", "error", ")", "{", "stateBlockDevice", ",", "err", ":=", "s", ".", "oneVolumeBlockDevice", "(", "arg", ",", "canAccess", ")", "\n", "if", "err", "!=", "nil", "{", "return", "storage", ".", "BlockDevice", "{", "}", ",", "err", "\n", "}", "\n", "return", "storagecommon", ".", "BlockDeviceFromState", "(", "stateBlockDevice", ")", ",", "nil", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Ids", "{", "var", "result", "params", ".", "BlockDeviceResult", "\n", "blockDevice", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "blockDevice", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// VolumeBlockDevices returns details of the block devices corresponding to the // volume attachments with the specified IDs.
[ "VolumeBlockDevices", "returns", "details", "of", "the", "block", "devices", "corresponding", "to", "the", "volume", "attachments", "with", "the", "specified", "IDs", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L666-L692
154,215
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
RemoveVolumeParams
func (s *StorageProvisionerAPIv4) RemoveVolumeParams(args params.Entities) (params.RemoveVolumeParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.RemoveVolumeParamsResults{}, err } results := params.RemoveVolumeParamsResults{ Results: make([]params.RemoveVolumeParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.RemoveVolumeParams, error) { tag, err := names.ParseVolumeTag(arg.Tag) if err != nil || !canAccess(tag) { return params.RemoveVolumeParams{}, common.ErrPerm } volume, err := s.sb.Volume(tag) if errors.IsNotFound(err) { return params.RemoveVolumeParams{}, common.ErrPerm } else if err != nil { return params.RemoveVolumeParams{}, err } if life := volume.Life(); life != state.Dead { return params.RemoveVolumeParams{}, errors.Errorf( "%s is not dead (%s)", names.ReadableString(tag), life, ) } volumeInfo, err := volume.Info() if err != nil { return params.RemoveVolumeParams{}, err } provider, _, err := storagecommon.StoragePoolConfig( volumeInfo.Pool, s.poolManager, s.registry, ) if err != nil { return params.RemoveVolumeParams{}, err } return params.RemoveVolumeParams{ Provider: string(provider), VolumeId: volumeInfo.VolumeId, Destroy: !volume.Releasing(), }, nil } for i, arg := range args.Entities { var result params.RemoveVolumeParamsResult volumeParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volumeParams } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv4) RemoveVolumeParams(args params.Entities) (params.RemoveVolumeParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.RemoveVolumeParamsResults{}, err } results := params.RemoveVolumeParamsResults{ Results: make([]params.RemoveVolumeParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.RemoveVolumeParams, error) { tag, err := names.ParseVolumeTag(arg.Tag) if err != nil || !canAccess(tag) { return params.RemoveVolumeParams{}, common.ErrPerm } volume, err := s.sb.Volume(tag) if errors.IsNotFound(err) { return params.RemoveVolumeParams{}, common.ErrPerm } else if err != nil { return params.RemoveVolumeParams{}, err } if life := volume.Life(); life != state.Dead { return params.RemoveVolumeParams{}, errors.Errorf( "%s is not dead (%s)", names.ReadableString(tag), life, ) } volumeInfo, err := volume.Info() if err != nil { return params.RemoveVolumeParams{}, err } provider, _, err := storagecommon.StoragePoolConfig( volumeInfo.Pool, s.poolManager, s.registry, ) if err != nil { return params.RemoveVolumeParams{}, err } return params.RemoveVolumeParams{ Provider: string(provider), VolumeId: volumeInfo.VolumeId, Destroy: !volume.Releasing(), }, nil } for i, arg := range args.Entities { var result params.RemoveVolumeParamsResult volumeParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = volumeParams } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv4", ")", "RemoveVolumeParams", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "RemoveVolumeParamsResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getStorageEntityAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveVolumeParamsResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "RemoveVolumeParamsResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "RemoveVolumeParamsResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "(", "params", ".", "RemoveVolumeParams", ",", "error", ")", "{", "tag", ",", "err", ":=", "names", ".", "ParseVolumeTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "||", "!", "canAccess", "(", "tag", ")", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "volume", ",", "err", ":=", "s", ".", "sb", ".", "Volume", "(", "tag", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "err", "\n", "}", "\n", "if", "life", ":=", "volume", ".", "Life", "(", ")", ";", "life", "!=", "state", ".", "Dead", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "names", ".", "ReadableString", "(", "tag", ")", ",", "life", ",", ")", "\n", "}", "\n", "volumeInfo", ",", "err", ":=", "volume", ".", "Info", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "err", "\n", "}", "\n", "provider", ",", "_", ",", "err", ":=", "storagecommon", ".", "StoragePoolConfig", "(", "volumeInfo", ".", "Pool", ",", "s", ".", "poolManager", ",", "s", ".", "registry", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveVolumeParams", "{", "}", ",", "err", "\n", "}", "\n", "return", "params", ".", "RemoveVolumeParams", "{", "Provider", ":", "string", "(", "provider", ")", ",", "VolumeId", ":", "volumeInfo", ".", "VolumeId", ",", "Destroy", ":", "!", "volume", ".", "Releasing", "(", ")", ",", "}", ",", "nil", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "var", "result", "params", ".", "RemoveVolumeParamsResult", "\n", "volumeParams", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "volumeParams", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// RemoveVolumeParams returns the parameters for destroying // or releasing the volumes with the specified tags.
[ "RemoveVolumeParams", "returns", "the", "parameters", "for", "destroying", "or", "releasing", "the", "volumes", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L821-L873
154,216
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
FilesystemParams
func (s *StorageProvisionerAPIv3) FilesystemParams(args params.Entities) (params.FilesystemParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.FilesystemParamsResults{}, err } modelConfig, err := s.st.ModelConfig() if err != nil { return params.FilesystemParamsResults{}, err } controllerCfg, err := s.st.ControllerConfig() if err != nil { return params.FilesystemParamsResults{}, err } results := params.FilesystemParamsResults{ Results: make([]params.FilesystemParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.FilesystemParams, error) { tag, err := names.ParseFilesystemTag(arg.Tag) if err != nil || !canAccess(tag) { return params.FilesystemParams{}, common.ErrPerm } filesystem, err := s.sb.Filesystem(tag) if errors.IsNotFound(err) { return params.FilesystemParams{}, common.ErrPerm } else if err != nil { return params.FilesystemParams{}, err } storageInstance, err := storagecommon.MaybeAssignedStorageInstance( filesystem.Storage, s.sb.StorageInstance, ) if err != nil { return params.FilesystemParams{}, err } filesystemParams, err := storagecommon.FilesystemParams( filesystem, storageInstance, modelConfig.UUID(), controllerCfg.ControllerUUID(), modelConfig, s.poolManager, s.registry, ) if err != nil { return params.FilesystemParams{}, err } return filesystemParams, nil } for i, arg := range args.Entities { var result params.FilesystemParamsResult filesystemParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = filesystemParams } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv3) FilesystemParams(args params.Entities) (params.FilesystemParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.FilesystemParamsResults{}, err } modelConfig, err := s.st.ModelConfig() if err != nil { return params.FilesystemParamsResults{}, err } controllerCfg, err := s.st.ControllerConfig() if err != nil { return params.FilesystemParamsResults{}, err } results := params.FilesystemParamsResults{ Results: make([]params.FilesystemParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.FilesystemParams, error) { tag, err := names.ParseFilesystemTag(arg.Tag) if err != nil || !canAccess(tag) { return params.FilesystemParams{}, common.ErrPerm } filesystem, err := s.sb.Filesystem(tag) if errors.IsNotFound(err) { return params.FilesystemParams{}, common.ErrPerm } else if err != nil { return params.FilesystemParams{}, err } storageInstance, err := storagecommon.MaybeAssignedStorageInstance( filesystem.Storage, s.sb.StorageInstance, ) if err != nil { return params.FilesystemParams{}, err } filesystemParams, err := storagecommon.FilesystemParams( filesystem, storageInstance, modelConfig.UUID(), controllerCfg.ControllerUUID(), modelConfig, s.poolManager, s.registry, ) if err != nil { return params.FilesystemParams{}, err } return filesystemParams, nil } for i, arg := range args.Entities { var result params.FilesystemParamsResult filesystemParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = filesystemParams } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "FilesystemParams", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "FilesystemParamsResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getStorageEntityAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParamsResults", "{", "}", ",", "err", "\n", "}", "\n", "modelConfig", ",", "err", ":=", "s", ".", "st", ".", "ModelConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParamsResults", "{", "}", ",", "err", "\n", "}", "\n", "controllerCfg", ",", "err", ":=", "s", ".", "st", ".", "ControllerConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParamsResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "FilesystemParamsResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "FilesystemParamsResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "(", "params", ".", "FilesystemParams", ",", "error", ")", "{", "tag", ",", "err", ":=", "names", ".", "ParseFilesystemTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "||", "!", "canAccess", "(", "tag", ")", "{", "return", "params", ".", "FilesystemParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "filesystem", ",", "err", ":=", "s", ".", "sb", ".", "Filesystem", "(", "tag", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "params", ".", "FilesystemParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "storageInstance", ",", "err", ":=", "storagecommon", ".", "MaybeAssignedStorageInstance", "(", "filesystem", ".", "Storage", ",", "s", ".", "sb", ".", "StorageInstance", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "filesystemParams", ",", "err", ":=", "storagecommon", ".", "FilesystemParams", "(", "filesystem", ",", "storageInstance", ",", "modelConfig", ".", "UUID", "(", ")", ",", "controllerCfg", ".", "ControllerUUID", "(", ")", ",", "modelConfig", ",", "s", ".", "poolManager", ",", "s", ".", "registry", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "FilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "return", "filesystemParams", ",", "nil", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "var", "result", "params", ".", "FilesystemParamsResult", "\n", "filesystemParams", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "filesystemParams", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// FilesystemParams returns the parameters for creating the filesystems // with the specified tags.
[ "FilesystemParams", "returns", "the", "parameters", "for", "creating", "the", "filesystems", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L877-L931
154,217
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
RemoveFilesystemParams
func (s *StorageProvisionerAPIv4) RemoveFilesystemParams(args params.Entities) (params.RemoveFilesystemParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.RemoveFilesystemParamsResults{}, err } results := params.RemoveFilesystemParamsResults{ Results: make([]params.RemoveFilesystemParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.RemoveFilesystemParams, error) { tag, err := names.ParseFilesystemTag(arg.Tag) if err != nil || !canAccess(tag) { return params.RemoveFilesystemParams{}, common.ErrPerm } filesystem, err := s.sb.Filesystem(tag) if errors.IsNotFound(err) { return params.RemoveFilesystemParams{}, common.ErrPerm } else if err != nil { return params.RemoveFilesystemParams{}, err } if life := filesystem.Life(); life != state.Dead { return params.RemoveFilesystemParams{}, errors.Errorf( "%s is not dead (%s)", names.ReadableString(tag), life, ) } filesystemInfo, err := filesystem.Info() if err != nil { return params.RemoveFilesystemParams{}, err } provider, _, err := storagecommon.StoragePoolConfig( filesystemInfo.Pool, s.poolManager, s.registry, ) if err != nil { return params.RemoveFilesystemParams{}, err } return params.RemoveFilesystemParams{ Provider: string(provider), FilesystemId: filesystemInfo.FilesystemId, Destroy: !filesystem.Releasing(), }, nil } for i, arg := range args.Entities { var result params.RemoveFilesystemParamsResult filesystemParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = filesystemParams } results.Results[i] = result } return results, nil }
go
func (s *StorageProvisionerAPIv4) RemoveFilesystemParams(args params.Entities) (params.RemoveFilesystemParamsResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.RemoveFilesystemParamsResults{}, err } results := params.RemoveFilesystemParamsResults{ Results: make([]params.RemoveFilesystemParamsResult, len(args.Entities)), } one := func(arg params.Entity) (params.RemoveFilesystemParams, error) { tag, err := names.ParseFilesystemTag(arg.Tag) if err != nil || !canAccess(tag) { return params.RemoveFilesystemParams{}, common.ErrPerm } filesystem, err := s.sb.Filesystem(tag) if errors.IsNotFound(err) { return params.RemoveFilesystemParams{}, common.ErrPerm } else if err != nil { return params.RemoveFilesystemParams{}, err } if life := filesystem.Life(); life != state.Dead { return params.RemoveFilesystemParams{}, errors.Errorf( "%s is not dead (%s)", names.ReadableString(tag), life, ) } filesystemInfo, err := filesystem.Info() if err != nil { return params.RemoveFilesystemParams{}, err } provider, _, err := storagecommon.StoragePoolConfig( filesystemInfo.Pool, s.poolManager, s.registry, ) if err != nil { return params.RemoveFilesystemParams{}, err } return params.RemoveFilesystemParams{ Provider: string(provider), FilesystemId: filesystemInfo.FilesystemId, Destroy: !filesystem.Releasing(), }, nil } for i, arg := range args.Entities { var result params.RemoveFilesystemParamsResult filesystemParams, err := one(arg) if err != nil { result.Error = common.ServerError(err) } else { result.Result = filesystemParams } results.Results[i] = result } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv4", ")", "RemoveFilesystemParams", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "RemoveFilesystemParamsResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getStorageEntityAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveFilesystemParamsResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "RemoveFilesystemParamsResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "RemoveFilesystemParamsResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "(", "params", ".", "RemoveFilesystemParams", ",", "error", ")", "{", "tag", ",", "err", ":=", "names", ".", "ParseFilesystemTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "||", "!", "canAccess", "(", "tag", ")", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "filesystem", ",", "err", ":=", "s", ".", "sb", ".", "Filesystem", "(", "tag", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "common", ".", "ErrPerm", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "if", "life", ":=", "filesystem", ".", "Life", "(", ")", ";", "life", "!=", "state", ".", "Dead", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "names", ".", "ReadableString", "(", "tag", ")", ",", "life", ",", ")", "\n", "}", "\n", "filesystemInfo", ",", "err", ":=", "filesystem", ".", "Info", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "provider", ",", "_", ",", "err", ":=", "storagecommon", ".", "StoragePoolConfig", "(", "filesystemInfo", ".", "Pool", ",", "s", ".", "poolManager", ",", "s", ".", "registry", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "RemoveFilesystemParams", "{", "}", ",", "err", "\n", "}", "\n", "return", "params", ".", "RemoveFilesystemParams", "{", "Provider", ":", "string", "(", "provider", ")", ",", "FilesystemId", ":", "filesystemInfo", ".", "FilesystemId", ",", "Destroy", ":", "!", "filesystem", ".", "Releasing", "(", ")", ",", "}", ",", "nil", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "var", "result", "params", ".", "RemoveFilesystemParamsResult", "\n", "filesystemParams", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "filesystemParams", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", "=", "result", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// RemoveFilesystemParams returns the parameters for destroying or // releasing the filesystems with the specified tags.
[ "RemoveFilesystemParams", "returns", "the", "parameters", "for", "destroying", "or", "releasing", "the", "filesystems", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L935-L987
154,218
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
AttachmentLife
func (s *StorageProvisionerAPIv3) AttachmentLife(args params.MachineStorageIds) (params.LifeResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.LifeResults{}, err } results := params.LifeResults{ Results: make([]params.LifeResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (params.Life, error) { hostTag, err := names.ParseTag(arg.MachineTag) if err != nil { return "", err } if hostTag.Kind() != names.MachineTagKind && hostTag.Kind() != names.UnitTagKind { return "", errors.NotValidf("attachment host tag %q", hostTag) } attachmentTag, err := names.ParseTag(arg.AttachmentTag) if err != nil { return "", err } if !canAccess(hostTag, attachmentTag) { return "", common.ErrPerm } var lifer state.Lifer switch attachmentTag := attachmentTag.(type) { case names.VolumeTag: lifer, err = s.sb.VolumeAttachment(hostTag, attachmentTag) case names.FilesystemTag: lifer, err = s.sb.FilesystemAttachment(hostTag, attachmentTag) } if err != nil { return "", errors.Trace(err) } return params.Life(lifer.Life().String()), nil } for i, arg := range args.Ids { life, err := one(arg) if err != nil { results.Results[i].Error = common.ServerError(err) } else { results.Results[i].Life = life } } return results, nil }
go
func (s *StorageProvisionerAPIv3) AttachmentLife(args params.MachineStorageIds) (params.LifeResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.LifeResults{}, err } results := params.LifeResults{ Results: make([]params.LifeResult, len(args.Ids)), } one := func(arg params.MachineStorageId) (params.Life, error) { hostTag, err := names.ParseTag(arg.MachineTag) if err != nil { return "", err } if hostTag.Kind() != names.MachineTagKind && hostTag.Kind() != names.UnitTagKind { return "", errors.NotValidf("attachment host tag %q", hostTag) } attachmentTag, err := names.ParseTag(arg.AttachmentTag) if err != nil { return "", err } if !canAccess(hostTag, attachmentTag) { return "", common.ErrPerm } var lifer state.Lifer switch attachmentTag := attachmentTag.(type) { case names.VolumeTag: lifer, err = s.sb.VolumeAttachment(hostTag, attachmentTag) case names.FilesystemTag: lifer, err = s.sb.FilesystemAttachment(hostTag, attachmentTag) } if err != nil { return "", errors.Trace(err) } return params.Life(lifer.Life().String()), nil } for i, arg := range args.Ids { life, err := one(arg) if err != nil { results.Results[i].Error = common.ServerError(err) } else { results.Results[i].Life = life } } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "AttachmentLife", "(", "args", "params", ".", "MachineStorageIds", ")", "(", "params", ".", "LifeResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getAttachmentAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "LifeResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "LifeResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "LifeResult", ",", "len", "(", "args", ".", "Ids", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "MachineStorageId", ")", "(", "params", ".", "Life", ",", "error", ")", "{", "hostTag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "MachineTag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "hostTag", ".", "Kind", "(", ")", "!=", "names", ".", "MachineTagKind", "&&", "hostTag", ".", "Kind", "(", ")", "!=", "names", ".", "UnitTagKind", "{", "return", "\"", "\"", ",", "errors", ".", "NotValidf", "(", "\"", "\"", ",", "hostTag", ")", "\n", "}", "\n", "attachmentTag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "AttachmentTag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "!", "canAccess", "(", "hostTag", ",", "attachmentTag", ")", "{", "return", "\"", "\"", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "var", "lifer", "state", ".", "Lifer", "\n", "switch", "attachmentTag", ":=", "attachmentTag", ".", "(", "type", ")", "{", "case", "names", ".", "VolumeTag", ":", "lifer", ",", "err", "=", "s", ".", "sb", ".", "VolumeAttachment", "(", "hostTag", ",", "attachmentTag", ")", "\n", "case", "names", ".", "FilesystemTag", ":", "lifer", ",", "err", "=", "s", ".", "sb", ".", "FilesystemAttachment", "(", "hostTag", ",", "attachmentTag", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "params", ".", "Life", "(", "lifer", ".", "Life", "(", ")", ".", "String", "(", ")", ")", ",", "nil", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Ids", "{", "life", ",", "err", ":=", "one", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "results", ".", "Results", "[", "i", "]", ".", "Life", "=", "life", "\n", "}", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// AttachmentLife returns the lifecycle state of each specified machine // storage attachment.
[ "AttachmentLife", "returns", "the", "lifecycle", "state", "of", "each", "specified", "machine", "storage", "attachment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L1486-L1530
154,219
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
Remove
func (s *StorageProvisionerAPIv3) Remove(args params.Entities) (params.ErrorResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } one := func(arg params.Entity) error { tag, err := names.ParseTag(arg.Tag) if err != nil { return errors.Trace(err) } if !canAccess(tag) { return common.ErrPerm } switch tag := tag.(type) { case names.FilesystemTag: return s.sb.RemoveFilesystem(tag) case names.VolumeTag: return s.sb.RemoveVolume(tag) default: // should have been picked up by canAccess logger.Debugf("unexpected %v tag", tag.Kind()) return common.ErrPerm } } for i, arg := range args.Entities { err := one(arg) results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (s *StorageProvisionerAPIv3) Remove(args params.Entities) (params.ErrorResults, error) { canAccess, err := s.getStorageEntityAuthFunc() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } one := func(arg params.Entity) error { tag, err := names.ParseTag(arg.Tag) if err != nil { return errors.Trace(err) } if !canAccess(tag) { return common.ErrPerm } switch tag := tag.(type) { case names.FilesystemTag: return s.sb.RemoveFilesystem(tag) case names.VolumeTag: return s.sb.RemoveVolume(tag) default: // should have been picked up by canAccess logger.Debugf("unexpected %v tag", tag.Kind()) return common.ErrPerm } } for i, arg := range args.Entities { err := one(arg) results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "Remove", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getStorageEntityAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "ErrorResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "ErrorResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "ErrorResult", ",", "len", "(", "args", ".", "Entities", ")", ")", ",", "}", "\n", "one", ":=", "func", "(", "arg", "params", ".", "Entity", ")", "error", "{", "tag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "!", "canAccess", "(", "tag", ")", "{", "return", "common", ".", "ErrPerm", "\n", "}", "\n", "switch", "tag", ":=", "tag", ".", "(", "type", ")", "{", "case", "names", ".", "FilesystemTag", ":", "return", "s", ".", "sb", ".", "RemoveFilesystem", "(", "tag", ")", "\n", "case", "names", ".", "VolumeTag", ":", "return", "s", ".", "sb", ".", "RemoveVolume", "(", "tag", ")", "\n", "default", ":", "// should have been picked up by canAccess", "logger", ".", "Debugf", "(", "\"", "\"", ",", "tag", ".", "Kind", "(", ")", ")", "\n", "return", "common", ".", "ErrPerm", "\n", "}", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Entities", "{", "err", ":=", "one", "(", "arg", ")", "\n", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// Remove removes volumes and filesystems from state.
[ "Remove", "removes", "volumes", "and", "filesystems", "from", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L1533-L1565
154,220
juju/juju
apiserver/facades/agent/storageprovisioner/storageprovisioner.go
RemoveAttachment
func (s *StorageProvisionerAPIv3) RemoveAttachment(args params.MachineStorageIds) (params.ErrorResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Ids)), } removeAttachment := func(arg params.MachineStorageId) error { hostTag, err := names.ParseTag(arg.MachineTag) if err != nil { return err } if hostTag.Kind() != names.MachineTagKind && hostTag.Kind() != names.UnitTagKind { return errors.NotValidf("attachment host tag %q", hostTag) } attachmentTag, err := names.ParseTag(arg.AttachmentTag) if err != nil { return err } if !canAccess(hostTag, attachmentTag) { return common.ErrPerm } switch attachmentTag := attachmentTag.(type) { case names.VolumeTag: return s.sb.RemoveVolumeAttachment(hostTag, attachmentTag) case names.FilesystemTag: return s.sb.RemoveFilesystemAttachment(hostTag, attachmentTag) default: return common.ErrPerm } } for i, arg := range args.Ids { if err := removeAttachment(arg); err != nil { results.Results[i].Error = common.ServerError(err) } } return results, nil }
go
func (s *StorageProvisionerAPIv3) RemoveAttachment(args params.MachineStorageIds) (params.ErrorResults, error) { canAccess, err := s.getAttachmentAuthFunc() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Ids)), } removeAttachment := func(arg params.MachineStorageId) error { hostTag, err := names.ParseTag(arg.MachineTag) if err != nil { return err } if hostTag.Kind() != names.MachineTagKind && hostTag.Kind() != names.UnitTagKind { return errors.NotValidf("attachment host tag %q", hostTag) } attachmentTag, err := names.ParseTag(arg.AttachmentTag) if err != nil { return err } if !canAccess(hostTag, attachmentTag) { return common.ErrPerm } switch attachmentTag := attachmentTag.(type) { case names.VolumeTag: return s.sb.RemoveVolumeAttachment(hostTag, attachmentTag) case names.FilesystemTag: return s.sb.RemoveFilesystemAttachment(hostTag, attachmentTag) default: return common.ErrPerm } } for i, arg := range args.Ids { if err := removeAttachment(arg); err != nil { results.Results[i].Error = common.ServerError(err) } } return results, nil }
[ "func", "(", "s", "*", "StorageProvisionerAPIv3", ")", "RemoveAttachment", "(", "args", "params", ".", "MachineStorageIds", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "getAttachmentAuthFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "ErrorResults", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "params", ".", "ErrorResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "ErrorResult", ",", "len", "(", "args", ".", "Ids", ")", ")", ",", "}", "\n", "removeAttachment", ":=", "func", "(", "arg", "params", ".", "MachineStorageId", ")", "error", "{", "hostTag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "MachineTag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "hostTag", ".", "Kind", "(", ")", "!=", "names", ".", "MachineTagKind", "&&", "hostTag", ".", "Kind", "(", ")", "!=", "names", ".", "UnitTagKind", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ",", "hostTag", ")", "\n", "}", "\n", "attachmentTag", ",", "err", ":=", "names", ".", "ParseTag", "(", "arg", ".", "AttachmentTag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "canAccess", "(", "hostTag", ",", "attachmentTag", ")", "{", "return", "common", ".", "ErrPerm", "\n", "}", "\n", "switch", "attachmentTag", ":=", "attachmentTag", ".", "(", "type", ")", "{", "case", "names", ".", "VolumeTag", ":", "return", "s", ".", "sb", ".", "RemoveVolumeAttachment", "(", "hostTag", ",", "attachmentTag", ")", "\n", "case", "names", ".", "FilesystemTag", ":", "return", "s", ".", "sb", ".", "RemoveFilesystemAttachment", "(", "hostTag", ",", "attachmentTag", ")", "\n", "default", ":", "return", "common", ".", "ErrPerm", "\n", "}", "\n", "}", "\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "Ids", "{", "if", "err", ":=", "removeAttachment", "(", "arg", ")", ";", "err", "!=", "nil", "{", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// RemoveAttachments removes the specified machine storage attachments // from state.
[ "RemoveAttachments", "removes", "the", "specified", "machine", "storage", "attachments", "from", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/storageprovisioner/storageprovisioner.go#L1569-L1607
154,221
juju/juju
api/firewaller/firewaller.go
NewClient
func NewClient(caller base.APICaller) (*Client, error) { modelTag, isModel := caller.ModelTag() if !isModel { return nil, errors.New("expected model specific API connection") } facadeCaller := base.NewFacadeCaller(caller, firewallerFacade) return &Client{ facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller), CloudSpecAPI: cloudspec.NewCloudSpecAPI(facadeCaller, modelTag), }, nil }
go
func NewClient(caller base.APICaller) (*Client, error) { modelTag, isModel := caller.ModelTag() if !isModel { return nil, errors.New("expected model specific API connection") } facadeCaller := base.NewFacadeCaller(caller, firewallerFacade) return &Client{ facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller), CloudSpecAPI: cloudspec.NewCloudSpecAPI(facadeCaller, modelTag), }, nil }
[ "func", "NewClient", "(", "caller", "base", ".", "APICaller", ")", "(", "*", "Client", ",", "error", ")", "{", "modelTag", ",", "isModel", ":=", "caller", ".", "ModelTag", "(", ")", "\n", "if", "!", "isModel", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "facadeCaller", ":=", "base", ".", "NewFacadeCaller", "(", "caller", ",", "firewallerFacade", ")", "\n", "return", "&", "Client", "{", "facade", ":", "facadeCaller", ",", "ModelWatcher", ":", "common", ".", "NewModelWatcher", "(", "facadeCaller", ")", ",", "CloudSpecAPI", ":", "cloudspec", ".", "NewCloudSpecAPI", "(", "facadeCaller", ",", "modelTag", ")", ",", "}", ",", "nil", "\n", "}" ]
// NewClient creates a new client-side Firewaller API facade.
[ "NewClient", "creates", "a", "new", "client", "-", "side", "Firewaller", "API", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L31-L42
154,222
juju/juju
api/firewaller/firewaller.go
ModelTag
func (c *Client) ModelTag() (names.ModelTag, bool) { return c.facade.RawAPICaller().ModelTag() }
go
func (c *Client) ModelTag() (names.ModelTag, bool) { return c.facade.RawAPICaller().ModelTag() }
[ "func", "(", "c", "*", "Client", ")", "ModelTag", "(", ")", "(", "names", ".", "ModelTag", ",", "bool", ")", "{", "return", "c", ".", "facade", ".", "RawAPICaller", "(", ")", ".", "ModelTag", "(", ")", "\n", "}" ]
// ModelTag returns the current model's tag.
[ "ModelTag", "returns", "the", "current", "model", "s", "tag", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L51-L53
154,223
juju/juju
api/firewaller/firewaller.go
life
func (c *Client) life(tag names.Tag) (params.Life, error) { return common.OneLife(c.facade, tag) }
go
func (c *Client) life(tag names.Tag) (params.Life, error) { return common.OneLife(c.facade, tag) }
[ "func", "(", "c", "*", "Client", ")", "life", "(", "tag", "names", ".", "Tag", ")", "(", "params", ".", "Life", ",", "error", ")", "{", "return", "common", ".", "OneLife", "(", "c", ".", "facade", ",", "tag", ")", "\n", "}" ]
// life requests the life cycle of the given entity from the server.
[ "life", "requests", "the", "life", "cycle", "of", "the", "given", "entity", "from", "the", "server", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L56-L58
154,224
juju/juju
api/firewaller/firewaller.go
WatchOpenedPorts
func (c *Client) WatchOpenedPorts() (watcher.StringsWatcher, error) { modelTag, ok := c.ModelTag() if !ok { return nil, errors.New("API connection is controller-only (should never happen)") } var results params.StringsWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: modelTag.String()}}, } if err := c.facade.FacadeCall("WatchOpenedPorts", args, &results); err != nil { return nil, err } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if err := result.Error; err != nil { return nil, result.Error } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
go
func (c *Client) WatchOpenedPorts() (watcher.StringsWatcher, error) { modelTag, ok := c.ModelTag() if !ok { return nil, errors.New("API connection is controller-only (should never happen)") } var results params.StringsWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: modelTag.String()}}, } if err := c.facade.FacadeCall("WatchOpenedPorts", args, &results); err != nil { return nil, err } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if err := result.Error; err != nil { return nil, result.Error } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
[ "func", "(", "c", "*", "Client", ")", "WatchOpenedPorts", "(", ")", "(", "watcher", ".", "StringsWatcher", ",", "error", ")", "{", "modelTag", ",", "ok", ":=", "c", ".", "ModelTag", "(", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "results", "params", ".", "StringsWatchResults", "\n", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "modelTag", ".", "String", "(", ")", "}", "}", ",", "}", "\n", "if", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "results", ".", "Results", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "results", ".", "Results", ")", ")", "\n", "}", "\n", "result", ":=", "results", ".", "Results", "[", "0", "]", "\n", "if", "err", ":=", "result", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n", "w", ":=", "apiwatcher", ".", "NewStringsWatcher", "(", "c", ".", "facade", ".", "RawAPICaller", "(", ")", ",", "result", ")", "\n", "return", "w", ",", "nil", "\n", "}" ]
// WatchOpenedPorts returns a StringsWatcher that notifies of // changes to the opened ports for the current model.
[ "WatchOpenedPorts", "returns", "a", "StringsWatcher", "that", "notifies", "of", "changes", "to", "the", "opened", "ports", "for", "the", "current", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L105-L126
154,225
juju/juju
api/firewaller/firewaller.go
Relation
func (c *Client) Relation(tag names.RelationTag) (*Relation, error) { life, err := c.life(tag) if err != nil { return nil, err } return &Relation{ tag: tag, life: life, }, nil }
go
func (c *Client) Relation(tag names.RelationTag) (*Relation, error) { life, err := c.life(tag) if err != nil { return nil, err } return &Relation{ tag: tag, life: life, }, nil }
[ "func", "(", "c", "*", "Client", ")", "Relation", "(", "tag", "names", ".", "RelationTag", ")", "(", "*", "Relation", ",", "error", ")", "{", "life", ",", "err", ":=", "c", ".", "life", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "Relation", "{", "tag", ":", "tag", ",", "life", ":", "life", ",", "}", ",", "nil", "\n", "}" ]
// Relation provides access to methods of a state.Relation through the // facade.
[ "Relation", "provides", "access", "to", "methods", "of", "a", "state", ".", "Relation", "through", "the", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L130-L139
154,226
juju/juju
api/firewaller/firewaller.go
ControllerAPIInfoForModel
func (c *Client) ControllerAPIInfoForModel(modelUUID string) (*api.Info, error) { modelTag := names.NewModelTag(modelUUID) args := params.Entities{[]params.Entity{{Tag: modelTag.String()}}} var results params.ControllerAPIInfoResults err := c.facade.FacadeCall("ControllerAPIInfoForModels", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } return &api.Info{ Addrs: result.Addresses, CACert: result.CACert, ModelTag: modelTag, }, nil }
go
func (c *Client) ControllerAPIInfoForModel(modelUUID string) (*api.Info, error) { modelTag := names.NewModelTag(modelUUID) args := params.Entities{[]params.Entity{{Tag: modelTag.String()}}} var results params.ControllerAPIInfoResults err := c.facade.FacadeCall("ControllerAPIInfoForModels", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } return &api.Info{ Addrs: result.Addresses, CACert: result.CACert, ModelTag: modelTag, }, nil }
[ "func", "(", "c", "*", "Client", ")", "ControllerAPIInfoForModel", "(", "modelUUID", "string", ")", "(", "*", "api", ".", "Info", ",", "error", ")", "{", "modelTag", ":=", "names", ".", "NewModelTag", "(", "modelUUID", ")", "\n", "args", ":=", "params", ".", "Entities", "{", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "modelTag", ".", "String", "(", ")", "}", "}", "}", "\n", "var", "results", "params", ".", "ControllerAPIInfoResults", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "len", "(", "results", ".", "Results", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "results", ".", "Results", ")", ")", "\n", "}", "\n", "result", ":=", "results", ".", "Results", "[", "0", "]", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n", "return", "&", "api", ".", "Info", "{", "Addrs", ":", "result", ".", "Addresses", ",", "CACert", ":", "result", ".", "CACert", ",", "ModelTag", ":", "modelTag", ",", "}", ",", "nil", "\n", "}" ]
// ControllerAPIInfoForModels returns the controller api connection details for the specified model.
[ "ControllerAPIInfoForModels", "returns", "the", "controller", "api", "connection", "details", "for", "the", "specified", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L186-L206
154,227
juju/juju
api/firewaller/firewaller.go
MacaroonForRelation
func (c *Client) MacaroonForRelation(relationKey string) (*macaroon.Macaroon, error) { relationTag := names.NewRelationTag(relationKey) args := params.Entities{[]params.Entity{{Tag: relationTag.String()}}} var results params.MacaroonResults err := c.facade.FacadeCall("MacaroonForRelations", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } return result.Result, nil }
go
func (c *Client) MacaroonForRelation(relationKey string) (*macaroon.Macaroon, error) { relationTag := names.NewRelationTag(relationKey) args := params.Entities{[]params.Entity{{Tag: relationTag.String()}}} var results params.MacaroonResults err := c.facade.FacadeCall("MacaroonForRelations", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } return result.Result, nil }
[ "func", "(", "c", "*", "Client", ")", "MacaroonForRelation", "(", "relationKey", "string", ")", "(", "*", "macaroon", ".", "Macaroon", ",", "error", ")", "{", "relationTag", ":=", "names", ".", "NewRelationTag", "(", "relationKey", ")", "\n", "args", ":=", "params", ".", "Entities", "{", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "relationTag", ".", "String", "(", ")", "}", "}", "}", "\n", "var", "results", "params", ".", "MacaroonResults", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "len", "(", "results", ".", "Results", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "results", ".", "Results", ")", ")", "\n", "}", "\n", "result", ":=", "results", ".", "Results", "[", "0", "]", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n", "return", "result", ".", "Result", ",", "nil", "\n", "}" ]
// MacaroonForRelation returns the macaroon to use when publishing changes for the relation.
[ "MacaroonForRelation", "returns", "the", "macaroon", "to", "use", "when", "publishing", "changes", "for", "the", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L209-L225
154,228
juju/juju
api/firewaller/firewaller.go
SetRelationStatus
func (c *Client) SetRelationStatus(relationKey string, status relation.Status, message string) error { relationTag := names.NewRelationTag(relationKey) args := params.SetStatus{Entities: []params.EntityStatusArgs{ {Tag: relationTag.String(), Status: status.String(), Info: message}, }} var results params.ErrorResults err := c.facade.FacadeCall("SetRelationsStatus", args, &results) if err != nil { return errors.Trace(err) } return results.OneError() }
go
func (c *Client) SetRelationStatus(relationKey string, status relation.Status, message string) error { relationTag := names.NewRelationTag(relationKey) args := params.SetStatus{Entities: []params.EntityStatusArgs{ {Tag: relationTag.String(), Status: status.String(), Info: message}, }} var results params.ErrorResults err := c.facade.FacadeCall("SetRelationsStatus", args, &results) if err != nil { return errors.Trace(err) } return results.OneError() }
[ "func", "(", "c", "*", "Client", ")", "SetRelationStatus", "(", "relationKey", "string", ",", "status", "relation", ".", "Status", ",", "message", "string", ")", "error", "{", "relationTag", ":=", "names", ".", "NewRelationTag", "(", "relationKey", ")", "\n", "args", ":=", "params", ".", "SetStatus", "{", "Entities", ":", "[", "]", "params", ".", "EntityStatusArgs", "{", "{", "Tag", ":", "relationTag", ".", "String", "(", ")", ",", "Status", ":", "status", ".", "String", "(", ")", ",", "Info", ":", "message", "}", ",", "}", "}", "\n\n", "var", "results", "params", ".", "ErrorResults", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "results", ".", "OneError", "(", ")", "\n", "}" ]
// SetRelationStatus sets the status for a given relation.
[ "SetRelationStatus", "sets", "the", "status", "for", "a", "given", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L228-L240
154,229
juju/juju
api/firewaller/firewaller.go
FirewallRules
func (c *Client) FirewallRules(knownServices ...string) ([]params.FirewallRule, error) { args := params.KnownServiceArgs{ KnownServices: make([]params.KnownServiceValue, len(knownServices)), } for i, s := range knownServices { args.KnownServices[i] = params.KnownServiceValue(s) } var results params.ListFirewallRulesResults err := c.facade.FacadeCall("FirewallRules", args, &results) if err != nil { return nil, errors.Trace(err) } return results.Rules, nil }
go
func (c *Client) FirewallRules(knownServices ...string) ([]params.FirewallRule, error) { args := params.KnownServiceArgs{ KnownServices: make([]params.KnownServiceValue, len(knownServices)), } for i, s := range knownServices { args.KnownServices[i] = params.KnownServiceValue(s) } var results params.ListFirewallRulesResults err := c.facade.FacadeCall("FirewallRules", args, &results) if err != nil { return nil, errors.Trace(err) } return results.Rules, nil }
[ "func", "(", "c", "*", "Client", ")", "FirewallRules", "(", "knownServices", "...", "string", ")", "(", "[", "]", "params", ".", "FirewallRule", ",", "error", ")", "{", "args", ":=", "params", ".", "KnownServiceArgs", "{", "KnownServices", ":", "make", "(", "[", "]", "params", ".", "KnownServiceValue", ",", "len", "(", "knownServices", ")", ")", ",", "}", "\n", "for", "i", ",", "s", ":=", "range", "knownServices", "{", "args", ".", "KnownServices", "[", "i", "]", "=", "params", ".", "KnownServiceValue", "(", "s", ")", "\n", "}", "\n\n", "var", "results", "params", ".", "ListFirewallRulesResults", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "results", ".", "Rules", ",", "nil", "\n", "}" ]
// FirewallRules returns the firewall rules for the specified known service names.
[ "FirewallRules", "returns", "the", "firewall", "rules", "for", "the", "specified", "known", "service", "names", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/firewaller/firewaller.go#L243-L257
154,230
juju/juju
cert/cert.go
Verify
func Verify(srvCertPEM, caCertPEM string, when time.Time) error { caCert, err := cert.ParseCert(caCertPEM) if err != nil { return errors.Annotate(err, "cannot parse CA certificate") } srvCert, err := cert.ParseCert(srvCertPEM) if err != nil { return errors.Annotate(err, "cannot parse server certificate") } pool := x509.NewCertPool() pool.AddCert(caCert) opts := x509.VerifyOptions{ Roots: pool, CurrentTime: when, } _, err = srvCert.Verify(opts) return err }
go
func Verify(srvCertPEM, caCertPEM string, when time.Time) error { caCert, err := cert.ParseCert(caCertPEM) if err != nil { return errors.Annotate(err, "cannot parse CA certificate") } srvCert, err := cert.ParseCert(srvCertPEM) if err != nil { return errors.Annotate(err, "cannot parse server certificate") } pool := x509.NewCertPool() pool.AddCert(caCert) opts := x509.VerifyOptions{ Roots: pool, CurrentTime: when, } _, err = srvCert.Verify(opts) return err }
[ "func", "Verify", "(", "srvCertPEM", ",", "caCertPEM", "string", ",", "when", "time", ".", "Time", ")", "error", "{", "caCert", ",", "err", ":=", "cert", ".", "ParseCert", "(", "caCertPEM", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "srvCert", ",", "err", ":=", "cert", ".", "ParseCert", "(", "srvCertPEM", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "pool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n", "pool", ".", "AddCert", "(", "caCert", ")", "\n", "opts", ":=", "x509", ".", "VerifyOptions", "{", "Roots", ":", "pool", ",", "CurrentTime", ":", "when", ",", "}", "\n", "_", ",", "err", "=", "srvCert", ".", "Verify", "(", "opts", ")", "\n", "return", "err", "\n", "}" ]
// Verify verifies that the given server certificate is valid with // respect to the given CA certificate at the given time.
[ "Verify", "verifies", "that", "the", "given", "server", "certificate", "is", "valid", "with", "respect", "to", "the", "given", "CA", "certificate", "at", "the", "given", "time", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cert/cert.go#L19-L36
154,231
juju/juju
provider/azure/environ.go
newEnviron
func newEnviron( provider *azureEnvironProvider, cloud environs.CloudSpec, cfg *config.Config, ) (*azureEnviron, error) { // The Azure storage code wants the endpoint host only, not the URL. storageEndpointURL, err := url.Parse(cloud.StorageEndpoint) if err != nil { return nil, errors.Annotate(err, "parsing storage endpoint URL") } env := azureEnviron{ provider: provider, cloud: cloud, location: canonicalLocation(cloud.Region), storageEndpoint: storageEndpointURL.Host, } if err := env.initEnviron(); err != nil { return nil, errors.Trace(err) } if err := env.SetConfig(cfg); err != nil { return nil, errors.Trace(err) } modelTag := names.NewModelTag(cfg.UUID()) env.resourceGroup = resourceGroupName(modelTag, cfg.Name()) env.envName = cfg.Name() // We need a deterministic storage account name, so that we can // defer creation of the storage account to the VM deployment, // and retain the ability to create multiple deployments in // parallel. // // We use the last 20 non-hyphen hex characters of the model's // UUID as the storage account name, prefixed with "juju". The // probability of clashing with another storage account should // be negligible. uuidAlphaNumeric := strings.Replace(env.config.Config.UUID(), "-", "", -1) env.storageAccountName = "juju" + uuidAlphaNumeric[len(uuidAlphaNumeric)-20:] return &env, nil }
go
func newEnviron( provider *azureEnvironProvider, cloud environs.CloudSpec, cfg *config.Config, ) (*azureEnviron, error) { // The Azure storage code wants the endpoint host only, not the URL. storageEndpointURL, err := url.Parse(cloud.StorageEndpoint) if err != nil { return nil, errors.Annotate(err, "parsing storage endpoint URL") } env := azureEnviron{ provider: provider, cloud: cloud, location: canonicalLocation(cloud.Region), storageEndpoint: storageEndpointURL.Host, } if err := env.initEnviron(); err != nil { return nil, errors.Trace(err) } if err := env.SetConfig(cfg); err != nil { return nil, errors.Trace(err) } modelTag := names.NewModelTag(cfg.UUID()) env.resourceGroup = resourceGroupName(modelTag, cfg.Name()) env.envName = cfg.Name() // We need a deterministic storage account name, so that we can // defer creation of the storage account to the VM deployment, // and retain the ability to create multiple deployments in // parallel. // // We use the last 20 non-hyphen hex characters of the model's // UUID as the storage account name, prefixed with "juju". The // probability of clashing with another storage account should // be negligible. uuidAlphaNumeric := strings.Replace(env.config.Config.UUID(), "-", "", -1) env.storageAccountName = "juju" + uuidAlphaNumeric[len(uuidAlphaNumeric)-20:] return &env, nil }
[ "func", "newEnviron", "(", "provider", "*", "azureEnvironProvider", ",", "cloud", "environs", ".", "CloudSpec", ",", "cfg", "*", "config", ".", "Config", ",", ")", "(", "*", "azureEnviron", ",", "error", ")", "{", "// The Azure storage code wants the endpoint host only, not the URL.", "storageEndpointURL", ",", "err", ":=", "url", ".", "Parse", "(", "cloud", ".", "StorageEndpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "env", ":=", "azureEnviron", "{", "provider", ":", "provider", ",", "cloud", ":", "cloud", ",", "location", ":", "canonicalLocation", "(", "cloud", ".", "Region", ")", ",", "storageEndpoint", ":", "storageEndpointURL", ".", "Host", ",", "}", "\n", "if", "err", ":=", "env", ".", "initEnviron", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "env", ".", "SetConfig", "(", "cfg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "modelTag", ":=", "names", ".", "NewModelTag", "(", "cfg", ".", "UUID", "(", ")", ")", "\n", "env", ".", "resourceGroup", "=", "resourceGroupName", "(", "modelTag", ",", "cfg", ".", "Name", "(", ")", ")", "\n", "env", ".", "envName", "=", "cfg", ".", "Name", "(", ")", "\n\n", "// We need a deterministic storage account name, so that we can", "// defer creation of the storage account to the VM deployment,", "// and retain the ability to create multiple deployments in", "// parallel.", "//", "// We use the last 20 non-hyphen hex characters of the model's", "// UUID as the storage account name, prefixed with \"juju\". The", "// probability of clashing with another storage account should", "// be negligible.", "uuidAlphaNumeric", ":=", "strings", ".", "Replace", "(", "env", ".", "config", ".", "Config", ".", "UUID", "(", ")", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "env", ".", "storageAccountName", "=", "\"", "\"", "+", "uuidAlphaNumeric", "[", "len", "(", "uuidAlphaNumeric", ")", "-", "20", ":", "]", "\n\n", "return", "&", "env", ",", "nil", "\n", "}" ]
// newEnviron creates a new azureEnviron.
[ "newEnviron", "creates", "a", "new", "azureEnviron", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L128-L171
154,232
juju/juju
provider/azure/environ.go
initResourceGroup
func (env *azureEnviron) initResourceGroup(ctx context.ProviderCallContext, controllerUUID string, controller bool) error { resourceGroupsClient := resources.GroupsClient{env.resources} env.mu.Lock() tags := tags.ResourceTags( names.NewModelTag(env.config.Config.UUID()), names.NewControllerTag(controllerUUID), env.config, ) env.mu.Unlock() logger.Debugf("creating resource group %q", env.resourceGroup) sdkCtx := stdcontext.Background() if _, err := resourceGroupsClient.CreateOrUpdate(sdkCtx, env.resourceGroup, resources.Group{ Location: to.StringPtr(env.location), Tags: *to.StringMapPtr(tags), }); err != nil { return errorutils.HandleCredentialError(errors.Annotate(err, "creating resource group"), ctx) } if !controller { // When we create a resource group for a non-controller model, // we must create the common resources up-front. This is so // that parallel deployments do not affect dynamic changes, // e.g. those made by the firewaller. For the controller model, // we fold the creation of these resources into the bootstrap // machine's deployment. if err := env.createCommonResourceDeployment(ctx, tags, nil); err != nil { return errors.Trace(err) } } // New models are not given a storage account. Initialise the // storage account pointer to a pointer to a nil pointer, so // "getStorageAccount" avoids making an API call. env.storageAccount = new(*storage.Account) return nil }
go
func (env *azureEnviron) initResourceGroup(ctx context.ProviderCallContext, controllerUUID string, controller bool) error { resourceGroupsClient := resources.GroupsClient{env.resources} env.mu.Lock() tags := tags.ResourceTags( names.NewModelTag(env.config.Config.UUID()), names.NewControllerTag(controllerUUID), env.config, ) env.mu.Unlock() logger.Debugf("creating resource group %q", env.resourceGroup) sdkCtx := stdcontext.Background() if _, err := resourceGroupsClient.CreateOrUpdate(sdkCtx, env.resourceGroup, resources.Group{ Location: to.StringPtr(env.location), Tags: *to.StringMapPtr(tags), }); err != nil { return errorutils.HandleCredentialError(errors.Annotate(err, "creating resource group"), ctx) } if !controller { // When we create a resource group for a non-controller model, // we must create the common resources up-front. This is so // that parallel deployments do not affect dynamic changes, // e.g. those made by the firewaller. For the controller model, // we fold the creation of these resources into the bootstrap // machine's deployment. if err := env.createCommonResourceDeployment(ctx, tags, nil); err != nil { return errors.Trace(err) } } // New models are not given a storage account. Initialise the // storage account pointer to a pointer to a nil pointer, so // "getStorageAccount" avoids making an API call. env.storageAccount = new(*storage.Account) return nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "initResourceGroup", "(", "ctx", "context", ".", "ProviderCallContext", ",", "controllerUUID", "string", ",", "controller", "bool", ")", "error", "{", "resourceGroupsClient", ":=", "resources", ".", "GroupsClient", "{", "env", ".", "resources", "}", "\n\n", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "tags", ":=", "tags", ".", "ResourceTags", "(", "names", ".", "NewModelTag", "(", "env", ".", "config", ".", "Config", ".", "UUID", "(", ")", ")", ",", "names", ".", "NewControllerTag", "(", "controllerUUID", ")", ",", "env", ".", "config", ",", ")", "\n", "env", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "env", ".", "resourceGroup", ")", "\n", "sdkCtx", ":=", "stdcontext", ".", "Background", "(", ")", "\n", "if", "_", ",", "err", ":=", "resourceGroupsClient", ".", "CreateOrUpdate", "(", "sdkCtx", ",", "env", ".", "resourceGroup", ",", "resources", ".", "Group", "{", "Location", ":", "to", ".", "StringPtr", "(", "env", ".", "location", ")", ",", "Tags", ":", "*", "to", ".", "StringMapPtr", "(", "tags", ")", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "errorutils", ".", "HandleCredentialError", "(", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", ",", "ctx", ")", "\n", "}", "\n\n", "if", "!", "controller", "{", "// When we create a resource group for a non-controller model,", "// we must create the common resources up-front. This is so", "// that parallel deployments do not affect dynamic changes,", "// e.g. those made by the firewaller. For the controller model,", "// we fold the creation of these resources into the bootstrap", "// machine's deployment.", "if", "err", ":=", "env", ".", "createCommonResourceDeployment", "(", "ctx", ",", "tags", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "// New models are not given a storage account. Initialise the", "// storage account pointer to a pointer to a nil pointer, so", "// \"getStorageAccount\" avoids making an API call.", "env", ".", "storageAccount", "=", "new", "(", "*", "storage", ".", "Account", ")", "\n\n", "return", "nil", "\n", "}" ]
// initResourceGroup creates a resource group for this environment.
[ "initResourceGroup", "creates", "a", "resource", "group", "for", "this", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L254-L292
154,233
juju/juju
provider/azure/environ.go
Config
func (env *azureEnviron) Config() *config.Config { env.mu.Lock() defer env.mu.Unlock() return env.config.Config }
go
func (env *azureEnviron) Config() *config.Config { env.mu.Lock() defer env.mu.Unlock() return env.config.Config }
[ "func", "(", "env", "*", "azureEnviron", ")", "Config", "(", ")", "*", "config", ".", "Config", "{", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "env", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "env", ".", "config", ".", "Config", "\n", "}" ]
// Config is specified in the Environ interface.
[ "Config", "is", "specified", "in", "the", "Environ", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L343-L347
154,234
juju/juju
provider/azure/environ.go
waitCommonResourcesCreated
func (env *azureEnviron) waitCommonResourcesCreated() error { env.mu.Lock() defer env.mu.Unlock() if env.commonResourcesCreated { return nil } deployment, err := env.waitCommonResourcesCreatedLocked() if err != nil { return errors.Trace(err) } env.commonResourcesCreated = true if deployment != nil { // Check if the common deployment created // a storage account. If it didn't, we can // avoid a query for the storage account. var hasStorageAccount bool if deployment.Properties.Providers != nil { for _, p := range *deployment.Properties.Providers { if to.String(p.Namespace) != "Microsoft.Storage" { continue } if p.ResourceTypes == nil { continue } for _, rt := range *p.ResourceTypes { if to.String(rt.ResourceType) != "storageAccounts" { continue } hasStorageAccount = true break } break } } if !hasStorageAccount { env.storageAccount = new(*storage.Account) } } return nil }
go
func (env *azureEnviron) waitCommonResourcesCreated() error { env.mu.Lock() defer env.mu.Unlock() if env.commonResourcesCreated { return nil } deployment, err := env.waitCommonResourcesCreatedLocked() if err != nil { return errors.Trace(err) } env.commonResourcesCreated = true if deployment != nil { // Check if the common deployment created // a storage account. If it didn't, we can // avoid a query for the storage account. var hasStorageAccount bool if deployment.Properties.Providers != nil { for _, p := range *deployment.Properties.Providers { if to.String(p.Namespace) != "Microsoft.Storage" { continue } if p.ResourceTypes == nil { continue } for _, rt := range *p.ResourceTypes { if to.String(rt.ResourceType) != "storageAccounts" { continue } hasStorageAccount = true break } break } } if !hasStorageAccount { env.storageAccount = new(*storage.Account) } } return nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "waitCommonResourcesCreated", "(", ")", "error", "{", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "env", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "env", ".", "commonResourcesCreated", "{", "return", "nil", "\n", "}", "\n", "deployment", ",", "err", ":=", "env", ".", "waitCommonResourcesCreatedLocked", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "env", ".", "commonResourcesCreated", "=", "true", "\n", "if", "deployment", "!=", "nil", "{", "// Check if the common deployment created", "// a storage account. If it didn't, we can", "// avoid a query for the storage account.", "var", "hasStorageAccount", "bool", "\n", "if", "deployment", ".", "Properties", ".", "Providers", "!=", "nil", "{", "for", "_", ",", "p", ":=", "range", "*", "deployment", ".", "Properties", ".", "Providers", "{", "if", "to", ".", "String", "(", "p", ".", "Namespace", ")", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "if", "p", ".", "ResourceTypes", "==", "nil", "{", "continue", "\n", "}", "\n", "for", "_", ",", "rt", ":=", "range", "*", "p", ".", "ResourceTypes", "{", "if", "to", ".", "String", "(", "rt", ".", "ResourceType", ")", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "hasStorageAccount", "=", "true", "\n", "break", "\n", "}", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "hasStorageAccount", "{", "env", ".", "storageAccount", "=", "new", "(", "*", "storage", ".", "Account", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// waitCommonResourcesCreated waits for the "common" deployment to complete.
[ "waitCommonResourcesCreated", "waits", "for", "the", "common", "deployment", "to", "complete", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L849-L888
154,235
juju/juju
provider/azure/environ.go
newStorageProfile
func newStorageProfile( vmName string, maybeStorageAccount *storage.Account, storageAccountType string, instanceSpec *instances.InstanceSpec, ) (*compute.StorageProfile, error) { logger.Debugf("creating storage profile for %q", vmName) urnParts := strings.SplitN(instanceSpec.Image.Id, ":", 4) if len(urnParts) != 4 { return nil, errors.Errorf("invalid image ID %q", instanceSpec.Image.Id) } publisher := urnParts[0] offer := urnParts[1] sku := urnParts[2] version := urnParts[3] osDiskName := vmName osDiskSizeGB := mibToGB(instanceSpec.InstanceType.RootDisk) osDisk := &compute.OSDisk{ Name: to.StringPtr(osDiskName), CreateOption: compute.DiskCreateOptionTypesFromImage, Caching: compute.CachingTypesReadWrite, DiskSizeGB: to.Int32Ptr(int32(osDiskSizeGB)), } if maybeStorageAccount == nil { // This model uses managed disks. osDisk.ManagedDisk = &compute.ManagedDiskParameters{ StorageAccountType: compute.StorageAccountTypes(storageAccountType), } } else { // This model uses unmanaged disks. osDiskVhdRoot := blobContainerURL(maybeStorageAccount, osDiskVHDContainer) vhdURI := osDiskVhdRoot + osDiskName + vhdExtension osDisk.Vhd = &compute.VirtualHardDisk{to.StringPtr(vhdURI)} } return &compute.StorageProfile{ ImageReference: &compute.ImageReference{ Publisher: to.StringPtr(publisher), Offer: to.StringPtr(offer), Sku: to.StringPtr(sku), Version: to.StringPtr(version), }, OsDisk: osDisk, }, nil }
go
func newStorageProfile( vmName string, maybeStorageAccount *storage.Account, storageAccountType string, instanceSpec *instances.InstanceSpec, ) (*compute.StorageProfile, error) { logger.Debugf("creating storage profile for %q", vmName) urnParts := strings.SplitN(instanceSpec.Image.Id, ":", 4) if len(urnParts) != 4 { return nil, errors.Errorf("invalid image ID %q", instanceSpec.Image.Id) } publisher := urnParts[0] offer := urnParts[1] sku := urnParts[2] version := urnParts[3] osDiskName := vmName osDiskSizeGB := mibToGB(instanceSpec.InstanceType.RootDisk) osDisk := &compute.OSDisk{ Name: to.StringPtr(osDiskName), CreateOption: compute.DiskCreateOptionTypesFromImage, Caching: compute.CachingTypesReadWrite, DiskSizeGB: to.Int32Ptr(int32(osDiskSizeGB)), } if maybeStorageAccount == nil { // This model uses managed disks. osDisk.ManagedDisk = &compute.ManagedDiskParameters{ StorageAccountType: compute.StorageAccountTypes(storageAccountType), } } else { // This model uses unmanaged disks. osDiskVhdRoot := blobContainerURL(maybeStorageAccount, osDiskVHDContainer) vhdURI := osDiskVhdRoot + osDiskName + vhdExtension osDisk.Vhd = &compute.VirtualHardDisk{to.StringPtr(vhdURI)} } return &compute.StorageProfile{ ImageReference: &compute.ImageReference{ Publisher: to.StringPtr(publisher), Offer: to.StringPtr(offer), Sku: to.StringPtr(sku), Version: to.StringPtr(version), }, OsDisk: osDisk, }, nil }
[ "func", "newStorageProfile", "(", "vmName", "string", ",", "maybeStorageAccount", "*", "storage", ".", "Account", ",", "storageAccountType", "string", ",", "instanceSpec", "*", "instances", ".", "InstanceSpec", ",", ")", "(", "*", "compute", ".", "StorageProfile", ",", "error", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "vmName", ")", "\n\n", "urnParts", ":=", "strings", ".", "SplitN", "(", "instanceSpec", ".", "Image", ".", "Id", ",", "\"", "\"", ",", "4", ")", "\n", "if", "len", "(", "urnParts", ")", "!=", "4", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "instanceSpec", ".", "Image", ".", "Id", ")", "\n", "}", "\n", "publisher", ":=", "urnParts", "[", "0", "]", "\n", "offer", ":=", "urnParts", "[", "1", "]", "\n", "sku", ":=", "urnParts", "[", "2", "]", "\n", "version", ":=", "urnParts", "[", "3", "]", "\n\n", "osDiskName", ":=", "vmName", "\n", "osDiskSizeGB", ":=", "mibToGB", "(", "instanceSpec", ".", "InstanceType", ".", "RootDisk", ")", "\n", "osDisk", ":=", "&", "compute", ".", "OSDisk", "{", "Name", ":", "to", ".", "StringPtr", "(", "osDiskName", ")", ",", "CreateOption", ":", "compute", ".", "DiskCreateOptionTypesFromImage", ",", "Caching", ":", "compute", ".", "CachingTypesReadWrite", ",", "DiskSizeGB", ":", "to", ".", "Int32Ptr", "(", "int32", "(", "osDiskSizeGB", ")", ")", ",", "}", "\n\n", "if", "maybeStorageAccount", "==", "nil", "{", "// This model uses managed disks.", "osDisk", ".", "ManagedDisk", "=", "&", "compute", ".", "ManagedDiskParameters", "{", "StorageAccountType", ":", "compute", ".", "StorageAccountTypes", "(", "storageAccountType", ")", ",", "}", "\n", "}", "else", "{", "// This model uses unmanaged disks.", "osDiskVhdRoot", ":=", "blobContainerURL", "(", "maybeStorageAccount", ",", "osDiskVHDContainer", ")", "\n", "vhdURI", ":=", "osDiskVhdRoot", "+", "osDiskName", "+", "vhdExtension", "\n", "osDisk", ".", "Vhd", "=", "&", "compute", ".", "VirtualHardDisk", "{", "to", ".", "StringPtr", "(", "vhdURI", ")", "}", "\n", "}", "\n\n", "return", "&", "compute", ".", "StorageProfile", "{", "ImageReference", ":", "&", "compute", ".", "ImageReference", "{", "Publisher", ":", "to", ".", "StringPtr", "(", "publisher", ")", ",", "Offer", ":", "to", ".", "StringPtr", "(", "offer", ")", ",", "Sku", ":", "to", ".", "StringPtr", "(", "sku", ")", ",", "Version", ":", "to", ".", "StringPtr", "(", "version", ")", ",", "}", ",", "OsDisk", ":", "osDisk", ",", "}", ",", "nil", "\n", "}" ]
// newStorageProfile creates the storage profile for a virtual machine, // based on the series and chosen instance spec.
[ "newStorageProfile", "creates", "the", "storage", "profile", "for", "a", "virtual", "machine", "based", "on", "the", "series", "and", "chosen", "instance", "spec", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L995-L1042
154,236
juju/juju
provider/azure/environ.go
cancelDeployment
func (env *azureEnviron) cancelDeployment(ctx context.ProviderCallContext, sdkCtx stdcontext.Context, name string) error { deploymentsClient := resources.DeploymentsClient{env.resources} logger.Debugf("- canceling deployment %q", name) cancelResult, err := deploymentsClient.Cancel(sdkCtx, env.resourceGroup, name) if err != nil { if cancelResult.Response != nil { switch cancelResult.StatusCode { case http.StatusNotFound: return errors.NewNotFound(err, fmt.Sprintf("deployment %q not found", name)) case http.StatusConflict: if err, ok := errorutils.ServiceError(err); ok { if err.Code == serviceErrorCodeDeploymentCannotBeCancelled || err.Code == serviceErrorCodeResourceGroupBeingDeleted { // Deployments can only canceled while they're running. return nil } } } } return errorutils.HandleCredentialError(errors.Annotatef(err, "canceling deployment %q", name), ctx) } return nil }
go
func (env *azureEnviron) cancelDeployment(ctx context.ProviderCallContext, sdkCtx stdcontext.Context, name string) error { deploymentsClient := resources.DeploymentsClient{env.resources} logger.Debugf("- canceling deployment %q", name) cancelResult, err := deploymentsClient.Cancel(sdkCtx, env.resourceGroup, name) if err != nil { if cancelResult.Response != nil { switch cancelResult.StatusCode { case http.StatusNotFound: return errors.NewNotFound(err, fmt.Sprintf("deployment %q not found", name)) case http.StatusConflict: if err, ok := errorutils.ServiceError(err); ok { if err.Code == serviceErrorCodeDeploymentCannotBeCancelled || err.Code == serviceErrorCodeResourceGroupBeingDeleted { // Deployments can only canceled while they're running. return nil } } } } return errorutils.HandleCredentialError(errors.Annotatef(err, "canceling deployment %q", name), ctx) } return nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "cancelDeployment", "(", "ctx", "context", ".", "ProviderCallContext", ",", "sdkCtx", "stdcontext", ".", "Context", ",", "name", "string", ")", "error", "{", "deploymentsClient", ":=", "resources", ".", "DeploymentsClient", "{", "env", ".", "resources", "}", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "name", ")", "\n", "cancelResult", ",", "err", ":=", "deploymentsClient", ".", "Cancel", "(", "sdkCtx", ",", "env", ".", "resourceGroup", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "if", "cancelResult", ".", "Response", "!=", "nil", "{", "switch", "cancelResult", ".", "StatusCode", "{", "case", "http", ".", "StatusNotFound", ":", "return", "errors", ".", "NewNotFound", "(", "err", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "case", "http", ".", "StatusConflict", ":", "if", "err", ",", "ok", ":=", "errorutils", ".", "ServiceError", "(", "err", ")", ";", "ok", "{", "if", "err", ".", "Code", "==", "serviceErrorCodeDeploymentCannotBeCancelled", "||", "err", ".", "Code", "==", "serviceErrorCodeResourceGroupBeingDeleted", "{", "// Deployments can only canceled while they're running.", "return", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "errorutils", ".", "HandleCredentialError", "(", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "name", ")", ",", "ctx", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// cancelDeployment cancels a template deployment.
[ "cancelDeployment", "cancels", "a", "template", "deployment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1212-L1234
154,237
juju/juju
provider/azure/environ.go
Instances
func (env *azureEnviron) Instances(ctx context.ProviderCallContext, ids []instance.Id) ([]instances.Instance, error) { return env.instances(ctx, env.resourceGroup, ids, true /* refresh addresses */) }
go
func (env *azureEnviron) Instances(ctx context.ProviderCallContext, ids []instance.Id) ([]instances.Instance, error) { return env.instances(ctx, env.resourceGroup, ids, true /* refresh addresses */) }
[ "func", "(", "env", "*", "azureEnviron", ")", "Instances", "(", "ctx", "context", ".", "ProviderCallContext", ",", "ids", "[", "]", "instance", ".", "Id", ")", "(", "[", "]", "instances", ".", "Instance", ",", "error", ")", "{", "return", "env", ".", "instances", "(", "ctx", ",", "env", ".", "resourceGroup", ",", "ids", ",", "true", "/* refresh addresses */", ")", "\n", "}" ]
// Instances is specified in the Environ interface.
[ "Instances", "is", "specified", "in", "the", "Environ", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1388-L1390
154,238
juju/juju
provider/azure/environ.go
AllInstances
func (env *azureEnviron) AllInstances(ctx context.ProviderCallContext) ([]instances.Instance, error) { return env.allInstances(ctx, env.resourceGroup, true /* refresh addresses */, false /* all instances */) }
go
func (env *azureEnviron) AllInstances(ctx context.ProviderCallContext) ([]instances.Instance, error) { return env.allInstances(ctx, env.resourceGroup, true /* refresh addresses */, false /* all instances */) }
[ "func", "(", "env", "*", "azureEnviron", ")", "AllInstances", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "instances", ".", "Instance", ",", "error", ")", "{", "return", "env", ".", "allInstances", "(", "ctx", ",", "env", ".", "resourceGroup", ",", "true", "/* refresh addresses */", ",", "false", "/* all instances */", ")", "\n", "}" ]
// AllInstances is specified in the InstanceBroker interface.
[ "AllInstances", "is", "specified", "in", "the", "InstanceBroker", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1531-L1533
154,239
juju/juju
provider/azure/environ.go
allInstances
func (env *azureEnviron) allInstances( ctx context.ProviderCallContext, resourceGroup string, refreshAddresses bool, controllerOnly bool, ) ([]instances.Instance, error) { deploymentsClient := resources.DeploymentsClient{env.resources} sdkCtx := stdcontext.Background() deploymentsResult, err := deploymentsClient.ListByResourceGroupComplete(sdkCtx, resourceGroup, "", nil) if err != nil { if isNotFoundResult(deploymentsResult.Response().Response) { // This will occur if the resource group does not // exist, e.g. in a fresh hosted environment. return nil, nil } return nil, errorutils.HandleCredentialError(errors.Trace(err), ctx) } if deploymentsResult.Response().IsEmpty() { return nil, nil } var azureInstances []*azureInstance for ; deploymentsResult.NotDone(); err = deploymentsResult.NextWithContext(sdkCtx) { if err != nil { return nil, errors.Annotate(err, "listing resources") } deployment := deploymentsResult.Value() name := to.String(deployment.Name) if _, err := names.ParseMachineTag(name); err != nil { // Deployments we create for Juju machines are named // with the machine tag. We also create a "common" // deployment, so this will exclude that VM and any // other stray deployment resources. continue } if deployment.Properties == nil || deployment.Properties.Dependencies == nil { continue } if controllerOnly && !isControllerDeployment(deployment) { continue } provisioningState := to.String(deployment.Properties.ProvisioningState) inst := &azureInstance{name, provisioningState, env, nil, nil} azureInstances = append(azureInstances, inst) } if len(azureInstances) > 0 && refreshAddresses { if err := setInstanceAddresses( ctx, resourceGroup, network.InterfacesClient{env.network}, network.PublicIPAddressesClient{env.network}, azureInstances, ); err != nil { return nil, errors.Trace(err) } } instances := make([]instances.Instance, len(azureInstances)) for i, inst := range azureInstances { instances[i] = inst } return instances, nil }
go
func (env *azureEnviron) allInstances( ctx context.ProviderCallContext, resourceGroup string, refreshAddresses bool, controllerOnly bool, ) ([]instances.Instance, error) { deploymentsClient := resources.DeploymentsClient{env.resources} sdkCtx := stdcontext.Background() deploymentsResult, err := deploymentsClient.ListByResourceGroupComplete(sdkCtx, resourceGroup, "", nil) if err != nil { if isNotFoundResult(deploymentsResult.Response().Response) { // This will occur if the resource group does not // exist, e.g. in a fresh hosted environment. return nil, nil } return nil, errorutils.HandleCredentialError(errors.Trace(err), ctx) } if deploymentsResult.Response().IsEmpty() { return nil, nil } var azureInstances []*azureInstance for ; deploymentsResult.NotDone(); err = deploymentsResult.NextWithContext(sdkCtx) { if err != nil { return nil, errors.Annotate(err, "listing resources") } deployment := deploymentsResult.Value() name := to.String(deployment.Name) if _, err := names.ParseMachineTag(name); err != nil { // Deployments we create for Juju machines are named // with the machine tag. We also create a "common" // deployment, so this will exclude that VM and any // other stray deployment resources. continue } if deployment.Properties == nil || deployment.Properties.Dependencies == nil { continue } if controllerOnly && !isControllerDeployment(deployment) { continue } provisioningState := to.String(deployment.Properties.ProvisioningState) inst := &azureInstance{name, provisioningState, env, nil, nil} azureInstances = append(azureInstances, inst) } if len(azureInstances) > 0 && refreshAddresses { if err := setInstanceAddresses( ctx, resourceGroup, network.InterfacesClient{env.network}, network.PublicIPAddressesClient{env.network}, azureInstances, ); err != nil { return nil, errors.Trace(err) } } instances := make([]instances.Instance, len(azureInstances)) for i, inst := range azureInstances { instances[i] = inst } return instances, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "allInstances", "(", "ctx", "context", ".", "ProviderCallContext", ",", "resourceGroup", "string", ",", "refreshAddresses", "bool", ",", "controllerOnly", "bool", ",", ")", "(", "[", "]", "instances", ".", "Instance", ",", "error", ")", "{", "deploymentsClient", ":=", "resources", ".", "DeploymentsClient", "{", "env", ".", "resources", "}", "\n", "sdkCtx", ":=", "stdcontext", ".", "Background", "(", ")", "\n", "deploymentsResult", ",", "err", ":=", "deploymentsClient", ".", "ListByResourceGroupComplete", "(", "sdkCtx", ",", "resourceGroup", ",", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "if", "isNotFoundResult", "(", "deploymentsResult", ".", "Response", "(", ")", ".", "Response", ")", "{", "// This will occur if the resource group does not", "// exist, e.g. in a fresh hosted environment.", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errorutils", ".", "HandleCredentialError", "(", "errors", ".", "Trace", "(", "err", ")", ",", "ctx", ")", "\n", "}", "\n", "if", "deploymentsResult", ".", "Response", "(", ")", ".", "IsEmpty", "(", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "var", "azureInstances", "[", "]", "*", "azureInstance", "\n", "for", ";", "deploymentsResult", ".", "NotDone", "(", ")", ";", "err", "=", "deploymentsResult", ".", "NextWithContext", "(", "sdkCtx", ")", "{", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "deployment", ":=", "deploymentsResult", ".", "Value", "(", ")", "\n", "name", ":=", "to", ".", "String", "(", "deployment", ".", "Name", ")", "\n", "if", "_", ",", "err", ":=", "names", ".", "ParseMachineTag", "(", "name", ")", ";", "err", "!=", "nil", "{", "// Deployments we create for Juju machines are named", "// with the machine tag. We also create a \"common\"", "// deployment, so this will exclude that VM and any", "// other stray deployment resources.", "continue", "\n", "}", "\n", "if", "deployment", ".", "Properties", "==", "nil", "||", "deployment", ".", "Properties", ".", "Dependencies", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "controllerOnly", "&&", "!", "isControllerDeployment", "(", "deployment", ")", "{", "continue", "\n", "}", "\n", "provisioningState", ":=", "to", ".", "String", "(", "deployment", ".", "Properties", ".", "ProvisioningState", ")", "\n", "inst", ":=", "&", "azureInstance", "{", "name", ",", "provisioningState", ",", "env", ",", "nil", ",", "nil", "}", "\n", "azureInstances", "=", "append", "(", "azureInstances", ",", "inst", ")", "\n", "}", "\n\n", "if", "len", "(", "azureInstances", ")", ">", "0", "&&", "refreshAddresses", "{", "if", "err", ":=", "setInstanceAddresses", "(", "ctx", ",", "resourceGroup", ",", "network", ".", "InterfacesClient", "{", "env", ".", "network", "}", ",", "network", ".", "PublicIPAddressesClient", "{", "env", ".", "network", "}", ",", "azureInstances", ",", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "instances", ":=", "make", "(", "[", "]", "instances", ".", "Instance", ",", "len", "(", "azureInstances", ")", ")", "\n", "for", "i", ",", "inst", ":=", "range", "azureInstances", "{", "instances", "[", "i", "]", "=", "inst", "\n", "}", "\n", "return", "instances", ",", "nil", "\n", "}" ]
// allInstances returns all of the instances in the given resource group, // and optionally ensures that each instance's addresses are up-to-date.
[ "allInstances", "returns", "all", "of", "the", "instances", "in", "the", "given", "resource", "group", "and", "optionally", "ensures", "that", "each", "instance", "s", "addresses", "are", "up", "-", "to", "-", "date", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1537-L1600
154,240
juju/juju
provider/azure/environ.go
Destroy
func (env *azureEnviron) Destroy(ctx context.ProviderCallContext) error { logger.Debugf("destroying model %q", env.envName) logger.Debugf("- deleting resource group %q", env.resourceGroup) sdkCtx := stdcontext.Background() if err := env.deleteResourceGroup(ctx, sdkCtx, env.resourceGroup); err != nil { return errors.Trace(err) } // Resource groups are self-contained and fully encompass // all environ resources. Once you delete the group, there // is nothing else to do. return nil }
go
func (env *azureEnviron) Destroy(ctx context.ProviderCallContext) error { logger.Debugf("destroying model %q", env.envName) logger.Debugf("- deleting resource group %q", env.resourceGroup) sdkCtx := stdcontext.Background() if err := env.deleteResourceGroup(ctx, sdkCtx, env.resourceGroup); err != nil { return errors.Trace(err) } // Resource groups are self-contained and fully encompass // all environ resources. Once you delete the group, there // is nothing else to do. return nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "Destroy", "(", "ctx", "context", ".", "ProviderCallContext", ")", "error", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "env", ".", "envName", ")", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "env", ".", "resourceGroup", ")", "\n", "sdkCtx", ":=", "stdcontext", ".", "Background", "(", ")", "\n", "if", "err", ":=", "env", ".", "deleteResourceGroup", "(", "ctx", ",", "sdkCtx", ",", "env", ".", "resourceGroup", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "// Resource groups are self-contained and fully encompass", "// all environ resources. Once you delete the group, there", "// is nothing else to do.", "return", "nil", "\n", "}" ]
// Destroy is specified in the Environ interface.
[ "Destroy", "is", "specified", "in", "the", "Environ", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1623-L1634
154,241
juju/juju
provider/azure/environ.go
DestroyController
func (env *azureEnviron) DestroyController(ctx context.ProviderCallContext, controllerUUID string) error { logger.Debugf("destroying model %q", env.envName) logger.Debugf("- deleting resource groups") if err := env.deleteControllerManagedResourceGroups(ctx, controllerUUID); err != nil { return errors.Trace(err) } // Resource groups are self-contained and fully encompass // all environ resources. Once you delete the group, there // is nothing else to do. return nil }
go
func (env *azureEnviron) DestroyController(ctx context.ProviderCallContext, controllerUUID string) error { logger.Debugf("destroying model %q", env.envName) logger.Debugf("- deleting resource groups") if err := env.deleteControllerManagedResourceGroups(ctx, controllerUUID); err != nil { return errors.Trace(err) } // Resource groups are self-contained and fully encompass // all environ resources. Once you delete the group, there // is nothing else to do. return nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "DestroyController", "(", "ctx", "context", ".", "ProviderCallContext", ",", "controllerUUID", "string", ")", "error", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "env", ".", "envName", ")", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "env", ".", "deleteControllerManagedResourceGroups", "(", "ctx", ",", "controllerUUID", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "// Resource groups are self-contained and fully encompass", "// all environ resources. Once you delete the group, there", "// is nothing else to do.", "return", "nil", "\n", "}" ]
// DestroyController is specified in the Environ interface.
[ "DestroyController", "is", "specified", "in", "the", "Environ", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1637-L1647
154,242
juju/juju
provider/azure/environ.go
resourceGroupName
func resourceGroupName(modelTag names.ModelTag, modelName string) string { return fmt.Sprintf("juju-%s-%s", modelName, resourceName(modelTag)) }
go
func resourceGroupName(modelTag names.ModelTag, modelName string) string { return fmt.Sprintf("juju-%s-%s", modelName, resourceName(modelTag)) }
[ "func", "resourceGroupName", "(", "modelTag", "names", ".", "ModelTag", ",", "modelName", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "modelName", ",", "resourceName", "(", "modelTag", ")", ")", "\n", "}" ]
// resourceGroupName returns the name of the environment's resource group.
[ "resourceGroupName", "returns", "the", "name", "of", "the", "environment", "s", "resource", "group", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1738-L1740
154,243
juju/juju
provider/azure/environ.go
getInstanceTypes
func (env *azureEnviron) getInstanceTypes(ctx context.ProviderCallContext) (map[string]instances.InstanceType, error) { env.mu.Lock() defer env.mu.Unlock() instanceTypes, err := env.getInstanceTypesLocked(ctx) if err != nil { return nil, errors.Annotate(err, "getting instance types") } return instanceTypes, nil }
go
func (env *azureEnviron) getInstanceTypes(ctx context.ProviderCallContext) (map[string]instances.InstanceType, error) { env.mu.Lock() defer env.mu.Unlock() instanceTypes, err := env.getInstanceTypesLocked(ctx) if err != nil { return nil, errors.Annotate(err, "getting instance types") } return instanceTypes, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "getInstanceTypes", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "map", "[", "string", "]", "instances", ".", "InstanceType", ",", "error", ")", "{", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "env", ".", "mu", ".", "Unlock", "(", ")", "\n", "instanceTypes", ",", "err", ":=", "env", ".", "getInstanceTypesLocked", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "instanceTypes", ",", "nil", "\n", "}" ]
// getInstanceTypes gets the instance types available for the configured // location, keyed by name.
[ "getInstanceTypes", "gets", "the", "instance", "types", "available", "for", "the", "configured", "location", "keyed", "by", "name", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1753-L1761
154,244
juju/juju
provider/azure/environ.go
getInstanceTypesLocked
func (env *azureEnviron) getInstanceTypesLocked(ctx context.ProviderCallContext) (map[string]instances.InstanceType, error) { if env.instanceTypes != nil { return env.instanceTypes, nil } location := env.location client := compute.VirtualMachineSizesClient{env.compute} result, err := client.List(stdcontext.Background(), location) if err != nil { return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing VM sizes"), ctx) } instanceTypes := make(map[string]instances.InstanceType) if result.Value != nil { for _, size := range *result.Value { instanceType := newInstanceType(size) instanceTypes[instanceType.Name] = instanceType // Create aliases for standard role sizes. if strings.HasPrefix(instanceType.Name, "Standard_") { instanceTypes[instanceType.Name[len("Standard_"):]] = instanceType } } } env.instanceTypes = instanceTypes return instanceTypes, nil }
go
func (env *azureEnviron) getInstanceTypesLocked(ctx context.ProviderCallContext) (map[string]instances.InstanceType, error) { if env.instanceTypes != nil { return env.instanceTypes, nil } location := env.location client := compute.VirtualMachineSizesClient{env.compute} result, err := client.List(stdcontext.Background(), location) if err != nil { return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing VM sizes"), ctx) } instanceTypes := make(map[string]instances.InstanceType) if result.Value != nil { for _, size := range *result.Value { instanceType := newInstanceType(size) instanceTypes[instanceType.Name] = instanceType // Create aliases for standard role sizes. if strings.HasPrefix(instanceType.Name, "Standard_") { instanceTypes[instanceType.Name[len("Standard_"):]] = instanceType } } } env.instanceTypes = instanceTypes return instanceTypes, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "getInstanceTypesLocked", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "map", "[", "string", "]", "instances", ".", "InstanceType", ",", "error", ")", "{", "if", "env", ".", "instanceTypes", "!=", "nil", "{", "return", "env", ".", "instanceTypes", ",", "nil", "\n", "}", "\n\n", "location", ":=", "env", ".", "location", "\n", "client", ":=", "compute", ".", "VirtualMachineSizesClient", "{", "env", ".", "compute", "}", "\n\n", "result", ",", "err", ":=", "client", ".", "List", "(", "stdcontext", ".", "Background", "(", ")", ",", "location", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errorutils", ".", "HandleCredentialError", "(", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", ",", "ctx", ")", "\n", "}", "\n", "instanceTypes", ":=", "make", "(", "map", "[", "string", "]", "instances", ".", "InstanceType", ")", "\n", "if", "result", ".", "Value", "!=", "nil", "{", "for", "_", ",", "size", ":=", "range", "*", "result", ".", "Value", "{", "instanceType", ":=", "newInstanceType", "(", "size", ")", "\n", "instanceTypes", "[", "instanceType", ".", "Name", "]", "=", "instanceType", "\n", "// Create aliases for standard role sizes.", "if", "strings", ".", "HasPrefix", "(", "instanceType", ".", "Name", ",", "\"", "\"", ")", "{", "instanceTypes", "[", "instanceType", ".", "Name", "[", "len", "(", "\"", "\"", ")", ":", "]", "]", "=", "instanceType", "\n", "}", "\n", "}", "\n", "}", "\n", "env", ".", "instanceTypes", "=", "instanceTypes", "\n", "return", "instanceTypes", ",", "nil", "\n", "}" ]
// getInstanceTypesLocked returns the instance types for Azure, by listing the // role sizes available to the subscription.
[ "getInstanceTypesLocked", "returns", "the", "instance", "types", "for", "Azure", "by", "listing", "the", "role", "sizes", "available", "to", "the", "subscription", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1765-L1790
154,245
juju/juju
provider/azure/environ.go
maybeGetStorageClient
func (env *azureEnviron) maybeGetStorageClient() (internalazurestorage.Client, *storage.Account, error) { storageClient, storageAccount, err := env.getStorageClient() if errors.IsNotFound(err) { // Only models created prior to Juju 2.3 will have a storage // account. Juju 2.3 onwards exclusively uses managed disks // for all new models, and handles both managed and unmanaged // disks for upgraded models. storageClient = nil storageAccount = nil } else if err != nil { return nil, nil, errors.Trace(err) } return storageClient, storageAccount, nil }
go
func (env *azureEnviron) maybeGetStorageClient() (internalazurestorage.Client, *storage.Account, error) { storageClient, storageAccount, err := env.getStorageClient() if errors.IsNotFound(err) { // Only models created prior to Juju 2.3 will have a storage // account. Juju 2.3 onwards exclusively uses managed disks // for all new models, and handles both managed and unmanaged // disks for upgraded models. storageClient = nil storageAccount = nil } else if err != nil { return nil, nil, errors.Trace(err) } return storageClient, storageAccount, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "maybeGetStorageClient", "(", ")", "(", "internalazurestorage", ".", "Client", ",", "*", "storage", ".", "Account", ",", "error", ")", "{", "storageClient", ",", "storageAccount", ",", "err", ":=", "env", ".", "getStorageClient", "(", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "// Only models created prior to Juju 2.3 will have a storage", "// account. Juju 2.3 onwards exclusively uses managed disks", "// for all new models, and handles both managed and unmanaged", "// disks for upgraded models.", "storageClient", "=", "nil", "\n", "storageAccount", "=", "nil", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "storageClient", ",", "storageAccount", ",", "nil", "\n", "}" ]
// maybeGetStorageClient returns the environment's storage client if it // has one, and nil if it does not.
[ "maybeGetStorageClient", "returns", "the", "environment", "s", "storage", "client", "if", "it", "has", "one", "and", "nil", "if", "it", "does", "not", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1794-L1807
154,246
juju/juju
provider/azure/environ.go
getStorageClient
func (env *azureEnviron) getStorageClient() (internalazurestorage.Client, *storage.Account, error) { env.mu.Lock() defer env.mu.Unlock() storageAccount, err := env.getStorageAccountLocked() if err != nil { return nil, nil, errors.Annotate(err, "getting storage account") } storageAccountKey, err := env.getStorageAccountKeyLocked( to.String(storageAccount.Name), false, ) if err != nil { return nil, nil, errors.Annotate(err, "getting storage account key") } client, err := getStorageClient( env.provider.config.NewStorageClient, env.storageEndpoint, storageAccount, storageAccountKey, ) if err != nil { return nil, nil, errors.Annotate(err, "getting storage client") } return client, storageAccount, nil }
go
func (env *azureEnviron) getStorageClient() (internalazurestorage.Client, *storage.Account, error) { env.mu.Lock() defer env.mu.Unlock() storageAccount, err := env.getStorageAccountLocked() if err != nil { return nil, nil, errors.Annotate(err, "getting storage account") } storageAccountKey, err := env.getStorageAccountKeyLocked( to.String(storageAccount.Name), false, ) if err != nil { return nil, nil, errors.Annotate(err, "getting storage account key") } client, err := getStorageClient( env.provider.config.NewStorageClient, env.storageEndpoint, storageAccount, storageAccountKey, ) if err != nil { return nil, nil, errors.Annotate(err, "getting storage client") } return client, storageAccount, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "getStorageClient", "(", ")", "(", "internalazurestorage", ".", "Client", ",", "*", "storage", ".", "Account", ",", "error", ")", "{", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "env", ".", "mu", ".", "Unlock", "(", ")", "\n", "storageAccount", ",", "err", ":=", "env", ".", "getStorageAccountLocked", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "storageAccountKey", ",", "err", ":=", "env", ".", "getStorageAccountKeyLocked", "(", "to", ".", "String", "(", "storageAccount", ".", "Name", ")", ",", "false", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "client", ",", "err", ":=", "getStorageClient", "(", "env", ".", "provider", ".", "config", ".", "NewStorageClient", ",", "env", ".", "storageEndpoint", ",", "storageAccount", ",", "storageAccountKey", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "client", ",", "storageAccount", ",", "nil", "\n", "}" ]
// getStorageClient queries the storage account key, and uses it to construct // a new storage client.
[ "getStorageClient", "queries", "the", "storage", "account", "key", "and", "uses", "it", "to", "construct", "a", "new", "storage", "client", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1811-L1834
154,247
juju/juju
provider/azure/environ.go
getStorageAccount
func (env *azureEnviron) getStorageAccount() (*storage.Account, error) { env.mu.Lock() defer env.mu.Unlock() return env.getStorageAccountLocked() }
go
func (env *azureEnviron) getStorageAccount() (*storage.Account, error) { env.mu.Lock() defer env.mu.Unlock() return env.getStorageAccountLocked() }
[ "func", "(", "env", "*", "azureEnviron", ")", "getStorageAccount", "(", ")", "(", "*", "storage", ".", "Account", ",", "error", ")", "{", "env", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "env", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "env", ".", "getStorageAccountLocked", "(", ")", "\n", "}" ]
// getStorageAccount returns the storage account for this environment's // resource group.
[ "getStorageAccount", "returns", "the", "storage", "account", "for", "this", "environment", "s", "resource", "group", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1838-L1842
154,248
juju/juju
provider/azure/environ.go
getStorageAccountKeyLocked
func (env *azureEnviron) getStorageAccountKeyLocked(accountName string, refresh bool) (*storage.AccountKey, error) { if !refresh && env.storageAccountKey != nil { return env.storageAccountKey, nil } client := storage.AccountsClient{env.storage} key, err := getStorageAccountKey(client, env.resourceGroup, accountName) if err != nil { return nil, errors.Trace(err) } env.storageAccountKey = key return key, nil }
go
func (env *azureEnviron) getStorageAccountKeyLocked(accountName string, refresh bool) (*storage.AccountKey, error) { if !refresh && env.storageAccountKey != nil { return env.storageAccountKey, nil } client := storage.AccountsClient{env.storage} key, err := getStorageAccountKey(client, env.resourceGroup, accountName) if err != nil { return nil, errors.Trace(err) } env.storageAccountKey = key return key, nil }
[ "func", "(", "env", "*", "azureEnviron", ")", "getStorageAccountKeyLocked", "(", "accountName", "string", ",", "refresh", "bool", ")", "(", "*", "storage", ".", "AccountKey", ",", "error", ")", "{", "if", "!", "refresh", "&&", "env", ".", "storageAccountKey", "!=", "nil", "{", "return", "env", ".", "storageAccountKey", ",", "nil", "\n", "}", "\n", "client", ":=", "storage", ".", "AccountsClient", "{", "env", ".", "storage", "}", "\n", "key", ",", "err", ":=", "getStorageAccountKey", "(", "client", ",", "env", ".", "resourceGroup", ",", "accountName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "env", ".", "storageAccountKey", "=", "key", "\n", "return", "key", ",", "nil", "\n", "}" ]
// getStorageAccountKeysLocked returns a storage account key for this // environment's storage account. If refresh is true, any cached key // will be refreshed. This method assumes that env.mu is held.
[ "getStorageAccountKeysLocked", "returns", "a", "storage", "account", "key", "for", "this", "environment", "s", "storage", "account", ".", "If", "refresh", "is", "true", "any", "cached", "key", "will", "be", "refreshed", ".", "This", "method", "assumes", "that", "env", ".", "mu", "is", "held", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/environ.go#L1870-L1881
154,249
juju/juju
worker/resumer/resumer.go
Validate
func (config Config) Validate() error { if config.Facade == nil { return errors.NotValidf("nil Facade") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.Interval <= 0 { return errors.NotValidf("non-positive Interval") } return nil }
go
func (config Config) Validate() error { if config.Facade == nil { return errors.NotValidf("nil Facade") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.Interval <= 0 { return errors.NotValidf("non-positive Interval") } return nil }
[ "func", "(", "config", "Config", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "Facade", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "config", ".", "Clock", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "config", ".", "Interval", "<=", "0", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate returns an error if config cannot be expected to drive // a Resumer.
[ "Validate", "returns", "an", "error", "if", "config", "cannot", "be", "expected", "to", "drive", "a", "Resumer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/resumer/resumer.go#L35-L46
154,250
juju/juju
apiserver/facades/agent/provisioner/machineerror.go
loop
func (w *machineErrorRetry) loop() error { out := w.out for { select { case <-w.tomb.Dying(): return tomb.ErrDying // TODO(fwereade): 2016-03-17 lp:1558657 case <-time.After(ErrorRetryWaitDelay): out = w.out case out <- struct{}{}: out = nil } } }
go
func (w *machineErrorRetry) loop() error { out := w.out for { select { case <-w.tomb.Dying(): return tomb.ErrDying // TODO(fwereade): 2016-03-17 lp:1558657 case <-time.After(ErrorRetryWaitDelay): out = w.out case out <- struct{}{}: out = nil } } }
[ "func", "(", "w", "*", "machineErrorRetry", ")", "loop", "(", ")", "error", "{", "out", ":=", "w", ".", "out", "\n", "for", "{", "select", "{", "case", "<-", "w", ".", "tomb", ".", "Dying", "(", ")", ":", "return", "tomb", ".", "ErrDying", "\n", "// TODO(fwereade): 2016-03-17 lp:1558657", "case", "<-", "time", ".", "After", "(", "ErrorRetryWaitDelay", ")", ":", "out", "=", "w", ".", "out", "\n", "case", "out", "<-", "struct", "{", "}", "{", "}", ":", "out", "=", "nil", "\n", "}", "\n", "}", "\n", "}" ]
// The initial implementation of this watcher simply acts as a poller, // triggering every ErrorRetryWaitDelay minutes.
[ "The", "initial", "implementation", "of", "this", "watcher", "simply", "acts", "as", "a", "poller", "triggering", "every", "ErrorRetryWaitDelay", "minutes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/provisioner/machineerror.go#L66-L79
154,251
juju/juju
cmd/juju/storage/listformatters.go
FormatStorageListForStatusTabular
func FormatStorageListForStatusTabular(writer *ansiterm.TabWriter, s CombinedStorage) error { w := output.Wrapper{writer} storagePool, storageSize := getStoragePoolAndSize(s) units, byUnit := sortStorageInstancesByUnitId(s) w.Println() w.Print("Storage Unit", "Storage id", "Type") if len(storagePool) > 0 { w.Print("Pool") } w.Println("Mountpoint", "Size", "Status", "Message") for _, unit := range units { byStorage := byUnit[unit] storageIds := make([]string, 0, len(byStorage)) for storageId := range byStorage { storageIds = append(storageIds, storageId) } sort.Strings(slashSeparatedIds(storageIds)) for _, storageId := range storageIds { info := byStorage[storageId] w.Print(info.unitId) w.Print(info.storageId) w.Print(info.kind) if len(storagePool) > 0 { w.Print(storagePool[info.storageId]) } w.Print(getFilesystemAttachment(s, info).MountPoint) w.Print(humanizeStorageSize(storageSize[storageId])) w.PrintStatus(info.status.Current) w.Println(info.status.Message) } } w.Flush() return nil }
go
func FormatStorageListForStatusTabular(writer *ansiterm.TabWriter, s CombinedStorage) error { w := output.Wrapper{writer} storagePool, storageSize := getStoragePoolAndSize(s) units, byUnit := sortStorageInstancesByUnitId(s) w.Println() w.Print("Storage Unit", "Storage id", "Type") if len(storagePool) > 0 { w.Print("Pool") } w.Println("Mountpoint", "Size", "Status", "Message") for _, unit := range units { byStorage := byUnit[unit] storageIds := make([]string, 0, len(byStorage)) for storageId := range byStorage { storageIds = append(storageIds, storageId) } sort.Strings(slashSeparatedIds(storageIds)) for _, storageId := range storageIds { info := byStorage[storageId] w.Print(info.unitId) w.Print(info.storageId) w.Print(info.kind) if len(storagePool) > 0 { w.Print(storagePool[info.storageId]) } w.Print(getFilesystemAttachment(s, info).MountPoint) w.Print(humanizeStorageSize(storageSize[storageId])) w.PrintStatus(info.status.Current) w.Println(info.status.Message) } } w.Flush() return nil }
[ "func", "FormatStorageListForStatusTabular", "(", "writer", "*", "ansiterm", ".", "TabWriter", ",", "s", "CombinedStorage", ")", "error", "{", "w", ":=", "output", ".", "Wrapper", "{", "writer", "}", "\n\n", "storagePool", ",", "storageSize", ":=", "getStoragePoolAndSize", "(", "s", ")", "\n", "units", ",", "byUnit", ":=", "sortStorageInstancesByUnitId", "(", "s", ")", "\n\n", "w", ".", "Println", "(", ")", "\n", "w", ".", "Print", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "len", "(", "storagePool", ")", ">", "0", "{", "w", ".", "Print", "(", "\"", "\"", ")", "\n", "}", "\n", "w", ".", "Println", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "for", "_", ",", "unit", ":=", "range", "units", "{", "byStorage", ":=", "byUnit", "[", "unit", "]", "\n", "storageIds", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "byStorage", ")", ")", "\n", "for", "storageId", ":=", "range", "byStorage", "{", "storageIds", "=", "append", "(", "storageIds", ",", "storageId", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "slashSeparatedIds", "(", "storageIds", ")", ")", "\n\n", "for", "_", ",", "storageId", ":=", "range", "storageIds", "{", "info", ":=", "byStorage", "[", "storageId", "]", "\n\n", "w", ".", "Print", "(", "info", ".", "unitId", ")", "\n", "w", ".", "Print", "(", "info", ".", "storageId", ")", "\n", "w", ".", "Print", "(", "info", ".", "kind", ")", "\n", "if", "len", "(", "storagePool", ")", ">", "0", "{", "w", ".", "Print", "(", "storagePool", "[", "info", ".", "storageId", "]", ")", "\n", "}", "\n", "w", ".", "Print", "(", "getFilesystemAttachment", "(", "s", ",", "info", ")", ".", "MountPoint", ")", "\n", "w", ".", "Print", "(", "humanizeStorageSize", "(", "storageSize", "[", "storageId", "]", ")", ")", "\n", "w", ".", "PrintStatus", "(", "info", ".", "status", ".", "Current", ")", "\n", "w", ".", "Println", "(", "info", ".", "status", ".", "Message", ")", "\n", "}", "\n", "}", "\n", "w", ".", "Flush", "(", ")", "\n", "return", "nil", "\n", "}" ]
// FormatStorageListForStatusTabular writes a tabular summary of storage for status tabular view.
[ "FormatStorageListForStatusTabular", "writes", "a", "tabular", "summary", "of", "storage", "for", "status", "tabular", "view", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/listformatters.go#L154-L192
154,252
juju/juju
state/applicationofferuser.go
GetOfferAccess
func (st *State) GetOfferAccess(offerUUID string, user names.UserTag) (permission.Access, error) { perm, err := st.userPermission(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user))) if err != nil { return "", errors.Trace(err) } return perm.access(), nil }
go
func (st *State) GetOfferAccess(offerUUID string, user names.UserTag) (permission.Access, error) { perm, err := st.userPermission(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user))) if err != nil { return "", errors.Trace(err) } return perm.access(), nil }
[ "func", "(", "st", "*", "State", ")", "GetOfferAccess", "(", "offerUUID", "string", ",", "user", "names", ".", "UserTag", ")", "(", "permission", ".", "Access", ",", "error", ")", "{", "perm", ",", "err", ":=", "st", ".", "userPermission", "(", "applicationOfferKey", "(", "offerUUID", ")", ",", "userGlobalKey", "(", "userAccessID", "(", "user", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "perm", ".", "access", "(", ")", ",", "nil", "\n", "}" ]
// GetOfferAccess gets the access permission for the specified user on an offer.
[ "GetOfferAccess", "gets", "the", "access", "permission", "for", "the", "specified", "user", "on", "an", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L17-L23
154,253
juju/juju
state/applicationofferuser.go
GetOfferUsers
func (st *State) GetOfferUsers(offerUUID string) (map[string]permission.Access, error) { perms, err := st.usersPermissions(applicationOfferKey(offerUUID)) if err != nil { return nil, errors.Trace(err) } result := make(map[string]permission.Access) for _, p := range perms { result[userIDFromGlobalKey(p.doc.SubjectGlobalKey)] = p.access() } return result, nil }
go
func (st *State) GetOfferUsers(offerUUID string) (map[string]permission.Access, error) { perms, err := st.usersPermissions(applicationOfferKey(offerUUID)) if err != nil { return nil, errors.Trace(err) } result := make(map[string]permission.Access) for _, p := range perms { result[userIDFromGlobalKey(p.doc.SubjectGlobalKey)] = p.access() } return result, nil }
[ "func", "(", "st", "*", "State", ")", "GetOfferUsers", "(", "offerUUID", "string", ")", "(", "map", "[", "string", "]", "permission", ".", "Access", ",", "error", ")", "{", "perms", ",", "err", ":=", "st", ".", "usersPermissions", "(", "applicationOfferKey", "(", "offerUUID", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "result", ":=", "make", "(", "map", "[", "string", "]", "permission", ".", "Access", ")", "\n", "for", "_", ",", "p", ":=", "range", "perms", "{", "result", "[", "userIDFromGlobalKey", "(", "p", ".", "doc", ".", "SubjectGlobalKey", ")", "]", "=", "p", ".", "access", "(", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// GetOfferUsers gets the access permissions on an offer.
[ "GetOfferUsers", "gets", "the", "access", "permissions", "on", "an", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L26-L36
154,254
juju/juju
state/applicationofferuser.go
CreateOfferAccess
func (st *State) CreateOfferAccess(offer names.ApplicationOfferTag, user names.UserTag, access permission.Access) error { if err := permission.ValidateOfferAccess(access); err != nil { return errors.Trace(err) } // Local users must exist. if user.IsLocal() { _, err := st.User(user) if err != nil { if errors.IsNotFound(err) { return errors.Annotatef(err, "user %q does not exist locally", user.Name()) } return errors.Trace(err) } } offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Annotate(err, "creating offer access") } op := createPermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)), access) err = st.db().RunTransaction([]txn.Op{op}) if err == txn.ErrAborted { err = errors.AlreadyExistsf("permission for user %q for offer %q", user.Id(), offer.Name) } return errors.Trace(err) }
go
func (st *State) CreateOfferAccess(offer names.ApplicationOfferTag, user names.UserTag, access permission.Access) error { if err := permission.ValidateOfferAccess(access); err != nil { return errors.Trace(err) } // Local users must exist. if user.IsLocal() { _, err := st.User(user) if err != nil { if errors.IsNotFound(err) { return errors.Annotatef(err, "user %q does not exist locally", user.Name()) } return errors.Trace(err) } } offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Annotate(err, "creating offer access") } op := createPermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)), access) err = st.db().RunTransaction([]txn.Op{op}) if err == txn.ErrAborted { err = errors.AlreadyExistsf("permission for user %q for offer %q", user.Id(), offer.Name) } return errors.Trace(err) }
[ "func", "(", "st", "*", "State", ")", "CreateOfferAccess", "(", "offer", "names", ".", "ApplicationOfferTag", ",", "user", "names", ".", "UserTag", ",", "access", "permission", ".", "Access", ")", "error", "{", "if", "err", ":=", "permission", ".", "ValidateOfferAccess", "(", "access", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "// Local users must exist.", "if", "user", ".", "IsLocal", "(", ")", "{", "_", ",", "err", ":=", "st", ".", "User", "(", "user", ")", "\n", "if", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "user", ".", "Name", "(", ")", ")", "\n", "}", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "offerUUID", ",", "err", ":=", "applicationOfferUUID", "(", "st", ",", "offer", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "op", ":=", "createPermissionOp", "(", "applicationOfferKey", "(", "offerUUID", ")", ",", "userGlobalKey", "(", "userAccessID", "(", "user", ")", ")", ",", "access", ")", "\n\n", "err", "=", "st", ".", "db", "(", ")", ".", "RunTransaction", "(", "[", "]", "txn", ".", "Op", "{", "op", "}", ")", "\n", "if", "err", "==", "txn", ".", "ErrAborted", "{", "err", "=", "errors", ".", "AlreadyExistsf", "(", "\"", "\"", ",", "user", ".", "Id", "(", ")", ",", "offer", ".", "Name", ")", "\n", "}", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// CreateOfferAccess creates a new access permission for a user on an offer.
[ "CreateOfferAccess", "creates", "a", "new", "access", "permission", "for", "a", "user", "on", "an", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L39-L66
154,255
juju/juju
state/applicationofferuser.go
UpdateOfferAccess
func (st *State) UpdateOfferAccess(offer names.ApplicationOfferTag, user names.UserTag, access permission.Access) error { if err := permission.ValidateOfferAccess(access); err != nil { return errors.Trace(err) } offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Trace(err) } buildTxn := func(int) ([]txn.Op, error) { _, err := st.GetOfferAccess(offerUUID, user) if err != nil { return nil, errors.Trace(err) } isAdmin, err := st.isControllerOrModelAdmin(user) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{updatePermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)), access)} if !isAdmin && access != permission.ConsumeAccess && access != permission.AdminAccess { suspendOps, err := st.suspendRevokedRelationsOps(offerUUID, user.Id()) if err != nil { return nil, errors.Trace(err) } ops = append(ops, suspendOps...) } return ops, nil } err = st.db().Run(buildTxn) return errors.Trace(err) }
go
func (st *State) UpdateOfferAccess(offer names.ApplicationOfferTag, user names.UserTag, access permission.Access) error { if err := permission.ValidateOfferAccess(access); err != nil { return errors.Trace(err) } offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Trace(err) } buildTxn := func(int) ([]txn.Op, error) { _, err := st.GetOfferAccess(offerUUID, user) if err != nil { return nil, errors.Trace(err) } isAdmin, err := st.isControllerOrModelAdmin(user) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{updatePermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)), access)} if !isAdmin && access != permission.ConsumeAccess && access != permission.AdminAccess { suspendOps, err := st.suspendRevokedRelationsOps(offerUUID, user.Id()) if err != nil { return nil, errors.Trace(err) } ops = append(ops, suspendOps...) } return ops, nil } err = st.db().Run(buildTxn) return errors.Trace(err) }
[ "func", "(", "st", "*", "State", ")", "UpdateOfferAccess", "(", "offer", "names", ".", "ApplicationOfferTag", ",", "user", "names", ".", "UserTag", ",", "access", "permission", ".", "Access", ")", "error", "{", "if", "err", ":=", "permission", ".", "ValidateOfferAccess", "(", "access", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "offerUUID", ",", "err", ":=", "applicationOfferUUID", "(", "st", ",", "offer", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "buildTxn", ":=", "func", "(", "int", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "_", ",", "err", ":=", "st", ".", "GetOfferAccess", "(", "offerUUID", ",", "user", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "isAdmin", ",", "err", ":=", "st", ".", "isControllerOrModelAdmin", "(", "user", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ops", ":=", "[", "]", "txn", ".", "Op", "{", "updatePermissionOp", "(", "applicationOfferKey", "(", "offerUUID", ")", ",", "userGlobalKey", "(", "userAccessID", "(", "user", ")", ")", ",", "access", ")", "}", "\n", "if", "!", "isAdmin", "&&", "access", "!=", "permission", ".", "ConsumeAccess", "&&", "access", "!=", "permission", ".", "AdminAccess", "{", "suspendOps", ",", "err", ":=", "st", ".", "suspendRevokedRelationsOps", "(", "offerUUID", ",", "user", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ops", "=", "append", "(", "ops", ",", "suspendOps", "...", ")", "\n", "}", "\n", "return", "ops", ",", "nil", "\n", "}", "\n\n", "err", "=", "st", ".", "db", "(", ")", ".", "Run", "(", "buildTxn", ")", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// UpdateOfferAccess changes the user's access permissions on an offer.
[ "UpdateOfferAccess", "changes", "the", "user", "s", "access", "permissions", "on", "an", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L69-L100
154,256
juju/juju
state/applicationofferuser.go
suspendRevokedRelationsOps
func (st *State) suspendRevokedRelationsOps(offerUUID, userId string) ([]txn.Op, error) { conns, err := st.OfferConnections(offerUUID) if err != nil { return nil, errors.Trace(err) } var ops []txn.Op relIdsToSuspend := make(set.Ints) for _, oc := range conns { if oc.UserName() == userId { rel, err := st.Relation(oc.RelationId()) if err != nil { return nil, errors.Trace(err) } if rel.Suspended() { continue } relIdsToSuspend.Add(rel.Id()) suspendOp := txn.Op{ C: relationsC, Id: rel.doc.DocID, Assert: txn.DocExists, Update: bson.D{{"$set", bson.D{{"suspended", true}}}}, } ops = append(ops, suspendOp) } } // Add asserts that the relations against the offered application don't change. // This is broader than what we need but it's all that's possible. ao := NewApplicationOffers(st) offer, err := ao.ApplicationOfferForUUID(offerUUID) if err != nil { return nil, errors.Trace(err) } app, err := st.Application(offer.ApplicationName) if err != nil { return nil, errors.Trace(err) } relations, err := app.Relations() if err != nil { return nil, errors.Trace(err) } sameRelCount := bson.D{{"relationcount", len(relations)}} ops = append(ops, txn.Op{ C: applicationsC, Id: app.doc.DocID, Assert: sameRelCount, }) // Ensure any relations not being updated still exist. for _, r := range relations { if relIdsToSuspend.Contains(r.Id()) { continue } ops = append(ops, txn.Op{ C: relationsC, Id: r.doc.DocID, Assert: txn.DocExists, }) } return ops, nil }
go
func (st *State) suspendRevokedRelationsOps(offerUUID, userId string) ([]txn.Op, error) { conns, err := st.OfferConnections(offerUUID) if err != nil { return nil, errors.Trace(err) } var ops []txn.Op relIdsToSuspend := make(set.Ints) for _, oc := range conns { if oc.UserName() == userId { rel, err := st.Relation(oc.RelationId()) if err != nil { return nil, errors.Trace(err) } if rel.Suspended() { continue } relIdsToSuspend.Add(rel.Id()) suspendOp := txn.Op{ C: relationsC, Id: rel.doc.DocID, Assert: txn.DocExists, Update: bson.D{{"$set", bson.D{{"suspended", true}}}}, } ops = append(ops, suspendOp) } } // Add asserts that the relations against the offered application don't change. // This is broader than what we need but it's all that's possible. ao := NewApplicationOffers(st) offer, err := ao.ApplicationOfferForUUID(offerUUID) if err != nil { return nil, errors.Trace(err) } app, err := st.Application(offer.ApplicationName) if err != nil { return nil, errors.Trace(err) } relations, err := app.Relations() if err != nil { return nil, errors.Trace(err) } sameRelCount := bson.D{{"relationcount", len(relations)}} ops = append(ops, txn.Op{ C: applicationsC, Id: app.doc.DocID, Assert: sameRelCount, }) // Ensure any relations not being updated still exist. for _, r := range relations { if relIdsToSuspend.Contains(r.Id()) { continue } ops = append(ops, txn.Op{ C: relationsC, Id: r.doc.DocID, Assert: txn.DocExists, }) } return ops, nil }
[ "func", "(", "st", "*", "State", ")", "suspendRevokedRelationsOps", "(", "offerUUID", ",", "userId", "string", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "conns", ",", "err", ":=", "st", ".", "OfferConnections", "(", "offerUUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "var", "ops", "[", "]", "txn", ".", "Op", "\n", "relIdsToSuspend", ":=", "make", "(", "set", ".", "Ints", ")", "\n", "for", "_", ",", "oc", ":=", "range", "conns", "{", "if", "oc", ".", "UserName", "(", ")", "==", "userId", "{", "rel", ",", "err", ":=", "st", ".", "Relation", "(", "oc", ".", "RelationId", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "rel", ".", "Suspended", "(", ")", "{", "continue", "\n", "}", "\n", "relIdsToSuspend", ".", "Add", "(", "rel", ".", "Id", "(", ")", ")", "\n", "suspendOp", ":=", "txn", ".", "Op", "{", "C", ":", "relationsC", ",", "Id", ":", "rel", ".", "doc", ".", "DocID", ",", "Assert", ":", "txn", ".", "DocExists", ",", "Update", ":", "bson", ".", "D", "{", "{", "\"", "\"", ",", "bson", ".", "D", "{", "{", "\"", "\"", ",", "true", "}", "}", "}", "}", ",", "}", "\n", "ops", "=", "append", "(", "ops", ",", "suspendOp", ")", "\n", "}", "\n", "}", "\n\n", "// Add asserts that the relations against the offered application don't change.", "// This is broader than what we need but it's all that's possible.", "ao", ":=", "NewApplicationOffers", "(", "st", ")", "\n", "offer", ",", "err", ":=", "ao", ".", "ApplicationOfferForUUID", "(", "offerUUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "app", ",", "err", ":=", "st", ".", "Application", "(", "offer", ".", "ApplicationName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "relations", ",", "err", ":=", "app", ".", "Relations", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "sameRelCount", ":=", "bson", ".", "D", "{", "{", "\"", "\"", ",", "len", "(", "relations", ")", "}", "}", "\n", "ops", "=", "append", "(", "ops", ",", "txn", ".", "Op", "{", "C", ":", "applicationsC", ",", "Id", ":", "app", ".", "doc", ".", "DocID", ",", "Assert", ":", "sameRelCount", ",", "}", ")", "\n", "// Ensure any relations not being updated still exist.", "for", "_", ",", "r", ":=", "range", "relations", "{", "if", "relIdsToSuspend", ".", "Contains", "(", "r", ".", "Id", "(", ")", ")", "{", "continue", "\n", "}", "\n", "ops", "=", "append", "(", "ops", ",", "txn", ".", "Op", "{", "C", ":", "relationsC", ",", "Id", ":", "r", ".", "doc", ".", "DocID", ",", "Assert", ":", "txn", ".", "DocExists", ",", "}", ")", "\n", "}", "\n\n", "return", "ops", ",", "nil", "\n", "}" ]
// suspendRevokedRelationsOps suspends any relations the given user has against // the specified offer.
[ "suspendRevokedRelationsOps", "suspends", "any", "relations", "the", "given", "user", "has", "against", "the", "specified", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L104-L166
154,257
juju/juju
state/applicationofferuser.go
RemoveOfferAccess
func (st *State) RemoveOfferAccess(offer names.ApplicationOfferTag, user names.UserTag) error { offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Trace(err) } buildTxn := func(int) ([]txn.Op, error) { _, err := st.GetOfferAccess(offerUUID, user) if err != nil { return nil, err } isAdmin, err := st.isControllerOrModelAdmin(user) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{removePermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)))} if !isAdmin { suspendOps, err := st.suspendRevokedRelationsOps(offerUUID, user.Id()) if err != nil { return nil, errors.Trace(err) } ops = append(ops, suspendOps...) } return ops, nil } err = st.db().Run(buildTxn) return errors.Trace(err) }
go
func (st *State) RemoveOfferAccess(offer names.ApplicationOfferTag, user names.UserTag) error { offerUUID, err := applicationOfferUUID(st, offer.Name) if err != nil { return errors.Trace(err) } buildTxn := func(int) ([]txn.Op, error) { _, err := st.GetOfferAccess(offerUUID, user) if err != nil { return nil, err } isAdmin, err := st.isControllerOrModelAdmin(user) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{removePermissionOp(applicationOfferKey(offerUUID), userGlobalKey(userAccessID(user)))} if !isAdmin { suspendOps, err := st.suspendRevokedRelationsOps(offerUUID, user.Id()) if err != nil { return nil, errors.Trace(err) } ops = append(ops, suspendOps...) } return ops, nil } err = st.db().Run(buildTxn) return errors.Trace(err) }
[ "func", "(", "st", "*", "State", ")", "RemoveOfferAccess", "(", "offer", "names", ".", "ApplicationOfferTag", ",", "user", "names", ".", "UserTag", ")", "error", "{", "offerUUID", ",", "err", ":=", "applicationOfferUUID", "(", "st", ",", "offer", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "buildTxn", ":=", "func", "(", "int", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "_", ",", "err", ":=", "st", ".", "GetOfferAccess", "(", "offerUUID", ",", "user", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "isAdmin", ",", "err", ":=", "st", ".", "isControllerOrModelAdmin", "(", "user", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ops", ":=", "[", "]", "txn", ".", "Op", "{", "removePermissionOp", "(", "applicationOfferKey", "(", "offerUUID", ")", ",", "userGlobalKey", "(", "userAccessID", "(", "user", ")", ")", ")", "}", "\n", "if", "!", "isAdmin", "{", "suspendOps", ",", "err", ":=", "st", ".", "suspendRevokedRelationsOps", "(", "offerUUID", ",", "user", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ops", "=", "append", "(", "ops", ",", "suspendOps", "...", ")", "\n", "}", "\n", "return", "ops", ",", "nil", "\n", "}", "\n\n", "err", "=", "st", ".", "db", "(", ")", ".", "Run", "(", "buildTxn", ")", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// RemoveOfferAccess removes the access permission for a user on an offer.
[ "RemoveOfferAccess", "removes", "the", "access", "permission", "for", "a", "user", "on", "an", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationofferuser.go#L169-L197
154,258
juju/juju
core/watcher/notify.go
Validate
func (config NotifyConfig) Validate() error { if config.Handler == nil { return errors.NotValidf("nil Handler") } return nil }
go
func (config NotifyConfig) Validate() error { if config.Handler == nil { return errors.NotValidf("nil Handler") } return nil }
[ "func", "(", "config", "NotifyConfig", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "Handler", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate returns an error if the config cannot start a NotifyWorker.
[ "Validate", "returns", "an", "error", "if", "the", "config", "cannot", "start", "a", "NotifyWorker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/watcher/notify.go#L54-L59
154,259
juju/juju
core/watcher/notify.go
NewNotifyWorker
func NewNotifyWorker(config NotifyConfig) (*NotifyWorker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } nw := &NotifyWorker{ config: config, } err := catacomb.Invoke(catacomb.Plan{ Site: &nw.catacomb, Work: nw.loop, }) if err != nil { return nil, errors.Trace(err) } return nw, nil }
go
func NewNotifyWorker(config NotifyConfig) (*NotifyWorker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } nw := &NotifyWorker{ config: config, } err := catacomb.Invoke(catacomb.Plan{ Site: &nw.catacomb, Work: nw.loop, }) if err != nil { return nil, errors.Trace(err) } return nw, nil }
[ "func", "NewNotifyWorker", "(", "config", "NotifyConfig", ")", "(", "*", "NotifyWorker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "nw", ":=", "&", "NotifyWorker", "{", "config", ":", "config", ",", "}", "\n", "err", ":=", "catacomb", ".", "Invoke", "(", "catacomb", ".", "Plan", "{", "Site", ":", "&", "nw", ".", "catacomb", ",", "Work", ":", "nw", ".", "loop", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "nw", ",", "nil", "\n", "}" ]
// NewNotifyWorker starts a new worker that runs a NotifyHandler.
[ "NewNotifyWorker", "starts", "a", "new", "worker", "that", "runs", "a", "NotifyHandler", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/watcher/notify.go#L62-L77
154,260
juju/juju
storage/provider/dummy/common.go
StorageProviders
func StorageProviders() storage.ProviderRegistry { return storage.StaticProviderRegistry{ map[storage.ProviderType]storage.Provider{ "static": &StorageProvider{IsDynamic: false}, "modelscoped": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: true, }, "modelscoped-unreleasable": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: false, }, "modelscoped-block": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: true, SupportsFunc: func(k storage.StorageKind) bool { return k == storage.StorageKindBlock }, }, "machinescoped": &StorageProvider{ StorageScope: storage.ScopeMachine, IsDynamic: true, }, }, } }
go
func StorageProviders() storage.ProviderRegistry { return storage.StaticProviderRegistry{ map[storage.ProviderType]storage.Provider{ "static": &StorageProvider{IsDynamic: false}, "modelscoped": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: true, }, "modelscoped-unreleasable": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: false, }, "modelscoped-block": &StorageProvider{ StorageScope: storage.ScopeEnviron, IsDynamic: true, IsReleasable: true, SupportsFunc: func(k storage.StorageKind) bool { return k == storage.StorageKindBlock }, }, "machinescoped": &StorageProvider{ StorageScope: storage.ScopeMachine, IsDynamic: true, }, }, } }
[ "func", "StorageProviders", "(", ")", "storage", ".", "ProviderRegistry", "{", "return", "storage", ".", "StaticProviderRegistry", "{", "map", "[", "storage", ".", "ProviderType", "]", "storage", ".", "Provider", "{", "\"", "\"", ":", "&", "StorageProvider", "{", "IsDynamic", ":", "false", "}", ",", "\"", "\"", ":", "&", "StorageProvider", "{", "StorageScope", ":", "storage", ".", "ScopeEnviron", ",", "IsDynamic", ":", "true", ",", "IsReleasable", ":", "true", ",", "}", ",", "\"", "\"", ":", "&", "StorageProvider", "{", "StorageScope", ":", "storage", ".", "ScopeEnviron", ",", "IsDynamic", ":", "true", ",", "IsReleasable", ":", "false", ",", "}", ",", "\"", "\"", ":", "&", "StorageProvider", "{", "StorageScope", ":", "storage", ".", "ScopeEnviron", ",", "IsDynamic", ":", "true", ",", "IsReleasable", ":", "true", ",", "SupportsFunc", ":", "func", "(", "k", "storage", ".", "StorageKind", ")", "bool", "{", "return", "k", "==", "storage", ".", "StorageKindBlock", "\n", "}", ",", "}", ",", "\"", "\"", ":", "&", "StorageProvider", "{", "StorageScope", ":", "storage", ".", "ScopeMachine", ",", "IsDynamic", ":", "true", ",", "}", ",", "}", ",", "}", "\n", "}" ]
// StorageProviders returns a provider registry with some // well-defined dummy storage providers.
[ "StorageProviders", "returns", "a", "provider", "registry", "with", "some", "well", "-", "defined", "dummy", "storage", "providers", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/dummy/common.go#L10-L38
154,261
juju/juju
cmd/juju/block/list.go
NewListCommand
func NewListCommand() cmd.Command { return modelcmd.Wrap(&listCommand{ apiFunc: func(c newAPIRoot) (blockListAPI, error) { return getBlockAPI(c) }, controllerAPIFunc: func(c newControllerAPIRoot) (controllerListAPI, error) { return getControllerAPI(c) }, }) }
go
func NewListCommand() cmd.Command { return modelcmd.Wrap(&listCommand{ apiFunc: func(c newAPIRoot) (blockListAPI, error) { return getBlockAPI(c) }, controllerAPIFunc: func(c newControllerAPIRoot) (controllerListAPI, error) { return getControllerAPI(c) }, }) }
[ "func", "NewListCommand", "(", ")", "cmd", ".", "Command", "{", "return", "modelcmd", ".", "Wrap", "(", "&", "listCommand", "{", "apiFunc", ":", "func", "(", "c", "newAPIRoot", ")", "(", "blockListAPI", ",", "error", ")", "{", "return", "getBlockAPI", "(", "c", ")", "\n", "}", ",", "controllerAPIFunc", ":", "func", "(", "c", "newControllerAPIRoot", ")", "(", "controllerListAPI", ",", "error", ")", "{", "return", "getControllerAPI", "(", "c", ")", "\n", "}", ",", "}", ")", "\n", "}" ]
// NewListCommand returns the command that lists the disabled // commands for the model.
[ "NewListCommand", "returns", "the", "command", "that", "lists", "the", "disabled", "commands", "for", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/block/list.go#L27-L36
154,262
juju/juju
cmd/juju/block/list.go
formatBlockInfo
func formatBlockInfo(all []params.Block) []BlockInfo { output := make([]BlockInfo, len(all)) for i, one := range all { set, ok := toCmdValue[one.Type] if !ok { set = "<unknown>" } output[i] = BlockInfo{ Commands: set, Message: one.Message, } } return output }
go
func formatBlockInfo(all []params.Block) []BlockInfo { output := make([]BlockInfo, len(all)) for i, one := range all { set, ok := toCmdValue[one.Type] if !ok { set = "<unknown>" } output[i] = BlockInfo{ Commands: set, Message: one.Message, } } return output }
[ "func", "formatBlockInfo", "(", "all", "[", "]", "params", ".", "Block", ")", "[", "]", "BlockInfo", "{", "output", ":=", "make", "(", "[", "]", "BlockInfo", ",", "len", "(", "all", ")", ")", "\n", "for", "i", ",", "one", ":=", "range", "all", "{", "set", ",", "ok", ":=", "toCmdValue", "[", "one", ".", "Type", "]", "\n", "if", "!", "ok", "{", "set", "=", "\"", "\"", "\n", "}", "\n", "output", "[", "i", "]", "=", "BlockInfo", "{", "Commands", ":", "set", ",", "Message", ":", "one", ".", "Message", ",", "}", "\n", "}", "\n", "return", "output", "\n", "}" ]
// formatBlockInfo takes a set of Block and creates a // mapping to information structures.
[ "formatBlockInfo", "takes", "a", "set", "of", "Block", "and", "creates", "a", "mapping", "to", "information", "structures", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/block/list.go#L159-L172
154,263
juju/juju
cmd/juju/block/list.go
formatBlocks
func formatBlocks(writer io.Writer, value interface{}) error { blocks, ok := value.([]BlockInfo) if !ok { return errors.Errorf("expected value of type %T, got %T", blocks, value) } if len(blocks) == 0 { fmt.Fprintf(writer, "No commands are currently disabled.") return nil } tw := output.TabWriter(writer) w := output.Wrapper{tw} w.Println("Disabled commands", "Message") for _, info := range blocks { w.Println(info.Commands, info.Message) } tw.Flush() return nil }
go
func formatBlocks(writer io.Writer, value interface{}) error { blocks, ok := value.([]BlockInfo) if !ok { return errors.Errorf("expected value of type %T, got %T", blocks, value) } if len(blocks) == 0 { fmt.Fprintf(writer, "No commands are currently disabled.") return nil } tw := output.TabWriter(writer) w := output.Wrapper{tw} w.Println("Disabled commands", "Message") for _, info := range blocks { w.Println(info.Commands, info.Message) } tw.Flush() return nil }
[ "func", "formatBlocks", "(", "writer", "io", ".", "Writer", ",", "value", "interface", "{", "}", ")", "error", "{", "blocks", ",", "ok", ":=", "value", ".", "(", "[", "]", "BlockInfo", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "blocks", ",", "value", ")", "\n", "}", "\n\n", "if", "len", "(", "blocks", ")", "==", "0", "{", "fmt", ".", "Fprintf", "(", "writer", ",", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "tw", ":=", "output", ".", "TabWriter", "(", "writer", ")", "\n", "w", ":=", "output", ".", "Wrapper", "{", "tw", "}", "\n", "w", ".", "Println", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "for", "_", ",", "info", ":=", "range", "blocks", "{", "w", ".", "Println", "(", "info", ".", "Commands", ",", "info", ".", "Message", ")", "\n", "}", "\n", "tw", ".", "Flush", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// formatBlocks writes block list representation.
[ "formatBlocks", "writes", "block", "list", "representation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/block/list.go#L175-L195
154,264
juju/juju
cmd/juju/block/list.go
getControllerAPI
func getControllerAPI(c newControllerAPIRoot) (*controller.Client, error) { root, err := c.NewControllerAPIRoot() if err != nil { return nil, errors.Trace(err) } return controller.NewClient(root), nil }
go
func getControllerAPI(c newControllerAPIRoot) (*controller.Client, error) { root, err := c.NewControllerAPIRoot() if err != nil { return nil, errors.Trace(err) } return controller.NewClient(root), nil }
[ "func", "getControllerAPI", "(", "c", "newControllerAPIRoot", ")", "(", "*", "controller", ".", "Client", ",", "error", ")", "{", "root", ",", "err", ":=", "c", ".", "NewControllerAPIRoot", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "controller", ".", "NewClient", "(", "root", ")", ",", "nil", "\n", "}" ]
// getControllerAPI returns a block api for block manipulation.
[ "getControllerAPI", "returns", "a", "block", "api", "for", "block", "manipulation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/block/list.go#L202-L208
154,265
juju/juju
cmd/juju/block/list.go
FormatTabularBlockedModels
func FormatTabularBlockedModels(writer io.Writer, value interface{}) error { models, ok := value.([]modelBlockInfo) if !ok { return errors.Errorf("expected value of type %T, got %T", models, value) } tw := output.TabWriter(writer) w := output.Wrapper{tw} w.Println("Name", "Model UUID", "Owner", "Disabled commands") for _, model := range models { w.Println(model.Name, model.UUID, model.Owner, strings.Join(model.CommandSets, ", ")) } tw.Flush() return nil }
go
func FormatTabularBlockedModels(writer io.Writer, value interface{}) error { models, ok := value.([]modelBlockInfo) if !ok { return errors.Errorf("expected value of type %T, got %T", models, value) } tw := output.TabWriter(writer) w := output.Wrapper{tw} w.Println("Name", "Model UUID", "Owner", "Disabled commands") for _, model := range models { w.Println(model.Name, model.UUID, model.Owner, strings.Join(model.CommandSets, ", ")) } tw.Flush() return nil }
[ "func", "FormatTabularBlockedModels", "(", "writer", "io", ".", "Writer", ",", "value", "interface", "{", "}", ")", "error", "{", "models", ",", "ok", ":=", "value", ".", "(", "[", "]", "modelBlockInfo", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "models", ",", "value", ")", "\n", "}", "\n\n", "tw", ":=", "output", ".", "TabWriter", "(", "writer", ")", "\n", "w", ":=", "output", ".", "Wrapper", "{", "tw", "}", "\n", "w", ".", "Println", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "for", "_", ",", "model", ":=", "range", "models", "{", "w", ".", "Println", "(", "model", ".", "Name", ",", "model", ".", "UUID", ",", "model", ".", "Owner", ",", "strings", ".", "Join", "(", "model", ".", "CommandSets", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "tw", ".", "Flush", "(", ")", "\n", "return", "nil", "\n", "}" ]
// FormatTabularBlockedModels writes out tabular format for blocked models. // This method is exported as it is also used by destroy-model.
[ "FormatTabularBlockedModels", "writes", "out", "tabular", "format", "for", "blocked", "models", ".", "This", "method", "is", "exported", "as", "it", "is", "also", "used", "by", "destroy", "-", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/block/list.go#L236-L250
154,266
juju/juju
cmd/juju/model/exportbundle.go
NewExportBundleCommand
func NewExportBundleCommand() cmd.Command { cmd := &exportBundleCommand{} cmd.newAPIFunc = func() (ExportBundleAPI, error) { return cmd.getAPI() } return modelcmd.Wrap(cmd) }
go
func NewExportBundleCommand() cmd.Command { cmd := &exportBundleCommand{} cmd.newAPIFunc = func() (ExportBundleAPI, error) { return cmd.getAPI() } return modelcmd.Wrap(cmd) }
[ "func", "NewExportBundleCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "exportBundleCommand", "{", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "ExportBundleAPI", ",", "error", ")", "{", "return", "cmd", ".", "getAPI", "(", ")", "\n", "}", "\n", "return", "modelcmd", ".", "Wrap", "(", "cmd", ")", "\n", "}" ]
// NewExportBundleCommand returns a fully constructed export bundle command.
[ "NewExportBundleCommand", "returns", "a", "fully", "constructed", "export", "bundle", "command", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/model/exportbundle.go#L19-L25
154,267
juju/juju
api/logsender/logsender.go
LogWriter
func (api *API) LogWriter() (LogWriter, error) { attrs := make(url.Values) attrs.Set("jujuclientversion", version.Current.String()) // Version 1 does ping/pong handling. attrs.Set("version", "1") conn, err := api.connector.ConnectStream("/logsink", attrs) if err != nil { return nil, errors.Annotatef(err, "cannot connect to /logsink") } logWriter := writer{conn} go logWriter.readLoop() return logWriter, nil }
go
func (api *API) LogWriter() (LogWriter, error) { attrs := make(url.Values) attrs.Set("jujuclientversion", version.Current.String()) // Version 1 does ping/pong handling. attrs.Set("version", "1") conn, err := api.connector.ConnectStream("/logsink", attrs) if err != nil { return nil, errors.Annotatef(err, "cannot connect to /logsink") } logWriter := writer{conn} go logWriter.readLoop() return logWriter, nil }
[ "func", "(", "api", "*", "API", ")", "LogWriter", "(", ")", "(", "LogWriter", ",", "error", ")", "{", "attrs", ":=", "make", "(", "url", ".", "Values", ")", "\n", "attrs", ".", "Set", "(", "\"", "\"", ",", "version", ".", "Current", ".", "String", "(", ")", ")", "\n", "// Version 1 does ping/pong handling.", "attrs", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "conn", ",", "err", ":=", "api", ".", "connector", ".", "ConnectStream", "(", "\"", "\"", ",", "attrs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "logWriter", ":=", "writer", "{", "conn", "}", "\n", "go", "logWriter", ".", "readLoop", "(", ")", "\n", "return", "logWriter", ",", "nil", "\n", "}" ]
// LogWriter returns a new log writer interface value // which must be closed when finished with.
[ "LogWriter", "returns", "a", "new", "log", "writer", "interface", "value", "which", "must", "be", "closed", "when", "finished", "with", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/logsender/logsender.go#L40-L52
154,268
juju/juju
apiserver/common/controllerconfig.go
ControllerConfig
func (s *ControllerConfigAPI) ControllerConfig() (params.ControllerConfigResult, error) { result := params.ControllerConfigResult{} config, err := s.st.ControllerConfig() if err != nil { return result, err } result.Config = params.ControllerConfig(config) return result, nil }
go
func (s *ControllerConfigAPI) ControllerConfig() (params.ControllerConfigResult, error) { result := params.ControllerConfigResult{} config, err := s.st.ControllerConfig() if err != nil { return result, err } result.Config = params.ControllerConfig(config) return result, nil }
[ "func", "(", "s", "*", "ControllerConfigAPI", ")", "ControllerConfig", "(", ")", "(", "params", ".", "ControllerConfigResult", ",", "error", ")", "{", "result", ":=", "params", ".", "ControllerConfigResult", "{", "}", "\n", "config", ",", "err", ":=", "s", ".", "st", ".", "ControllerConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "err", "\n", "}", "\n", "result", ".", "Config", "=", "params", ".", "ControllerConfig", "(", "config", ")", "\n", "return", "result", ",", "nil", "\n", "}" ]
// ControllerConfig returns the controller's configuration.
[ "ControllerConfig", "returns", "the", "controller", "s", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/controllerconfig.go#L33-L41
154,269
juju/juju
apiserver/common/controllerconfig.go
ControllerAPIInfoForModels
func (s *ControllerConfigAPI) ControllerAPIInfoForModels(args params.Entities) (params.ControllerAPIInfoResults, error) { var result params.ControllerAPIInfoResults result.Results = make([]params.ControllerAPIInfoResult, len(args.Entities)) for i, entity := range args.Entities { modelTag, err := names.ParseModelTag(entity.Tag) if err != nil { result.Results[i].Error = ServerError(err) continue } addrs, caCert, err := s.st.ControllerInfo(modelTag.Id()) if err != nil { result.Results[i].Error = ServerError(err) continue } result.Results[i].Addresses = addrs result.Results[i].CACert = caCert } return result, nil }
go
func (s *ControllerConfigAPI) ControllerAPIInfoForModels(args params.Entities) (params.ControllerAPIInfoResults, error) { var result params.ControllerAPIInfoResults result.Results = make([]params.ControllerAPIInfoResult, len(args.Entities)) for i, entity := range args.Entities { modelTag, err := names.ParseModelTag(entity.Tag) if err != nil { result.Results[i].Error = ServerError(err) continue } addrs, caCert, err := s.st.ControllerInfo(modelTag.Id()) if err != nil { result.Results[i].Error = ServerError(err) continue } result.Results[i].Addresses = addrs result.Results[i].CACert = caCert } return result, nil }
[ "func", "(", "s", "*", "ControllerConfigAPI", ")", "ControllerAPIInfoForModels", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "ControllerAPIInfoResults", ",", "error", ")", "{", "var", "result", "params", ".", "ControllerAPIInfoResults", "\n", "result", ".", "Results", "=", "make", "(", "[", "]", "params", ".", "ControllerAPIInfoResult", ",", "len", "(", "args", ".", "Entities", ")", ")", "\n", "for", "i", ",", "entity", ":=", "range", "args", ".", "Entities", "{", "modelTag", ",", "err", ":=", "names", ".", "ParseModelTag", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "addrs", ",", "caCert", ",", "err", ":=", "s", ".", "st", ".", "ControllerInfo", "(", "modelTag", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "result", ".", "Results", "[", "i", "]", ".", "Error", "=", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "result", ".", "Results", "[", "i", "]", ".", "Addresses", "=", "addrs", "\n", "result", ".", "Results", "[", "i", "]", ".", "CACert", "=", "caCert", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// ControllerAPIInfoForModels returns the controller api connection details for the specified models.
[ "ControllerAPIInfoForModels", "returns", "the", "controller", "api", "connection", "details", "for", "the", "specified", "models", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/controllerconfig.go#L44-L62
154,270
juju/juju
apiserver/common/controllerconfig.go
ControllerInfo
func (s *controllerStateShim) ControllerInfo(modelUUID string) (addrs []string, CACert string, _ error) { // First see if the requested model UUID is hosted by this controller. modelExists, err := s.State.ModelExists(modelUUID) if err != nil { return nil, "", errors.Trace(err) } if modelExists { return StateControllerInfo(s.State) } // Now check any external controllers. ec := state.NewExternalControllers(s.State) info, err := ec.ControllerForModel(modelUUID) if err != nil { return nil, "", errors.Trace(err) } return info.ControllerInfo().Addrs, info.ControllerInfo().CACert, nil }
go
func (s *controllerStateShim) ControllerInfo(modelUUID string) (addrs []string, CACert string, _ error) { // First see if the requested model UUID is hosted by this controller. modelExists, err := s.State.ModelExists(modelUUID) if err != nil { return nil, "", errors.Trace(err) } if modelExists { return StateControllerInfo(s.State) } // Now check any external controllers. ec := state.NewExternalControllers(s.State) info, err := ec.ControllerForModel(modelUUID) if err != nil { return nil, "", errors.Trace(err) } return info.ControllerInfo().Addrs, info.ControllerInfo().CACert, nil }
[ "func", "(", "s", "*", "controllerStateShim", ")", "ControllerInfo", "(", "modelUUID", "string", ")", "(", "addrs", "[", "]", "string", ",", "CACert", "string", ",", "_", "error", ")", "{", "// First see if the requested model UUID is hosted by this controller.", "modelExists", ",", "err", ":=", "s", ".", "State", ".", "ModelExists", "(", "modelUUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "modelExists", "{", "return", "StateControllerInfo", "(", "s", ".", "State", ")", "\n", "}", "\n\n", "// Now check any external controllers.", "ec", ":=", "state", ".", "NewExternalControllers", "(", "s", ".", "State", ")", "\n", "info", ",", "err", ":=", "ec", ".", "ControllerForModel", "(", "modelUUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "info", ".", "ControllerInfo", "(", ")", ".", "Addrs", ",", "info", ".", "ControllerInfo", "(", ")", ".", "CACert", ",", "nil", "\n", "}" ]
// ControllerInfo returns the external controller details for the specified model.
[ "ControllerInfo", "returns", "the", "external", "controller", "details", "for", "the", "specified", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/controllerconfig.go#L69-L86
154,271
juju/juju
apiserver/common/controllerconfig.go
StateControllerInfo
func StateControllerInfo(st *state.State) (addrs []string, caCert string, _ error) { addr, err := apiAddresses(st) if err != nil { return nil, "", errors.Trace(err) } controllerConfig, err := st.ControllerConfig() if err != nil { return nil, "", errors.Trace(err) } caCert, _ = controllerConfig.CACert() return addr, caCert, nil }
go
func StateControllerInfo(st *state.State) (addrs []string, caCert string, _ error) { addr, err := apiAddresses(st) if err != nil { return nil, "", errors.Trace(err) } controllerConfig, err := st.ControllerConfig() if err != nil { return nil, "", errors.Trace(err) } caCert, _ = controllerConfig.CACert() return addr, caCert, nil }
[ "func", "StateControllerInfo", "(", "st", "*", "state", ".", "State", ")", "(", "addrs", "[", "]", "string", ",", "caCert", "string", ",", "_", "error", ")", "{", "addr", ",", "err", ":=", "apiAddresses", "(", "st", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "controllerConfig", ",", "err", ":=", "st", ".", "ControllerConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "caCert", ",", "_", "=", "controllerConfig", ".", "CACert", "(", ")", "\n", "return", "addr", ",", "caCert", ",", "nil", "\n", "}" ]
// StateControllerInfo returns the local controller details for the given State.
[ "StateControllerInfo", "returns", "the", "local", "controller", "details", "for", "the", "given", "State", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/controllerconfig.go#L89-L100
154,272
juju/juju
cmd/juju/cloud/showcredential.go
NewShowCredentialCommand
func NewShowCredentialCommand() cmd.Command { cmd := &showCredentialCommand{ store: jujuclient.NewFileClientStore(), } cmd.newAPIFunc = func() (CredentialContentAPI, error) { return cmd.NewCredentialAPI() } return modelcmd.WrapBase(cmd) }
go
func NewShowCredentialCommand() cmd.Command { cmd := &showCredentialCommand{ store: jujuclient.NewFileClientStore(), } cmd.newAPIFunc = func() (CredentialContentAPI, error) { return cmd.NewCredentialAPI() } return modelcmd.WrapBase(cmd) }
[ "func", "NewShowCredentialCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "showCredentialCommand", "{", "store", ":", "jujuclient", ".", "NewFileClientStore", "(", ")", ",", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "CredentialContentAPI", ",", "error", ")", "{", "return", "cmd", ".", "NewCredentialAPI", "(", ")", "\n", "}", "\n", "return", "modelcmd", ".", "WrapBase", "(", "cmd", ")", "\n", "}" ]
// NewShowCredentialCommand returns a command to show information about // credentials stored on the controller.
[ "NewShowCredentialCommand", "returns", "a", "command", "to", "show", "information", "about", "credentials", "stored", "on", "the", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/cloud/showcredential.go#L34-L42
154,273
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
NewModelGenerationFacade
func NewModelGenerationFacade(ctx facade.Context) (*API, error) { authorizer := ctx.Auth() st := &stateShim{State: ctx.State()} m, err := st.Model() if err != nil { return nil, errors.Trace(err) } return NewModelGenerationAPI(st, authorizer, m) }
go
func NewModelGenerationFacade(ctx facade.Context) (*API, error) { authorizer := ctx.Auth() st := &stateShim{State: ctx.State()} m, err := st.Model() if err != nil { return nil, errors.Trace(err) } return NewModelGenerationAPI(st, authorizer, m) }
[ "func", "NewModelGenerationFacade", "(", "ctx", "facade", ".", "Context", ")", "(", "*", "API", ",", "error", ")", "{", "authorizer", ":=", "ctx", ".", "Auth", "(", ")", "\n", "st", ":=", "&", "stateShim", "{", "State", ":", "ctx", ".", "State", "(", ")", "}", "\n", "m", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "NewModelGenerationAPI", "(", "st", ",", "authorizer", ",", "m", ")", "\n", "}" ]
// NewModelGenerationFacade provides the signature required for facade registration.
[ "NewModelGenerationFacade", "provides", "the", "signature", "required", "for", "facade", "registration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L35-L43
154,274
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
NewModelGenerationAPI
func NewModelGenerationAPI( st State, authorizer facade.Authorizer, m Model, ) (*API, error) { if !authorizer.AuthClient() { return nil, common.ErrPerm } // Since we know this is a user tag (because AuthClient is true), // we just do the type assertion to the UserTag. apiUser, _ := authorizer.GetAuthTag().(names.UserTag) // Pretty much all of the user manager methods have special casing for admin // users, so look once when we start and remember if the user is an admin. isAdmin, err := authorizer.HasPermission(permission.SuperuserAccess, st.ControllerTag()) if err != nil { return nil, errors.Trace(err) } return &API{ authorizer: authorizer, isControllerAdmin: isAdmin, apiUser: apiUser, st: st, model: m, }, nil }
go
func NewModelGenerationAPI( st State, authorizer facade.Authorizer, m Model, ) (*API, error) { if !authorizer.AuthClient() { return nil, common.ErrPerm } // Since we know this is a user tag (because AuthClient is true), // we just do the type assertion to the UserTag. apiUser, _ := authorizer.GetAuthTag().(names.UserTag) // Pretty much all of the user manager methods have special casing for admin // users, so look once when we start and remember if the user is an admin. isAdmin, err := authorizer.HasPermission(permission.SuperuserAccess, st.ControllerTag()) if err != nil { return nil, errors.Trace(err) } return &API{ authorizer: authorizer, isControllerAdmin: isAdmin, apiUser: apiUser, st: st, model: m, }, nil }
[ "func", "NewModelGenerationAPI", "(", "st", "State", ",", "authorizer", "facade", ".", "Authorizer", ",", "m", "Model", ",", ")", "(", "*", "API", ",", "error", ")", "{", "if", "!", "authorizer", ".", "AuthClient", "(", ")", "{", "return", "nil", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "// Since we know this is a user tag (because AuthClient is true),", "// we just do the type assertion to the UserTag.", "apiUser", ",", "_", ":=", "authorizer", ".", "GetAuthTag", "(", ")", ".", "(", "names", ".", "UserTag", ")", "\n", "// Pretty much all of the user manager methods have special casing for admin", "// users, so look once when we start and remember if the user is an admin.", "isAdmin", ",", "err", ":=", "authorizer", ".", "HasPermission", "(", "permission", ".", "SuperuserAccess", ",", "st", ".", "ControllerTag", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "return", "&", "API", "{", "authorizer", ":", "authorizer", ",", "isControllerAdmin", ":", "isAdmin", ",", "apiUser", ":", "apiUser", ",", "st", ":", "st", ",", "model", ":", "m", ",", "}", ",", "nil", "\n", "}" ]
// NewModelGenerationAPI creates a new API endpoint for dealing with model generations.
[ "NewModelGenerationAPI", "creates", "a", "new", "API", "endpoint", "for", "dealing", "with", "model", "generations", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L46-L71
154,275
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
AddBranch
func (api *API) AddBranch(arg params.BranchArg) (params.ErrorResult, error) { result := params.ErrorResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } if err := model.ValidateBranchName(arg.BranchName); err != nil { result.Error = common.ServerError(err) } else { result.Error = common.ServerError(api.model.AddBranch(arg.BranchName, api.apiUser.Name())) } return result, nil }
go
func (api *API) AddBranch(arg params.BranchArg) (params.ErrorResult, error) { result := params.ErrorResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } if err := model.ValidateBranchName(arg.BranchName); err != nil { result.Error = common.ServerError(err) } else { result.Error = common.ServerError(api.model.AddBranch(arg.BranchName, api.apiUser.Name())) } return result, nil }
[ "func", "(", "api", "*", "API", ")", "AddBranch", "(", "arg", "params", ".", "BranchArg", ")", "(", "params", ".", "ErrorResult", ",", "error", ")", "{", "result", ":=", "params", ".", "ErrorResult", "{", "}", "\n", "isModelAdmin", ",", "err", ":=", "api", ".", "hasAdminAccess", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "!", "isModelAdmin", "&&", "!", "api", ".", "isControllerAdmin", "{", "return", "result", ",", "common", ".", "ErrPerm", "\n", "}", "\n\n", "if", "err", ":=", "model", ".", "ValidateBranchName", "(", "arg", ".", "BranchName", ")", ";", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "api", ".", "model", ".", "AddBranch", "(", "arg", ".", "BranchName", ",", "api", ".", "apiUser", ".", "Name", "(", ")", ")", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// AddBranch adds a new branch with the input name to the model.
[ "AddBranch", "adds", "a", "new", "branch", "with", "the", "input", "name", "to", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L82-L98
154,276
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
CommitBranch
func (api *API) CommitBranch(arg params.BranchArg) (params.IntResult, error) { result := params.IntResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } generation, err := api.model.Branch(arg.BranchName) if err != nil { return result, errors.Trace(err) } if genId, err := generation.Commit(api.apiUser.Name()); err != nil { result.Error = common.ServerError(err) } else { result.Result = genId } return result, nil }
go
func (api *API) CommitBranch(arg params.BranchArg) (params.IntResult, error) { result := params.IntResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } generation, err := api.model.Branch(arg.BranchName) if err != nil { return result, errors.Trace(err) } if genId, err := generation.Commit(api.apiUser.Name()); err != nil { result.Error = common.ServerError(err) } else { result.Result = genId } return result, nil }
[ "func", "(", "api", "*", "API", ")", "CommitBranch", "(", "arg", "params", ".", "BranchArg", ")", "(", "params", ".", "IntResult", ",", "error", ")", "{", "result", ":=", "params", ".", "IntResult", "{", "}", "\n\n", "isModelAdmin", ",", "err", ":=", "api", ".", "hasAdminAccess", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "!", "isModelAdmin", "&&", "!", "api", ".", "isControllerAdmin", "{", "return", "result", ",", "common", ".", "ErrPerm", "\n", "}", "\n\n", "generation", ",", "err", ":=", "api", ".", "model", ".", "Branch", "(", "arg", ".", "BranchName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "if", "genId", ",", "err", ":=", "generation", ".", "Commit", "(", "api", ".", "apiUser", ".", "Name", "(", ")", ")", ";", "err", "!=", "nil", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "else", "{", "result", ".", "Result", "=", "genId", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// CommitBranch commits the input branch, making its changes applicable to // the whole model and marking it complete.
[ "CommitBranch", "commits", "the", "input", "branch", "making", "its", "changes", "applicable", "to", "the", "whole", "model", "and", "marking", "it", "complete", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L140-L162
154,277
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
BranchInfo
func (api *API) BranchInfo(args params.BranchInfoArgs) (params.GenerationResults, error) { result := params.GenerationResults{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } // From clients, we expect a single branch name or none, // but we accommodate any number - they all must exist to avoid an error. // If no branch is supplied, get them all. var branches []Generation if len(args.BranchNames) > 0 { branches = make([]Generation, len(args.BranchNames)) for i, name := range args.BranchNames { if branches[i], err = api.model.Branch(name); err != nil { return generationInfoError(err) } } } else { if branches, err = api.model.Branches(); err != nil { return generationInfoError(err) } } results := make([]params.Generation, len(branches)) for i, b := range branches { if results[i], err = api.oneBranchInfo(b, args.Detailed); err != nil { return generationInfoError(err) } } result.Generations = results return result, nil }
go
func (api *API) BranchInfo(args params.BranchInfoArgs) (params.GenerationResults, error) { result := params.GenerationResults{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } // From clients, we expect a single branch name or none, // but we accommodate any number - they all must exist to avoid an error. // If no branch is supplied, get them all. var branches []Generation if len(args.BranchNames) > 0 { branches = make([]Generation, len(args.BranchNames)) for i, name := range args.BranchNames { if branches[i], err = api.model.Branch(name); err != nil { return generationInfoError(err) } } } else { if branches, err = api.model.Branches(); err != nil { return generationInfoError(err) } } results := make([]params.Generation, len(branches)) for i, b := range branches { if results[i], err = api.oneBranchInfo(b, args.Detailed); err != nil { return generationInfoError(err) } } result.Generations = results return result, nil }
[ "func", "(", "api", "*", "API", ")", "BranchInfo", "(", "args", "params", ".", "BranchInfoArgs", ")", "(", "params", ".", "GenerationResults", ",", "error", ")", "{", "result", ":=", "params", ".", "GenerationResults", "{", "}", "\n\n", "isModelAdmin", ",", "err", ":=", "api", ".", "hasAdminAccess", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "!", "isModelAdmin", "&&", "!", "api", ".", "isControllerAdmin", "{", "return", "result", ",", "common", ".", "ErrPerm", "\n", "}", "\n\n", "// From clients, we expect a single branch name or none,", "// but we accommodate any number - they all must exist to avoid an error.", "// If no branch is supplied, get them all.", "var", "branches", "[", "]", "Generation", "\n", "if", "len", "(", "args", ".", "BranchNames", ")", ">", "0", "{", "branches", "=", "make", "(", "[", "]", "Generation", ",", "len", "(", "args", ".", "BranchNames", ")", ")", "\n", "for", "i", ",", "name", ":=", "range", "args", ".", "BranchNames", "{", "if", "branches", "[", "i", "]", ",", "err", "=", "api", ".", "model", ".", "Branch", "(", "name", ")", ";", "err", "!=", "nil", "{", "return", "generationInfoError", "(", "err", ")", "\n", "}", "\n", "}", "\n", "}", "else", "{", "if", "branches", ",", "err", "=", "api", ".", "model", ".", "Branches", "(", ")", ";", "err", "!=", "nil", "{", "return", "generationInfoError", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "results", ":=", "make", "(", "[", "]", "params", ".", "Generation", ",", "len", "(", "branches", ")", ")", "\n", "for", "i", ",", "b", ":=", "range", "branches", "{", "if", "results", "[", "i", "]", ",", "err", "=", "api", ".", "oneBranchInfo", "(", "b", ",", "args", ".", "Detailed", ")", ";", "err", "!=", "nil", "{", "return", "generationInfoError", "(", "err", ")", "\n", "}", "\n", "}", "\n", "result", ".", "Generations", "=", "results", "\n", "return", "result", ",", "nil", "\n", "}" ]
// BranchInfo will return details of branch identified by the input argument, // including units on the branch and the configuration disjoint with the // master generation. // An error is returned if no in-flight branch matching in input is found.
[ "BranchInfo", "will", "return", "details", "of", "branch", "identified", "by", "the", "input", "argument", "including", "units", "on", "the", "branch", "and", "the", "configuration", "disjoint", "with", "the", "master", "generation", ".", "An", "error", "is", "returned", "if", "no", "in", "-", "flight", "branch", "matching", "in", "input", "is", "found", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L168-L204
154,278
juju/juju
apiserver/facades/client/modelgeneration/modelgeneration.go
HasActiveBranch
func (api *API) HasActiveBranch(arg params.BranchArg) (params.BoolResult, error) { result := params.BoolResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } if _, err := api.model.Branch(arg.BranchName); err != nil { if errors.IsNotFound(err) { result.Result = false } else { result.Error = common.ServerError(err) } } else { result.Result = true } return result, nil }
go
func (api *API) HasActiveBranch(arg params.BranchArg) (params.BoolResult, error) { result := params.BoolResult{} isModelAdmin, err := api.hasAdminAccess() if err != nil { return result, errors.Trace(err) } if !isModelAdmin && !api.isControllerAdmin { return result, common.ErrPerm } if _, err := api.model.Branch(arg.BranchName); err != nil { if errors.IsNotFound(err) { result.Result = false } else { result.Error = common.ServerError(err) } } else { result.Result = true } return result, nil }
[ "func", "(", "api", "*", "API", ")", "HasActiveBranch", "(", "arg", "params", ".", "BranchArg", ")", "(", "params", ".", "BoolResult", ",", "error", ")", "{", "result", ":=", "params", ".", "BoolResult", "{", "}", "\n", "isModelAdmin", ",", "err", ":=", "api", ".", "hasAdminAccess", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "!", "isModelAdmin", "&&", "!", "api", ".", "isControllerAdmin", "{", "return", "result", ",", "common", ".", "ErrPerm", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "api", ".", "model", ".", "Branch", "(", "arg", ".", "BranchName", ")", ";", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "result", ".", "Result", "=", "false", "\n", "}", "else", "{", "result", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "}", "else", "{", "result", ".", "Result", "=", "true", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// HasActiveBranch returns a true result if the input model has an "in-flight" // branch matching the input name.
[ "HasActiveBranch", "returns", "a", "true", "result", "if", "the", "input", "model", "has", "an", "in", "-", "flight", "branch", "matching", "the", "input", "name", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/modelgeneration.go#L256-L276
154,279
juju/juju
provider/openstack/provider.go
newGooseClient
func newGooseClient(endpoint string) client.AuthenticatingClient { // Use NonValidatingClient, in case the endpoint is behind a cert return client.NewNonValidatingClient(&identity.Credentials{URL: endpoint}, 0, nil) }
go
func newGooseClient(endpoint string) client.AuthenticatingClient { // Use NonValidatingClient, in case the endpoint is behind a cert return client.NewNonValidatingClient(&identity.Credentials{URL: endpoint}, 0, nil) }
[ "func", "newGooseClient", "(", "endpoint", "string", ")", "client", ".", "AuthenticatingClient", "{", "// Use NonValidatingClient, in case the endpoint is behind a cert", "return", "client", ".", "NewNonValidatingClient", "(", "&", "identity", ".", "Credentials", "{", "URL", ":", "endpoint", "}", ",", "0", ",", "nil", ")", "\n", "}" ]
// newGooseClient is the default function in EnvironProvider.ClientFromEndpoint.
[ "newGooseClient", "is", "the", "default", "function", "in", "EnvironProvider", ".", "ClientFromEndpoint", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L238-L241
154,280
juju/juju
provider/openstack/provider.go
getAddresses
func (inst *openstackInstance) getAddresses(ctx context.ProviderCallContext) (map[string][]nova.IPAddress, error) { addrs := inst.getServerDetail().Addresses if len(addrs) == 0 { server, err := inst.e.nova().GetServer(string(inst.Id())) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } addrs = server.Addresses } return addrs, nil }
go
func (inst *openstackInstance) getAddresses(ctx context.ProviderCallContext) (map[string][]nova.IPAddress, error) { addrs := inst.getServerDetail().Addresses if len(addrs) == 0 { server, err := inst.e.nova().GetServer(string(inst.Id())) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } addrs = server.Addresses } return addrs, nil }
[ "func", "(", "inst", "*", "openstackInstance", ")", "getAddresses", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "map", "[", "string", "]", "[", "]", "nova", ".", "IPAddress", ",", "error", ")", "{", "addrs", ":=", "inst", ".", "getServerDetail", "(", ")", ".", "Addresses", "\n", "if", "len", "(", "addrs", ")", "==", "0", "{", "server", ",", "err", ":=", "inst", ".", "e", ".", "nova", "(", ")", ".", "GetServer", "(", "string", "(", "inst", ".", "Id", "(", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "addrs", "=", "server", ".", "Addresses", "\n", "}", "\n", "return", "addrs", ",", "nil", "\n", "}" ]
// getAddresses returns the existing server information on addresses, // but fetches the details over the api again if no addresses exist.
[ "getAddresses", "returns", "the", "existing", "server", "information", "on", "addresses", "but", "fetches", "the", "details", "over", "the", "api", "again", "if", "no", "addresses", "exist", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L410-L421
154,281
juju/juju
provider/openstack/provider.go
convertNovaAddresses
func convertNovaAddresses(publicIP string, addresses map[string][]nova.IPAddress) []network.Address { var machineAddresses []network.Address if publicIP != "" { publicAddr := network.NewScopedAddress(publicIP, network.ScopePublic) machineAddresses = append(machineAddresses, publicAddr) } // TODO(gz) Network ordering may be significant but is not preserved by // the map, see lp:1188126 for example. That could potentially be fixed // in goose, or left to be derived by other means. for netName, ips := range addresses { networkScope := network.ScopeUnknown if netName == "public" { networkScope = network.ScopePublic } for _, address := range ips { // If this address has already been added as a floating IP, skip it. if publicIP == address.Address { continue } // Assume IPv4 unless specified otherwise addrtype := network.IPv4Address if address.Version == 6 { addrtype = network.IPv6Address } machineAddr := network.NewScopedAddress(address.Address, networkScope) if machineAddr.Type != addrtype { logger.Warningf("derived address type %v, nova reports %v", machineAddr.Type, addrtype) } machineAddresses = append(machineAddresses, machineAddr) } } return machineAddresses }
go
func convertNovaAddresses(publicIP string, addresses map[string][]nova.IPAddress) []network.Address { var machineAddresses []network.Address if publicIP != "" { publicAddr := network.NewScopedAddress(publicIP, network.ScopePublic) machineAddresses = append(machineAddresses, publicAddr) } // TODO(gz) Network ordering may be significant but is not preserved by // the map, see lp:1188126 for example. That could potentially be fixed // in goose, or left to be derived by other means. for netName, ips := range addresses { networkScope := network.ScopeUnknown if netName == "public" { networkScope = network.ScopePublic } for _, address := range ips { // If this address has already been added as a floating IP, skip it. if publicIP == address.Address { continue } // Assume IPv4 unless specified otherwise addrtype := network.IPv4Address if address.Version == 6 { addrtype = network.IPv6Address } machineAddr := network.NewScopedAddress(address.Address, networkScope) if machineAddr.Type != addrtype { logger.Warningf("derived address type %v, nova reports %v", machineAddr.Type, addrtype) } machineAddresses = append(machineAddresses, machineAddr) } } return machineAddresses }
[ "func", "convertNovaAddresses", "(", "publicIP", "string", ",", "addresses", "map", "[", "string", "]", "[", "]", "nova", ".", "IPAddress", ")", "[", "]", "network", ".", "Address", "{", "var", "machineAddresses", "[", "]", "network", ".", "Address", "\n", "if", "publicIP", "!=", "\"", "\"", "{", "publicAddr", ":=", "network", ".", "NewScopedAddress", "(", "publicIP", ",", "network", ".", "ScopePublic", ")", "\n", "machineAddresses", "=", "append", "(", "machineAddresses", ",", "publicAddr", ")", "\n", "}", "\n", "// TODO(gz) Network ordering may be significant but is not preserved by", "// the map, see lp:1188126 for example. That could potentially be fixed", "// in goose, or left to be derived by other means.", "for", "netName", ",", "ips", ":=", "range", "addresses", "{", "networkScope", ":=", "network", ".", "ScopeUnknown", "\n", "if", "netName", "==", "\"", "\"", "{", "networkScope", "=", "network", ".", "ScopePublic", "\n", "}", "\n", "for", "_", ",", "address", ":=", "range", "ips", "{", "// If this address has already been added as a floating IP, skip it.", "if", "publicIP", "==", "address", ".", "Address", "{", "continue", "\n", "}", "\n", "// Assume IPv4 unless specified otherwise", "addrtype", ":=", "network", ".", "IPv4Address", "\n", "if", "address", ".", "Version", "==", "6", "{", "addrtype", "=", "network", ".", "IPv6Address", "\n", "}", "\n", "machineAddr", ":=", "network", ".", "NewScopedAddress", "(", "address", ".", "Address", ",", "networkScope", ")", "\n", "if", "machineAddr", ".", "Type", "!=", "addrtype", "{", "logger", ".", "Warningf", "(", "\"", "\"", ",", "machineAddr", ".", "Type", ",", "addrtype", ")", "\n", "}", "\n", "machineAddresses", "=", "append", "(", "machineAddresses", ",", "machineAddr", ")", "\n", "}", "\n", "}", "\n", "return", "machineAddresses", "\n", "}" ]
// convertNovaAddresses returns nova addresses in generic format
[ "convertNovaAddresses", "returns", "nova", "addresses", "in", "generic", "format" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L439-L471
154,282
juju/juju
provider/openstack/provider.go
AvailabilityZones
func (e *Environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) { e.availabilityZonesMutex.Lock() defer e.availabilityZonesMutex.Unlock() if e.availabilityZones == nil { zones, err := novaListAvailabilityZones(e.nova()) if gooseerrors.IsNotImplemented(err) { return nil, errors.NotImplementedf("availability zones") } if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } e.availabilityZones = make([]common.AvailabilityZone, len(zones)) for i, z := range zones { e.availabilityZones[i] = &openstackAvailabilityZone{z} } } return e.availabilityZones, nil }
go
func (e *Environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) { e.availabilityZonesMutex.Lock() defer e.availabilityZonesMutex.Unlock() if e.availabilityZones == nil { zones, err := novaListAvailabilityZones(e.nova()) if gooseerrors.IsNotImplemented(err) { return nil, errors.NotImplementedf("availability zones") } if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } e.availabilityZones = make([]common.AvailabilityZone, len(zones)) for i, z := range zones { e.availabilityZones[i] = &openstackAvailabilityZone{z} } } return e.availabilityZones, nil }
[ "func", "(", "e", "*", "Environ", ")", "AvailabilityZones", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "common", ".", "AvailabilityZone", ",", "error", ")", "{", "e", ".", "availabilityZonesMutex", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "availabilityZonesMutex", ".", "Unlock", "(", ")", "\n", "if", "e", ".", "availabilityZones", "==", "nil", "{", "zones", ",", "err", ":=", "novaListAvailabilityZones", "(", "e", ".", "nova", "(", ")", ")", "\n", "if", "gooseerrors", ".", "IsNotImplemented", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "NotImplementedf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "e", ".", "availabilityZones", "=", "make", "(", "[", "]", "common", ".", "AvailabilityZone", ",", "len", "(", "zones", ")", ")", "\n", "for", "i", ",", "z", ":=", "range", "zones", "{", "e", ".", "availabilityZones", "[", "i", "]", "=", "&", "openstackAvailabilityZone", "{", "z", "}", "\n", "}", "\n", "}", "\n", "return", "e", ".", "availabilityZones", ",", "nil", "\n", "}" ]
// AvailabilityZones returns a slice of availability zones.
[ "AvailabilityZones", "returns", "a", "slice", "of", "availability", "zones", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L562-L580
154,283
juju/juju
provider/openstack/provider.go
newClientByType
func newClientByType( cred identity.Credentials, authMode identity.AuthMode, gooseLogger gooselogging.CompatLogger, sslHostnameVerification bool, certs []string, ) (client.AuthenticatingClient, error) { switch { case len(certs) > 0: tlsConfig := tlsConfig(certs) logger.Tracef("using NewClientTLSConfig") return client.NewClientTLSConfig(&cred, authMode, gooseLogger, tlsConfig), nil case sslHostnameVerification == false: logger.Tracef("using NewNonValidatingClient") return client.NewNonValidatingClient(&cred, authMode, gooseLogger), nil default: logger.Tracef("using NewClient") return client.NewClient(&cred, authMode, gooseLogger), nil } }
go
func newClientByType( cred identity.Credentials, authMode identity.AuthMode, gooseLogger gooselogging.CompatLogger, sslHostnameVerification bool, certs []string, ) (client.AuthenticatingClient, error) { switch { case len(certs) > 0: tlsConfig := tlsConfig(certs) logger.Tracef("using NewClientTLSConfig") return client.NewClientTLSConfig(&cred, authMode, gooseLogger, tlsConfig), nil case sslHostnameVerification == false: logger.Tracef("using NewNonValidatingClient") return client.NewNonValidatingClient(&cred, authMode, gooseLogger), nil default: logger.Tracef("using NewClient") return client.NewClient(&cred, authMode, gooseLogger), nil } }
[ "func", "newClientByType", "(", "cred", "identity", ".", "Credentials", ",", "authMode", "identity", ".", "AuthMode", ",", "gooseLogger", "gooselogging", ".", "CompatLogger", ",", "sslHostnameVerification", "bool", ",", "certs", "[", "]", "string", ",", ")", "(", "client", ".", "AuthenticatingClient", ",", "error", ")", "{", "switch", "{", "case", "len", "(", "certs", ")", ">", "0", ":", "tlsConfig", ":=", "tlsConfig", "(", "certs", ")", "\n", "logger", ".", "Tracef", "(", "\"", "\"", ")", "\n", "return", "client", ".", "NewClientTLSConfig", "(", "&", "cred", ",", "authMode", ",", "gooseLogger", ",", "tlsConfig", ")", ",", "nil", "\n", "case", "sslHostnameVerification", "==", "false", ":", "logger", ".", "Tracef", "(", "\"", "\"", ")", "\n", "return", "client", ".", "NewNonValidatingClient", "(", "&", "cred", ",", "authMode", ",", "gooseLogger", ")", ",", "nil", "\n", "default", ":", "logger", ".", "Tracef", "(", "\"", "\"", ")", "\n", "return", "client", ".", "NewClient", "(", "&", "cred", ",", "authMode", ",", "gooseLogger", ")", ",", "nil", "\n", "}", "\n", "}" ]
// newClientByType returns an authenticating client to talk to the // OpenStack cloud. CACertificate and SSLHostnameVerification == false // config options are mutually exclusive here.
[ "newClientByType", "returns", "an", "authenticating", "client", "to", "talk", "to", "the", "OpenStack", "cloud", ".", "CACertificate", "and", "SSLHostnameVerification", "==", "false", "config", "options", "are", "mutually", "exclusive", "here", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L830-L849
154,284
juju/juju
provider/openstack/provider.go
getKeystoneImageSource
func getKeystoneImageSource(env environs.Environ) (simplestreams.DataSource, error) { e, ok := env.(*Environ) if !ok { return nil, errors.NotSupportedf("non-openstack model") } return e.getKeystoneDataSource(&e.keystoneImageDataSourceMutex, &e.keystoneImageDataSource, "product-streams") }
go
func getKeystoneImageSource(env environs.Environ) (simplestreams.DataSource, error) { e, ok := env.(*Environ) if !ok { return nil, errors.NotSupportedf("non-openstack model") } return e.getKeystoneDataSource(&e.keystoneImageDataSourceMutex, &e.keystoneImageDataSource, "product-streams") }
[ "func", "getKeystoneImageSource", "(", "env", "environs", ".", "Environ", ")", "(", "simplestreams", ".", "DataSource", ",", "error", ")", "{", "e", ",", "ok", ":=", "env", ".", "(", "*", "Environ", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "NotSupportedf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "e", ".", "getKeystoneDataSource", "(", "&", "e", ".", "keystoneImageDataSourceMutex", ",", "&", "e", ".", "keystoneImageDataSource", ",", "\"", "\"", ")", "\n", "}" ]
// getKeystoneImageSource is an imagemetadata.ImageDataSourceFunc that // returns a DataSource using the "product-streams" keystone URL.
[ "getKeystoneImageSource", "is", "an", "imagemetadata", ".", "ImageDataSourceFunc", "that", "returns", "a", "DataSource", "using", "the", "product", "-", "streams", "keystone", "URL", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L956-L962
154,285
juju/juju
provider/openstack/provider.go
getKeystoneToolsSource
func getKeystoneToolsSource(env environs.Environ) (simplestreams.DataSource, error) { e, ok := env.(*Environ) if !ok { return nil, errors.NotSupportedf("non-openstack model") } return e.getKeystoneDataSource(&e.keystoneToolsDataSourceMutex, &e.keystoneToolsDataSource, "juju-tools") }
go
func getKeystoneToolsSource(env environs.Environ) (simplestreams.DataSource, error) { e, ok := env.(*Environ) if !ok { return nil, errors.NotSupportedf("non-openstack model") } return e.getKeystoneDataSource(&e.keystoneToolsDataSourceMutex, &e.keystoneToolsDataSource, "juju-tools") }
[ "func", "getKeystoneToolsSource", "(", "env", "environs", ".", "Environ", ")", "(", "simplestreams", ".", "DataSource", ",", "error", ")", "{", "e", ",", "ok", ":=", "env", ".", "(", "*", "Environ", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "NotSupportedf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "e", ".", "getKeystoneDataSource", "(", "&", "e", ".", "keystoneToolsDataSourceMutex", ",", "&", "e", ".", "keystoneToolsDataSource", ",", "\"", "\"", ")", "\n", "}" ]
// getKeystoneToolsSource is a tools.ToolsDataSourceFunc that // returns a DataSource using the "juju-tools" keystone URL.
[ "getKeystoneToolsSource", "is", "a", "tools", ".", "ToolsDataSourceFunc", "that", "returns", "a", "DataSource", "using", "the", "juju", "-", "tools", "keystone", "URL", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L966-L972
154,286
juju/juju
provider/openstack/provider.go
assignPublicIP
func (e *Environ) assignPublicIP(fip *string, serverId string) (err error) { if *fip == "" { return errors.Errorf("cannot assign a nil public IP to %q", serverId) } // At startup nw_info is not yet cached so this may fail // temporarily while the server is being built for a := common.LongAttempt.Start(); a.Next(); { err = e.nova().AddServerFloatingIP(serverId, *fip) if err == nil { return nil } } return err }
go
func (e *Environ) assignPublicIP(fip *string, serverId string) (err error) { if *fip == "" { return errors.Errorf("cannot assign a nil public IP to %q", serverId) } // At startup nw_info is not yet cached so this may fail // temporarily while the server is being built for a := common.LongAttempt.Start(); a.Next(); { err = e.nova().AddServerFloatingIP(serverId, *fip) if err == nil { return nil } } return err }
[ "func", "(", "e", "*", "Environ", ")", "assignPublicIP", "(", "fip", "*", "string", ",", "serverId", "string", ")", "(", "err", "error", ")", "{", "if", "*", "fip", "==", "\"", "\"", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "serverId", ")", "\n", "}", "\n", "// At startup nw_info is not yet cached so this may fail", "// temporarily while the server is being built", "for", "a", ":=", "common", ".", "LongAttempt", ".", "Start", "(", ")", ";", "a", ".", "Next", "(", ")", ";", "{", "err", "=", "e", ".", "nova", "(", ")", ".", "AddServerFloatingIP", "(", "serverId", ",", "*", "fip", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "return", "err", "\n", "}" ]
// assignPublicIP tries to assign the given floating IP address to the // specified server, or returns an error.
[ "assignPublicIP", "tries", "to", "assign", "the", "given", "floating", "IP", "address", "to", "the", "specified", "server", "or", "returns", "an", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1002-L1015
154,287
juju/juju
provider/openstack/provider.go
MaintainInstance
func (*Environ) MaintainInstance(ctx context.ProviderCallContext, args environs.StartInstanceParams) error { return nil }
go
func (*Environ) MaintainInstance(ctx context.ProviderCallContext, args environs.StartInstanceParams) error { return nil }
[ "func", "(", "*", "Environ", ")", "MaintainInstance", "(", "ctx", "context", ".", "ProviderCallContext", ",", "args", "environs", ".", "StartInstanceParams", ")", "error", "{", "return", "nil", "\n", "}" ]
// MaintainInstance is specified in the InstanceBroker interface.
[ "MaintainInstance", "is", "specified", "in", "the", "InstanceBroker", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1032-L1034
154,288
juju/juju
provider/openstack/provider.go
updateFloatingIPAddresses
func (e *Environ) updateFloatingIPAddresses(ctx context.ProviderCallContext, instances map[string]instances.Instance) error { servers, err := e.nova().ListServersDetail(jujuMachineFilter()) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return err } for _, server := range servers { // server.Addresses is a map with entries containing []nova.IPAddress for _, net := range server.Addresses { for _, addr := range net { if addr.Type == "floating" { instId := server.Id if inst, ok := instances[instId]; ok { instFip := &addr.Address inst.(*openstackInstance).floatingIP = instFip } } } } } return nil }
go
func (e *Environ) updateFloatingIPAddresses(ctx context.ProviderCallContext, instances map[string]instances.Instance) error { servers, err := e.nova().ListServersDetail(jujuMachineFilter()) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return err } for _, server := range servers { // server.Addresses is a map with entries containing []nova.IPAddress for _, net := range server.Addresses { for _, addr := range net { if addr.Type == "floating" { instId := server.Id if inst, ok := instances[instId]; ok { instFip := &addr.Address inst.(*openstackInstance).floatingIP = instFip } } } } } return nil }
[ "func", "(", "e", "*", "Environ", ")", "updateFloatingIPAddresses", "(", "ctx", "context", ".", "ProviderCallContext", ",", "instances", "map", "[", "string", "]", "instances", ".", "Instance", ")", "error", "{", "servers", ",", "err", ":=", "e", ".", "nova", "(", ")", ".", "ListServersDetail", "(", "jujuMachineFilter", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "err", "\n", "}", "\n", "for", "_", ",", "server", ":=", "range", "servers", "{", "// server.Addresses is a map with entries containing []nova.IPAddress", "for", "_", ",", "net", ":=", "range", "server", ".", "Addresses", "{", "for", "_", ",", "addr", ":=", "range", "net", "{", "if", "addr", ".", "Type", "==", "\"", "\"", "{", "instId", ":=", "server", ".", "Id", "\n", "if", "inst", ",", "ok", ":=", "instances", "[", "instId", "]", ";", "ok", "{", "instFip", ":=", "&", "addr", ".", "Address", "\n", "inst", ".", "(", "*", "openstackInstance", ")", ".", "floatingIP", "=", "instFip", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// updateFloatingIPAddresses updates the instances with any floating IP address // that have been assigned to those instances.
[ "updateFloatingIPAddresses", "updates", "the", "instances", "with", "any", "floating", "IP", "address", "that", "have", "been", "assigned", "to", "those", "instances", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1494-L1515
154,289
juju/juju
provider/openstack/provider.go
AllInstances
func (e *Environ) AllInstances(ctx context.ProviderCallContext) ([]instances.Instance, error) { tagFilter := tagValue{tags.JujuModel, e.ecfg().UUID()} instances, err := e.allInstances(ctx, tagFilter, e.ecfg().useFloatingIP()) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return instances, err } return instances, nil }
go
func (e *Environ) AllInstances(ctx context.ProviderCallContext) ([]instances.Instance, error) { tagFilter := tagValue{tags.JujuModel, e.ecfg().UUID()} instances, err := e.allInstances(ctx, tagFilter, e.ecfg().useFloatingIP()) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return instances, err } return instances, nil }
[ "func", "(", "e", "*", "Environ", ")", "AllInstances", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "instances", ".", "Instance", ",", "error", ")", "{", "tagFilter", ":=", "tagValue", "{", "tags", ".", "JujuModel", ",", "e", ".", "ecfg", "(", ")", ".", "UUID", "(", ")", "}", "\n", "instances", ",", "err", ":=", "e", ".", "allInstances", "(", "ctx", ",", "tagFilter", ",", "e", ".", "ecfg", "(", ")", ".", "useFloatingIP", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "instances", ",", "err", "\n", "}", "\n", "return", "instances", ",", "nil", "\n", "}" ]
// AllInstances returns all instances in this environment.
[ "AllInstances", "returns", "all", "instances", "in", "this", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1655-L1663
154,290
juju/juju
provider/openstack/provider.go
destroyControllerManagedEnvirons
func (e *Environ) destroyControllerManagedEnvirons(ctx context.ProviderCallContext, controllerUUID string) error { // Terminate all instances managed by the controller. insts, err := e.allControllerManagedInstances(ctx, controllerUUID, false) if err != nil { return errors.Annotate(err, "listing instances") } instIds := make([]instance.Id, len(insts)) for i, inst := range insts { instIds[i] = inst.Id() } if err := e.terminateInstances(ctx, instIds); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "terminating instances") } // Delete all volumes managed by the controller. cinder, err := e.cinderProvider() if err == nil { volumes, err := controllerCinderVolumes(cinder.storageAdapter, controllerUUID) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "listing volumes") } volIds := volumeInfoToVolumeIds(cinderToJujuVolumeInfos(volumes)) errs := foreachVolume(ctx, cinder.storageAdapter, volIds, destroyVolume) for i, err := range errs { if err == nil { continue } common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotatef(err, "destroying volume %q", volIds[i]) } } else if !errors.IsNotSupported(err) { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Trace(err) } // Security groups for hosted models are destroyed by the // DeleteAllControllerGroups method call from Destroy(). return nil }
go
func (e *Environ) destroyControllerManagedEnvirons(ctx context.ProviderCallContext, controllerUUID string) error { // Terminate all instances managed by the controller. insts, err := e.allControllerManagedInstances(ctx, controllerUUID, false) if err != nil { return errors.Annotate(err, "listing instances") } instIds := make([]instance.Id, len(insts)) for i, inst := range insts { instIds[i] = inst.Id() } if err := e.terminateInstances(ctx, instIds); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "terminating instances") } // Delete all volumes managed by the controller. cinder, err := e.cinderProvider() if err == nil { volumes, err := controllerCinderVolumes(cinder.storageAdapter, controllerUUID) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "listing volumes") } volIds := volumeInfoToVolumeIds(cinderToJujuVolumeInfos(volumes)) errs := foreachVolume(ctx, cinder.storageAdapter, volIds, destroyVolume) for i, err := range errs { if err == nil { continue } common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotatef(err, "destroying volume %q", volIds[i]) } } else if !errors.IsNotSupported(err) { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Trace(err) } // Security groups for hosted models are destroyed by the // DeleteAllControllerGroups method call from Destroy(). return nil }
[ "func", "(", "e", "*", "Environ", ")", "destroyControllerManagedEnvirons", "(", "ctx", "context", ".", "ProviderCallContext", ",", "controllerUUID", "string", ")", "error", "{", "// Terminate all instances managed by the controller.", "insts", ",", "err", ":=", "e", ".", "allControllerManagedInstances", "(", "ctx", ",", "controllerUUID", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "instIds", ":=", "make", "(", "[", "]", "instance", ".", "Id", ",", "len", "(", "insts", ")", ")", "\n", "for", "i", ",", "inst", ":=", "range", "insts", "{", "instIds", "[", "i", "]", "=", "inst", ".", "Id", "(", ")", "\n", "}", "\n", "if", "err", ":=", "e", ".", "terminateInstances", "(", "ctx", ",", "instIds", ")", ";", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Delete all volumes managed by the controller.", "cinder", ",", "err", ":=", "e", ".", "cinderProvider", "(", ")", "\n", "if", "err", "==", "nil", "{", "volumes", ",", "err", ":=", "controllerCinderVolumes", "(", "cinder", ".", "storageAdapter", ",", "controllerUUID", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "volIds", ":=", "volumeInfoToVolumeIds", "(", "cinderToJujuVolumeInfos", "(", "volumes", ")", ")", "\n", "errs", ":=", "foreachVolume", "(", "ctx", ",", "cinder", ".", "storageAdapter", ",", "volIds", ",", "destroyVolume", ")", "\n", "for", "i", ",", "err", ":=", "range", "errs", "{", "if", "err", "==", "nil", "{", "continue", "\n", "}", "\n", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "volIds", "[", "i", "]", ")", "\n", "}", "\n", "}", "else", "if", "!", "errors", ".", "IsNotSupported", "(", "err", ")", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "// Security groups for hosted models are destroyed by the", "// DeleteAllControllerGroups method call from Destroy().", "return", "nil", "\n", "}" ]
// destroyControllerManagedEnvirons destroys all environments managed by this // models's controller.
[ "destroyControllerManagedEnvirons", "destroys", "all", "environments", "managed", "by", "this", "models", "s", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1749-L1789
154,291
juju/juju
provider/openstack/provider.go
jujuMachineFilter
func jujuMachineFilter() *nova.Filter { filter := nova.NewFilter() filter.Set(nova.FilterServer, "juju-.*") return filter }
go
func jujuMachineFilter() *nova.Filter { filter := nova.NewFilter() filter.Set(nova.FilterServer, "juju-.*") return filter }
[ "func", "jujuMachineFilter", "(", ")", "*", "nova", ".", "Filter", "{", "filter", ":=", "nova", ".", "NewFilter", "(", ")", "\n", "filter", ".", "Set", "(", "nova", ".", "FilterServer", ",", "\"", "\"", ")", "\n", "return", "filter", "\n", "}" ]
// jujuMachineFilter returns a nova.Filter matching machines created by Juju. // The machines are not filtered to any particular environment. To do that, // instance tags must be compared.
[ "jujuMachineFilter", "returns", "a", "nova", ".", "Filter", "matching", "machines", "created", "by", "Juju", ".", "The", "machines", "are", "not", "filtered", "to", "any", "particular", "environment", ".", "To", "do", "that", "instance", "tags", "must", "be", "compared", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1798-L1802
154,292
juju/juju
provider/openstack/provider.go
rulesToRuleInfo
func rulesToRuleInfo(groupId string, rules []network.IngressRule) []neutron.RuleInfoV2 { var result []neutron.RuleInfoV2 for _, r := range rules { ruleInfo := neutron.RuleInfoV2{ Direction: "ingress", ParentGroupId: groupId, PortRangeMin: r.FromPort, PortRangeMax: r.ToPort, IPProtocol: r.Protocol, } sourceCIDRs := r.SourceCIDRs if len(sourceCIDRs) == 0 { sourceCIDRs = []string{"0.0.0.0/0"} } for _, sr := range sourceCIDRs { ruleInfo.RemoteIPPrefix = sr result = append(result, ruleInfo) } } return result }
go
func rulesToRuleInfo(groupId string, rules []network.IngressRule) []neutron.RuleInfoV2 { var result []neutron.RuleInfoV2 for _, r := range rules { ruleInfo := neutron.RuleInfoV2{ Direction: "ingress", ParentGroupId: groupId, PortRangeMin: r.FromPort, PortRangeMax: r.ToPort, IPProtocol: r.Protocol, } sourceCIDRs := r.SourceCIDRs if len(sourceCIDRs) == 0 { sourceCIDRs = []string{"0.0.0.0/0"} } for _, sr := range sourceCIDRs { ruleInfo.RemoteIPPrefix = sr result = append(result, ruleInfo) } } return result }
[ "func", "rulesToRuleInfo", "(", "groupId", "string", ",", "rules", "[", "]", "network", ".", "IngressRule", ")", "[", "]", "neutron", ".", "RuleInfoV2", "{", "var", "result", "[", "]", "neutron", ".", "RuleInfoV2", "\n", "for", "_", ",", "r", ":=", "range", "rules", "{", "ruleInfo", ":=", "neutron", ".", "RuleInfoV2", "{", "Direction", ":", "\"", "\"", ",", "ParentGroupId", ":", "groupId", ",", "PortRangeMin", ":", "r", ".", "FromPort", ",", "PortRangeMax", ":", "r", ".", "ToPort", ",", "IPProtocol", ":", "r", ".", "Protocol", ",", "}", "\n", "sourceCIDRs", ":=", "r", ".", "SourceCIDRs", "\n", "if", "len", "(", "sourceCIDRs", ")", "==", "0", "{", "sourceCIDRs", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "}", "\n", "for", "_", ",", "sr", ":=", "range", "sourceCIDRs", "{", "ruleInfo", ".", "RemoteIPPrefix", "=", "sr", "\n", "result", "=", "append", "(", "result", ",", "ruleInfo", ")", "\n", "}", "\n", "}", "\n", "return", "result", "\n", "}" ]
// rulesToRuleInfo maps ingress rules to nova rules
[ "rulesToRuleInfo", "maps", "ingress", "rules", "to", "nova", "rules" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1805-L1825
154,293
juju/juju
provider/openstack/provider.go
TagInstance
func (e *Environ) TagInstance(ctx context.ProviderCallContext, id instance.Id, tags map[string]string) error { if err := e.nova().SetServerMetadata(string(id), tags); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "setting server metadata") } return nil }
go
func (e *Environ) TagInstance(ctx context.ProviderCallContext, id instance.Id, tags map[string]string) error { if err := e.nova().SetServerMetadata(string(id), tags); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return errors.Annotate(err, "setting server metadata") } return nil }
[ "func", "(", "e", "*", "Environ", ")", "TagInstance", "(", "ctx", "context", ".", "ProviderCallContext", ",", "id", "instance", ".", "Id", ",", "tags", "map", "[", "string", "]", "string", ")", "error", "{", "if", "err", ":=", "e", ".", "nova", "(", ")", ".", "SetServerMetadata", "(", "string", "(", "id", ")", ",", "tags", ")", ";", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// TagInstance implements environs.InstanceTagger.
[ "TagInstance", "implements", "environs", ".", "InstanceTagger", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1908-L1914
154,294
juju/juju
provider/openstack/provider.go
Subnets
func (e *Environ) Subnets(ctx context.ProviderCallContext, instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) { subnets, err := e.networking.Subnets(instId, subnetIds) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return subnets, errors.Trace(err) } return subnets, nil }
go
func (e *Environ) Subnets(ctx context.ProviderCallContext, instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) { subnets, err := e.networking.Subnets(instId, subnetIds) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return subnets, errors.Trace(err) } return subnets, nil }
[ "func", "(", "e", "*", "Environ", ")", "Subnets", "(", "ctx", "context", ".", "ProviderCallContext", ",", "instId", "instance", ".", "Id", ",", "subnetIds", "[", "]", "network", ".", "Id", ")", "(", "[", "]", "network", ".", "SubnetInfo", ",", "error", ")", "{", "subnets", ",", "err", ":=", "e", ".", "networking", ".", "Subnets", "(", "instId", ",", "subnetIds", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "subnets", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "subnets", ",", "nil", "\n", "}" ]
// Subnets is specified on environs.Networking.
[ "Subnets", "is", "specified", "on", "environs", ".", "Networking", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1948-L1955
154,295
juju/juju
provider/openstack/provider.go
NetworkInterfaces
func (e *Environ) NetworkInterfaces(ctx context.ProviderCallContext, instId instance.Id) ([]network.InterfaceInfo, error) { infos, err := e.networking.NetworkInterfaces(instId) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return infos, errors.Trace(err) } return infos, nil }
go
func (e *Environ) NetworkInterfaces(ctx context.ProviderCallContext, instId instance.Id) ([]network.InterfaceInfo, error) { infos, err := e.networking.NetworkInterfaces(instId) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return infos, errors.Trace(err) } return infos, nil }
[ "func", "(", "e", "*", "Environ", ")", "NetworkInterfaces", "(", "ctx", "context", ".", "ProviderCallContext", ",", "instId", "instance", ".", "Id", ")", "(", "[", "]", "network", ".", "InterfaceInfo", ",", "error", ")", "{", "infos", ",", "err", ":=", "e", ".", "networking", ".", "NetworkInterfaces", "(", "instId", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "infos", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "infos", ",", "nil", "\n", "}" ]
// NetworkInterfaces is specified on environs.Networking.
[ "NetworkInterfaces", "is", "specified", "on", "environs", ".", "Networking", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1958-L1965
154,296
juju/juju
provider/openstack/provider.go
SuperSubnets
func (e *Environ) SuperSubnets(ctx context.ProviderCallContext) ([]string, error) { subnets, err := e.networking.Subnets("", nil) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } cidrs := make([]string, len(subnets)) for i, subnet := range subnets { cidrs[i] = subnet.CIDR } return cidrs, nil }
go
func (e *Environ) SuperSubnets(ctx context.ProviderCallContext) ([]string, error) { subnets, err := e.networking.Subnets("", nil) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, err } cidrs := make([]string, len(subnets)) for i, subnet := range subnets { cidrs[i] = subnet.CIDR } return cidrs, nil }
[ "func", "(", "e", "*", "Environ", ")", "SuperSubnets", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "string", ",", "error", ")", "{", "subnets", ",", "err", ":=", "e", ".", "networking", ".", "Subnets", "(", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "cidrs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "subnets", ")", ")", "\n", "for", "i", ",", "subnet", ":=", "range", "subnets", "{", "cidrs", "[", "i", "]", "=", "subnet", ".", "CIDR", "\n", "}", "\n", "return", "cidrs", ",", "nil", "\n", "}" ]
// SuperSubnets is specified on environs.Networking
[ "SuperSubnets", "is", "specified", "on", "environs", ".", "Networking" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L1988-L1999
154,297
juju/juju
provider/openstack/provider.go
SSHAddresses
func (*Environ) SSHAddresses(ctx context.ProviderCallContext, addresses []network.Address) ([]network.Address, error) { return addresses, nil }
go
func (*Environ) SSHAddresses(ctx context.ProviderCallContext, addresses []network.Address) ([]network.Address, error) { return addresses, nil }
[ "func", "(", "*", "Environ", ")", "SSHAddresses", "(", "ctx", "context", ".", "ProviderCallContext", ",", "addresses", "[", "]", "network", ".", "Address", ")", "(", "[", "]", "network", ".", "Address", ",", "error", ")", "{", "return", "addresses", ",", "nil", "\n", "}" ]
// SSHAddresses is specified on environs.SSHAddresses.
[ "SSHAddresses", "is", "specified", "on", "environs", ".", "SSHAddresses", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/provider.go#L2022-L2024
154,298
juju/juju
cmd/juju/application/removesaas.go
NewRemoveSaasCommand
func NewRemoveSaasCommand() cmd.Command { cmd := &removeSaasCommand{} cmd.newAPIFunc = func() (RemoveSaasAPI, error) { root, err := cmd.NewAPIRoot() if err != nil { return nil, errors.Trace(err) } return application.NewClient(root), nil } return modelcmd.Wrap(cmd) }
go
func NewRemoveSaasCommand() cmd.Command { cmd := &removeSaasCommand{} cmd.newAPIFunc = func() (RemoveSaasAPI, error) { root, err := cmd.NewAPIRoot() if err != nil { return nil, errors.Trace(err) } return application.NewClient(root), nil } return modelcmd.Wrap(cmd) }
[ "func", "NewRemoveSaasCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "removeSaasCommand", "{", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "RemoveSaasAPI", ",", "error", ")", "{", "root", ",", "err", ":=", "cmd", ".", "NewAPIRoot", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "application", ".", "NewClient", "(", "root", ")", ",", "nil", "\n", "}", "\n", "return", "modelcmd", ".", "Wrap", "(", "cmd", ")", "\n", "}" ]
// NewRemoveSaasCommand returns a command which removes a consumed application.
[ "NewRemoveSaasCommand", "returns", "a", "command", "which", "removes", "a", "consumed", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/removesaas.go#L19-L29
154,299
juju/juju
provider/gce/google/conn.go
Connect
func Connect(connCfg ConnectionConfig, creds *Credentials) (*Connection, error) { raw, err := newRawConnection(creds) if err != nil { return nil, errors.Trace(err) } conn := &Connection{ raw: &rawConn{raw}, region: connCfg.Region, projectID: connCfg.ProjectID, } return conn, nil }
go
func Connect(connCfg ConnectionConfig, creds *Credentials) (*Connection, error) { raw, err := newRawConnection(creds) if err != nil { return nil, errors.Trace(err) } conn := &Connection{ raw: &rawConn{raw}, region: connCfg.Region, projectID: connCfg.ProjectID, } return conn, nil }
[ "func", "Connect", "(", "connCfg", "ConnectionConfig", ",", "creds", "*", "Credentials", ")", "(", "*", "Connection", ",", "error", ")", "{", "raw", ",", "err", ":=", "newRawConnection", "(", "creds", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "conn", ":=", "&", "Connection", "{", "raw", ":", "&", "rawConn", "{", "raw", "}", ",", "region", ":", "connCfg", ".", "Region", ",", "projectID", ":", "connCfg", ".", "ProjectID", ",", "}", "\n", "return", "conn", ",", "nil", "\n", "}" ]
// Connect authenticates using the provided credentials and opens a // low-level connection to the GCE API for the Connection. Calling // Connect after a successful connection has already been made will // result in an error. All errors that happen while authenticating and // connecting are returned by Connect.
[ "Connect", "authenticates", "using", "the", "provided", "credentials", "and", "opens", "a", "low", "-", "level", "connection", "to", "the", "GCE", "API", "for", "the", "Connection", ".", "Calling", "Connect", "after", "a", "successful", "connection", "has", "already", "been", "made", "will", "result", "in", "an", "error", ".", "All", "errors", "that", "happen", "while", "authenticating", "and", "connecting", "are", "returned", "by", "Connect", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/conn.go#L130-L142