Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

patch and test for GH-33

  • Loading branch information...
commit 7f2726a56b29f0bc92146bc3c918da7d69807497 1 parent f77ef5e
John Bresnahan authored
View
4 cloudinitd/bootfabtasks.py
@@ -85,9 +85,9 @@ def readypgm(pgm=None, args=None, stagedir=None):
with cd(stagedir):
run(destpgm)
-def bootpgm(pgm=None, args=None, conf=None, env_conf=None, output=None, stagedir=None):
+def bootpgm(pgm=None, args=None, conf=None, env_conf=None, output=None, stagedir=None, remotedir=None):
args = urllib.unquote(args)
- run('mkdir %s;chmod 777 %s' % (REMOTE_WORKING_DIR, REMOTE_WORKING_DIR))
+ run('mkdir %s;chmod 777 %s' % (remotedir, remotedir))
run('mkdir -p %s' % stagedir)
relpgm = os.path.basename(pgm)
destpgm = "%s/%s" % (stagedir, relpgm)
View
16 cloudinitd/nosetests/__init__.py
@@ -24,17 +24,5 @@
os.environ['CLOUDINITD_IAAS_SSHKEY'] = "/etc/group"
os.environ['CLOUDINITD_SSH_USERNAME'] = "NOTHING"
-
-from cloudinitd.nosetests.service_tests import *
-from cloudinitd.nosetests.basic_tests import *
-from cloudinitd.nosetests.basic_unit_tests import *
-from cloudinitd.nosetests.instance_dies_tests import *
-from cloudinitd.nosetests.pollable_tests import *
-from cloudinitd.nosetests.service_unit_tests import *
-from cloudinitd.nosetests.cloudinitd_tests import *
-from cloudinitd.nosetests.prelaunch_tests import *
-from cloudinitd.nosetests.plan_tests import *
-from cloudinitd.nosetests.outputjson_tests import *
-from cloudinitd.nosetests.validate_tests import *
-from cloudinitd.nosetests.singlevm_tests import *
-from cloudinitd.nosetests.badplan_cleanup_tests import *
+def is_a_test():
+ return 'CLOUDINITD_TESTENV' in os.environ and os.environ['CLOUDINITD_TESTENV'] == "1"
View
2  cloudinitd/nosetests/many_at_once_tests.py
@@ -59,7 +59,7 @@ def test_kill_first_level(self):
self._status(dir, cb.run_name)
self._terminate(dir, cb.run_name)
- def test_ge_service(self):
+ def test_get_service(self):
tst_name = "multilevelsimple"
(dir, cb) = self._start_one(tst_name)
svc = cb.get_service("Two")
View
62 cloudinitd/nosetests/remote_locations_tests.py
@@ -0,0 +1,62 @@
+from unittest.case import SkipTest
+import uuid
+import cloudinitd
+import cloudinitd.nosetests
+from cloudinitd.statics import REMOTE_WORKING_DIR_ENV_STR
+from cloudinitd.user_api import CloudInitD
+import tempfile
+import unittest
+import os
+
+class RemoteDirInspectionTests(unittest.TestCase):
+
+ def setUp(self):
+ self.plan_basedir = cloudinitd.nosetests.g_plans_dir
+ self.remote_dir = "/tmp/" + str(uuid.uuid4()).split("-")[0]
+ os.environ[REMOTE_WORKING_DIR_ENV_STR] = self.remote_dir
+
+ def tearDown(self):
+ del os.environ[REMOTE_WORKING_DIR_ENV_STR]
+ cloudinitd.close_log_handlers()
+
+ def _get_running_vms(self):
+
+ key = None
+ secret = None
+ url = None
+ try:
+ key = os.environ['CLOUDINITD_IAAS_ACCESS_KEY']
+ secret = os.environ['CLOUDINITD_IAAS_SECRET_KEY']
+ url = os.environ['CLOUDINITD_IAAS_URL']
+ except:
+ pass
+
+ # XXX this test may fail for nimbus
+ con = cloudinitd.cb_iaas.iaas_get_con(None, key=key, secret=secret, iaasurl=url)
+ i_list = con.get_all_instances()
+ return i_list
+
+ def test_env_set(self):
+ if cloudinitd.nosetests.is_a_test():
+ raise SkipTest()
+ dir = tempfile.mkdtemp()
+ conf_file = self.plan_basedir + "/oneservice/top.conf"
+ cb = CloudInitD(dir, conf_file, terminate=False, boot=True, ready=True)
+ cb.start()
+ cb.block_until_complete(poll_period=1.0)
+ svc = cb.get_service("sampleservice")
+ ssh_cmd = svc.get_ssh_command() + " ls -l %s" % (self.remote_dir)
+
+ # form test directory command
+ print ssh_cmd
+
+ rc = os.system(ssh_cmd)
+ self.assertEquals(rc, 0)
+
+ cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
+ cb.shutdown()
+ cb.block_until_complete(poll_period=1.0)
+
+
+if __name__ == '__main__':
+ unittest.main()
View
1  cloudinitd/persistence.py
@@ -1,5 +1,4 @@
import sqlalchemy
-import shlex
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relation
from sqlalchemy.orm import mapper
View
6 cloudinitd/services.py
@@ -10,8 +10,6 @@
import tempfile
import string
from cloudinitd.exceptions import APIUsageException, ConfigException, ServiceException, MultilevelException
-import logging
-import cloudinitd
from cloudinitd.statics import *
from cloudinitd.cb_iaas import *
import simplejson as json
@@ -147,7 +145,7 @@ def __init__(self, db, s, top_level, boot=True, ready=True, terminate=False, log
if self._s.state == 0:
pass
- self._stagedir = "%s/%s" % (REMOTE_WORKING_DIR, self.name)
+ self._stagedir = "%s/%s" % (get_remote_working_dir(), self.name)
self._validate_and_reinit(boot=boot, ready=ready, terminate=terminate, callback=callback, repair=reload)
self._db.db_commit()
@@ -684,7 +682,7 @@ def _get_boot_cmd(self):
(osf, self._boot_output_file) = tempfile.mkstemp()
os.close(osf)
- cmd = self._get_fab_command() + " 'bootpgm:hosts=%s,pgm=%s,args=%s,conf=%s,env_conf=%s,output=%s,stagedir=%s'" % (host, bootpgm, bootpgm_args, self._bootconf, self._bootenv_file, self._boot_output_file, self._stagedir)
+ cmd = self._get_fab_command() + " 'bootpgm:hosts=%s,pgm=%s,args=%s,conf=%s,env_conf=%s,output=%s,stagedir=%s,remotedir=%s'" % (host, bootpgm, bootpgm_args, self._bootconf, self._bootenv_file, self._boot_output_file, self._stagedir, get_remote_working_dir())
cloudinitd.log(self._log, logging.DEBUG, "Using boot pgm command %s" % (cmd))
return cmd
View
8 cloudinitd/statics.py
@@ -1,4 +1,4 @@
-
+import os
callback_action_started = "starting"
callback_action_transition = "transition"
@@ -9,4 +9,10 @@
callback_return_restart = "restart"
REMOTE_WORKING_DIR = "/tmp/nimbusready"
+REMOTE_WORKING_DIR_ENV_STR = "REMOTE_WORKING_DIR_ENV"
+
+def get_remote_working_dir():
+ if REMOTE_WORKING_DIR_ENV_STR in os.environ:
+ return os.environ[REMOTE_WORKING_DIR_ENV_STR]
+ return REMOTE_WORKING_DIR
Please sign in to comment.
Something went wrong with that request. Please try again.