Пример #1
0
func (fix *SimpleToolsFixture) paths(entityName, xName string) (confPath, agentDir, toolsDir string) {
	confName := fmt.Sprintf("jujud-%s:%s.conf", xName, entityName)
	confPath = filepath.Join(fix.initDir, confName)
	agentDir = environs.AgentDir(fix.dataDir, entityName)
	toolsDir = environs.AgentToolsDir(fix.dataDir, entityName)
	return
}
Пример #2
0
func (mgr *SimpleManager) RecallUnit(unitName string) error {
	svc := mgr.upstartService(unitName)
	if !svc.Installed() {
		return fmt.Errorf("unit %q is not deployed", unitName)
	}
	if err := svc.Remove(); err != nil {
		return err
	}
	entityName := state.UnitEntityName(unitName)
	agentDir := environs.AgentDir(mgr.DataDir, entityName)
	if err := os.RemoveAll(agentDir); err != nil {
		return err
	}
	toolsDir := environs.AgentToolsDir(mgr.DataDir, entityName)
	return os.Remove(toolsDir)
}
Пример #3
0
// ReadConf reads configuration data for the given
// entity from the given data directory.
func ReadConf(dataDir, entityName string) (*Conf, error) {
	dir := environs.AgentDir(dataDir, entityName)
	data, err := ioutil.ReadFile(filepath.Join(dir, "agent.conf"))
	if err != nil {
		return nil, err
	}
	var c Conf
	if err := goyaml.Unmarshal(data, &c); err != nil {
		return nil, err
	}
	c.DataDir = dataDir
	if err := c.Check(); err != nil {
		return nil, err
	}
	if c.StateInfo != nil {
		c.StateInfo.EntityName = entityName
	}
	if c.APIInfo != nil {
		c.APIInfo.EntityName = entityName
	}
	return &c, nil
}
Пример #4
0
// Dir returns the agent's directory.
func (c *Conf) Dir() string {
	return environs.AgentDir(c.DataDir, c.EntityName())
}