Example #1
0
// 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()
}
Example #2
0
// 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()
}
Example #3
0
// 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()
}
Example #4
0
// 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()
}
Example #5
0
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()
}
Example #6
0
// 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()
}
Example #7
0
// ReleaseContainerAddresses releases a static IP address allocated to a
// container.
func (st *State) ReleaseContainerAddresses(containerTag names.MachineTag) (err error) {
	defer errors.DeferredAnnotatef(&err, "cannot release static addresses for %q", containerTag.Id())
	var result params.ErrorResults
	args := params.Entities{
		Entities: []params.Entity{{Tag: containerTag.String()}},
	}
	if err := st.facade.FacadeCall("ReleaseContainerAddresses", args, &result); err != nil {
		return err
	}
	return result.OneError()
}
Example #8
0
// 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()
}
Example #9
0
File: machine.go Project: bac/juju
// 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()
}
Example #10
0
// 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()
}
Example #11
0
File: unit.go Project: kapilt/juju
// 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()
}
Example #12
0
// CleanupOldMetrics looks for metrics that are 24 hours old (or older)
// and have been sent. Any metrics it finds are deleted.
func (c *Client) CleanupOldMetrics() error {
	p := params.Entities{Entities: []params.Entity{
		{c.st.EnvironTag()},
	}}
	results := new(params.ErrorResults)
	err := c.facade.FacadeCall("CleanupOldMetrics", p, results)
	if err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
Example #13
0
// 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.facade.FacadeCall("Remove", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #14
0
File: machine.go Project: bac/juju
// 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()
}
Example #15
0
File: client.go Project: bac/juju
// 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()
}
Example #16
0
File: unit.go Project: kapilt/juju
// 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()
}
Example #17
0
// SetMetricCredentials sets the metric credentials for the service specified.
func (c *Client) SetMetricCredentials(service string, credentials []byte) error {
	creds := []params.ServiceMetricCredential{
		{service, credentials},
	}
	p := params.ServiceMetricCredentials{creds}
	results := new(params.ErrorResults)
	err := c.facade.FacadeCall("SetMetricCredentials", p, results)
	if err != nil {
		return errors.Trace(err)
	}
	return errors.Trace(results.OneError())
}
Example #18
0
File: facade.go Project: bac/juju
// ReportKeys reports the public SSH host keys for a machine to the
// controller. The keys should be in the same format as the sshd host
// key files, one entry per key.
func (f *Facade) ReportKeys(machineId string, publicKeys []string) error {
	args := params.SSHHostKeySet{EntityKeys: []params.SSHHostKeys{{
		Tag:        names.NewMachineTag(machineId).String(),
		PublicKeys: publicKeys,
	}}}
	var result params.ErrorResults
	err := f.caller.FacadeCall("ReportKeys", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #19
0
File: cloud.go Project: bac/juju
// RevokeCredential revokes/deletes a cloud credential.
func (c *Client) RevokeCredential(tag names.CloudCredentialTag) error {
	var results params.ErrorResults
	args := params.Entities{
		Entities: []params.Entity{{
			Tag: tag.String(),
		}},
	}
	if err := c.facade.FacadeCall("RevokeCredentials", args, &results); err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
Example #20
0
File: api.go Project: bac/juju
// Wait blocks until nobody has responsibility for model administration. It
// should probably be doing something watchy rather than blocky, but it's
// following the lease manager implementation underlying the original
// leadership approach and it doesn't seem worth rewriting all that.
func (api *API) Wait() error {
	args := params.Entities{
		Entities: []params.Entity{{
			Tag: api.modelTag.String(),
		}},
	}
	var results params.ErrorResults
	err := api.facadeCaller.FacadeCall("Wait", args, &results)
	if err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
Example #21
0
File: unit.go Project: kapilt/juju
// SetStatus sets the status of the unit.
func (u *Unit) SetStatus(status params.Status, info string, data params.StatusData) error {
	var result params.ErrorResults
	args := params.SetStatus{
		Entities: []params.EntityStatus{
			{Tag: u.tag.String(), Status: status, Info: info, Data: data},
		},
	}
	err := u.st.facade.FacadeCall("SetStatus", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #22
0
File: unit.go Project: kapilt/juju
// 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.String(), Protocol: protocol, Port: number},
		},
	}
	err := u.st.facade.FacadeCall("ClosePort", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #23
0
File: context.go Project: bac/juju
// SetUnitWorkloadVersion sets the current unit's workload version to
// the specified value.
func (ctx *HookContext) SetUnitWorkloadVersion(version string) error {
	var result params.ErrorResults
	args := params.EntityWorkloadVersions{
		Entities: []params.EntityWorkloadVersion{
			{Tag: ctx.unit.Tag().String(), WorkloadVersion: version},
		},
	}
	err := ctx.state.Facade().FacadeCall("SetWorkloadVersion", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #24
0
func (c *Client) SetPassword(username, password string) error {
	userArgs := usermanager.ModifyUsers{
		Changes: []usermanager.ModifyUser{{
			Username: username,
			Password: password}},
	}
	results := new(params.ErrorResults)
	err := c.facade.FacadeCall("SetPassword", userArgs, results)
	if err != nil {
		return err
	}
	return results.OneError()
}
Example #25
0
// DeleteImage deletes the specified image.
func (c *Client) DeleteImage(kind, series, arch string) error {
	p := params.ImageFilterParams{
		Images: []params.ImageSpec{
			{Kind: kind, Series: series, Arch: arch},
		},
	}
	results := new(params.ErrorResults)
	err := c.facade.FacadeCall("DeleteImages", p, results)
	if err != nil {
		return err
	}
	return results.OneError()
}
Example #26
0
// 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.facade.FacadeCall("SetPasswords", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #27
0
// ClearReboot clears the reboot flag of the machine.
func (m *Entity) ClearReboot() error {
	var result params.ErrorResults
	args := params.SetStatus{
		Entities: []params.EntityStatus{
			{Tag: m.tag.String()},
		},
	}
	err := m.st.facade.FacadeCall("ClearReboot", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #28
0
File: machine.go Project: bac/juju
// 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().String(), Addresses: params.FromNetworkAddresses(addresses...)},
		},
	}
	err := m.st.facade.FacadeCall("SetMachineAddresses", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #29
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.String(),
			Unit:     ru.unit.tag.String(),
		}},
	}
	err := ru.st.facade.FacadeCall("LeaveScope", args, &result)
	if err != nil {
		return err
	}
	return result.OneError()
}
Example #30
0
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 := c.facade.FacadeCall("AddUser", userArgs, results)
	if err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}