Example #1
0
    def create_router_interface(cls, router_link, subnet_name, subnet_ip):
        """
        Function for creating a router interface

        :param router_link: link of router details for specified router
        :param subnet_name: name of subnet
        :param subnet_ip: ip of subnet
        """

        print "Create Router Interface (Admin -> System -> Routers)----------------------------------------------------"
        print subnet_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(router_link + constants.ROUTER_INTERFACE_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        create_button = driver.find_element_by_id("interfaces__action_create")
        create_button.click()

        subnet_name_input = Select(driver.find_element_by_id("id_subnet_id"))
        subnet_name_input.select_by_visible_text(subnet_name)

        subnet_ip_input = driver.find_element_by_id("id_ip_address")
        subnet_ip_input.send_keys(subnet_ip)

        subnet_ip_input.submit()
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #2
0
    def create_mem_profile(cls, host_name, mem_profile_name):
        """
        Function for creating a memory profile for specified host

        :param host_name: name of host in Hosts table
        :param mem_profile_name: name of memory profile for specified host
        """

        # Check if profile already exists
        return_value = cls.check_profile_exists(
            mem_profile_name, "?tab=inventory__memoryprofiles")
        if (return_value == 1):
            # Reset URL to home page in Horizon
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
            return
        else:
            pass
        print "Create Memory Profile (Admin -> System -> Inventory)----------------------------------------------------"
        host_link = ""
        print host_name
        print mem_profile_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(url +
                                "/admin/inventory/?tab=inventory__hosts"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get URL of compute passed to function
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_to_lock with link
            if (host_name in host_local):
                host_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(DriverUtils.set_url(host_link + constants.HOST_MEMORY_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id(
            "memorys__action_createMemoryProfile")
        create_button.click()

        mem_profile_name_input = driver.find_element_by_id("id_hostname")
        mem_profile_name_input.send_keys(mem_profile_name)
        mem_profile_name_input.submit()

        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #3
0
    def tenants(cls, username, password, email, project_name):
        """
        Function for initializing tenants class

        :param username: username of tenant
        :param password: password of tenant
        :param email: email of tenant
        :param project_name: name of project
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/identity/users/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        return_value = cls.check_tenants(username)
        if (return_value == 1):
            # Reset URL to home page in Horizon
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
            return
        else:
            pass
        cls.create_tenant(username, password, email, project_name)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #4
0
    def routers(cls, router_name, external_network_name):
        """
        Function for initializing routers class

        :param router_name: name of router
        :param external_network_name: name of external network
        :return router_full_link: link of router details for specified router
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/project/routers/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        cls.create_router(router_name, external_network_name)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        router_full_link = cls.get_router_link(router_name)
        if (router_full_link == -1):
            print "Test: FAIL - Error finding flavor name"
            return
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        return router_full_link
Example #5
0
    def volumes(cls, volume_name, volume_source, image_source,
                availability_zone):
        """
        Function for initializing volumes class

        :param volume_name: name of volume
        :param volume_source: source of volume [image]
        :param image_source: image name
        :param availability_zone: [any or nova]
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(
                url +
                "/project/volumes/?tab=volumes_and_snapshots__volumes_tab"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        cls.create_volume(volume_name, volume_source, image_source,
                          availability_zone)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #6
0
    def get_sensors(cls, host_name):

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        cls.base_url = url
        # Append to end of URL
        driver.get(url + "/admin/inventory/")
        driver.find_element_by_link_text("Inventory").click()
        driver.find_element_by_link_text("Hosts").click()
        driver.find_element_by_link_text("controller-0").click()
        #driver.find_element_by_link_text(host_name).click()
        driver.find_element_by_link_text("Sensors").click()

        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        # Confirm sensor present
        time.sleep(10)
        check_return_value = cls.check_sensor_exists()
        if (check_return_value == 1):
            print "Configured alarms found"
            return True
        else:
            print "No configured alarms found"
            return False
Example #7
0
    def check_profile_exists(cls, profile_name, url_tab):
        """
        Function to check if profile exists
        :param profile_name: name of profile to check

        :return return_value
        """

        return_value = -1
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/inventory/" + url_tab))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Check if profile already exists
        words_on_page = driver.find_element_by_xpath("//*[contains(text()," +
                                                     profile_name + ")]")
        if (profile_name in words_on_page.text):
            return 1
        else:
            return_value = 0
        return return_value
Example #8
0
    def hosts(cls):
        """
        Function for initializing hosts class

        :return host_list: list of hosts in host table
        """

        print "Check Hosts (Admin -> System -> Inventory)--------------------------------------------------------------"
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(url +
                                "/admin/inventory/?tab=inventory__hosts"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        host_list = cls.get_hosts()
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        return host_list
Example #9
0
    def networks(cls, network_provider_name, network_provider_type, mtu, vlan_transparent):
        """
        Function for initializing networks class

        :param network_provider_name: provider network name for network
        :param network_provider_type: type of network [flat, vlan, vxlan]
        :param mtu: maximum transfer units
        :param vlan_transparent: True or False
        :return provider_net_link: link to provider net details to specified provider network
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/networks/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        cls.create_provider_net(network_provider_name, network_provider_type, mtu, vlan_transparent)
        time.sleep(5)
        provider_net_link = cls.get_provider_net(network_provider_name)
        if(provider_net_link == -1):
            print "Test: FAIL - Error finding provider net name"
            return
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        return provider_net_link
Example #10
0
    def images(cls, image_name, image_location, format, copy_data, timeout, downtime, public, instance_auto_recovery):
        """
        Function for initializing images class

        :param image_name: name of image
        :param image_location: URL of image location
        :param format: format of image
        :param copy_data: copy image data to service [True or False]
        :param timeout: timeout for live migration
        :param downtime: downtime for live migration
        :param public: is the image public [True or False]
        :param instance_auto_recovery: [True or False]
        """

        print "Create Image (Admin -> System -> Images)----------------------------------------------------------------"
        print image_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/images/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        cls.create_images(image_name, image_location, format, copy_data, timeout, downtime, public,
                          instance_auto_recovery)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #11
0
    def key_pairs(cls, key_pair_name):
        """
        Function for initializing key pairs class

        :param key_pair_name: name of key pair
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(
                url +
                "/project/access_and_security/?tab=access_security_tabs__keypairs_tab"
            ))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        return_value = cls.check_key_pair(key_pair_name)
        if (return_value == 1):
            # Reset URL to home page in Horizon
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
            return
        else:
            pass
        cls.create_key_pair(key_pair_name)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #12
0
    def get_flavor_link(cls, flavor_name):
        """
        Function for getting flavor details link

        :param flavor_name: name of flavor
        :return flavor_id_link: link for details page of flavor name sent
        """

        flavor_id_link = -1
        # Get driver
        driver = DriverUtils.get_driver()
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_to_lock with link
            if(flavor_name in host_local):
                flavor_id_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(DriverUtils.set_url(flavor_id_link + constants.FLAVOR_EXTRA_SPEC_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        return flavor_id_link
Example #13
0
    def flavors(cls, flavor_name, vcpus, ram, root_disk, ephemeral_disk, swap_disk):
        """
        Function for initializing flavors class

        :param flavor_name: name of flavor
        :param vcpus: number of vcpus
        :param ram: amount of RAM (MB)
        :param root_disk: size of root disk (GB)
        :param ephemeral_disk: size of ephemeral disk (GB)
        :param swap_disk: size of swap disk (MB)
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/flavors/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        cls.create_flavor(flavor_name, vcpus, ram, root_disk, ephemeral_disk, swap_disk)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        flavor_full_link = cls.get_flavor_link(flavor_name)
        if(flavor_full_link == -1):
            print "Test: FAIL - Error finding flavor name"
            return
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        return flavor_full_link
Example #14
0
    def quotas(cls, project_name, quota_dict):
        """
        Function for initializing modify quotas class

        :param project_name: name of project in Horizon
        :param quota_dict: dictionary of all quotas to modify [example (input_id_name: value)]
        """

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/identity/"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call Functions below
        project_id = cls.get_project_id(project_name)
        if(project_id == -1):
            print "Test: FAIL - Error finding project name"
            return
        cls.modify_quotas(project_id, quota_dict)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #15
0
    def create_provider_net(cls, network_provider_name, network_provider_type, mtu, vlan_transparent):
        """
        Function for creating a provider network

        :param network_provider_name: provider network name for network
        :param network_provider_type: type of network [flat, vlan, vxlan]
        :param mtu: maximum transfer units
        :param vlan_transparent: True or False
        """

        print "Create Provider Network (Admin -> System -> Networks)---------------------------------------------------"
        print network_provider_name
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "?tab=networks__provider_networks"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id("provider_networks__action_create")
        create_button.click()

        name_input = driver.find_element_by_id("id_name")
        name_input.send_keys(network_provider_name)

        type_input = Select(driver.find_element_by_id("id_type"))
        # Consider changing 'flat' 'vlan' 'vxlan' to constants?
        if(network_provider_type == "flat"):
            type_input.select_by_visible_text("flat")
        if(network_provider_type == "vlan"):
            type_input.select_by_visible_text("vlan")
        if(network_provider_type == "vxlan"):
            type_input.select_by_visible_text("vxlan")

        mtu_input = driver.find_element_by_id("id_mtu")
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(mtu)

        vlan_input = driver.find_element_by_id("id_vlan_transparent")
        if(vlan_transparent == True):
            vlan_input.click()
        if(vlan_transparent == False):
            pass

        vlan_input.submit()
Example #16
0
    def set_alarm_action(cls,
                         link,
                         action='log',
                         severity='critical',
                         alarm_name='server power'):

        driver = DriverUtils.get_driver()
        driver.get(link)

        driver.find_element_by_link_text("Sensors").click()

        links = driver.find_elements_by_partial_link_text('')
        for i in range(len(links)):
            sensor_name = links[i].get_attribute("text")
            #print("link: %s" % sensor_name)
            if (alarm_name in sensor_name):
                sensor_id = links[i + 1].get_attribute("id")
                print("Sensor name: %s" % sensor_name)
                print("Sensor id: %s" % sensor_id)
                driver.find_element_by_id(sensor_id).click()
                break

        # set the audit interval to 10secs
        driver.find_element_by_id("id_audit_interval_group").clear()
        driver.find_element_by_id("id_audit_interval_group").send_keys("10")

        # set the action for the severity level specified
        Select(driver.find_element_by_id(
            "id_actions_%s_group" % severity)).select_by_visible_text(action)
        driver.find_element_by_css_selector("option[value=\"%s\"]" %
                                            action.lower()).click()

        # save the entries
        driver.find_element_by_xpath("//input[@value='Save']").click()

        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        time.sleep(10)

        # Confirm alarm severity and action
        check_return_value = cls.check_alarm(severity)
        if (check_return_value == 1):
            print("Changed for alarm severity: %s to action: %s" %
                  (severity, action))
            pass
        else:
            print(
                "No alarms found for alarm severity: %s. Please check logs." %
                severity)
            return
Example #17
0
    def provider_net_range_create(cls, provider_net_link, provider_name, shared, project_name, min_range, max_range):
        """
        Function for creating a net range in specified provider network

        :param provider_net_link: link to provider net details
        :param provider_name: name of provider net
        :param shared: True or False
        :param project_name: name of project
        :param min_range: minimum segmentation range
        :param max_range: maximum segmentation range
        """

        print "Create Provider Network: Range (Admin -> System -> Networks)--------------------------------------------"
        # Get driver
        driver = DriverUtils.get_driver()
        DriverUtils.set_url(provider_net_link)
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id("provider_network_ranges__action_create")
        create_button.click()

        name_input = driver.find_element_by_id("id_name")
        name_input.send_keys(provider_name)

        if(shared == True):
            shared_input = driver.find_element_by_id("id_shared")
            shared_input.click()
        else:
            pass

        if(project_name == None):
            pass
        else:
            project_input = Select(driver.find_element_by_id("id_tenant_id"))
            project_input.select_by_visible_text(project_name)

        min_range_input = driver.find_element_by_id("id_minimum")
        min_range_input.send_keys(min_range)

        max_range_input = driver.find_element_by_id("id_maximum")
        max_range_input.send_keys(max_range)
        max_range_input.submit()
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #18
0
    def router_distributed(cls, router_link, distributed):
        """
        Function for changing router distribution

        :param router_link: link of router details for specified router
        :param distributed: True or False
        """

        if (distributed == False):
            pass
        else:
            # Get driver
            driver = DriverUtils.get_driver()
            # Get URL text from class
            url = DriverUtils.get_url()
            # Append to end of URL
            driver.get(DriverUtils.set_url(router_link))
            # Navigate to newly appended URL
            driver.get(DriverUtils.get_url())
            # Wait for elements on page to load
            DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

            # Parse router link
            parse = router_link.split("/")
            router_id = parse[5]

            # Edit router button

            edit_dropdown_button = driver.find_element_by_css_selector(
                constants.ROUTER_EDIT_INTERFACE_DROPDOWN)
            edit_dropdown_button.click()

            edit_button = constants.ROUTER_EDIT_INTERFACE_FIRST_HALF + router_id + constants.ROUTER_EDIT_INTERFACE_SECOND_HALF

            edit_button_input = driver.find_element_by_id(edit_button)
            edit_button_input.click()

            distributed_input = Select(driver.find_element_by_id("id_mode"))
            distributed_input.select_by_visible_text("Distributed")

            # Get name for form submission
            name_input = driver.find_element_by_id("id_name")
            name_input.submit()

            # Reset URL to home page in Horizon
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #19
0
    def create_qos_policy(cls, policy_name, description, weight, project_name):
        """
        Function for creating a QoS policy

        :param policy_name: name of QoS policy
        :param description: description of QoS policy
        :param weight: scheduler weight
        :param project_name: name of project
        """

        print "Create Network QoS Policy (Admin -> System -> Networks)-------------------------------------------------"
        print policy_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/networks/?tab=networks__qos"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id("qos__action_create")
        create_button.click()

        policy_name_input = driver.find_element_by_id("id_name")
        policy_name_input.send_keys(policy_name)

        description_input = driver.find_element_by_id("id_description")
        description_input.send_keys(description)

        weight_input = driver.find_element_by_id("id_weight")
        weight_input.send_keys(weight)

        if(project_name == None):
            pass
        else:
            project_input = Select(driver.find_element_by_id("id_tenant_id"))
            project_input.select_by_visible_text(project_name)

        policy_name_input.submit()

        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #20
0
    def swact_host(cls, host_name):

        print "Swact Host Information------------------------------------------"
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/inventory/?tab=inventory__hosts"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Call function to get list of all hosts
        cls.get_hosts(host_name)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
Example #21
0
    def create_extra_spec(cls, flavor_full_link, first_input, second_input):
        """
        Function for creating flavor extra spec

        :param flavor_full_link: link to flavor details section in Horizon
        :param first_input: extra spec type [example (CPU Policy)]
        :param second_input: extra spec type details [example (Dedicated)]
        """

        print "Flavors: Create Extra Spec (Admin -> System -> Flavors)-------------------------------------------------"
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(flavor_full_link + constants.FLAVOR_EXTRA_SPEC_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        create_button = driver.find_element_by_id("extras__action_create")
        create_button.click()

        # Select extra spec
        extra_spec_first_input = Select(driver.find_element_by_id("id_type"))
        if(first_input in constants.FLAVOR_EXTRA_SPEC_TYPE_CPU_POLICY):
            extra_spec_first_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_CPU_POLICY)
            if(second_input in constants.FLAVOR_EXTRA_SPEC_TYPE_CPU_POLICY_DEDICATED):
                extra_spec_second_input = Select(driver.find_element_by_id("id_cpu_policy"))
                extra_spec_second_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_CPU_POLICY_DEDICATED)
        if(first_input in constants.FLAVOR_EXTRA_SPEC_TYPE_MEMORY_PAGE_SIZE):
            extra_spec_first_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_MEMORY_PAGE_SIZE)
            if(second_input in constants.FLAVOR_EXTRA_SPEC_TYPE_MEMORY_PAGE_SIZE_2048):
                extra_spec_second_input = Select(driver.find_element_by_id("id_mem_page_size"))
                extra_spec_second_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_MEMORY_PAGE_SIZE_2048)
        if(first_input in constants.FLAVOR_EXTRA_SPEC_TYPE_VCPU_MODEL):
            extra_spec_first_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_VCPU_MODEL)
            if(second_input in constants.FLAVOR_EXTRA_SPEC_TYPE_VCPU_MODEL_INTEL_9XX):
                extra_spec_second_input = Select(driver.find_element_by_id("id_cpu_model"))
                extra_spec_second_input.select_by_visible_text(constants.FLAVOR_EXTRA_SPEC_TYPE_VCPU_MODEL_INTEL_9XX)
        submit_form = driver.find_element_by_id("id_type")
        submit_form.submit()
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #22
0
 def check_alarms(cls):
     """
     Function for checking alarms in Fault Management
     """
     print "Fault Alarm Management Information----------------------------------------------------------------------"
     # Get driver
     driver = DriverUtils.get_driver()
     # Get URL text from class
     url = DriverUtils.get_url()
     # Append to end of URL
     driver.get(
         DriverUtils.set_url(
             url + "/admin/fault_management/?tab=alarms_tabs__alarms"))
     # Navigate to newly appended URL
     driver.get(DriverUtils.get_url())
     # Wait for elements on page to load
     DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
     # Call function to get fault names
     cls.get_fault_names()
     # Reset URL to home page in Horizon
     DriverUtils.set_url(settings.DEFAULT_URL)
Example #23
0
    def set_sensor_action(cls,
                          host_name,
                          action,
                          severity='critical',
                          alarm_name='server power'):

        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        cls.base_url = url
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(url +
                                "/admin/inventory/?tab=inventory__hosts"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        # Call function to set action
        cls.set_host_alarms(host_name, action, severity, alarm_name)
        # Reset URL to home page in Horizon
        DriverUtils.set_url(cls.base_url)
Example #24
0
    def add_local_storage(cls, host_name, lvm_size):
        """
        Function for creating local storage on a host

        :param host_name: name of host in Hosts table
        :param lvm_size: local volume size
        """

        print "Add Local Storage (Admin -> System -> Inventory)--------------------------------------------------------"
        print host_name
        print lvm_size
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        DriverUtils.set_url(url + "/admin/inventory/?tab=inventory__hosts")
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get URL of compute passed to function
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_name with link
            if (host_name in host_local):
                host_link = link.get_attribute("href")
        # Append to end of URL
        DriverUtils.set_url(host_link + constants.HOST_STORAGE_TAB)
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Save current URL
        save_url = DriverUtils.get_url()
        # Find create button
        create_button = driver.find_element_by_id(
            "localvolumegroups__action_addlocalvolumegroup")
        create_button.click()
        # Find element and submit form
        submit_element = driver.find_element_by_id("id_lvm_vg_name")
        submit_element.submit()

        time.sleep(settings.DEFAULT_SLEEP_TIME)

        DriverUtils.set_url(save_url)
        driver.get(DriverUtils.get_url())

        # Find create button
        add_pv_button = driver.find_element_by_id(
            "physicalvolumes__action_addphysicalvolume")
        add_pv_button.click()
        # Find element and submit form
        submit_element_pv = driver.find_element_by_id("id_disks")
        submit_element_pv.submit()

        time.sleep(settings.DEFAULT_SLEEP_TIME)

        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get URL of compute passed to function
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match nova-local with link
            if ("nova-local" in host_local):
                host_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(
                host_link +
                constants.HOST_STORAGE_LOCAL_VOLUME_GROUP_PARAM_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        # TODO: Find edit size button
        edit_button = driver.find_element_by_id(
            "params__row_instances_lv_size_mib__action_edit")
        edit_button.click()
        # TODO: Find size input
        lvm_size_input = driver.find_element_by_id("id_instances_lv_size_mib")
        lvm_size_input.send_keys(Keys.BACKSPACE)
        lvm_size_input.send_keys(Keys.BACKSPACE)
        lvm_size_input.send_keys(lvm_size)
        # TODO: Submit form
        lvm_size_input.submit()

        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #25
0
    def create_network(cls, network_name, project_name, network_type, physical_network, \
                       segmentation_id, qos_policy, shared, external_network, vlan_transparent):
        """
        Function for creating a network

        :param network_name: name of network
        :param project_name: name of project
        :param network_type: type of network [flat, vlan, vxlan]
        :param physical_network: name of provider network(s)
        :param segmentation_id: [int]
        :param qos_policy: name of QoS policy
        :param shared: True or False
        :param external_network: True or False
        :param vlan_transparent: True or False
        :return network_name: name of network
        """

        print "Create Network (Admin -> System -> Networks)------------------------------------------------------------"
        print network_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(DriverUtils.set_url(url + "/admin/networks/?tab=networks__networks"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id("networks__action_create")
        create_button.click()

        network_name_input = driver.find_element_by_id("id_name")
        network_name_input.send_keys(network_name)

        project_input = Select(driver.find_element_by_id("id_tenant_id"))
        project_input.select_by_visible_text(project_name)

        network_type_input = Select(driver.find_element_by_id("id_network_type"))
        network_type_input.select_by_visible_text(network_type)

        physical_network_input = Select(driver.find_element_by_id("id_physical_network_vlan"))
        physical_network_input.select_by_visible_text(physical_network)

        if(segmentation_id == None):
            pass
        else:
            segmentation_id_input = driver.find_element_by_id("id_segmentation_id")
            segmentation_id_input.send_keys(segmentation_id)

        if(qos_policy == None):
            pass
        else:
            qos_policy_input = Select(driver.find_element_by_id("id_qos"))
            qos_policy_input.select_by_visible_text(qos_policy)

        if(shared == True):
            shared_input = driver.find_element_by_id("id_shared")
            shared_input.click()
        else:
            pass

        if(external_network == True):
            external_network_input = driver.find_element_by_id("id_external")
            external_network_input.click()
        else:
            pass

        if(vlan_transparent == True):
            vlan_transparent_input = driver.find_element_by_id("id_vlan_transparent")
            vlan_transparent_input.click()
        else:
            pass

        # Submit create network form
        network_name_input.submit()
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        return network_name
Example #26
0
    def create_project_subnet(cls, network_name, subnet_name, network_address, gateway_ip, disable_gateway,
                              system_managed_subnet, dhcp, allocation_pools, dns_name_servers, host_routes, vlan):
        """
        Function for creating a project network subnet

        :param network_name: name of network
        :param subnet_name: name of subnet
        :param network_address: network address in CIDR format
        :param gateway_ip: ip address of gateway
        :param disable_gateway: True or False
        :param system_managed_subnet: True or False
        :param dhcp: True or False
        :param allocation_pools: ip address allocation pools
        :param dns_name_servers: ip address list of DNS name servers
        :param host_routes: additional routes announced to the hosts
        :param vlan: vlan id of subnet
        """

        print "Create Project Network Subnet (Project -> Network -> Networks)------------------------------------------"
        print subnet_name
        network_link = -1
        print network_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        DriverUtils.set_url(url + "/project/networks/?tab=networks__networks")
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_to_lock with link
            if(network_name in host_local):
                network_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(DriverUtils.set_url(network_link))
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        create_button = driver.find_element_by_id("subnets__action_create")
        create_button.click()

        subnet_name_input = driver.find_element_by_id("id_subnet_name")
        subnet_name_input.send_keys(subnet_name)

        network_address_input = driver.find_element_by_id("id_cidr")
        network_address_input.send_keys(network_address)

        if(gateway_ip == None):
            pass
        else:
            gateway_ip_input = driver.find_element_by_id("id_gateway_ip")
            gateway_ip_input.send_keys(gateway_ip)

        if(disable_gateway == False):
            pass
        else:
            disable_gateway_input = driver.find_element_by_id("id_no_gateway")
            disable_gateway_input.click()

        next_button = driver.find_element_by_css_selector("button.btn-primary:nth-child(1)")
        next_button.click()

        if(system_managed_subnet == False):
            system_managed_subnet_input = driver.find_element_by_id("id_managed")
            system_managed_subnet_input.click()
        else:
            pass

        if(dhcp == False):
            dhcp_input = driver.find_element_by_id("id_enable_dhcp")
            dhcp_input.click()
        else:
            pass

        if(allocation_pools == None):
            pass
        else:
            allocation_pools_input = driver.find_element_by_id("id_allocation_pools")
            allocation_pools_input.send_keys(allocation_pools)

        if(dns_name_servers == None):
            pass
        else:
            dns_name_servers_input = driver.find_element_by_id("id_dns_nameservers")
            dns_name_servers_input.send_keys(dns_name_servers)

        if(host_routes == None):
            pass
        else:
            host_routes_input = driver.find_element_by_id("id_host_routes")
            host_routes_input.send_keys(host_routes)

        if(vlan == None):
            pass
        else:
            vlan_input = driver.find_element_by_id("id_vlan_id")
            vlan_input.send_keys(vlan)

        vlan_input = driver.find_element_by_id("id_vlan_id")
        vlan_input.submit()
        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #27
0
def main():

    # Get opts
    parser = argparse.ArgumentParser(
        description='Automated lab setup in Horizon')
    parser.add_argument("--headless",
                        help="Must have pyvirtualdisplay module",
                        required=False,
                        action='store_true')
    args = parser.parse_args()
    try:

        # Prep ---------------------------------------------------------------------------------------------------------
        Images.get_guest_image()
        print "Test: PASS - Get cgcs-guest.img"
        # End of Prep --------------------------------------------------------------------------------------------------

        # LAB_SETUP GUI VERSION ----------------------------------------------------------------------------------------
        project_name_one = "admin"
        project_name_two = "tenant1"
        project_name_three = "tenant2"
        tenant_list = [project_name_two, project_name_three]

        # Start web driver with firefox and set URL address to 10.10.10.2
        DriverUtils.open_driver(settings.DEFAULT_BROWSER, args.headless)
        DriverUtils.set_url(settings.DEFAULT_URL)

        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        # Call login module
        Login.login(project_name_one, project_name_one)

        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        print "Test: PASS - Begin Lab Setup"

        # Create Tenants -----------------------------------------------------------------------------------------------
        tenant_two = [
            project_name_two, project_name_two, "*****@*****.**",
            project_name_two
        ]
        tenant_three = [
            project_name_three, project_name_three, "*****@*****.**",
            project_name_three
        ]

        Tenants.tenants(tenant_two[0], tenant_two[1], tenant_two[2],
                        tenant_two[3])
        Tenants.tenants(tenant_three[0], tenant_three[1], tenant_three[2],
                        tenant_three[3])
        print "Test: PASS - Create tenants"
        # End of Create Tenants ----------------------------------------------------------------------------------------

        # Modify Quotas ------------------------------------------------------------------------------------------------
        # params (user_name, metadata Items, VCPUs, Instances, Injected Files, Injected File Content (Bytes), Volumes,
        # Volume Snapshots ,Total Size of Volumes and Snapshots (GB), RAM (MB), Security Groups, Security Groups Rules,
        # Floating IPs, Networks, Ports, Routers, Subnets)
        quota_dict_tenant_one = {
            'id_metadata_items': None,
            'id_cores': [0, 'text'],
            'id_instances': [0, 'text'],
            'id_injected_files': None,
            'id_injected_file_content_bytes': None,
            'id_volumes': [2, 'text'],
            'id_snapshots': [2, 'text'],
            'id_gigabytes': None,
            'id_ram': None,
            'id_security_group': None,
            'id_security_group_rule': None,
            'id_floatingip': [0, 'text'],
            'id_network': [4, 'text'],
            'id_port': [10, 'text'],
            'id_router': None,
            'id_subnet': [3, 'text']
        }
        quota_dict_tenant_two = {
            'id_metadata_items': None,
            'id_cores': [2, 'text'],
            'id_instances': [1, 'text'],
            'id_injected_files': None,
            'id_injected_file_content_bytes': None,
            'id_volumes': [2, 'text'],
            'id_snapshots': [2, 'text'],
            'id_gigabytes': None,
            'id_ram': None,
            'id_security_group': None,
            'id_security_group_rule': None,
            'id_floatingip': [1, 'text'],
            'id_network': [3, 'text'],
            'id_port': [39, 'text'],
            'id_router': None,
            'id_subnet': [13, 'text']
        }
        quota_dict_tenant_three = {
            'id_metadata_items': None,
            'id_cores': [2, 'text'],
            'id_instances': [1, 'text'],
            'id_injected_files': None,
            'id_injected_file_content_bytes': None,
            'id_volumes': [2, 'text'],
            'id_snapshots': [2, 'text'],
            'id_gigabytes': None,
            'id_ram': None,
            'id_security_group': None,
            'id_security_group_rule': None,
            'id_floatingip': [1, 'text'],
            'id_network': [3, 'text'],
            'id_port': [39, 'text'],
            'id_router': None,
            'id_subnet': [13, 'text']
        }
        ModifyQuotas.quotas(project_name_one, quota_dict_tenant_one)
        ModifyQuotas.quotas(project_name_two, quota_dict_tenant_two)
        ModifyQuotas.quotas(project_name_three, quota_dict_tenant_three)
        print "Test: PASS - Modify quotas"
        # End of Modify Quotas -----------------------------------------------------------------------------------------

        # Create Flavors -----------------------------------------------------------------------------------------------
        # Params (flavor_name, vcpus, ram, root_disk, ephemeral_disk, swap_disk)
        flavor_one = [
            "small", 1, 512, 1, 0, 0, "CPU Policy", "Dedicated",
            "Memory Page Size", "2048"
        ]
        flavor_two = [
            "medium.dpdk", 2, 1024, 1, 0, 0, "CPU Policy", "Dedicated",
            "Memory Page Size", "2048", "VCPU Model",
            "Intel Core i7 9xx (Nehalem Class Core i7)"
        ]
        flavor_three = [
            "small.float", 1, 512, 1, 0, 0, "CPU Policy", "Dedicated",
            "Memory Page Size", "2048"
        ]

        flavor_full_link = Flavors.flavors(flavor_one[0], flavor_one[1],
                                           flavor_one[2], flavor_one[3],
                                           flavor_one[4], flavor_one[5])
        Flavors.create_extra_spec(flavor_full_link, flavor_one[6],
                                  flavor_one[7])
        Flavors.create_extra_spec(flavor_full_link, flavor_one[8],
                                  flavor_one[9])
        flavor_full_link = Flavors.flavors(flavor_two[0], flavor_two[1],
                                           flavor_two[2], flavor_two[3],
                                           flavor_two[4], flavor_two[5])
        Flavors.create_extra_spec(flavor_full_link, flavor_two[6],
                                  flavor_two[7])
        Flavors.create_extra_spec(flavor_full_link, flavor_two[8],
                                  flavor_two[9])
        Flavors.create_extra_spec(flavor_full_link, flavor_two[10],
                                  flavor_two[11])
        flavor_full_link = Flavors.flavors(flavor_three[0], flavor_three[1],
                                           flavor_three[2], flavor_three[3],
                                           flavor_three[4], flavor_three[5])
        Flavors.create_extra_spec(flavor_full_link, flavor_three[6],
                                  flavor_three[7])
        Flavors.create_extra_spec(flavor_full_link, flavor_three[8],
                                  flavor_three[9])
        print "Test: PASS - Create flavors"
        # End of Create Flavors ----------------------------------------------------------------------------------------

        # Create Key Pairs ---------------------------------------------------------------------------------------------
        Logout.logout()
        Login.login(project_name_two, project_name_two)
        KeyPairs.key_pairs("keypair-tenant1")
        Logout.logout()
        Login.login(project_name_three, project_name_three)
        KeyPairs.key_pairs("keypair-tenant2")
        Logout.logout()
        Login.login(project_name_one, project_name_one)
        print "Test: PASS - Create key pairs"
        # End of Create Key Pairs --------------------------------------------------------------------------------------
        # Provider Networks --------------------------------------------------------------------------------------------
        provider_network_one = [
            "group0-ext0", "vlan", 1500, True, "group0-ext0-r0-0", True, None,
            10, 10
        ]
        provider_network_two = [
            "group0-data0", "vlan", 1500, True, "group0-data0-r1-0", True,
            project_name_two, 600, 615
        ]
        provider_network_three = [
            "group0-data0b", "vlan", 1500, True, "group0-data0b-r2-0", True,
            None, 700, 731
        ]
        provider_network_four = [
            "group0-data1", "vlan", 1500, True, "group0-data1-r3-0", True,
            project_name_three, 616, 631
        ]

        provider_net_link = Networks.networks(provider_network_one[0],
                                              provider_network_one[1],
                                              provider_network_one[2],
                                              provider_network_one[3])
        print provider_net_link
        # Create range for provider net above
        Networks.provider_net_range_create(provider_net_link,
                                           provider_network_one[4],
                                           provider_network_one[5],
                                           provider_network_one[6],
                                           provider_network_one[7],
                                           provider_network_one[8])
        provider_net_link = Networks.networks(provider_network_two[0],
                                              provider_network_two[1],
                                              provider_network_two[2],
                                              provider_network_two[3])
        # Create range for provider net above
        Networks.provider_net_range_create(provider_net_link,
                                           provider_network_two[4],
                                           provider_network_two[5],
                                           provider_network_two[6],
                                           provider_network_two[7],
                                           provider_network_two[8])
        provider_net_link = Networks.networks(provider_network_three[0],
                                              provider_network_three[1],
                                              provider_network_three[2],
                                              provider_network_three[3])
        # Create range for provider net above
        Networks.provider_net_range_create(provider_net_link,
                                           provider_network_three[4],
                                           provider_network_three[5],
                                           provider_network_three[6],
                                           provider_network_three[7],
                                           provider_network_three[8])
        provider_net_link = Networks.networks(provider_network_four[0],
                                              provider_network_four[1],
                                              provider_network_four[2],
                                              provider_network_four[3])
        # Create range for provider net above
        Networks.provider_net_range_create(provider_net_link,
                                           provider_network_four[4],
                                           provider_network_four[5],
                                           provider_network_four[6],
                                           provider_network_four[7],
                                           provider_network_four[8])
        print "Test: PASS - Create provider networks"
        # END Of Provider Networks--------------------------------------------------------------------------------------

        # SCRIPT EXPECTS COMPUTES TO BE ONLINE NOW
        # Check computes have 'Availability State' as 'Online'
        host_list = Hosts.hosts()

        # Create Interfaces & Modify Hosts -----------------------------------------------------------------------------
        provider_net_list1 = ["group0-ext0", "group0-data0", "group0-data0b"]
        provider_net_list2 = ["group0-data1"]

        for hostname in host_list:
            Hosts.modify_interface(hostname[0], "data0", "data", "eth2", 1500,
                                   provider_net_list1)
            Hosts.modify_interface(hostname[0], "data1", "data", "eth3", 1500,
                                   provider_net_list2)
            # Local storage changes:
            Hosts.add_local_storage(hostname[0], 2048)

        # Controller-1 Changes:
        # Modify OAM interfaces for controller-1
        Hosts.modify_interface("controller-1", "oam0", "oam", "eth0", 1500,
                               None)
        # Add cinder device configuration for controller-1
        Hosts.create_cinder_device("controller-1")

        for host in host_list:
            # Host Profiles
            if_profile_name = "ifprofile-" + host[0]
            cpu_profile_name = "cpuprofile-" + host[0]
            mem_profile_name = "memprofile-" + host[0]
            Hosts.create_interface_profile(host[0], if_profile_name)
            Hosts.create_cpu_profile(host[0], cpu_profile_name)
            Hosts.create_mem_profile(host[0], mem_profile_name)
            # Not sure how to apply profiles? Look like lab_setup.sh profiles when I create them
        print "Test: PASS - Create & modify host interfaces"
        # Create Interfaces & Modify Hosts -----------------------------------------------------------------------------

        # Create Images ------------------------------------------------------------------------------------------------
        # FIX TODO: Jira: https://jira.wrs.com:8443/browse/CGTS-3158
        # TODO: If Jira above is fixed, please uncomment the two lines of code (Images.images) below.
        # TODO: You no longer need to manually createthe guest image.
        # Images.images("cgcs-guest", "http://yow-cgcs-test.wrs.com/files/cgcs_guestimg/cgcs-guest.img", "Raw", False,
        #              None, None, True, False)
        print "Test: PASS - Create image"
        # End of Create Images -----------------------------------------------------------------------------------------

        # Create Volumes -----------------------------------------------------------------------------------------------
        Logout.logout()
        Login.login(project_name_two, project_name_two)
        Volumes.volumes("vol-tenant1-avp1", "Image", "cgcs-guest (608.0 MB)",
                        "nova")
        Logout.logout()
        Login.login(project_name_three, project_name_three)
        Volumes.volumes("vol-tenant2-avp1", "Image", "cgcs-guest (608.0 MB)",
                        "nova")
        Logout.logout()
        Login.login(project_name_one, project_name_one)
        print "Test: PASS - Create volumes"
        # End of Create Volumes ----------------------------------------------------------------------------------------

        # Create QoS Policies ------------------------------------------------------------------------------------------
        qos_policy_list = ["external-qos", "internal-qos"]

        Networks.create_qos_policy("external-qos", "External Network Policy",
                                   16, project_name_one)
        Networks.create_qos_policy("internal-qos", "Internal Network Policy",
                                   4, project_name_one)

        for tenant in tenant_list:
            name = tenant + "-mgmt-qos"
            desc = tenant + "Management Network Policy"
            Networks.create_qos_policy(name, desc, 8, tenant)
            qos_policy_list.append(name)
        print "Test: PASS - QoS policies"
        # End of Create QoS Policies -----------------------------------------------------------------------------------

        # Create Networks ----------------------------------------------------------------------------------------------
        network_one = [
            "external-net0", project_name_one, "vlan", "group0-ext0", 10,
            "external-qos", True, True, False
        ]
        network_two = [
            "internal0-net0", project_name_one, "vlan", "group0-data0b", 700,
            "internal-qos", True, False, False
        ]
        network_three = [
            "tenant1-mgmt-net", project_name_two, "vlan", "group0-data0", None,
            "tenant1-mgmt-qos", False, False, False
        ]
        subnet_one = [
            "external-subnet0", "192.168.1.0/24", "192.168.1.1", False, True,
            False, "192.168.1.2,192.168.1.254", None, None, None
        ]
        subnet_two = [
            "internal0-subnet0-1", "10.0.1.0/24", None, True, False, False,
            None, None, None, 1
        ]

        network_name = Networks.create_network(network_one[0], network_one[1],
                                               network_one[2], network_one[3],
                                               network_one[4], network_one[5],
                                               network_one[6], network_one[7],
                                               network_one[8])
        # Create subnet for network above
        Networks.create_subnet(network_name, subnet_one[0], subnet_one[1],
                               subnet_one[2], subnet_one[3], subnet_one[4],
                               subnet_one[5], subnet_one[6], subnet_one[7],
                               subnet_one[8], subnet_one[9])

        # Create Network
        network_name = Networks.create_network(network_two[0], network_two[1],
                                               network_two[2], network_two[3],
                                               network_two[4], network_two[5],
                                               network_two[6], network_two[7],
                                               network_two[8])
        # Create subnet for network above
        Networks.create_subnet(network_name, subnet_two[0], subnet_two[1],
                               subnet_two[2], subnet_two[3], subnet_two[4],
                               subnet_two[5], subnet_two[6], subnet_two[7],
                               subnet_two[8], subnet_two[9])

        network_name = Networks.create_network(
            network_three[0], network_three[1], network_three[2],
            network_three[3], network_three[4], network_three[5],
            network_three[6], network_three[7], network_three[8])
        print "Test: PASS - Create networks"
        # End of Create Networks ---------------------------------------------------------------------------------------

        # Create Router, router interfaces and Subnets -----------------------------------------------------------------
        # ...............................................Tenant 1.......................................................
        project_subnet_t1_zero = [
            "tenant1-mgmt-subnet0", "192.168.101.0/27", "192.168.101.1", False,
            True, True, "192.168.101.2,192.168.101.30",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t1_one = [
            "tenant1-mgmt-subnet1", "192.168.101.32/27", "192.168.101.33",
            False, True, True, "192.168.101.34,192.168.101.62",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t1_two = [
            "tenant1-mgmt-subnet2", "192.168.101.64/27", "192.168.101.65",
            False, True, True, "192.168.101.66,192.168.101.94",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t1_three = [
            "tenant1-mgmt-subnet3", "10.101.1.0/27", "10.101.1.1", False, True,
            True, "10.101.1.2,10.101.1.30",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]
        project_subnet_t1_four = [
            "tenant1-mgmt-subnet4", "10.101.1.32/27", "10.101.1.33", False,
            True, True, "10.101.1.34,10.101.1.62",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]
        project_subnet_t1_five = [
            "tenant1-mgmt-subnet5", "10.101.1.64/27", "10.101.1.65", False,
            True, True, "10.101.1.66,10.101.1.94",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]
        Logout.logout()
        # Tenant 1 Router and Subnets
        Login.login(project_name_two, project_name_two)
        router_one = "tenant1-router"
        router_link = Routers.routers(router_one, "external-net0")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_zero[0], project_subnet_t1_zero[1],
            project_subnet_t1_zero[2], project_subnet_t1_zero[3],
            project_subnet_t1_zero[4], project_subnet_t1_zero[5],
            project_subnet_t1_zero[6], project_subnet_t1_zero[7],
            project_subnet_t1_zero[8], project_subnet_t1_zero[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "192.168.101.0/27 " + "(tenant1-mgmt-subnet0)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.101.1")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_one[0], project_subnet_t1_one[1],
            project_subnet_t1_one[2], project_subnet_t1_one[3],
            project_subnet_t1_one[4], project_subnet_t1_one[5],
            project_subnet_t1_one[6], project_subnet_t1_one[7],
            project_subnet_t1_one[8], project_subnet_t1_one[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "192.168.101.32/27 " + "(tenant1-mgmt-subnet1)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.101.33")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_two[0], project_subnet_t1_two[1],
            project_subnet_t1_two[2], project_subnet_t1_two[3],
            project_subnet_t1_two[4], project_subnet_t1_two[5],
            project_subnet_t1_two[6], project_subnet_t1_two[7],
            project_subnet_t1_two[8], project_subnet_t1_two[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "192.168.101.64/27 " + "(tenant1-mgmt-subnet2)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.101.65")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_three[0],
            project_subnet_t1_three[1], project_subnet_t1_three[2],
            project_subnet_t1_three[3], project_subnet_t1_three[4],
            project_subnet_t1_three[5], project_subnet_t1_three[6],
            project_subnet_t1_three[7], project_subnet_t1_three[8],
            project_subnet_t1_three[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "10.101.1.0/27 " + "(tenant1-mgmt-subnet3)"
        Routers.create_router_interface(router_link, subnet_name, "10.101.1.1")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_four[0], project_subnet_t1_four[1],
            project_subnet_t1_four[2], project_subnet_t1_four[3],
            project_subnet_t1_four[4], project_subnet_t1_four[5],
            project_subnet_t1_four[6], project_subnet_t1_four[7],
            project_subnet_t1_four[8], project_subnet_t1_four[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "10.101.1.32/27 " + "(tenant1-mgmt-subnet4)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "10.101.1.33")
        Networks.create_project_subnet(
            network_name, project_subnet_t1_five[0], project_subnet_t1_five[1],
            project_subnet_t1_five[2], project_subnet_t1_five[3],
            project_subnet_t1_five[4], project_subnet_t1_five[5],
            project_subnet_t1_five[6], project_subnet_t1_five[7],
            project_subnet_t1_five[8], project_subnet_t1_five[9])
        # Create router interface
        subnet_name = "tenant1-mgmt-net: " + "10.101.1.64/27 " + "(tenant1-mgmt-subnet5)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "10.101.1.65")
        Logout.logout()
        Login.login(project_name_one, project_name_one)
        Routers.router_distributed(router_link, False)
        print "Test: PASS - Create router & subnets for tenant 1"
        # ............................................End of Tenant 1...................................................

        # ...............................................Tenant 2.......................................................

        project_subnet_t2_zero = [
            "tenant2-mgmt-subnet0", "192.168.201.0/27", "192.168.201.1", False,
            True, True, "192.168.201.2,192.168.201.30",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t2_one = [
            "tenant2-mgmt-subnet1", "192.168.201.32/27", "192.168.201.33",
            False, True, True, "192.168.201.34,192.168.201.62",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t2_two = [
            "tenant2-mgmt-subnet2", "192.168.201.64/27", "192.168.201.65",
            False, True, True, "192.168.201.66,192.168.201.94",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, None
        ]
        project_subnet_t2_three = [
            "tenant2-mgmt-subnet3", "10.201.1.0/27", "10.201.1.1", False, True,
            True, "10.201.1.2,10.201.1.30",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]
        project_subnet_t2_four = [
            "tenant2-mgmt-subnet4", "10.201.1.32/27", "10.201.1.33", False,
            True, True, "10.201.1.34,10.201.1.62",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]
        project_subnet_t2_five = [
            "tenant2-mgmt-subnet5", "10.201.1.64/27", "10.201.1.65", False,
            True, True, "10.201.1.66,10.201.1.94",
            "147.11.57.133\n128.224.144.130\n147.11.57.128", None, 1
        ]

        # Tenant 2 Router and Subnets
        # Create Network
        network_name = Networks.create_network("tenant2-mgmt-net",
                                               project_name_three, "vlan",
                                               "group0-data1", None,
                                               "tenant2-mgmt-qos", False,
                                               False, False)
        Logout.logout()
        Login.login(project_name_three, project_name_three)
        router_two = "tenant2-router"
        router_link = Routers.routers(router_two, "external-net0")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_zero[0], project_subnet_t2_zero[1],
            project_subnet_t2_zero[2], project_subnet_t2_zero[3],
            project_subnet_t2_zero[4], project_subnet_t2_zero[5],
            project_subnet_t2_zero[6], project_subnet_t2_zero[7],
            project_subnet_t2_zero[8], project_subnet_t2_zero[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "192.168.201.0/27 " + "(tenant2-mgmt-subnet0)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.201.1")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_one[0], project_subnet_t2_one[1],
            project_subnet_t2_one[2], project_subnet_t2_one[3],
            project_subnet_t2_one[4], project_subnet_t2_one[5],
            project_subnet_t2_one[6], project_subnet_t2_one[7],
            project_subnet_t2_one[8], project_subnet_t2_one[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "192.168.201.32/27 " + "(tenant2-mgmt-subnet1)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.201.33")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_two[0], project_subnet_t2_two[1],
            project_subnet_t2_two[2], project_subnet_t2_two[3],
            project_subnet_t2_two[4], project_subnet_t2_two[5],
            project_subnet_t2_two[6], project_subnet_t2_two[7],
            project_subnet_t2_two[8], project_subnet_t2_two[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "192.168.201.64/27 " + "(tenant2-mgmt-subnet2)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "192.168.201.65")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_three[0],
            project_subnet_t2_three[1], project_subnet_t2_three[2],
            project_subnet_t2_three[3], project_subnet_t2_three[4],
            project_subnet_t2_three[5], project_subnet_t2_three[6],
            project_subnet_t2_three[7], project_subnet_t2_three[8],
            project_subnet_t2_three[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "10.201.1.0/27 " + "(tenant2-mgmt-subnet3)"
        Routers.create_router_interface(router_link, subnet_name, "10.201.1.1")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_four[0], project_subnet_t2_four[1],
            project_subnet_t2_four[2], project_subnet_t2_four[3],
            project_subnet_t2_four[4], project_subnet_t2_four[5],
            project_subnet_t2_four[6], project_subnet_t2_four[7],
            project_subnet_t2_four[8], project_subnet_t2_four[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "10.201.1.32/27 " + "(tenant2-mgmt-subnet4)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "10.201.1.33")
        Networks.create_project_subnet(
            network_name, project_subnet_t2_five[0], project_subnet_t2_five[1],
            project_subnet_t2_five[2], project_subnet_t2_five[3],
            project_subnet_t2_five[4], project_subnet_t2_five[5],
            project_subnet_t2_five[6], project_subnet_t2_five[7],
            project_subnet_t2_five[8], project_subnet_t2_five[9])
        # Create router interface
        subnet_name = "tenant2-mgmt-net: " + "10.201.1.64/27 " + "(tenant2-mgmt-subnet5)"
        Routers.create_router_interface(router_link, subnet_name,
                                        "10.201.1.65")
        Logout.logout()
        Login.login(project_name_one, project_name_one)
        Routers.router_distributed(router_link, True)
        network_name = Networks.create_network("tenant1-net0",
                                               project_name_two, "vlan",
                                               "group0-data0", None, None,
                                               False, False, False)
        # Create Subnet
        Networks.create_subnet(network_name, "tenant1-subnet0",
                               "172.16.0.0/24", None, True, False, False, None,
                               None, None, None)
        network_name = Networks.create_network("tenant2-net0",
                                               project_name_three, "vlan",
                                               "group0-data1", None, None,
                                               False, False, False)
        # Create Subnet
        Networks.create_subnet(network_name, "tenant2-subnet0",
                               "172.18.0.0/24", None, True, False, False, None,
                               None, None, None)
        print "Test: PASS - Create router & subnets for tenant 2"
        # ............................................End of Tenant 2...................................................

        print "Test: UI Tests finished"
        DriverUtils.driver.quit()

    except:
        print "Test: FAIL - Exception Thrown"
        traceback.print_exc()
        print "Common exceptions are: Timeout,\nElementNotVisibleException,\nElementNotSelectableException,\n" \
              "NoSuchElementException"
Example #28
0
    def modify_interface(cls, host_name, iface_name, network_type, port, mtu,
                         provider_networks):
        """
        Function for creating an interface for specified host

        :param host_name: name of host in Hosts table
        :param iface_name: name of interface
        :param network_type: type of network [mgmt, oam, data, infra, pxeboot]
        :param iface_type: type of interface [aggregated or vlan]
        :param eth_mode: aggregated ethernet mode
        :param ports: network adapter?
        :param mtu: maximum transmit unit
        :param provider_networks: list of provider networks
        """

        print "Modify Interface (Admin -> System -> Inventory)---------------------------------------------------------"
        host_link = ""
        row_number = -1
        numbers = []
        print host_name
        print iface_name
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(url +
                                "/admin/inventory/?tab=inventory__hosts"))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_name with link
            if (host_name in host_local):
                host_link = link.get_attribute("href")
        # Append to end of URL
        DriverUtils.set_url(host_link + constants.HOST_INTERFACE_TAB)
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get link from partial text in host table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_interface = link.get_attribute("text")
            # Match host_local link name with compute
            if (port in host_interface):
                parse = link.get_attribute("href")
                # Parse number from link
                parse = parse.split("/")
                # Get row number in table
                row_number = parse[7]
            # TODO - Possible Enhancement: Add proper check for existing interfaces
            # Note: This a workaround because lab_cleanup.sh does not remove interface from con-1
            # Interface check for con-1 is currently hard-coded as 'oam0'
            if (host_interface == "oam0"):
                # Reset URL to home page in Horizon
                DriverUtils.set_url(settings.DEFAULT_URL)
                time.sleep(settings.DEFAULT_SLEEP_TIME)
                return
            else:
                continue

        # Get Edit Interface button
        edit_interface_button = constants.HOST_INTERFACE_EDIT_FIRST_HALF + str(
            row_number) + constants.HOST_INTERFACE_EDIT_SECOND_HALF
        edit_button = driver.find_element_by_id(edit_interface_button)
        edit_button.click()

        iface_name_input = driver.find_element_by_id("id_ifname")
        iface_name_input.send_keys(Keys.DELETE)
        iface_name_input.send_keys(Keys.DELETE)
        iface_name_input.send_keys(Keys.DELETE)
        iface_name_input.send_keys(Keys.DELETE)
        iface_name_input.send_keys(Keys.DELETE)
        iface_name_input.send_keys(iface_name)

        print network_type
        if (network_type == "data"):
            network_type_input = driver.find_element_by_id("id_networktype_5")
            network_type_input.click()
        if (network_type == "oam"):
            network_type_input = driver.find_element_by_id("id_networktype_2")
            network_type_input.click()

        time.sleep(2)

        # Provider Networks
        if (not provider_networks):
            pass
        else:
            if ("group0-data0" in provider_networks):
                provider_networks_input1 = driver.find_element_by_id(
                    "id_providernetworks_data_1")
                provider_networks_input1.click()
            if ("group0-data0b" in provider_networks):
                provider_networks_input2 = driver.find_element_by_id(
                    "id_providernetworks_data_2")
                provider_networks_input2.click()
            if ("group0-ext0" in provider_networks):
                provider_networks_input3 = driver.find_element_by_id(
                    "id_providernetworks_data_0")
                provider_networks_input3.click()
            if ("group0-data1" in provider_networks):
                provider_networks_input4 = driver.find_element_by_id(
                    "id_providernetworks_data_3")
                provider_networks_input4.click()

        mtu_input = driver.find_element_by_id("id_imtu")
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(Keys.BACKSPACE)
        mtu_input.send_keys(mtu)
        time.sleep(2)
        # Submit interface form
        mtu_input.submit()

        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)
Example #29
0
    def create_cinder_device(cls, host_name):
        """
        Function for creating a cinder device on a host

        :param host_name: name of host in Hosts table
        """

        print "Create Cinder Device (Admin -> System -> Inventory)-----------------------------------------------------"
        print host_name
        host_link = ""
        # Get driver
        driver = DriverUtils.get_driver()
        # Get URL text from class
        url = DriverUtils.get_url()
        # Append to end of URL
        DriverUtils.set_url(url + "/admin/inventory/?tab=inventory__hosts")
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)
        # Get URL of compute passed to function
        time.sleep(settings.DEFAULT_SLEEP_TIME)
        # Get link from partial text in table (Host Name column)
        links = driver.find_elements_by_partial_link_text('')
        for link in links:
            host_local = link.get_attribute("text")
            # Match host_to_lock with link
            if (host_name in host_local):
                host_link = link.get_attribute("href")
        # If controller-1 does not exist skip
        if (host_link == ""):
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
            return
        # Append to end of URL
        driver.get(DriverUtils.set_url(host_link + constants.HOST_STORAGE_TAB))
        # Navigate to newly appended URL
        driver.get(DriverUtils.get_url())
        # Wait for elements on page to load
        DriverUtils.wait_for_elements(settings.DEFAULT_ELEMENT_LOAD_TIME)

        words_on_page = driver.find_element_by_xpath(
            "//*[contains(text(),/dev/sdb)]")
        if ("/dev/sdb" in words_on_page.text):
            # Reset URL to home page in Horizon
            DriverUtils.set_url(settings.DEFAULT_URL)
            time.sleep(settings.DEFAULT_SLEEP_TIME)
            return
        else:
            pass

        # TODO: Find create button
        create_button = driver.find_element_by_id()
        create_button.click()
        # TODO: Find element and submit form
        submit_element = driver.find_element_by_id()
        submit_element.submit()

        # Reset URL to home page in Horizon
        DriverUtils.set_url(settings.DEFAULT_URL)
        time.sleep(settings.DEFAULT_SLEEP_TIME)