本文整理汇总了Golang中github.com/juju/juju/state/api/params.ErrorResults类的典型用法代码示例。如果您正苦于以下问题:Golang ErrorResults类的具体用法?Golang ErrorResults怎么用?Golang ErrorResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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 := call(c.st, "RemoveUser", p, results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
示例2: EnsureDead
// EnsureDead sets the machine lifecycle to Dead if it is Alive or
// Dying. It does nothing otherwise.
func (m *Machine) EnsureDead() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag}},
}
err := m.st.call("EnsureDead", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例3: Remove
// Remove removes the unit from state, calling EnsureDead first, then Remove.
// It will fail if the unit is not present.
func (u *Unit) Remove() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: u.tag}},
}
err := u.st.call("Remove", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例4: Remove
// Remove removes the machine from state. It will fail if the machine
// is not Dead.
func (m *Machine) Remove() error {
var result params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag.String()}},
}
err := m.st.call("Remove", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例5: SetMachineAddresses
// SetMachineAddresses sets the machine determined addresses of the machine.
func (m *Machine) SetMachineAddresses(addresses []network.Address) error {
var result params.ErrorResults
args := params.SetMachinesAddresses{
MachineAddresses: []params.MachineAddresses{
{Tag: m.Tag(), Addresses: addresses},
},
}
err := m.st.call("SetMachineAddresses", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例6: SetPassword
// SetPassword sets the unit's password.
func (u *Unit) SetPassword(password string) error {
var result params.ErrorResults
args := params.EntityPasswords{
Changes: []params.EntityPassword{
{Tag: u.tag, Password: password},
},
}
err := u.st.call("SetPasswords", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例7: SetPassword
func (c *Client) SetPassword(username, password string) error {
userArgs := usermanager.ModifyUsers{
Changes: []usermanager.ModifyUser{{
Username: username,
Password: password}},
}
results := new(params.ErrorResults)
err := call(c.st, "SetPassword", userArgs, results)
if err != nil {
return err
}
return results.OneError()
}
示例8: SetPassword
// SetPassword sets the machine's password.
func (m *Machine) SetPassword(password string) error {
var result params.ErrorResults
args := params.EntityPasswords{
Changes: []params.EntityPassword{
{Tag: m.tag.String(), Password: password},
},
}
err := m.st.call("SetPasswords", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例9: SetPassword
// SetPassword sets the password associated with the agent's entity.
func (m *Entity) SetPassword(password string) error {
var results params.ErrorResults
args := params.EntityPasswords{
Changes: []params.EntityPassword{{
Tag: m.tag,
Password: password,
}},
}
err := m.st.caller.Call("Agent", "", "SetPasswords", args, &results)
if err != nil {
return err
}
return results.OneError()
}
示例10: LeaveScope
// LeaveScope signals that the unit has left its scope in the relation.
// After the unit has left its relation scope, it is no longer a member
// of the relation; if the relation is dying when its last member unit
// leaves, it is removed immediately. It is not an error to leave a scope
// that the unit is not, or never was, a member of.
func (ru *RelationUnit) LeaveScope() error {
var result params.ErrorResults
args := params.RelationUnits{
RelationUnits: []params.RelationUnit{{
Relation: ru.relation.tag,
Unit: ru.unit.tag,
}},
}
err := ru.st.call("LeaveScope", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例11: AddUser
func (c *Client) AddUser(username, displayName, password string) error {
if !names.IsValidUser(username) {
return fmt.Errorf("invalid user name %q", username)
}
userArgs := usermanager.ModifyUsers{
Changes: []usermanager.ModifyUser{{Username: username, DisplayName: displayName, Password: password}},
}
results := new(params.ErrorResults)
err := call(c.st, "AddUser", userArgs, results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
示例12: SetVersion
// SetVersion sets the tools version associated with the entity with
// the given tag, which must be the tag of the entity that the
// upgrader is running on behalf of.
func (st *State) SetVersion(tag string, v version.Binary) error {
var results params.ErrorResults
args := params.EntitiesVersion{
AgentTools: []params.EntityVersion{{
Tag: tag,
Tools: ¶ms.Version{v},
}},
}
err := st.call("SetTools", args, &results)
if err != nil {
// TODO: Not directly tested
return err
}
return results.OneError()
}
示例13: ImportKeys
// ImportKeys imports new authorised ssh keys from the specified key ids for the specified user.
func (api *KeyManagerAPI) ImportKeys(arg params.ModifyUserSSHKeys) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(arg.Keys)),
}
if len(arg.Keys) == 0 {
return result, nil
}
canWrite, err := api.getCanWrite()
if err != nil {
return params.ErrorResults{}, common.ServerError(err)
}
if !canWrite(arg.User) {
return params.ErrorResults{}, common.ServerError(common.ErrPerm)
}
// For now, authorised keys are global, common to all users.
sshKeys, currentFingerprints, err := api.currentKeyDataForAdd()
if err != nil {
return params.ErrorResults{}, common.ServerError(fmt.Errorf("reading current key data: %v", err))
}
importedKeyInfo := runSSHKeyImport(arg.Keys)
// Ensure we are not going to add invalid or duplicate keys.
result.Results = make([]params.ErrorResult, len(importedKeyInfo))
for i, keyInfo := range importedKeyInfo {
if keyInfo.err != nil {
result.Results[i].Error = common.ServerError(keyInfo.err)
continue
}
if currentFingerprints.Contains(keyInfo.fingerprint) {
result.Results[i].Error = common.ServerError(fmt.Errorf("duplicate ssh key: %s", keyInfo.key))
continue
}
sshKeys = append(sshKeys, keyInfo.key)
}
err = api.writeSSHKeys(sshKeys)
if err != nil {
return params.ErrorResults{}, common.ServerError(err)
}
return result, nil
}
示例14: SetInstanceInfo
// SetInstanceInfo sets the provider specific instance id, nonce,
// metadata, networks and interfaces for this machine. Once set, the
// instance id cannot be changed.
func (m *Machine) SetInstanceInfo(
id instance.Id, nonce string, characteristics *instance.HardwareCharacteristics,
networks []params.Network, interfaces []params.NetworkInterface,
) error {
var result params.ErrorResults
args := params.InstancesInfo{
Machines: []params.InstanceInfo{{
Tag: m.tag,
InstanceId: id,
Nonce: nonce,
Characteristics: characteristics,
Networks: networks,
Interfaces: interfaces,
}},
}
err := m.st.call("SetInstanceInfo", args, &result)
if err != nil {
return err
}
return result.OneError()
}
示例15: Write
// Write writes changes made to s back onto its node. Keys set to
// empty values will be deleted, others will be updated to the new
// value.
//
// TODO(dimitern): 2013-09-06 bug 1221798
// Once the machine addressability changes lands, we may need to
// revise the logic here to take into account that the
// "private-address" setting for a unit can be changed outside of the
// uniter's control. So we may need to send diffs of what has changed
// to make sure we update the address (and other settings) correctly,
// without overwritting.
func (s *Settings) Write() error {
// First make a copy of the map, including deleted keys.
settingsCopy := make(params.RelationSettings)
for k, v := range s.settings {
settingsCopy[k] = v
}
var result params.ErrorResults
args := params.RelationUnitsSettings{
RelationUnits: []params.RelationUnitSettings{{
Relation: s.relationTag,
Unit: s.unitTag,
Settings: settingsCopy,
}},
}
err := s.st.call("UpdateSettings", args, &result)
if err != nil {
return err
}
return result.OneError()
}