示例#1
0
文件: client.go 项目: jameinel/core
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.call("RemoveUser", p, results)
	if err != nil {
		return err
	}
	return results.OneError()
}
示例#2
0
文件: client.go 项目: jameinel/core
func (c *Client) AddUser(tag, password string) error {
	u := params.EntityPassword{Tag: tag, Password: password}
	p := params.EntityPasswords{Changes: []params.EntityPassword{u}}
	results := new(params.ErrorResults)
	err := c.call("AddUser", p, results)
	if err != nil {
		return err
	}
	return results.OneError()
}
示例#3
0
文件: machine.go 项目: jameinel/core
// 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}},
	}
	err := m.st.call("Remove", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#4
0
文件: unit.go 项目: jameinel/core
// 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}},
	}
	err := u.st.call("EnsureDead", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#5
0
文件: unit.go 项目: jameinel/core
// 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}},
	}
	err := u.st.call("DestroyAllSubordinates", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#6
0
文件: machine.go 项目: jameinel/core
// SetStatus sets the status of the machine.
func (m *Machine) SetStatus(status params.Status, info string, data params.StatusData) error {
	var result params.ErrorResults
	args := params.SetStatus{
		Entities: []params.EntityStatus{
			{Tag: m.tag, Status: status, Info: info, Data: data},
		},
	}
	err := m.st.call("SetStatus", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#7
0
文件: machine.go 项目: jameinel/core
// 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, Password: password},
		},
	}
	err := m.st.call("SetPasswords", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#8
0
文件: unit.go 项目: jameinel/core
// ClosePort sets the policy of the port with protocol and number to
// be closed.
//
// TODO: We should really be opening and closing ports on machines,
// rather than units.
func (u *Unit) ClosePort(protocol string, number int) error {
	var result params.ErrorResults
	args := params.EntitiesPorts{
		Entities: []params.EntityPort{
			{Tag: u.tag, Protocol: protocol, Port: number},
		},
	}
	err := u.st.call("ClosePort", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#9
0
文件: machine.go 项目: jameinel/core
// SetMachineAddresses sets the machine determined addresses of the machine.
func (m *Machine) SetMachineAddresses(addresses []instance.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()
}
示例#10
0
// 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
0
文件: state.go 项目: jameinel/core
// 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()
}
示例#12
0
文件: upgrader.go 项目: jameinel/core
// 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: &params.Version{v},
		}},
	}
	err := st.call("SetTools", args, &results)
	if err != nil {
		// TODO: Not directly tested
		return err
	}
	return results.OneError()
}
示例#13
0
文件: unit.go 项目: jameinel/core
// SetCharmURL marks the unit as currently using the supplied charm URL.
// An error will be returned if the unit is dead, or the charm URL not known.
func (u *Unit) SetCharmURL(curl *charm.URL) error {
	if curl == nil {
		return fmt.Errorf("charm URL cannot be nil")
	}
	var result params.ErrorResults
	args := params.EntitiesCharmURL{
		Entities: []params.EntityCharmURL{
			{Tag: u.tag, CharmURL: curl.String()},
		},
	}
	err := u.st.call("SetCharmURL", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
示例#14
0
文件: machine.go 项目: jameinel/core
// 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
0
文件: settings.go 项目: jameinel/core
// 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()
}