Пример #1
0
    def test_validateiaas(self):
        self.plan_basedir = cloudinitd.nosetests.g_plans_dir
        dir = tempfile.mkdtemp()
        conf_file = self.plan_basedir + "/iaastypevalidate/top.conf"
        cb = CloudInitD(dir, conf_file, terminate=False, boot=True, ready=True)
        cb.start()

        cb.block_until_complete(poll_period=1.0)

        # check the log for a warning
        fname = os.path.expanduser("~/.cloudinitd/%s/badsvc.log" % (cb.run_name))
        print fname
        self.assertTrue(os.path.exists(fname), "The path %s should exist" % (fname))
        f = open(fname, "r")
        found = False
        for l in f.readlines():
            print l
            ndx = l.find("WARN")
            if ndx >= 0:
                ndx = l.find("2.7")
                if ndx >= 0:
                    found = True
        self.assertTrue(found, "a warning with the key 2.7 should be in the logfile %s" %(fname))
        f.close()

        cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
        cb.shutdown()
        cb.block_until_complete(poll_period=1.0)
        fname = cb.get_db_file()
        os.remove(fname)
Пример #2
0
    def _start_one(self, conf_file):
        self.plan_basedir = cloudinitd.nosetests.g_plans_dir
        dir = tempfile.mkdtemp()
        conf_file = self.plan_basedir + "/" + conf_file + "/top.conf"
        cb = CloudInitD(dir, conf_file, terminate=False, boot=True, ready=True)
        cb.start()
        cb.block_until_complete(poll_period=1.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)
        fname = cb.get_db_file()
        os.remove(fname)
Пример #3
0
    def get_status_test(self):
        self.plan_basedir = cloudinitd.nosetests.g_plans_dir
        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")
        status = svc.get_iaas_status()
        self.assertEqual("running", status, "status is %s" % (status))

        cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
        cb.shutdown()
        cb.block_until_complete(poll_period=1.0)
        fname = cb.get_db_file()
        os.remove(fname)
Пример #4
0
    def dep_keys_test(self):
        self.plan_basedir = cloudinitd.nosetests.g_plans_dir
        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")
        attr_keys = svc.get_keys_from_bag()
        # until we figure out how to get __dict__ values from the sqlalchemy objects this will be in complete
        expectations = [
            "hostname",
            "instance_id",
#            "name",
#            "level_id",
#            "image",
#            "iaas",
#            "allocation",
#            "keyname",
#            "localkey",
#            "username",
#            "scp_username",
#            "readypgm",
#            "hostname",
#            "bootconf",
#            "bootpgm",
#            "instance_id",
#            "iaas_url",
#            "iaas_key",
#            "iaas_secret",
#            "contextualized",
#            "securitygroups",
            "webmessage"
            ]
        for e in expectations:
            self.assertTrue(e in attr_keys, "The key %s should exist in %s" % (e, str(attr_keys)))

        cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
        cb.shutdown()
        cb.block_until_complete(poll_period=1.0)
        fname = cb.get_db_file()
        os.remove(fname)
Пример #5
0
    def test_prelaunch(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()
        conf_file = "multilevelsimple"
        self.plan_basedir = cloudinitd.nosetests.g_plans_dir
        dir = tempfile.mkdtemp()
        conf_file = self.plan_basedir + "/" + conf_file + "/top.conf"
        cb = CloudInitD(dir, conf_file, terminate=False, boot=True, ready=True)
        cb.pre_start_iaas()

        post_boot_list = con.get_all_instances()

        self.assertNotEqual(len(i_list), len(post_boot_list), "The list of instances should have grown")
        self.assertTrue(len(i_list)+3 < len(post_boot_list), "The list of instances should have grown by more than the number of services in the first level")

        cb.start()
        post_start_list = con.get_all_instances()
        self.assertEqual(len(post_boot_list), len(post_start_list), "The list should not have grown")
        cb.block_until_complete(poll_period=1.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)
        fname = cb.get_db_file()
        os.remove(fname)
Пример #6
0
 def _terminate(self, dir, run_name):
     cb = CloudInitD(dir, db_name=run_name, terminate=True, boot=False, ready=False, continue_on_error=True)
     cb.shutdown()
     cb.block_until_complete(poll_period=1.0)
     fname = cb.get_db_file()
     os.remove(fname)