Exemplo n.º 1
0
// serviceSetSettingsYAML updates the settings for the given service,
// taking the configuration from a YAML string.
func serviceSetSettingsYAML(service *state.Service, settings string) error {
	ch, _, err := service.Charm()
	if err != nil {
		return err
	}
	changes, err := ch.Config().ParseSettingsYAML([]byte(settings), service.Name())
	if err != nil {
		return err
	}
	return service.UpdateConfigSettings(changes)
}
Exemplo n.º 2
0
// serviceSetSettingsStrings updates the settings for the given service,
// taking the configuration from a map of strings.
func serviceSetSettingsStrings(service *state.Service, settings map[string]string) error {
	ch, _, err := service.Charm()
	if err != nil {
		return err
	}
	changes, err := ch.Config().ParseSettingsStrings(settings)
	if err != nil {
		return err
	}
	return service.UpdateConfigSettings(changes)
}
Exemplo n.º 3
0
func processService(service *state.Service) (map[string]interface{}, error) {
	r := m()
	ch, _, err := service.Charm()
	if err != nil {
		return nil, err
	}
	r["charm"] = ch.String()
	r["exposed"] = service.IsExposed()

	// TODO(dfc) service.IsSubordinate() ?

	units, err := service.AllUnits()
	if err != nil {
		return nil, err
	}

	u := checkError(processUnits(units))
	if len(u) > 0 {
		r["units"] = u
	}

	// TODO(dfc) process relations
	return r, nil
}