本文整理汇总了Golang中github.com/juju/juju/apiserver/params.ErrorResults类的典型用法代码示例。如果您正苦于以下问题:Golang ErrorResults类的具体用法?Golang ErrorResults怎么用?Golang ErrorResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorResults类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SetStatus
// SetStatus sets the status of the service if the passed unitName,
// corresponding to the calling unit, is of the leader.
func (s *Service) SetStatus(unitName string, status params.Status, info string, data map[string]interface{}) error {
//TODO(perrito666) bump api version for this?
if s.st.facade.BestAPIVersion() < 2 {
return errors.NotImplementedf("SetStatus")
}
tag := names.NewUnitTag(unitName)
var result params.ErrorResults
args := params.SetStatus{
Entities: []params.EntityStatusArgs{
{
Tag: tag.String(),
Status: status,
Info: info,
Data: data,
},
},
}
err := s.st.facade.FacadeCall("SetServiceStatus", args, &result)
if err != nil {
if params.IsCodeNotImplemented(err) {
return errors.NotImplementedf("SetServiceStatus")
}
return errors.Trace(err)
}
return result.OneError()
}
开发者ID:felicianotech,项目名称:juju,代码行数:28,代码来源:service.go
示例2: Deploy
// Deploy obtains the charm, either locally or from the charm store,
// and deploys it. It allows the specification of requested networks
// that must be present on the machines where the service is
// deployed. Another way to specify networks to include/exclude is
// using constraints. Placement directives, if provided, specify the
// machine on which the charm is deployed.
func (c *Client) Deploy(args DeployArgs) error {
deployArgs := params.ServicesDeploy{
Services: []params.ServiceDeploy{{
ServiceName: args.ServiceName,
Series: args.Series,
CharmUrl: args.CharmID.URL.String(),
Channel: string(args.CharmID.Channel),
NumUnits: args.NumUnits,
ConfigYAML: args.ConfigYAML,
Constraints: args.Cons,
Placement: args.Placement,
Networks: args.Networks,
Storage: args.Storage,
EndpointBindings: args.EndpointBindings,
Resources: args.Resources,
}},
}
var results params.ErrorResults
var err error
err = c.facade.FacadeCall("Deploy", deployArgs, &results)
if err != nil {
return err
}
return results.OneError()
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:31,代码来源:client.go
示例3: ServiceDeploy
// ServiceDeploy obtains the charm, either locally or from
// the charm store, and deploys it. It allows the specification of
// requested networks that must be present on the machines where the
// service is deployed. Another way to specify networks to include/exclude
// is using constraints.
func (c *Client) ServiceDeploy(
charmURL string,
serviceName string,
numUnits int,
configYAML string,
cons constraints.Value,
toMachineSpec string,
networks []string,
storage map[string]storage.Constraints,
) error {
args := params.ServicesDeploy{
Services: []params.ServiceDeploy{{
ServiceName: serviceName,
CharmUrl: charmURL,
NumUnits: numUnits,
ConfigYAML: configYAML,
Constraints: cons,
ToMachineSpec: toMachineSpec,
Networks: networks,
Storage: storage,
}},
}
var results params.ErrorResults
err := c.facade.FacadeCall("ServicesDeploy", args, &results)
if err != nil {
return err
}
return results.OneError()
}
开发者ID:Pankov404,项目名称:juju,代码行数:34,代码来源:client.go
示例4: DeleteImages
// DeleteImages deletes the images matching the specified filter.
func (api *ImageManagerAPI) DeleteImages(arg params.ImageFilterParams) (params.ErrorResults, error) {
if err := api.check.ChangeAllowed(); err != nil {
return params.ErrorResults{}, errors.Trace(err)
}
var result params.ErrorResults
result.Results = make([]params.ErrorResult, len(arg.Images))
stor := api.state.ImageStorage()
for i, imageSpec := range arg.Images {
filter := imagestorage.ImageFilter{
Kind: imageSpec.Kind,
Series: imageSpec.Series,
Arch: imageSpec.Arch,
}
imageMetadata, err := stor.ListImages(filter)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
if len(imageMetadata) != 1 {
result.Results[i].Error = common.ServerError(
errors.NotFoundf("image %s/%s/%s", filter.Kind, filter.Series, filter.Arch))
continue
}
logger.Infof("deleting image with metadata %+v", *imageMetadata[0])
err = stor.DeleteImage(imageMetadata[0])
if err != nil {
result.Results[i].Error = common.ServerError(err)
}
}
return result, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:32,代码来源:imagemanager.go
示例5: modifyControllerUser
func (c *Client) modifyControllerUser(action params.ControllerAction, user, access string) error {
var args params.ModifyControllerAccessRequest
if !names.IsValidUser(user) {
return errors.Errorf("invalid username: %q", user)
}
userTag := names.NewUserTag(user)
args.Changes = []params.ModifyControllerAccess{{
UserTag: userTag.String(),
Action: action,
Access: access,
}}
var result params.ErrorResults
err := c.facade.FacadeCall("ModifyControllerAccess", args, &result)
if err != nil {
return errors.Trace(err)
}
if len(result.Results) != len(args.Changes) {
return errors.Errorf("expected %d results, got %d", len(args.Changes), len(result.Results))
}
return result.Combine()
}
开发者ID:kat-co,项目名称:juju,代码行数:25,代码来源:controller.go
示例6: Deploy
// Deploy obtains the charm, either locally or from
// the charm store, and deploys it. It allows the specification of
// requested networks that must be present on the machines where the
// service is deployed. Another way to specify networks to include/exclude
// is using constraints. Placement directives, if provided, specify the
// machine on which the charm is deployed.
func (c *Client) Deploy(
charmURL string,
serviceName string,
series string,
numUnits int,
configYAML string,
cons constraints.Value,
placement []*instance.Placement,
networks []string,
storage map[string]storage.Constraints,
) error {
args := params.ServicesDeploy{
Services: []params.ServiceDeploy{{
ServiceName: serviceName,
Series: series,
CharmUrl: charmURL,
NumUnits: numUnits,
ConfigYAML: configYAML,
Constraints: cons,
Placement: placement,
Networks: networks,
Storage: storage,
}},
}
var results params.ErrorResults
var err error
err = c.facade.FacadeCall("Deploy", args, &results)
if err != nil {
return err
}
return results.OneError()
}
开发者ID:exekias,项目名称:juju,代码行数:38,代码来源:client.go
示例7: ShareModel
// ShareModel allows the given users access to the model.
func (c *Client) ShareModel(users ...names.UserTag) error {
var args params.ModifyModelUsers
for _, user := range users {
if &user != nil {
args.Changes = append(args.Changes, params.ModifyModelUser{
UserTag: user.String(),
Action: params.AddModelUser,
})
}
}
var result params.ErrorResults
err := c.facade.FacadeCall("ShareModel", args, &result)
if err != nil {
return errors.Trace(err)
}
for i, r := range result.Results {
if r.Error != nil && r.Error.Code == params.CodeAlreadyExists {
logger.Warningf("model is already shared with %s", users[i].Canonical())
result.Results[i].Error = nil
}
}
return result.Combine()
}
开发者ID:exekias,项目名称:juju,代码行数:26,代码来源:client.go
示例8: enableUserImpl
func (api *UserManagerAPI) enableUserImpl(args params.Entities, action string, method func(*state.User) error) (params.ErrorResults, error) {
var result params.ErrorResults
if len(args.Entities) == 0 {
return result, nil
}
isSuperUser, err := api.hasControllerAdminAccess()
if err != nil {
return result, errors.Trace(err)
}
if !api.isAdmin && isSuperUser {
return result, common.ErrPerm
}
// Create the results list to populate.
result.Results = make([]params.ErrorResult, len(args.Entities))
for i, arg := range args.Entities {
user, err := api.getUser(arg.Tag)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = method(user)
if err != nil {
result.Results[i].Error = common.ServerError(errors.Errorf("failed to %s user: %s", action, err))
}
}
return result, nil
}
开发者ID:bac,项目名称:juju,代码行数:32,代码来源:usermanager.go
示例9: UnshareEnvironment
// UnshareEnvironment removes access to the environment for the given users.
func (c *Client) UnshareEnvironment(users ...names.UserTag) error {
var args params.ModifyEnvironUsers
for _, user := range users {
if &user != nil {
args.Changes = append(args.Changes, params.ModifyEnvironUser{
UserTag: user.String(),
Action: params.RemoveEnvUser,
})
}
}
var result params.ErrorResults
err := c.facade.FacadeCall("ShareEnvironment", args, &result)
if err != nil {
return errors.Trace(err)
}
for i, r := range result.Results {
if r.Error != nil && r.Error.Code == params.CodeNotFound {
logger.Warningf("environment was not previously shared with user %s", users[i].Username())
result.Results[i].Error = nil
}
}
return result.Combine()
}
开发者ID:Pankov404,项目名称:juju,代码行数:26,代码来源:client.go
示例10: SetStatus
// SetStatus sets the status of storage entities.
func (st *State) SetStatus(args []params.EntityStatusArgs) error {
var result params.ErrorResults
err := st.facade.FacadeCall("SetStatus", params.SetStatus{args}, &result)
if err != nil {
return err
}
return result.Combine()
}
开发者ID:felicianotech,项目名称:juju,代码行数:9,代码来源:provisioner.go
示例11: SetAgentStatus
// SetAgentStatus sets the status of the unit agents.
func (a API) SetAgentStatus(args params.SetStatus) error {
var result params.ErrorResults
err := a.facade.FacadeCall("SetAgentStatus", args, &result)
if err != nil {
return err
}
return result.Combine()
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:unitassigner.go
示例12: RemoveUser
func (c *Client) RemoveUser(tag string) error {
u := params.Entity{Tag: tag}
p := params.Entities{Entities: []params.Entity{u}}
results := new(params.ErrorResults)
err := c.facade.FacadeCall("RemoveUser", p, results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
开发者ID:kapilt,项目名称:juju,代码行数:10,代码来源:client.go
示例13: Remove
// Remove removes the IP address.
func (a *IPAddress) Remove() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: a.tag.String()}},
}
err := a.facade.FacadeCall("Remove", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:12,代码来源:ipaddress.go
示例14: EnsureDead
// EnsureDead sets the unit lifecycle to Dead if it is Alive or
// Dying. It does nothing otherwise.
func (u *Unit) EnsureDead() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: u.tag.String()}},
}
err := u.st.facade.FacadeCall("EnsureDead", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:kapilt,项目名称:juju,代码行数:13,代码来源:unit.go
示例15: SetInstanceStatus
// SetInstanceStatus sets the instance status of the machine.
func (m *Machine) SetInstanceStatus(status string) error {
var result params.ErrorResults
args := params.SetInstancesStatus{Entities: []params.InstanceStatus{
{Tag: m.tag.String(), Status: status},
}}
err := m.facade.FacadeCall("SetInstanceStatus", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:machine.go
示例16: DestroyAllSubordinates
// DestroyAllSubordinates destroys all subordinates of the unit.
func (u *Unit) DestroyAllSubordinates() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: u.tag.String()}},
}
err := u.st.facade.FacadeCall("DestroyAllSubordinates", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:kapilt,项目名称:juju,代码行数:12,代码来源:unit.go
示例17: CreateSpace
// CreateSpace creates a new Juju network space, associating the
// specified subnets with it (optional; can be empty).
func (api *API) CreateSpace(name string, subnetIds []string, public bool) error {
var response params.ErrorResults
params := params.CreateSpacesParams{
Spaces: []params.CreateSpaceParams{makeCreateSpaceParams(name, subnetIds, public)},
}
err := api.facade.FacadeCall("CreateSpaces", params, &response)
if err != nil {
return errors.Trace(err)
}
return response.OneError()
}
开发者ID:mhilton,项目名称:juju,代码行数:13,代码来源:spaces.go
示例18: SendMetrics
// SendMetrics will send any unsent metrics to the collection service.
func (c *Client) SendMetrics() error {
p := params.Entities{Entities: []params.Entity{
{c.modelTag.String()},
}}
var results params.ErrorResults
err := c.facade.FacadeCall("SendMetrics", p, &results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:client.go
示例19: SetProviderNetworkConfig
// SetProviderNetworkConfig sets the machine network config as seen by the
// provider.
func (m *Machine) SetProviderNetworkConfig() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag.String()}},
}
err := m.st.facade.FacadeCall("SetProviderNetworkConfig", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:machine.go
示例20: SetInstanceStatus
// SetInstanceStatus sets the status for the provider instance.
func (m *Machine) SetInstanceStatus(status status.Status, message string, data map[string]interface{}) error {
var result params.ErrorResults
args := params.SetStatus{Entities: []params.EntityStatusArgs{
{Tag: m.tag.String(), Status: status.String(), Info: message, Data: data},
}}
err := m.st.facade.FacadeCall("SetInstanceStatus", args, &result)
if err != nil {
return err
}
return result.OneError()
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:machine.go
注:本文中的github.com/juju/juju/apiserver/params.ErrorResults类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论