Exemplo n.º 1
0
    def info(self):
        HEADING("CLOUD MESH INFO")
        try:
            for name in self.clouds.keys():
                cloud_type = self.clouds[name]['cm_type']
                provider = self.cloud_provider(cloud_type)
                cloud = provider(name)
                HEADING("Info " + name)
                cloud.refresh("all")
                cloud.info()

        except Exception, e:
            log.error(str(e))
Exemplo n.º 2
0
 def test06_wrong_status(self):
     HEADING()
     try:
         print(self.projects.names("wrong"))
     except Exception, e:
         print(e)
         pass
Exemplo n.º 3
0
    def test08_set(self):
        HEADING()

        print(self.key_store["keys"])
        print(self.key_store["default"])

        assert type(self.key_store["keys"]) == dict
Exemplo n.º 4
0
 def test00_file(self):
     HEADING()
     try:
         self.key_store = cm_keys_yaml("wrong file")
     except:
         pass
     assert True
Exemplo n.º 5
0
 def test10_fingerprint(self):
     HEADING()
     for name in self.key_store.names():
         key = self.key_store[name]
         print(name, key)
         print(get_fingerprint(key))
     assert True
Exemplo n.º 6
0
    def test18_initialize(self):
        HEADING()
        username = '******'
        self.config.userdata_handler = mock_user
        self.config.cloudcreds_handler = mock_cloud
        self.config.initialize(username)

        assert 'cloudmesh' in self.config.data
        assert len(self.config.data.keys()) == 1

        cmdata = self.config.data['cloudmesh']
        assert 'prefix' in cmdata
        assert 'profile' in cmdata
        assert 'username' in cmdata['profile']
        assert cmdata['profile']['username'] == username
        assert 'keys' in cmdata
        assert 'projects' in cmdata
        assert 'active' in cmdata
        assert 'default' in cmdata
        assert 'clouds' in cmdata
        assert 'security' in cmdata
        assert 'default' in cmdata['keys']
        assert 'india-openstack' in cmdata['clouds']
        assert 'sierra' in cmdata['clouds']
        assert 'credentials' in cmdata['clouds']['sierra']
        assert cmdata['clouds']['sierra']['credentials'][
            'OS_VERSION'] == 'grizzly'
        assert cmdata['clouds']['sierra']['credentials'][
            'OS_USERNAME'] == username
        assert cmdata['prefix'] == username
Exemplo n.º 7
0
 def test07_delete(self):
     HEADING()
     print(self.projects.add("gregor"))
     print(self.projects.dump())
     print(self.projects.delete("gregor"))
     print(self.projects.dump())
     pass
Exemplo n.º 8
0
 def test_12_assign_public_ip(cls):
     HEADING()
     for vm in cls.vm:
         vm_id = vm['server']['id']
         ip = cls.mesh.assign_public_ip(cls.cloudname, vm_id, cls.username)
         log.info("{0} allocated to {1}".format(ip, vm_id))
         cls.ip.append(ip)
Exemplo n.º 9
0
    def test_job_submit(self):
        HEADING()
        xmkdir(self.manager, "~/scripts/test")

        self.pbs.jobid_incr()

        banner('qsub')

        jobname = "job-" + self.pbs.jobid + ".pbs"

        print(jobname)
        print(self.host)
        script_template = self.pbs.read_script("etc/job.pbs")
        r = self.pbs.qsub(jobname,
                          self.host,
                          'echo "Hello"',
                          template=script_template)
        pprint(r)
        #banner('variable list')
        #pprint(self.pbs.variable_list(r))
        assert len(r.keys()) == 1

        banner('status')
        jobid = self.pbs.getid(r)
        print(jobid)
        r = self.pbs.jobstatus(self.host, jobid)
        print(r)
Exemplo n.º 10
0
    def test_set(self):
        HEADING()
        """
        data = self.inventory.find({'cm_id': self.name})

        for e in data:
            pprint (e)
        """
        print(70 * '=')
        """
        print "BEFORE"

        data = self.inventory.host(self.name)
        pprint(data)
        """

        attribute = "cm_temp"
        value = "32"

        print("SET ATTRIBUTE")
        print(70 * '=')
        data = self.inventory.set_attribute(self.name, attribute, value)
        print(70 * '=')
        print(data)

        print("GET ATTRIBUTE")
        data = self.inventory.get_attribute(self.name, attribute)
        print(data)
Exemplo n.º 11
0
 def get_qinfo(self, host):
     HEADING()
     self.pbs = PBS(self.user, host)
     results = self.pbs.qinfo()
     for name in results:
         element = results[name]
         pprint(element)
Exemplo n.º 12
0
 def test_05_delete_vms(self):
     HEADING()
     global vm
     for vmname in vm:
         cmd = ('cm "vm delete {0} --cloud=india --force"'.format(vmname))
         res = os.popen(cmd).read()
         assert res.find("{'msg': 'success'}") != -1
Exemplo n.º 13
0
 def test_02_validate_activation(self):
     HEADING()
     res = os.popen('cm cloud list |'
                    'grep india |'
                    'grep True |'
                    'wc -l').read()
     assert res.strip() == "1"
Exemplo n.º 14
0
 def test_04_validate_vm_running(self):
     HEADING()
     global vm
     for vmname in vm:
         res = os.popen('cm "list vm india --refresh" '
                        ' | grep {0} | wc -l'.format(vmname)).read()
         assert res.strip() == "1"
Exemplo n.º 15
0
    def test_008_modify(self):
        """
        tests modifying a single job in the db
        :return:
        """
        HEADING()
        db = self.db

        db.connect()

        job = {"job_name": "modifyme", "input_filename": "file1"}

        db.add(job)

        originalFilename = self.db.find_jobs("job_name",
                                             "modifyme")[0]["input_filename"]

        job = {"job_name": "modifyme", "input_filename": "file2"}

        db.modify(job)

        newFilename = self.db.find_jobs("job_name",
                                        "modifyme")[0]["input_filename"]

        assert (originalFilename != newFilename)
Exemplo n.º 16
0
 def test_help_commands(self):
     HEADING()
     help_commands = [("cloud", "cloud on", None),
                      ("flavor", "", "<"),
                      ("init", "KIND", None),
                      ("list", "projects", None),
                      ("rain", "KIND", None),
                      ("reservation", "duration", None),
                      ("storm", "ID", None),
                      ("vm", "CLOUD", "<"),
                      ("defaults", "clean", None),
                      ("image", "CLOUD", "<"),
                      ("inventory", "exists", None),
                      ("metric", "CLOUD", None),
                      ("register", "CLOUD", None),
                      ("security_group", "CLOUD", "<"),
                      ]
     allok = True
     for (command, valid, invalid) in help_commands:
         r = Shell.cm("help " + command)
         testing = True
         if valid is not None:
             testing = valid in r
         if invalid is not None:
             testing = testing and invalid not in r
         if testing:
             msg = "pass"
         else:
             msg = "fail"
         print("TESTING help", command, msg)
         allok = allok and testing
     assert allok
Exemplo n.º 17
0
    def test_delete_vm(self):
        HEADING()
        configuration = cm_config()
        print("NAME", self.name)

        print("Getting Flavours")
        self.cloud.refresh('flavors')
        flavor = configuration.default(self.name)['flavor']

        print("Getting Images")
        self.cloud.refresh('images')
        image = configuration.default(self.name)['image']

        # print self.cloud.flavors_cache
        # print self.cloud.images_cache

        print("STARTING VM", image, flavor)
        result = self.cloud.vm_create(
            "gregor-test-del", flavor_name=flavor, image_id=image)
        print(result)

        print("DELETE VM", image, flavor)
        self.cloud.refresh('servers')
        result = self.cloud.vm_delete("gregor-test-del")
        print(result)

        assert len(result.keys()) > 0
Exemplo n.º 18
0
 def test_09_print_vms(self):
     """print the servers"""
     HEADING()
     self.cloud.refresh('servers')
     print(json.dumps(self.cloud.dump('servers'), indent=4))
     # we assume that there are always images running
     assert len(self.cloud.servers) > 0
Exemplo n.º 19
0
    def test_list_flavors(self):
        HEADING()
        self.cloud.refresh('flavors')

        print(json.dumps(self.cloud.dump('flavors'), indent=4))

        # doing a simple test as tiny is usually 512
        assert self.cloud.flavors['m1.small']['ram'] == 512
Exemplo n.º 20
0
 def test_06_validate_vm_deleted(self):
     HEADING()
     global vm
     for vmname in vm:
         res = os.popen('cm "list vm india --refresh" '
                        '| grep {0}|wc -l'.format(vmname)).read()
         assert res.strip() == "0"
         vm.remove(vmname)
Exemplo n.º 21
0
    def test_info(self):
        HEADING()

        for host in self.hosts:
            self.pbs = PBS(self.user, host)
            results = self.pbs.qstat()

            print(host, " =", len(results), "jobs")
Exemplo n.º 22
0
 def test_generate(self):
     HEADING()
     """
     Test to generate 10 users and 10 projects
     """
     self._xyz()
     generate_users(1)
     generate_projects(10)
Exemplo n.º 23
0
    def test_i066(self):
        HEADING()

        name = "i066"
        attribute = "cm_doesnotexist"
        print("GET ATTRIBUTE")
        data = self.inventory.get_attribute(name, attribute)
        print(data)
Exemplo n.º 24
0
 def test_13_ssh_vm(self):
     HEADING()
     for ip in self.ip:
         result = self.mesh.wait(ipaddr=ip,
                                 command="uname -a",
                                 interval=10,
                                 retry=5)
         log.info("ssh call to [{0}]: {1}".format(ip, str(result)))
Exemplo n.º 25
0
    def test_30_get_images(self):
        """test to get the images"""
        HEADING()
        self.cloud.refresh('images')
        print(json.dumps(self.cloud.dump('images'), indent=4))

        print(json.dumps(self.cloud.get_images(), indent=4))
        assert True
Exemplo n.º 26
0
    def test_29_get_flavors(self):
        """test to get the flavors"""
        HEADING()
        # self.cloud.refresh('flavors')
        # print json.dumps(self.cloud.dump('flavors'), indent=4)

        print(json.dumps(self.cloud.get_flavors(), indent=4))
        assert True
Exemplo n.º 27
0
 def test_04_start_a_vm(cls):
     HEADING()
     import random
     vm_name = "nosetests_" + str(random.randint(1, 100))
     cloudmesh.shell("vm start --name={0} --cloud=india \
                     --image=futuregrid/ubuntu-14.04 \
                     --flavor=m1.small".format(vm_name))
     cls.vm.append(vm_name)
Exemplo n.º 28
0
 def test_run(self):
     HEADING()
     self.launcher.register(None)
     for host in self.launcher.recipies:
         recipie_list = self.launcher.recipies[host]
         for recipie in recipie_list:
             # assuming "name" to be the key in the dictionary
             assert (self.launcher.run(host, recipie["name"]))
Exemplo n.º 29
0
    def test_clean(self):
        HEADING()
        self.db.clean()
        dbpath = self.db.config['dbpath']
        logpath = self.db.config['dbpath']

        assert not os.path.isfile(path_expand(dbpath)) and os.path.isfile(
            path_expand(logpath))
Exemplo n.º 30
0
    def test_exportcollection(self):
        HEADING()

        """
        Test to export a collection in json format to a directory named "dumps"
        """
        self._xyz()
        db = DBUtil()
        db.serialize(db="manage", collection="cloudmesh_object")