Permalink
Browse files

adding first class local exe with some tests

  • Loading branch information...
1 parent aaf2f14 commit 2a91c7c3ac3004167ccda7b5690d77777be64048 @buzztroll buzztroll committed Jul 24, 2012
@@ -101,8 +101,6 @@ def cleanup_dirs(stagedir=None, local_exe=None):
local_exe = str(local_exe).lower() == 'true'
if local_exe:
shutil.rmtree(stagedir, ignore_errors=True)
- else:
- run("rm -rf %s" % (stagedir))
def bootpgm(pgm=None, args=None, conf=None, env_conf=None, output=None, stagedir=None, remotedir=None, local_exe=None):
local_exe = str(local_exe).lower() == 'true'
@@ -55,5 +55,9 @@ def test_cloudconf(self):
tst_name = "cloudconf"
self._start_one(tst_name)
+ def test_localexe(self):
+ tst_name = "localhostexe"
+ self._start_one(tst_name)
+
if __name__ == '__main__':
unittest.main()
View
@@ -19,6 +19,19 @@
metadata = MetaData()
+def config_get_or_none_bool(parser, s, v, default=None):
+ try:
+ x = parser.get(s, v)
+ if not x:
+ return x
+ x = cloudinitd.get_env_val(x)
+
+ x = x.lower() == "true"
+ return x
+ except:
+ return default
+
+
def config_get_or_none(parser, s, v, default=None):
try:
x = parser.get(s, v)
@@ -192,7 +205,7 @@ def _load_from_conf(self, parser, section, db, conf_dir, cloud_confs, conf_file)
pgm_timeout = config_get_or_none(parser, section, "pgm_timeout", self.pgm_timeout)
- local_exe = config_get_or_none(parser, section, "local_exe", self.local_exe)
+ local_exe = config_get_or_none_bool(parser, section, "local_exe", self.local_exe)
allo = config_get_or_none(parser, section, "allocation", self.allocation)
@@ -424,7 +437,7 @@ def load_from_conf(self, conf_file):
self.default_terminatepgm = config_get_or_none(parser, s, "terminatepgm")
self.default_terminatepgm_args = config_get_or_none(parser, s, "terminatepgm_args")
self.default_pgm_timeout = config_get_or_none(parser, s, "pgm_timeout")
- self.default_local_exe = config_get_or_none(parser, s, "local_exe")
+ self.default_local_exe = config_get_or_none_bool(parser, s, "local_exe")
all_sections = parser.sections()
for s in all_sections:
View
@@ -720,7 +720,7 @@ def get_ssh_command(self):
def _get_directory_cleanup_cmd(self):
host = self._expand_attr(self._s.hostname)
cmd = self._get_fab_command() + " cleanup_dirs:hosts=%s,stagedir=%s,local_exe=%s" % (host, self._stagedir, (self._s.local_exe))
- cloudinitd.log(self._log, logging.DEBUG, "Using terminate pgm command %s" % (cmd))
+ cloudinitd.log(self._log, logging.DEBUG, "Using cleanup pgm command %s" % (cmd))
return cmd
@cloudinitd.LogEntryDecorator
@@ -733,15 +733,6 @@ def _get_ssh_ready_cmd(self):
cloudinitd.log(self._log, logging.DEBUG, "Using ssh command %s" % (cmd))
return cmd
- def _make_local_stage_dir(self, pgm):
-
- try:
- os.mkdir(self._stagedir)
- except OSError, ex:
- if ex.errno != 17:
- raise
-
-
def _copy_local_file(self):
rel_pgm = os.path.basename(pgm)
dst = os.path.join(self._stagedir, rel_pgm)
@@ -770,12 +761,6 @@ def _get_boot_cmd(self):
bootpgm = self._expand_attr(self._s.bootpgm)
bootpgm_args = self._expand_attr_list(self._s.bootpgm_args)
- if self._s.local_exe:
- self._make_local_stage_dir()
- cmd = "%s %s" % (bootpgm, bootpgm_args)
- cloudinitd.log(self._log, logging.DEBUG, "Using the local boot command %s" % (cmd))
- return cmd
-
bootpgm_args = urllib.quote(bootpgm_args)
(osf, self._boot_output_file) = tempfile.mkstemp()
@@ -1,6 +1,6 @@
[svc-sampleservice]
bootpgm: bootpgm.sh
readypgm: sampletest.sh
+terminatepgm: sampletest.sh
hostname: localhost
-
-
+local_exe: True
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0
@@ -0,0 +1,6 @@
+[svc-sampleservice]
+bootpgm: bootpgm.sh
+readypgm: sampletest.sh
+terminatepgm: sampletest.sh
+hostname: localhost
+local_exe: True
@@ -0,0 +1,15 @@
+# This is a sample top level configuration file. Each entry under runlevels
+# is a file with a single runlevel description. All of the services in that
+# file are run at the same time but the next level is not begun until
+# all of these services in the previous successfully complete.
+
+[defaults]
+
+ssh_username: env.USER
+
+sshkeyname: env.CLOUDINITD_IAAS_SSHKEYNAME
+localsshkeypath: env.CLOUDINITD_IAAS_SSHKEY
+
+[runlevels]
+level1: test-level1.conf
+

0 comments on commit 2a91c7c

Please sign in to comment.