예제 #1
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)
예제 #2
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
예제 #3
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
예제 #4
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)
예제 #5
0
    def login(cls, username, password):
        """
        Function for logging into Horizon

        :param username: username for Horizon login
        :param password: password for Horizon login
        """

        # Get driver
        driver = DriverUtils.get_driver()
        driver.get(DriverUtils.get_url())

        # Check username and password are NOT empty
        if(username != ""):
            if(password != ""):
                # Perform login
                # Find HTML element for username input field
                username_element = driver.find_element_by_name("username")
                # Type in the input for username
                username_element.send_keys(username)
                # Find HTML element for password input field
                password_element = driver.find_element_by_name("password")
                # Type in the input for password
                password_element.send_keys(password)
                # Submit HTML form
                password_element.submit()
                time.sleep(settings.DEFAULT_SLEEP_TIME)
        else:
            print "Test: FAIL - Username or Password is missing/invalid"
            exit(1)
예제 #6
0
    def check_alarm(cls, alarm_name):

        return_value = -1

        DriverUtils.set_url(cls.base_url)
        FaultAlarms.check_alarms()

        for name in FaultAlarms.fault_names:
            if (alarm_name in name):
                return_value = 1
        return return_value
예제 #7
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
예제 #8
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)
예제 #9
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
예제 #10
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
예제 #11
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)
예제 #12
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
예제 #13
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)
예제 #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)
예제 #15
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
예제 #16
0
    def check_sensor_exists(cls, alarm_name='Temp_CPU0'):
        """
        Function for getting sensor names in host
        """

        fault_count = 0
        return_value = -1
        cls.sensor_names = []
        # Get driver
        driver = DriverUtils.get_driver()

        sensor_name = driver.find_element_by_xpath("//table[@id='sensors']")
        #print ('sensor_name: %s' % sensor_name.text)
        sensor_name = sensor_name.text
        sensor_name = sensor_name.split('\n')
        sensor_name = sensor_name[6:]
        sensor_name = sensor_name[1::2]
        for name in sensor_name:
            fault_count += 1
            # Append all faults found in table to list
            #print('Name: %s' % name)
            cls.sensor_names.append(name)
            # Or check against constants for matching faults
            # cls.check_faults_found(name)
        # Call function to output faults to console

        for name in cls.sensor_names:
            if (alarm_name in name):
                print("%s alarm found" % alarm_name)
                return_value = 1
        return return_value
예제 #17
0
    def get_project_id(cls, project_name):
        """
        Function for getting project id

        :param project_name: name of project in Horizon
        :return project_id: id of project taken from project_name link
        """

        project_id = -1
        index = [4]
        # 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(project_name in host_local):
                parse = link.get_attribute("href")
                # Parse number from link
                parse = parse.split("/")
                # Find the project ID in the list
                # Find 4th item in list
                project_id_list = [parse[x] for x in index]
                for item in project_id_list:
                    project_id = item
        return project_id
예제 #18
0
    def set_host_lock(cls, row_number):
        driver = DriverUtils.get_driver()

        check_return_value = cls.check_host(row_number)
        if (check_return_value == 1):
            print "Host lock failed, host was already locked"
            return
        elif (check_return_value == 2):
            print "Host is attempting to lock"
            pass
        elif (check_return_value == 3):
            return

        #print row_number
        host_drop_down_id = constants.CONST_DROPDOWN_FIRST_HALF + str(
            row_number) + constants.CONST_DROPDOWN_SECOND_HALF
        drop_down_host = driver.find_element_by_css_selector(host_drop_down_id)
        drop_down_host.click()
        lock_host_id = constants.CONST_LOCK_LABEL_FIRST_HALF + str(
            row_number) + constants.CONST_LOCK_LABEL_SECOND_HALF
        drop_down_lock = driver.find_element_by_css_selector(lock_host_id)
        drop_down_lock.click()
        # Confirm lock host
        confirm_lock = driver.find_element_by_css_selector(".btn-submit")
        confirm_lock.click()

        check_return_value = cls.check_host(row_number)
        if (check_return_value == 1):
            pass
        elif (check_return_value == 2):
            print "Lock Failed"
            return
        elif (check_return_value == 3):
            return
예제 #19
0
    def set_host_unlock(cls, row_number):
        driver = DriverUtils.get_driver()

        check_return_value = cls.check_host(row_number)
        if (check_return_value == 1):
            print "Host is attempting to unlock"
            pass
        elif (check_return_value == 2):
            print "Host unlock failed, host was already unlocked"
            return
        elif (check_return_value == 3):
            return

        host_drop_down_id = constants.CONST_DROPDOWN_FIRST_HALF + str(
            row_number) + constants.CONST_DROPDOWN_SECOND_HALF
        drop_down_host = driver.find_element_by_css_selector(host_drop_down_id)
        drop_down_host.click()
        unlock_host_id = constants.CONST_UNLOCK_LABEL_FIRST_HALF + str(
            row_number) + constants.CONST_UNLOCK_LABEL_SECOND_HALF
        drop_down_lock = driver.find_element_by_css_selector(unlock_host_id)
        drop_down_lock.click()

        check_return_value = cls.check_host(row_number)
        if (check_return_value == 1):
            print "Unlock Failed"
            return
        elif (check_return_value == 2):
            pass
        elif (check_return_value == 3):
            return
예제 #20
0
    def set_host_alarms(cls,
                        host_to_alarm,
                        action,
                        severity='critical',
                        alarm_name='server power'):

        host_list = []
        row_number = -1
        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_alarm with link
            if (host_to_alarm in host_local):
                print('Setting sensor action for: %s' % host_local)
                host_link = link.get_attribute("href")
                # Parse number from link
                parse = host_link.split("/")
                # Find the number in the list
                for num in parse:
                    if num.isdigit():
                        row_number = num
                temp_tuple = [host_local, row_number]
                host_list.append(temp_tuple)

        for item in host_list:
            host = item[0]
            row = item[1]
            if (host_to_alarm == host):
                # Call function with row number
                cls.set_alarm_action(host_link, action, severity, alarm_name)
            else:
                print "Wrong Host found"
예제 #21
0
    def create_router(cls, router_name, external_network_name):
        """
        Function for creating a router

        :param router_name: name of router
        :param external_network_name: name of external network
        """

        print "Create Router (Admin -> System -> Routers)--------------------------------------------------------------"
        print router_name
        # Get driver
        driver = DriverUtils.get_driver()

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

        router_name_input = driver.find_element_by_id("id_name")
        router_name_input.send_keys(router_name)

        external_network_name_input = Select(
            driver.find_element_by_id("id_external_network"))
        external_network_name_input.select_by_visible_text(
            external_network_name)

        router_name_input.submit()
예제 #22
0
    def set_host_action(cls, row_number):

        DROP_DOWN_LABEL_FIRST_HALF = constants.CONST_SWACT_LABEL_FIRST_HALF
        DROP_DOWN_LABEL_SECOND_HALF = constants.CONST_SWACT_LABEL_SECOND_HALF

        driver = DriverUtils.get_driver()

        # check that the host can be swacted
        check_return_value = cls.check_host_is_active(row_number)
        if(check_return_value == 1):
            pass
        elif(check_return_value == 2):
            return

        # swact host
        #host_drop_down_id = constants.CONST_DROPDOWN_FIRST_HALF + str(row_number) + constants.CONST_DROPDOWN_SECOND_HALF
        #drop_down_host = driver.find_element_by_css_selector(host_drop_down_id)
        #drop_down_host.click()

        #swact_host_id = DROP_DOWN_LABEL_FIRST_HALF + str(row_number) + DROP_DOWN_LABEL_SECOND_HALF
        #drop_down_swact = driver.find_element_by_css_selector(swact_host_id)
        #drop_down_swact.click()

        # Confirm swact host
        #confirm_swact = driver.find_element_by_css_selector(".btn-submit")
        #confirm_swact.click()

        check_return_value = cls.check_swact_in_progress(row_number)
        if(check_return_value == 1):
            pass
        elif(check_return_value == 2):
            print "Swact Failed"
            return
예제 #23
0
    def get_hosts(cls, host_to_lock):
        #print host_to_lock
        host_list = []
        row_number = -1
        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(host_to_lock in host_local):
                print host_local
                parse = link.get_attribute("href")
                # Parse number from link
                parse = parse.split("/")
                print parse
                # Find the number in the list
                for num in parse:
                    if num.isdigit():
                        row_number = num
                temp_tuple = [host_local, row_number]
                host_list.append(temp_tuple)
        for item in host_list:
            host = item[0]
            row = item[1]
            if(host_to_lock == host):
                print "Found Host"
                # Call function with row number
                cls.set_host_action(row)
            else:
                print "Wrong Host"
예제 #24
0
    def get_provider_net(cls, network_provider_name):
        """
        Function for getting provider net details

        :param network_provider_name: provider network name for network
        :return provider_id_link: link to provider net details to specified provider network
        """

        provider_net_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(network_provider_name in host_local):
                provider_id_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(DriverUtils.set_url(provider_net_link))
        return provider_id_link
예제 #25
0
 def check_swact_in_progress(cls, row_number):
     return_value = -1
     driver = DriverUtils.get_driver()
     host_label = constants.HOST_CHECK_STATUS_FIRST_HALF + str(row_number) + constants.HOST_CHECK_STATUS_SECOND_HALF
     check = driver.find_element_by_css_selector(host_label)
     if("Swact" in check.text):
         print "SWACT is successful"
         return_value = 1
     else:
         print "An error has occurred"
         return_value = 2
     return return_value
예제 #26
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
예제 #27
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)
예제 #28
0
    def get_router_link(cls, router_name):
        """
        Function for getting details page of specified router

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

        router_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 (router_name in host_local):
                router_id_link = link.get_attribute("href")
        # Append to end of URL
        driver.get(
            DriverUtils.set_url(router_id_link +
                                constants.ROUTER_INTERFACE_TAB))
        return router_id_link
예제 #29
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)
예제 #30
0
 def check_host_is_active(cls, row_number):
     return_value = -1
     driver = DriverUtils.get_driver()
     host_label = constants.CONST_CHECK_PERSONALITY_FIRST_HALF + str(row_number) + constants.CONST_CHECK_PERSONALITY_SECOND_HALF
     check = driver.find_element_by_css_selector(host_label)
     if("Active" in check.text):
         print "Host Status: Host is active"
         return_value = 1
     elif("Standby" in check.text):
         print "Host Status: Host is standby - SWACT not allowed"
         return_value = 2
     else:
         print "An error has occurred"
         return_value = 3
     return return_value