class Node(AbstractView):
    def __init__(self, parent=None):
        self.name = HtmlElement(
            xpath=".//div[@class='node-name']", element_name="Cluster name")

        self._select = HtmlElement(
            xpath=".//div[@class='node-select']", element_name="Select tick")

        self.status = HtmlElement(
            xpath=".//div[@class='node-status']", element_name="Status")

        self.hardware = HtmlElement(
            xpath=".//div[@class='node-hardware']", element_name="Hardware")

        AbstractView.__init__(self, parent)

    def get_name(self):
        return self.name.get_value()

    def get_status(self):
        return self.status.get_value().strip()

    def is_selected(self):
        return self._select.get_element().is_displayed()

    def select(self):
        if self.is_selected():
            return Result("Node is already selected")
        else:
            return self.name.click()

    def click_hardware(self):
        return self.hardware.click()
Beispiel #2
0
class Node(AbstractView):
    def __init__(self, parent=None):
        self.name = HtmlElement(
            xpath=".//div[@class='node-name']//p[@class='node-renameable']",
            element_name="Cluster name"
        )

        self.role = HtmlElement(
            xpath=".//div[@class='roles']//li",
            element_name="Cluster role"
        )

        self._checkbox = Checkbox(
            xpath=".//label[@class='node-checkbox']"
                  "//div[@class='custom-tumbler']/input",
            element_name="Checkbox")

        self.status = HtmlElement(
            xpath=".//div[@class='node-status']", element_name="Status")

        self.details = HtmlElement(
            xpath=".//div[@class='node-details']",
            element_name="Node details icon")

        AbstractView.__init__(self, parent)

    def get_name(self):
        return self.name.get_value()

    def get_status(self):
        return self.status.get_value().strip()

    def is_selected(self):
        return self._checkbox.verify_value("on")

    def verify_checkbox(self, expectedValue):
        return self._checkbox.verify_value(expectedValue)

    def set_checkbox(self, value):
        return self._checkbox.set_value(value)

    def select(self):
        if self.is_selected().i_passed():
            return Result("Node is already selected")
        else:
            return self._checkbox.set_value(Checkbox.VALUE_ON)

    def click_node_details(self):
        return self.details.click()

    def get_roles(self):
        roles_elements = ActionBot().find_elements(
            By.XPATH, ".//div[@class='roles']//li")
        return [HtmlElement(element=we).get_value() for we in roles_elements]
Beispiel #3
0
class Node(AbstractView):
    def __init__(self, parent=None):
        self.name = HtmlElement(
            xpath=".//div[@class='node-name']//p[@class='node-renameable']",
            element_name="Cluster name")

        self.role = HtmlElement(xpath=".//div[@class='roles']//li",
                                element_name="Cluster role")

        self._checkbox = Checkbox(xpath=".//label[@class='node-checkbox']"
                                  "//div[@class='custom-tumbler']/input",
                                  element_name="Checkbox")

        self.status = HtmlElement(xpath=".//div[@class='node-status']",
                                  element_name="Status")

        self.details = HtmlElement(xpath=".//div[@class='node-details']",
                                   element_name="Node details icon")

        AbstractView.__init__(self, parent)

    def get_name(self):
        return self.name.get_value()

    def get_status(self):
        return self.status.get_value().strip()

    def is_selected(self):
        return self._checkbox.verify_value("on")

    def verify_checkbox(self, expectedValue):
        return self._checkbox.verify_value(expectedValue)

    def set_checkbox(self, value):
        return self._checkbox.set_value(value)

    def select(self):
        if self.is_selected().i_passed():
            return Result("Node is already selected")
        else:
            return self._checkbox.set_value(Checkbox.VALUE_ON)

    def click_node_details(self):
        return self.details.click()

    def get_roles(self):
        roles_elements = ActionBot().find_elements(
            By.XPATH, ".//div[@class='roles']//li")
        return [HtmlElement(element=we).get_value() for we in roles_elements]
Beispiel #4
0
class Cluster(AbstractView):
    DEPLOYMENT_MODE_MULTI_NODE = "Multi-node"
    DEPLOYMENT_MODE_MULTI_NODE_WITH_HA = "Multi-node with HA"

    def __init__(self, parent=None):
        self.clusterName = HtmlElement(xpath="./div[@class='cluster-name']",
                                       element_name="Cluster name")
        self.status = HtmlElement(xpath="./div[@class='cluster-status']",
                                  element_name="Status")

        AbstractView.__init__(self, parent)

    def get_name(self):
        return self.clusterName.get_value()

    def get_status(self):
        return self.status.get_value().strip()

    def verify_status(self, status):
        return self.get_status().verify_value(status)
class Cluster(AbstractView):
    DEPLOYMENT_MODE_MULTI_NODE = "Multi-node"
    DEPLOYMENT_MODE_MULTI_NODE_WITH_HA = "Multi-node with HA"

    def __init__(self, parent=None):
        self.clusterName = HtmlElement(
            xpath="./div[@class='cluster-name']",
            element_name="Cluster name"
        )
        self.status = HtmlElement(
            xpath="./div[@class='cluster-status']",
            element_name="Status"
        )

        AbstractView.__init__(self, parent)

    def get_name(self):
        return self.clusterName.get_value()

    def get_status(self):
        return self.status.get_value().strip()
class Cluster_Nodes_View(AbstractView):
    def __init__(self, parent=None):
        self.addCompute = Link(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-compute')]"
                  "//a[contains(@class, 'btn-add-nodes')]",
            element_name="Add compute"
        )
        self.addController = Link(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-controller')]"
                  "//a[contains(@class, 'btn-add-nodes')]",
            element_name="Add controller"
        )
        self.addCinder = Link(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-cinder')]"
                  "//a[contains(@class, 'btn-add-nodes')]",
            element_name="Add controller"
        )
        self.computes = Button(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-compute')]",
            element_name="computes"
        )
        self.controllers = HtmlElement(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-controller')]",
            element_name="controllers"
        )
        self.cinders = Button(
            xpath="//div[@id='tab-nodes']"
                  "//div[contains(@class, 'node-list-cinder')]",
            element_name="cinders"
        )
        self.deploymentMode = Link(
            xpath="//li[contains(@class, 'change-cluster-mode-btn')]",
            element_name="Deployment mode"
        )
        self.alertError = HtmlElement(
            xpath="//div[contains(@class, 'alert-block') "
                  "and contains(@class, 'global-error')]/p",
            element_name="Alert Error"
        )

        AbstractView.__init__(self, parent)

    def click_add_compute(self):
        return self.addCompute.click_and_wait()

    def click_add_controller(self):
        return self.addController.click_and_wait()

    def click_add_cinder(self):
        return self.addCinder.click_and_wait()

    def click_deployment_mode(self):
        return self.deploymentMode.click()

    def select_environment_mode(self, deploymentMode):
        rl = ResultList(
            "Select environment mode [{mode}]".format(
                mode=deploymentMode)
        )
        rl.push(self.click_deployment_mode())
        rl.push(EnvironmentDeploymentModeDialog().populate(
            deploymentMode=deploymentMode,
            submit=True
        ))
        return rl

    def verify_cinder_nodes(self, *args):
        return Cluster_Nodes_ListView(
            self.cinders.get_element()
        ).verify_nodes(*args)

    def verify_compute_nodes(self, *args):
        return Cluster_Nodes_ListView(
            self.computes.get_element()
        ).verify_nodes(*args)

    def verify_controller_nodes(self, *args):
        return Cluster_Nodes_ListView(
            self.controllers.get_element()
        ).verify_nodes(*args)

    def get_nodes_controllers(self):
        return Cluster_Nodes_ListView(self.controllers.get_element())\
            .get_nodes()

    def get_nodes_computes(self):
        return Cluster_Nodes_ListView(self.computes.get_element())\
            .get_nodes()

    def get_nodes_cinders(self):
        return Cluster_Nodes_ListView(self.cinders.get_element())\
            .get_nodes()

    def verify_error_contains(self, *args):
        rl = ResultList("Verify error alert contains")
        for string in args:
            rl.push(Result(
                "String [{string}] exists".format(string=string),
                self.alertError.get_value().find(string) != -1
            ))
        return rl
Beispiel #7
0
class Cluster_Nodes_View(AbstractView):
    def __init__(self, parent=None):
        self.addNodes = Link(
            xpath="//div//a[@class='btn btn-success btn-add-nodes']",
            element_name="Add nodes"
        )
        self.deleteNodes = Button(
            xpath="//button[contains(@class,'btn-delete-nodes')]",
            element_name="Delete nodes"
        )
        self.reassignRoles = Button(
            xpath="//button[contains(@class, 'btn-assign-roles')]"
                  "and contains(text(),'Reassign Roles')]",
            element_name="Reassign roles"
        )
        self.assignRoles = Button(
            xpath="//button[contains("
                  "@class, 'btn btn-success btn-assign-roles') "
                  "and contains(text(),'Assign Roles')]",
            element_name="Assign roles"
        )
        self.environment_status = HtmlElement(
            xpath="//div[@class='environment-status']",
            element_name="Environment status"
        )
        self.groupBy = Select(
            xpath="//div[@class='cluster-toolbar-item nodes-filter']"
                  "//select[@name='grouping']",
            element_name="Select group by"
        )
        self.backToEnvironmentNodeList = Button(
            xpath="//div[@class='btn btn-go-to-cluster']",
            element_name="Back to Environment Node List"
        )

        self.nodelist = HtmlElement(
            xpath="//div[@class='node-groups' and "
                  "contains(div[@class='row-fluid node-group-header']"
                  "//h4/text(),'{role}')]",
            element_name="'{role}' block"
        )
        self.deploymentMode = Button(
            xpath="//button[contains(@class,'btn btn-cluster-actions')]",
            element_name="Deployment mode"
        )
        self.alertError = HtmlElement(
            xpath="//div[contains(@class, 'alert-block') "
                  "and contains(@class, 'global-error')]/p",
            element_name="Alert Error"
        )

        AbstractView.__init__(self, parent)

    def click_deployment_mode(self):
        return self.deploymentMode.click()

    @catch_stale_error
    def click_add_nodes(self):
        return self.addNodes.click_and_wait()

    def select_environment_mode(self, deploymentMode):
        rl = ResultList(
            "Select environment mode [{mode}]".format(
                mode=deploymentMode)
        )
        rl.push(self.click_deployment_mode())
        rl.push(CreateEnvironmentDialog().select_deployment_mode(
            deploymentMode
        ))
        rl.push(CreateEnvironmentDialog().clickNext())
        return rl

    @catch_stale_error
    def verify_nodes(self, role, nodes):
        return Cluster_Nodes_ListView(
            self.nodelist.find(role=role).get_element()
        ).verify_nodes(*nodes)

    def get_nodes(self, role):
        return Cluster_Nodes_ListView(
            self.nodelist.find(role=role).get_element()).get_nodes()

    def verify_node_with_role_not_exists(self, role, *args):
        return Cluster_Nodes_ListView(
            self.nodelist.find(role=role).get_element()
        ).verify_nodes_not_exist(*args)

    def verify_error_contains(self, *args):
        rl = ResultList("Verify error alert contains")
        for string in args:
            rl.push(Result(
                "String [{string}] exists".format(string=string),
                self.alertError.get_value().find(string) != -1
            ))
        return rl

    def verify_nodelists_visibility(self, value, *roles):
        rl = ResultList("Verify node lists visibility")
        for role in roles:
            rl.push(VerifyBot().verify_visibility(
                self.nodelist.find(role=role).get_element(),
                value, "'{role}' nodelist"))
        return rl

    def verify_amount(self, elements_role, value):
        result = None
        try:
            elements = self.get_nodes(role=elements_role)

            if value == 0:
                result = Result(
                    "Verify if amount of {role} is 0".format(
                        role=elements_role, value=value),
                    VerifyBot().verify_visibility(
                        elements, False, elements_role).i_passed())
            else:
                result = Result(
                    "Verify if amount of {role} is {value}".format(
                        role=elements_role, value=value),
                    len(elements) == value)

        except ElementNotFoundException:
            if value == 0:
                result = Result("There are no {name}".format(
                    role=elements_role), True)
        return result

    def select_nodes(self, *args):
        rl = ResultList("Select nodes")
        for name in args:
            node = Node(Cluster_Nodes_ListView().node.find(
                name=name).get_element())
            rl.push(node.select())
        return rl

    def select_roles(self, *roles):
        rl = ResultList("Select roles")
        for role in roles:
            rl.push(RolesPanel().checkbox_role.find(role=role).set_value('on'))
        return rl

    def assign_roles_to_nodes(self, roles, node_names):
        rl = ResultList("Select nodes and assign roles")
        rl.push(self.select_nodes(*node_names))
        rl.push(self.select_roles(*roles))
        rl.push(self.apply())
        ActionBot().wait_for_time(2)
        return rl

    def delete_nodes(self, *args):
        rl = ResultList("Delete nodes")
        rl.push(self.select_nodes(*args))
        rl.push(self.deleteNodes.click_and_wait())
        rl.push(DeleteNodeDialog().delete())
        return rl