def test_cluster(self): driver = self.login() # Get user quota from kamaki user_quota = check_quota(self.token, self.project_id) flavors = get_flavor_lists(self.token) # List of disk size choices disk_list = flavors['disk'] # Avalable user disk size available_disk = user_quota['disk']['available'] # Give Selenium the values cluster_size, master and slave to use for # the cluster_size, master and slave disksize buttons of # cluster/create screen. cluster_size, master, slave ,remaining_disk = self.calculate_cluster_resources(disk_list, available_disk) try: Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(str(cluster_size)) time.sleep(1) except: self.assertTrue(False,'Not enough vms to run the test') time.sleep(1) try: # Call the bind function that creates ~okeanos vms and # causes later the server to respond with an error message to # user's create cluster request master_ip, server = self.bind_okeanos_resources(remaining_disk, disk_list) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div/div/button").click() time.sleep(1) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[2]/div/button").click() time.sleep(1) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[3]/div/button["+ master +"]").click() time.sleep(1) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div/div/button").click() time.sleep(1) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[2]/div/button").click() time.sleep(1) driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[3]/div/button["+ slave +"]").click() time.sleep(1) driver.find_element_by_id("next").click() for i in range(60): try: if "Disk size selection exceeded cyclades disk size limit" == driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text: break except: pass time.sleep(1) else: self.fail("time out") time.sleep(3) self.assertEqual("Disk size selection exceeded cyclades disk size limit", driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text) finally: os.system('rm *_root_password') destroy_cluster(self.token, master_ip)
def project_list_flavor_quota(user): """Creates the list of resources for every project a user has quota""" okeanos_token = unmask_token(encrypt_key, user.okeanos_token) list_of_resources = list() flavors = get_flavor_lists(okeanos_token) auth = check_credentials(okeanos_token) ssh_info = ssh_key_list(okeanos_token) ssh_keys_names =list() dict_quotas = auth.get_quotas() try: list_of_projects = auth.get_projects(state='active') except ClientError: msg = ' Could not get list of projects' raise ClientError(msg, error_get_list_projects) # Id for ember-data, will use it for store.push the different projects ember_project_id = 1 for item in ssh_info: # find the names of available ssh keys if item.has_key('name'): ssh_keys_names.append(item['name']) for project in list_of_projects: # Put system project in the first place of project list if project['name'] == 'system:'+str(project['id']): list_of_projects.remove(project) list_of_projects.insert(0,project) for project in list_of_projects: if project['id'] in dict_quotas: quotas = check_quota(okeanos_token, project['id']) images = check_images(okeanos_token, project['id']) list_of_resources.append(retrieve_ClusterCreationParams(flavors, quotas, images, project['name'], user, ember_project_id, ssh_keys_names)) ember_project_id = ember_project_id + 1 return list_of_resources