Esempio n. 1
0
    class vms(View):  # noqa
        import_btn = Button('Import')
        importcsv = Button('Import CSV')
        hidden_field = HiddenFileInput(locator='.//input[contains(@accept,".csv")]')
        # TODO: Replace string keys by integer keys after row indexing issue get fixed
        # TODO: Replace Text by Button or GenericLocatorWidget after button text get added
        table = Table('.//div[contains(@class, "container-fluid")]/table', column_widgets={
            'Select': Checkbox(locator=".//input"),
            1: Text('.//span/button[contains(@class,"btn btn-link")]')})
        filter_by_dropdown = SelectorDropdown('id', 'filterFieldTypeMenu')
        search_box = TextInput(locator='.//div[contains(@class, "modal-content")]'
            '//div[contains(@class,"input-group")]/input')
        clear_filters = Text(".//a[text()='Clear All Filters']")
        error_text = Text('.//h3[contains(@class,"blank-slate-pf-main-action") and '
                          'contains(text(), "Error:")]')
        error_icon = Text(locator='.//span[contains(@class, "pficon-error-circle-o")]')
        popover_text = Text(locator='.//div[contains(@class, "popover-content")]')

        @property
        def is_displayed(self):
            return (self.table.is_displayed and
                 (len(self.browser.elements(".//div[contains(@class,'spinner')]")) == 0))

        def filter_by_name(self, vm_name):
            try:
                # remove `if` cond https://github.com/ManageIQ/manageiq-v2v/issues/771 fixed
                if self.browser.appliance.version < '5.10':  # Don't remove nxt line, remove `if`
                    self.filter_by_dropdown.item_select("VM Name")  # just unindent
            except NoSuchElementException:
                self.logger.info("`VM Name` not present in filter dropdown!")
            self.search_box.fill(vm_name)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def filter_by_source_cluster(self, cluster_name):
            try:
                self.filter_by_dropdown.item_select("Source Cluster")
            except NoSuchElementException:
                self.logger.info("`Source Cluster` not present in filter dropdown!")
            self.search_box.fill(cluster_name)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def filter_by_path(self, path):
            try:
                self.filter_by_dropdown.item_select("Path")
            except NoSuchElementException:
                self.logger.info("`Path` not present in filter dropdown!")
            self.search_box.fill(path)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def select_by_name(self, vm_name):
            self.filter_by_name(vm_name)
            vms_selected = []
            for row in self.table.rows():
                if vm_name in row.read()['VM Name']:
                    row.select.fill(True)
                    vms_selected.append(row.read()['VM Name'])
            return vms_selected
Esempio n. 2
0
    class vms(View):  # noqa
        import_btn = Button('Import')
        importcsv = Button('Import CSV')
        hidden_field = HiddenFileInput(
            locator='.//input[contains(@accept,".csv")]')
        table = Table('.//div[contains(@class, "container-fluid")]/table',
                      column_widgets={"Select": Checkbox(locator=".//input")})
        filter_by_dropdown = SelectorDropdown('id', 'filterFieldTypeMenu')
        search_box = TextInput(
            locator=".//div[contains(@class,'input-group')]/input")
        clear_filters = Text(".//a[text()='Clear All Filters']")

        @property
        def is_displayed(self):
            return self.filter_by_dropdown.is_displayed

        def filter_by_name(self, vm_name):
            try:
                self.filter_by_dropdown.item_select("VM Name")
            except NoSuchElementException:
                self.logger.info("`VM Name` not present in filter dropdown!")
            self.search_box.fill(vm_name)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def filter_by_source_cluster(self, cluster_name):
            try:
                self.filter_by_dropdown.item_select("Source Cluster")
            except NoSuchElementException:
                self.logger.info(
                    "`Source Cluster` not present in filter dropdown!")
            self.search_box.fill(cluster_name)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def filter_by_path(self, path):
            try:
                self.filter_by_dropdown.item_select("Path")
            except NoSuchElementException:
                self.logger.info("`Path` not present in filter dropdown!")
            self.search_box.fill(path)
            self.browser.send_keys(Keys.ENTER, self.search_box)

        def select_by_name(self, vm_name):
            self.filter_by_name(vm_name)
            vms_selected = []
            for row in self.table.rows():
                if vm_name in row.read()['VM Name']:
                    row.select.fill(True)
                    vms_selected.append(row.read()['VM Name'])
            return vms_selected
Esempio n. 3
0
    class authentication(View):  # noqa
        fill_strategy = WaitFillViewStrategy("15s")
        conv_host_key = HiddenFileInput(locator='.//div[@id="conversionHostSshKey"]/div/input')
        transformation_method = BootstrapSelect("transformationMethod")
        vddk_library_path = Input(id='vddk-library-path')
        vmware_ssh_key = TextInput(locator='.//textarea[@id="vmware-ssh-key-input"]')
        osp_cert_switch = V2VBootstrapSwitch(label='Verify TLS Certificates for OpenStack')
        osp_ca_cert = TextInput(locator='.//textarea[@id="openstack-ca-certs-input"]')

        @property
        def is_displayed(self):
            return self.conv_host_key.is_displayed

        def after_fill(self, was_change):
            self.parent.configure_btn.click()
    class vms(View):  # noqa
        import_btn = Button("Import")
        hidden_field = HiddenFileInput(locator='.//input[contains(@accept,".csv")]')
        clear_filters = Text(".//a[text()='Clear All Filters']")
        error_text = Text('.//h3[contains(@class,"blank-slate-pf-main-action") and '
                          'contains(text(), "Error:")]')
        popover_text = Text(locator='.//div[contains(@class, "popover-content")]')
        table = Table(
            './/div[contains(@class, "container-fluid")]/table',
            column_widgets={
                "Select": Checkbox(locator=".//input"),
                1: Text('.//span/button[contains(@class,"btn btn-link")]'),
            },
        )
        search_box = SearchBox(
            locator='.//div[contains(@class, "modal-content")]'
                    '//div[contains(@class,"input-group")]/input'
        )

        @property
        def is_displayed(self):
            return self.table.is_displayed and (
                len(self.browser.elements(".//div[contains(@class,'spinner')]")) == 0
            )

        def csv_import(self, vm_list):
            """
            Vm's can be imported using csv for migration.
            Opens a temporary csv with Columns Name and Provider
            and fill it with vm's from vm_list to be used in fill
            Args:
                vm_list: list of vm's to be imported through csv
            """
            temp_file = tempfile.NamedTemporaryFile(suffix=".csv")
            with open(temp_file.name, "w") as file:
                headers = ["Name", "Provider"]
                writer = csv.DictWriter(file, fieldnames=headers)
                writer.writeheader()
                for vm in vm_list:
                    writer.writerow({"Name": vm.name, "Provider": vm.provider.name})
            self.hidden_field.fill(temp_file.name)

        def fill(self, values):
            """
            If importing Vm's from csv file , use the file created in csv_import method.
            Search Vm using searchbox.
            Select checkbox(row[0]) of all the Vm's imported in the table
            Args:
                 values : List of Vm's
            """
            csv_import = values.get('csv_import')
            vm_list = values.get('vm_list')
            if csv_import:
                self.csv_import(vm_list)
            for vm in vm_list:
                self.search_box.fill(vm.name)
                for row in self.table.rows():
                    if vm.name in row.vm_name.read():
                        # select checkbox
                        row[0].fill(True)
                    self.clear_filters.click()
            was_change = True
            self.after_fill(was_change)
            return was_change

        def after_fill(self, was_change):
            self.parent.next_btn.click()