~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to environs/maas/util.go

  • Committer: Tarmac
  • Author(s): jtv at canonical
  • Date: 2013-07-15 04:51:31 UTC
  • mfrom: (1440.2.4 var-lib-juju)
  • Revision ID: tarmac-20130715045131-ecmza5n94prfehz1
[r=jtv] Make "/var/lib/juju" path a variable.

That particular path, for cloudinit's benefit, is hard-coded all over the
provider code. It may be an obstacle to testing, because tests can't
substitute a fake (and obviously tests shouldn't mess with /var/lib/juju, or
even rely on its existence).

If we later find that one of these mentions is different from the others, it's
quite possible that we have to specialize some of the uses into separate
variables. For now, the main things are to be aware, and to have an injection
point for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
        "fmt"
8
8
        "launchpad.net/goyaml"
9
9
        cloudinit_core "launchpad.net/juju-core/cloudinit"
 
10
        "launchpad.net/juju-core/environs"
10
11
        "launchpad.net/juju-core/environs/cloudinit"
11
12
        "launchpad.net/juju-core/instance"
12
13
        "launchpad.net/juju-core/log"
66
67
        Hostname   string `yaml:,omitempty`
67
68
}
68
69
 
69
 
var _MAASInstanceFilename = jujuDataDir + "/MAASmachine.txt"
 
70
var _MAASInstanceFilename = environs.DataDir + "/MAASmachine.txt"
70
71
 
71
72
// cloudinitRunCmd returns the shell command that, when run, will create the
72
73
// "machine info" file containing the instanceId and the hostname of a machine.
76
77
        if err != nil {
77
78
                return "", err
78
79
        }
79
 
        script := fmt.Sprintf(`mkdir -p %s; echo -n %s > %s`, utils.ShQuote(jujuDataDir), utils.ShQuote(string(yaml)), utils.ShQuote(_MAASInstanceFilename))
 
80
        script := fmt.Sprintf(`mkdir -p %s; echo -n %s > %s`, utils.ShQuote(environs.DataDir), utils.ShQuote(string(yaml)), utils.ShQuote(_MAASInstanceFilename))
80
81
        return script, nil
81
82
}
82
83