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
def test07_delete(self): HEADING() print self.projects.add("gregor") print self.projects.dump() print self.projects.delete("gregor") print self.projects.dump() pass
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)
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"
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_openstack_grizzly' in cmdata['clouds'] assert 'credentials' in cmdata['clouds']['sierra_openstack_grizzly'] assert cmdata['clouds']['sierra_openstack_grizzly']['credentials'][ 'OS_VERSION'] == 'grizzly' assert cmdata['clouds']['sierra_openstack_grizzly']['credentials'][ 'OS_USERNAME'] == username assert cmdata['prefix'] == username
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
def test_02_validate_activation(self): HEADING() res = os.popen('cm cloud list |' 'grep india |' 'grep True |' 'wc -l').read() assert res.strip() == "1"
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
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)
def test06_wrong_status(self): HEADING() try: print self.projects.names("wrong") except Exception, e: print e pass
def test_i066(self): HEADING() name = "i066" attribute = "cm_doesnotexist" print("GET ATTRIBUTE") data = self.inventory.get_attribute(name, attribute) print(data)
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)
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
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
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
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)
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"
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"]))
def test09_type(self): HEADING() print("Find key type of {0}:".format(self.mykey), keytype(self.mykey)) for name in self.key_store.names(): print(name) value = self.key_store[name] print(keytype(name), name, value) assert True
def test_expand(self): HEADING() result = self.config.get('cloudmesh.clouds.india') dir = result['credentials']['OS_CACERT'] print(dir) assert dir.startswith("~") dir = path_expand(dir) print(dir) assert not dir.startswith("~")
def test_getitem_server(self): HEADING() filename = config_file("/cloudmesh_server.yaml") config = ConfigDict(filename=filename) print(config) existing = config.get("cloudmesh.server.mongo.db") test1 = existing is not None print("QUERY", existing) print("Port", config.get("cloudmesh.server.mongo.port"))
def test_11_quick_start(self): HEADING() global vm vmname = "nosetests_" + str(random.randint(1, 100)) res = os.popen('cm "vm start --name={0}"'.format(vmname)).read() assert ("job status: PENDING" in res or "job status: STARTED" in res) == True vm.append(vmname) time.sleep(1)
def test_add(self): HEADING() self.db.add('gregor', '/hello', 'VMs', '100') self.db.add('gregor', '/hello', 'images', '99') vms = self.db.get('gregor', '/hello', 'VMs') images = self.db.get('gregor', '/hello', 'images') assert vms == 100 assert images == 99
def test_07_list_public_ips(self): """list the ips""" HEADING() print "List all public ips allocated to the current account..." ips = self.cloud.list_allocated_ips() ips_id_to_instance = {} for ip in ips: ips_id_to_instance[ip['id']] = ip['instance_id'] print ips_id_to_instance
def test_03_flavors(self): """get the flavor""" 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.flavor('m1.tiny')['ram'] == 512
def test_expand(self): HEADING() result = self.config.get('cloudmesh.clouds.sierra_openstack_grizzly') dir = result['credentials']['OS_CACERT'] print dir assert dir.startswith("~") dir = path_expand(dir) print dir assert not dir.startswith("~")
def test09_type(self): HEADING() print "Find key type of gregor:", self.keys.type("gregor") for name in self.keys.names(): print name value = self.keys[name] print self.keys.type(name), name, value assert True
def test17_key(self): HEADING() keys = self.config.userkeys() # print "DEFAULT>", self.config.userkeys('default') # print "TEST>", self.config.userkeys('test') print keys, keys['default'], keys['keylist'][keys['default']] assert ('default' in keys) and (keys['default'] in keys['keylist'])
def test_getitem_server(self): HEADING() filename = "~/.futuregrid/cloudmesh_server.yaml" config = ConfigDict(filename=filename) print config existing = config.get("cloudmesh.server.mongo.db") test1 = existing is not None print "QUERY", existing print "Port", config.get("cloudmesh.server.mongo.port")
def start(self): HEADING() image = self.configuration.default(self.name)['image'] flavor = self.configuration.default(self.name)['flavor'] self.configuration.prefix = "gvonlasz-test" self.configuration.incr() name = self.configuration.vmname print("STARTING IMAGE", name, image, flavor) result = self.cloud.vm_create(name, flavor, image) print(result)