Exemplo n.º 1
0
// ServiceGetCharmURL gets the charm URL for a given service.
func (c *compat) ServiceGetCharmURL(args params.ServiceGet) (params.StringResult, error) {
	serviceApi, err := service.NewAPI(c.client.api.state(), c.client.api.resources, c.client.api.auth)
	if err != nil {
		return params.StringResult{}, err
	}
	return serviceApi.ServiceGetCharmURL(args)
}
Exemplo n.º 2
0
// ServiceSetCharm sets the charm for a given service.
func (c *compat) ServiceSetCharm(args params.ServiceSetCharm) error {
	// Older Juju's required a charm to be added first; the GUI assumes this behaviour.
	curl, err := charm.ParseURL(args.CharmUrl)
	if err != nil {
		return err
	}
	if curl.Schema != "cs" {
		return fmt.Errorf(`charm url has unsupported schema %q`, curl.Schema)
	}
	if curl.Revision < 0 {
		return fmt.Errorf("charm url must include revision")
	}
	_, err = c.client.api.state().Charm(curl)
	if errors.IsNotFound(err) {
		if err := c.client.AddCharm(params.CharmURL{URL: curl.String()}); err != nil {
			return err
		}
	} else if err != nil {
		return err
	}
	serviceApi, err := service.NewAPI(c.client.api.state(), c.client.api.resources, c.client.api.auth)
	if err != nil {
		return err
	}
	return serviceApi.ServiceSetCharm(args)
}
Exemplo n.º 3
0
// ServiceUpdate updates the service attributes, including charm URL,
// minimum number of units, settings and constraints.
// All parameters in params.ServiceUpdate except the service name are optional.
func (c *compat) ServiceUpdate(args params.ServiceUpdate) error {
	serviceApi, err := service.NewAPI(c.client.api.state(), c.client.api.resources, c.client.api.auth)
	if err != nil {
		return err
	}
	return serviceApi.ServiceUpdate(args)
}
Exemplo n.º 4
0
func (s *getSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)

	s.authorizer = apiservertesting.FakeAuthorizer{
		Tag: s.AdminUserTag(c),
	}
	var err error
	s.serviceApi, err = service.NewAPI(s.State, nil, s.authorizer)
	c.Assert(err, jc.ErrorIsNil)
}
Exemplo n.º 5
0
// ServiceSetYAML implements the server side of Client.ServerSetYAML.
func (c *compat) ServiceSetYAML(p params.ServiceSetYAML) error {
	serviceApi, err := service.NewAPI(c.client.api.state(), c.client.api.resources, c.client.api.auth)
	if err != nil {
		return err
	}
	return serviceApi.ServiceUpdate(params.ServiceUpdate{
		ServiceName:  p.ServiceName,
		SettingsYAML: p.Config,
	})
}
Exemplo n.º 6
0
func (s *serviceSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.BlockHelper = commontesting.NewBlockHelper(s.APIState)
	s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() })

	s.CharmStoreSuite.Session = s.JujuConnSuite.Session
	s.CharmStoreSuite.SetUpTest(c)

	s.service = s.Factory.MakeService(c, nil)

	s.authorizer = apiservertesting.FakeAuthorizer{
		Tag: s.AdminUserTag(c),
	}
	var err error
	s.serviceApi, err = service.NewAPI(s.State, nil, s.authorizer)
	c.Assert(err, jc.ErrorIsNil)
}