def __init__(self):
     self.licence_rhsm = Radio(
         xpath=".//div[@class='custom-tumbler' "
               "and input[@value='rhsm']]",
         element_name="RHSM"
     )
     self.licence_rhn = Radio(
         xpath=".//div[@class='custom-tumbler' "
               "and input[@value='rhn']]",
         element_name="RHN Satellite"
     )
     self.rh_user = Input(
         xpath=".//input[@name='username']",
         element_name="Red Hat Username"
     )
     self.rh_password = Input(
         xpath=".//input[@name='password']",
         element_name="Red Hat Password"
     )
     self.satellite_server = Input(
         xpath=".//input[@name='satellite']",
         element_name="Satellite server hostname"
     )
     self.activation_key = Input(
         xpath=".//input[@name='activation_key']",
         element_name="Activation key"
     )
     AbstractDialog.__init__(self)
Пример #2
0
class OpenstackSettingsView(AbstractView):
    def __init__(self, parent=None):
        self.parameter_input = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='text']",
            element_name="Parameter {name}")

        self.parameter_radio = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='radio']",
            element_name="Parameter {name}")

        self.parameter_checkbox = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='checkbox']",
            element_name="Parameter {name}")

        AbstractView.__init__(self, parent)

    def set_parameter_input(self, name, value):
        return self.parameter_input.find(name=name).set_value(value)

    def set_parameter_radio(self, name, value):
        return self.parameter_radio.find(name=name).set_value(value)

    def set_parameter_checkbox(self, name, value):
        return self.parameter_checkbox.find(name=name).set_value(value)
Пример #3
0
class OpenstackSettingsView(AbstractView):
    def __init__(self, parent=None):
        self.save_settings = Button(
            xpath=".//button[contains(@class, 'btn-apply-changes')]",
            element_name="Save Settings")

        self.cancel_changes = Button(
            xpath=".//button[contains(@class, 'btn-revert-changes')]",
            element_name="Cancel Changes")

        self.load_defaults = Button(
            xpath=".//button[contains(@class, 'btn btn-load-defaults')]",
            element_name="Load Defaults")

        self.parameter_input = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='text']",
            element_name="Parameter {name}")

        self.parameter_radio = Radio(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']",
            element_name="Parameter {name}")

        self.parameter_checkbox = Checkbox(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='checkbox']",
            element_name="Parameter {name}")

        self.show_password = Button(
            xpath=".//span[@class='add-on' "
                  "and i[contains(@class, 'icon-eye')]]",
            element_name="Show password button")

        self.show_password_on = Button(
            xpath=".//i[@class ='icon-eye' and @style='display: inline;']",
            element_name="Show password button")

        self.show_password_off = Button(
            xpath=".//i[@class ='icon-eye-off hide' "
                  "and @style='display: inline;']",
            element_name="Show password button")

        AbstractView.__init__(self, parent)

    def set_parameter_input(self, name, value):
        return self.parameter_input.find(name=name).set_value(value)

    def set_parameter_radio(self, name, value):
        return self.parameter_radio.find(name=name).set_value(value)

    def set_parameter_checkbox(self, name, value):
        return self.parameter_checkbox.find(name=name).set_value(value)

    def verify_parameter_input(self, name, value):
        return self.parameter_input.find(name=name).verify_value(value)
Пример #4
0
class IpRangeRow(BasePage):
    def __init__(self, parent=None):
        self.ip_range_start = Input(
            xpath=".//input[@name='ip_ranges-start']",
            element_name="Ip range start")

        self.ip_range_end = Input(
            xpath=".//input[@name='ip_ranges-end']",
            element_name="Ip range end")

        self.ip_range_add = Button(
            xpath=".//button[contains(@class,'ip-ranges-add')]",
            element_name="Ip range add")

        self.ip_range_delete = Button(
            xpath=".//button[contains(@class,'ip-ranges-delete')]",
            element_name="Ip range delete")

        BasePage.__init__(self, parent)

    def set_start_ip(self, args):
        return self.ip_range_start.set_value(args)

    def is_invalid(self):
        return self.ip_range_start.verify_attribute("class", "error")

    def is_correct(self):
        return self.ip_range_start.verify_attribute("class", "")

    def set_start_ip_verify_error(self, args):
        rl = ResultList("Set ip range start with '{args}' "
                        "and verify error".format(args=args)) \
            .push(self.set_start_ip(args)) \
            .push(self.is_invalid())
        return rl

    def set_start_ip_correct(self, args):
        rl = ResultList("Set ip range start with '{args}' and verify "
                        "error does not exist".format(args=args)) \
            .push(self.set_start_ip(args)) \
            .push(self.is_correct())
        return rl

    def set_start_ip_and_verify(self, args, value):
        if value:
            return self.set_start_ip_correct(args)
        else:
            return self.set_start_ip_verify_error(args)
Пример #5
0
    def __init__(self, parent=None):
        self.ip_range_start = Input(xpath=".//input[@name='ip_ranges-start']",
                                    element_name="Ip range start")

        self.ip_range_end = Input(xpath=".//input[@name='ip_ranges-end']",
                                  element_name="Ip range end")

        self.ip_range_add = Button(
            xpath=".//button[contains(@class,'ip-ranges-add')]",
            element_name="Ip range add")

        self.ip_range_delete = Button(
            xpath=".//button[contains(@class,'ip-ranges-delete')]",
            element_name="Ip range delete")

        BasePage.__init__(self, parent)
class CreateEnvironmentDialog(AbstractDialog):
    def __init__(self):
        self.name = Input(
            xpath=".//input[@name='name']", element_name="Name"
        )
        self.nameErrorMessage = HtmlElement(
            xpath="//div[contains(@class,'control-group') and "
                  ".//input[contains(@name, 'name')]]"
                  "//span[@class='help-inline']",
            element_name="name error message"
        )
        self.version = Select(
            xpath=".//select[@name='release']", element_name="Version"
        )

        AbstractDialog.__init__(self)

    def populate(self, name, version, submit=False):
        environment = Storage.get_current(TD_Cluster.NAME)
        environment.name = name
        environment.version = version

        rl = ResultList("Populate create new Environment dialog") \
            .push(self.name.set_value(name)) \
            .push(self.version.set_value(version))
        if submit:
            rl.push(self.create())
        return rl

    def verify_name_error(self, value):
        return self.nameErrorMessage.verify_value(value)
Пример #7
0
class IpRangeRow(BasePage):
    def __init__(self, parent=None):
        self.ip_range_start = Input(xpath=".//input[@name='ip_ranges-start']",
                                    element_name="Ip range start")

        self.ip_range_end = Input(xpath=".//input[@name='ip_ranges-end']",
                                  element_name="Ip range end")

        self.ip_range_add = Button(
            xpath=".//button[contains(@class,'ip-ranges-add')]",
            element_name="Ip range add")

        self.ip_range_delete = Button(
            xpath=".//button[contains(@class,'ip-ranges-delete')]",
            element_name="Ip range delete")

        BasePage.__init__(self, parent)

    def set_start_ip(self, args):
        return self.ip_range_start.set_value(args)

    def is_invalid(self):
        return self.ip_range_start.verify_attribute("class", "error")

    def is_correct(self):
        return self.ip_range_start.verify_attribute("class", "")

    def set_start_ip_verify_error(self, args):
        rl = ResultList("Set ip range start with '{args}' "
                        "and verify error".format(args=args)) \
            .push(self.set_start_ip(args)) \
            .push(self.is_invalid())
        return rl

    def set_start_ip_correct(self, args):
        rl = ResultList("Set ip range start with '{args}' and verify "
                        "error does not exist".format(args=args)) \
            .push(self.set_start_ip(args)) \
            .push(self.is_correct())
        return rl

    def set_start_ip_and_verify(self, args, value):
        if value:
            return self.set_start_ip_correct(args)
        else:
            return self.set_start_ip_verify_error(args)
Пример #8
0
    def __init__(self, parent=None):
        self.parameter_input = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='text']",
            element_name="Parameter {name}")

        self.parameter_radio = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='radio']",
            element_name="Parameter {name}")

        self.parameter_checkbox = Input(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='checkbox']",
            element_name="Parameter {name}")

        AbstractView.__init__(self, parent)
Пример #9
0
    def __init__(self, parent=None):
        self.name = HtmlElement(xpath=".//div[@class='volume-group-box-name']",
                                element_name="name")

        self.size = Input(
            xpath=".//div[@class='volume-group-box-input']/input",
            element_name="size")

        self.use_all_unallocated = Link(
            xpath=".//div[@class='use-all-unallocated']",
            element_name="Use all unallocated")

        BasePage.__init__(self, parent)
 def __init__(self):
     self.licence_rhsm = Radio(xpath=".//div[@class='custom-tumbler' "
                               "and input[@value='rhsm']]",
                               element_name="RHSM")
     self.licence_rhn = Radio(xpath=".//div[@class='custom-tumbler' "
                              "and input[@value='rhn']]",
                              element_name="RHN Satellite")
     self.rh_user = Input(xpath=".//input[@name='username']",
                          element_name="Red Hat Username")
     self.rh_password = Input(xpath=".//input[@name='password']",
                              element_name="Red Hat Password")
     self.satellite_server = Input(xpath=".//input[@name='satellite']",
                                   element_name="Satellite server hostname")
     self.activation_key = Input(xpath=".//input[@name='activation_key']",
                                 element_name="Activation key")
     AbstractDialog.__init__(self)
    def __init__(self):
        self.name = Input(
            xpath=".//input[@name='name']", element_name="Name"
        )
        self.nameErrorMessage = HtmlElement(
            xpath="//div[contains(@class,'control-group') and "
                  ".//input[contains(@name, 'name')]]"
                  "//span[@class='help-inline']",
            element_name="name error message"
        )
        self.version = Select(
            xpath=".//select[@name='release']", element_name="Version"
        )

        AbstractDialog.__init__(self)
Пример #12
0
    def __init__(self, parent=None):
        self.ip_range_start = Input(
            xpath=".//input[@name='ip_ranges-start']",
            element_name="Ip range start")

        self.ip_range_end = Input(
            xpath=".//input[@name='ip_ranges-end']",
            element_name="Ip range end")

        self.ip_range_add = Button(
            xpath=".//button[contains(@class,'ip-ranges-add')]",
            element_name="Ip range add")

        self.ip_range_delete = Button(
            xpath=".//button[contains(@class,'ip-ranges-delete')]",
            element_name="Ip range delete")

        BasePage.__init__(self, parent)
    def __init__(self):

        self.activationKey = Input(
            xpath=".//input[@name='activation_key']",
            element_name="Activation key"
        )
        self.deploymentMode = Radio(
            xpath=".//div[contains(@class, 'mode-control-group')]"
            "//label[div[contains(@class, 'parameter-name') "
            "and text()='{mode}']]",
            element_name="Deployment mode [{mode}]"
        )
        self.downloadType = Radio(
            xpath=".//div[contains(@class, 'custom-tumbler') "
                  "and input[@type='radio' and @value='{type}']]",
            element_name="Download type [{type}]"
        )
        self.instruction = HtmlElement(
            xpath=".//div[@class='alert alert-info rhel-license hide']",
            element_name="Instruction to deploy RHOS"
        )
        self.message_configuration_ready = HtmlElement(
            xpath=".//div[contains(text(), 'Configuration is finished and "
                  "now you can create your cluster!')]",
            element_name="Message: ready to create environment"
        )
        self.name = Input(
            xpath=".//input[@name='name']", element_name="Name"
        )
        self.nameErrorMessage = HtmlElement(
            xpath="//div[contains(@class,'control-group') and "
                  ".//input[contains(@name, 'name')]]"
                  "//span[@class='help-inline']",
            element_name="name error message"
        )
        self.parameter_radio = Radio(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]/text()='{name}']",
            element_name="Parameter {name}"
        )
        self.parameter_checkbox = Checkbox(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='checkbox']",
            element_name="Parameter {name}")
        self.password = Input(
            xpath=".//input[@name='password']",
            element_name="Password"
        )
        self.releaseDescription = HtmlElement(
            xpath=".//div[@class='release-description help-block']",
            element_name="Release description"
        )
        self.serverHostname = Input(
            xpath=".//input[@name='satellite']",
            element_name="Satellite server hostname"
        )
        self.storage_cinder = Radio(
            xpath=".//div[contains(@class, 'span6') and contains(./h5/text(), "
                  "'Cinder backend')]//label[contains(@class,'parameter-box') "
                  "and div[contains(@class,'parameter-name')]"
                  "/text()='{name}']",
            element_name="Cinder backend {name}"
        )
        self.storage_glance = Radio(
            xpath=".//div[contains(@class, 'span6') and contains(./h5/text(), "
                  "'Glance backend')]//label[contains(@class,'parameter-box') "
                  "and div[contains(@class,'parameter-name')]"
                  "/text()='{name}']",
            element_name="Glance backend {name}"
        )
        self.username = Input(
            xpath=".//input[@name='username']",
            element_name="Username"
        )
        self.version = Select(
            xpath=".//select[@name='release']", element_name="Version"
        )

        AbstractDialog.__init__(self)
class CreateEnvironmentDialog(AbstractDialog):

    def __init__(self):

        self.activationKey = Input(
            xpath=".//input[@name='activation_key']",
            element_name="Activation key"
        )
        self.deploymentMode = Radio(
            xpath=".//div[contains(@class, 'mode-control-group')]"
            "//label[div[contains(@class, 'parameter-name') "
            "and text()='{mode}']]",
            element_name="Deployment mode [{mode}]"
        )
        self.downloadType = Radio(
            xpath=".//div[contains(@class, 'custom-tumbler') "
                  "and input[@type='radio' and @value='{type}']]",
            element_name="Download type [{type}]"
        )
        self.instruction = HtmlElement(
            xpath=".//div[@class='alert alert-info rhel-license hide']",
            element_name="Instruction to deploy RHOS"
        )
        self.message_configuration_ready = HtmlElement(
            xpath=".//div[contains(text(), 'Configuration is finished and "
                  "now you can create your cluster!')]",
            element_name="Message: ready to create environment"
        )
        self.name = Input(
            xpath=".//input[@name='name']", element_name="Name"
        )
        self.nameErrorMessage = HtmlElement(
            xpath="//div[contains(@class,'control-group') and "
                  ".//input[contains(@name, 'name')]]"
                  "//span[@class='help-inline']",
            element_name="name error message"
        )
        self.parameter_radio = Radio(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]/text()='{name}']",
            element_name="Parameter {name}"
        )
        self.parameter_checkbox = Checkbox(
            xpath=".//label[contains(@class,'parameter-box') and "
                  "div[contains(@class,'parameter-name')]='{name}']//"
                  "input[@type='checkbox']",
            element_name="Parameter {name}")
        self.password = Input(
            xpath=".//input[@name='password']",
            element_name="Password"
        )
        self.releaseDescription = HtmlElement(
            xpath=".//div[@class='release-description help-block']",
            element_name="Release description"
        )
        self.serverHostname = Input(
            xpath=".//input[@name='satellite']",
            element_name="Satellite server hostname"
        )
        self.storage_cinder = Radio(
            xpath=".//div[contains(@class, 'span6') and contains(./h5/text(), "
                  "'Cinder backend')]//label[contains(@class,'parameter-box') "
                  "and div[contains(@class,'parameter-name')]"
                  "/text()='{name}']",
            element_name="Cinder backend {name}"
        )
        self.storage_glance = Radio(
            xpath=".//div[contains(@class, 'span6') and contains(./h5/text(), "
                  "'Glance backend')]//label[contains(@class,'parameter-box') "
                  "and div[contains(@class,'parameter-name')]"
                  "/text()='{name}']",
            element_name="Glance backend {name}"
        )
        self.username = Input(
            xpath=".//input[@name='username']",
            element_name="Username"
        )
        self.version = Select(
            xpath=".//select[@name='release']", element_name="Version"
        )

        AbstractDialog.__init__(self)

    def select_deployment_mode(self, value):
        return self.deploymentMode.find(mode=value).click()

    def populate(self, settings, clickNext=False):
        environment = Storage.get_current(TD_Cluster.NAME)
        environment.name = settings["name"]
        environment.version = settings["version"]

        rl = ResultList("Populate create new Environment dialog")

        rl.push(self.name.set_value(settings["name"]))
        rl.push(WaitBot().wait_loading())
        rl.push(self.version.set_value(settings["version"]))
        rl.push(self.name.click())

        if "rh" in settings and len(settings["rh"]) > 0 and \
                self.instruction.is_visible():

            rh = settings["rh"]
            self.wait_loading()
            rl.push(self.select_download_mode(rh["mode"]))
            rl.push(self.username.set_value(rh["username"]))
            rl.push(self.password.set_value(rh["password"]))

            if rh["mode"] == 'rhn':
                rl.push(self.serverHostname.set_value(rh["host"]))
                rl.push(self.activationKey.set_value(rh["activation_key"]))

        if clickNext:
            self.wait_loading()
            rl.push(self.clickNext())
            WaitBot().wait_loading()

        return rl

    def verify_name_error(self, value):
        return self.nameErrorMessage.verify_value(value)

    def verify_release_description(self, value):
        return self.releaseDescription.verify_value_contains(value)

    def select_download_mode(self, value):
        return self.downloadType.find(type=value).set_value("on")

    def set_parameter_radio(self, name, value):
        return self.parameter_radio.find(name=name).set_value(value)

    def set_parameter_checkbox(self, name, value):
        return self.parameter_checkbox.find(name=name).set_value(value)

    def create_environment(self, settings):
        """
        :param settings: {
            "name": "",
            "version": "",
            "rh": {
                "mode": "",
                "username": "",
                "password": "",
                "host": "",
                "activation_key": ""
            },
            "deployment_mode": "",
            "compute_type": "",
            "network": "",
            "storage": {
                "cinder": "",
                "glance": ""
            },
            "services":{
                "savanna": True,
                "murano": True
            }
        }
        """
        rl = ResultList("Create new environment")

        rl.push(self.populate(settings, True))

        rl.push(self.select_deployment_mode(settings["deployment_mode"]))
        rl.push(self.clickNext(()))

        #Set compute type (hypervisor)
        if "compute_type" in settings:
            rl.push(self.set_parameter_radio(
                settings["compute_type"], Radio.VALUE_ON))
        rl.push(self.clickNext())

        # Set network type
        if "network" in settings:
            rl.push(self.set_parameter_radio(
                settings["network"], Radio.VALUE_ON))
        rl.push(self.clickNext())

        if "storage" in settings:
            storage = settings["storage"]
            # Set cinder backend
            if "cinder" in storage:
                rl.push(
                    self.storage_cinder.find(storage["cinder"])
                    .set_value(Radio.VALUE_ON))

            # Set glance backend
            if "glance" in storage:
                rl.push(
                    self.storage_glance.find(storage["glance"])
                    .set_value(Radio.VALUE_ON))
        rl.push(self.clickNext())

        if "services" in settings:
            services = settings["services"]
            if "savanna" in services and services["savanna"]:
                rl.push(self.set_parameter_checkbox(
                    "Install Savanna", Checkbox.VALUE_ON))
            if "murano" in services and services["murano"]:
                rl.push(self.set_parameter_checkbox(
                    "Install Murano", Checkbox.VALUE_ON))
        rl.push(self.clickNext())

        rl.push(self.create())
        return rl
class Configure_Release_Dialog(AbstractDialog):
    def __init__(self):
        self.licence_rhsm = Radio(xpath=".//div[@class='custom-tumbler' "
                                  "and input[@value='rhsm']]",
                                  element_name="RHSM")
        self.licence_rhn = Radio(xpath=".//div[@class='custom-tumbler' "
                                 "and input[@value='rhn']]",
                                 element_name="RHN Satellite")
        self.rh_user = Input(xpath=".//input[@name='username']",
                             element_name="Red Hat Username")
        self.rh_password = Input(xpath=".//input[@name='password']",
                                 element_name="Red Hat Password")
        self.satellite_server = Input(xpath=".//input[@name='satellite']",
                                      element_name="Satellite server hostname")
        self.activation_key = Input(xpath=".//input[@name='activation_key']",
                                    element_name="Activation key")
        AbstractDialog.__init__(self)

    def download(self):
        return self.footerButton.find(name="Download").click()

    def populate(self, name, password, server=None, key=None):
        rl = ResultList("Populate dialog")\
            .push(self.rh_user.set_value(name))\
            .push(self.rh_password.set_value(password))
        if server is not None:
            rl.push(self.satellite_server.set_value(server))\
                .push(self.activation_key.set_value(key))
        return rl

    def verify_controls_presence(self, licence):
        rl = ResultList(
            "Verify controls presence on form for {}".format(licence))
        if licence == "RHSM":
            rl.push(self.rh_user.verify_visible(True)) \
                .push(self.rh_password.verify_visible(True)) \
                .push(self.satellite_server.verify_visible(False)) \
                .push(self.activation_key.verify_visible(False))
        else:
            rl.push(self.rh_user.verify_visible(True)) \
                .push(self.rh_password.verify_visible(True)) \
                .push(self.satellite_server.verify_visible(True)) \
                .push(self.activation_key.verify_visible(True))
        return rl
class Configure_Release_Dialog(AbstractDialog):
    def __init__(self):
        self.licence_rhsm = Radio(
            xpath=".//div[@class='custom-tumbler' "
                  "and input[@value='rhsm']]",
            element_name="RHSM"
        )
        self.licence_rhn = Radio(
            xpath=".//div[@class='custom-tumbler' "
                  "and input[@value='rhn']]",
            element_name="RHN Satellite"
        )
        self.rh_user = Input(
            xpath=".//input[@name='username']",
            element_name="Red Hat Username"
        )
        self.rh_password = Input(
            xpath=".//input[@name='password']",
            element_name="Red Hat Password"
        )
        self.satellite_server = Input(
            xpath=".//input[@name='satellite']",
            element_name="Satellite server hostname"
        )
        self.activation_key = Input(
            xpath=".//input[@name='activation_key']",
            element_name="Activation key"
        )
        AbstractDialog.__init__(self)

    def download(self):
        return self.footerButton.find(name="Download").click()

    def populate(self, name, password, server=None, key=None):
        rl = ResultList("Populate dialog")\
            .push(self.rh_user.set_value(name))\
            .push(self.rh_password.set_value(password))
        if server is not None:
            rl.push(self.satellite_server.set_value(server))\
                .push(self.activation_key.set_value(key))
        return rl

    def verify_controls_presence(self, licence):
        rl = ResultList(
            "Verify controls presence on form for {}".format(licence)
        )
        if licence == "RHSM":
            rl.push(self.rh_user.verify_visible(True)) \
                .push(self.rh_password.verify_visible(True)) \
                .push(self.satellite_server.verify_visible(False)) \
                .push(self.activation_key.verify_visible(False))
        else:
            rl.push(self.rh_user.verify_visible(True)) \
                .push(self.rh_password.verify_visible(True)) \
                .push(self.satellite_server.verify_visible(True)) \
                .push(self.activation_key.verify_visible(True))
        return rl
Пример #17
0
    def __init__(self, parent=None):
        self.save_settings = Button(
            xpath=".//div[contains(@class, 'apply-btn')]",
            element_name="Save Settings")

        self.cancel_changes = Button(
            xpath=".//div[contains(@class, 'btn-revert-changes')]",
            element_name="Cancel Changes")

        self.verify_networks = Button(
            xpath=".//div[contains(@class, 'verify-networks-btn')]",
            element_name="Verify networks")

        self.flat_dhcp_manager = Radio(xpath=".//div[@class='custom-tumbler' "
                                       "and input[@value='FlatDHCPManager']]",
                                       element_name="FlatDHCP Manager")

        self.vlan_manager = Radio(xpath=".//div[@class='custom-tumbler' "
                                  "and input[@value='VlanManager']]",
                                  element_name="Vlan Manager")

        self.ip_range_row = HtmlElement(
            xpath=".//div[@class='{name}']/"
            "div[contains(@class,'range-row ')][{num}]",
            element_name="Range row {name} [{num}]")

        self.public_vlan_id = Input(
            xpath=".//input[@name='public-vlan_start']",
            element_name="Public VLAN ID")

        self.public_netmask = Input(xpath=".//input[@name='public-netmask']",
                                    element_name="Public Netmask")

        self.public_gateway = Input(xpath=".//input[@name='public-gateway']",
                                    element_name="Public Gateway")

        self.management_cidr = Input(xpath=".//input[@name='management-cidr']",
                                     element_name="Management CIDR")

        self.management_vlan_id = Input(
            xpath=".//input[@name='management-vlan_start']",
            element_name="Management VLAN ID")

        self.storage_cidr = Input(xpath=".//input[@name='storage-cidr']",
                                  element_name="Storage CIDR")

        self.storage_vlan_id = Input(
            xpath=".//input[@name='storage-vlan_start']",
            element_name="Storage VLAN ID")

        self.vm_networks_cidr = Input(xpath=".//input[@name='fixed-cidr']",
                                      element_name="VM Networks CIDR")

        self.vm_networks_vlan_id = Input(
            xpath=".//input[@name='fixed-vlan_start']",
            element_name="VM Networks VLAN ID")

        self.vm_networks_vlan_id_range_start = Input(
            xpath=".//input[@name='fixed-vlan_range-start']",
            element_name="VM Networks VLAN ID range start")

        self.vm_networks_vlan_id_range_end = Input(
            xpath=".//input[@name='fixed-vlan_range-end']",
            element_name="VM Networks VLAN ID range end")

        self.vm_networks_number_of_networks = Input(
            xpath=".//input[@name='fixed-amount']",
            element_name="VM Networks. Number of networks")

        self.vm_networks_size_of_networks = Select(
            xpath=".//select[@name='fixed-network_size']",
            element_name="VM Networks. Size of networks")

        self.verify_networks = Button(
            xpath=".//button[contains(@class,'verify-networks-btn')]",
            element_name="Verify networks")

        self.cancel_changes = Button(
            xpath=".//button[contains(@class, 'btn-revert-changes')]",
            element_name="Cancel changes")
        self.save_settings = Button(
            xpath=".//button[contains(@class, 'btn-success apply-btn')]",
            element_name="Save settings")

        AbstractView.__init__(self, parent)
Пример #18
0
class NetworkSettingsView(AbstractView):
    def __init__(self, parent=None):
        self.save_settings = Button(
            xpath=".//div[contains(@class, 'apply-btn')]",
            element_name="Save Settings")

        self.cancel_changes = Button(
            xpath=".//div[contains(@class, 'btn-revert-changes')]",
            element_name="Cancel Changes")

        self.verify_networks = Button(
            xpath=".//div[contains(@class, 'verify-networks-btn')]",
            element_name="Verify networks")

        self.flat_dhcp_manager = Radio(xpath=".//div[@class='custom-tumbler' "
                                       "and input[@value='FlatDHCPManager']]",
                                       element_name="FlatDHCP Manager")

        self.vlan_manager = Radio(xpath=".//div[@class='custom-tumbler' "
                                  "and input[@value='VlanManager']]",
                                  element_name="Vlan Manager")

        self.ip_range_row = HtmlElement(
            xpath=".//div[@class='{name}']/"
            "div[contains(@class,'range-row ')][{num}]",
            element_name="Range row {name} [{num}]")

        self.public_vlan_id = Input(
            xpath=".//input[@name='public-vlan_start']",
            element_name="Public VLAN ID")

        self.public_netmask = Input(xpath=".//input[@name='public-netmask']",
                                    element_name="Public Netmask")

        self.public_gateway = Input(xpath=".//input[@name='public-gateway']",
                                    element_name="Public Gateway")

        self.management_cidr = Input(xpath=".//input[@name='management-cidr']",
                                     element_name="Management CIDR")

        self.management_vlan_id = Input(
            xpath=".//input[@name='management-vlan_start']",
            element_name="Management VLAN ID")

        self.storage_cidr = Input(xpath=".//input[@name='storage-cidr']",
                                  element_name="Storage CIDR")

        self.storage_vlan_id = Input(
            xpath=".//input[@name='storage-vlan_start']",
            element_name="Storage VLAN ID")

        self.vm_networks_cidr = Input(xpath=".//input[@name='fixed-cidr']",
                                      element_name="VM Networks CIDR")

        self.vm_networks_vlan_id = Input(
            xpath=".//input[@name='fixed-vlan_start']",
            element_name="VM Networks VLAN ID")

        self.vm_networks_vlan_id_range_start = Input(
            xpath=".//input[@name='fixed-vlan_range-start']",
            element_name="VM Networks VLAN ID range start")

        self.vm_networks_vlan_id_range_end = Input(
            xpath=".//input[@name='fixed-vlan_range-end']",
            element_name="VM Networks VLAN ID range end")

        self.vm_networks_number_of_networks = Input(
            xpath=".//input[@name='fixed-amount']",
            element_name="VM Networks. Number of networks")

        self.vm_networks_size_of_networks = Select(
            xpath=".//select[@name='fixed-network_size']",
            element_name="VM Networks. Size of networks")

        self.verify_networks = Button(
            xpath=".//button[contains(@class,'verify-networks-btn')]",
            element_name="Verify networks")

        self.cancel_changes = Button(
            xpath=".//button[contains(@class, 'btn-revert-changes')]",
            element_name="Cancel changes")
        self.save_settings = Button(
            xpath=".//button[contains(@class, 'btn-success apply-btn')]",
            element_name="Save settings")

        AbstractView.__init__(self, parent)

    def get_ip_range_row(self, name, num):
        return IpRangeRow(self.ip_range_row.find(name=name, num=num))

    def verify_error(self,
                     obj,
                     args,
                     value,
                     error_class="error",
                     simple_class=""):
        rl = ResultList(
            "Set '{args}' and verify validation".format(args=args)).\
            push(obj.set_value(args))
        if value:
            rl.push(obj.verify_attribute("class", simple_class))
        else:
            rl.push(obj.verify_attribute("class", error_class))
        return rl

    def verify_cidr_vm_networks(self, args, value):
        return self.verify_error(self.vm_networks_cidr, args, value)

    def verify_amount(self, args, value):
        return self.verify_error(self.vm_networks_number_of_networks, args,
                                 value, "range error", "range")

    def verify_vlan_id_range_start(self, args, value):
        return self.verify_error(self.vm_networks_vlan_id_range_start, args,
                                 value, "mini range error", "mini range")

    def verify_error_amount(self,
                            arg_number,
                            value,
                            arg_start_range=1,
                            arg_end_range=None):
        rl = ResultList("Verify validation of field number of networks"
                        " with value '{args}'".format(args=arg_number))
        rl.push(
            self.vm_networks_vlan_id_range_start.set_value(arg_start_range))
        rl.push(self.verify_amount(arg_number, value))
        if arg_end_range is not None:
            rl.push(
                self.vm_networks_vlan_id_range_end.verify_value(arg_end_range))
        return rl

    def set_flatDHCP_manager(self, value):
        return self.flat_dhcp_manager.set_value(value)

    def set_VLAN_manager(self, value):
        return self.vlan_manager.set_value(value)

    def verify_flatDHCP_manager_value(self, value):
        return self.flat_dhcp_manager.verify_value(value)

    def verify_VLAN_manager_value(self, value):
        return self.vlan_manager.verify_value(value)

    def get_networks_blocks(self):
        return self.get_action_bot().find_elements(
            By.XPATH, ".//div/legend[@class='networks']")

    def verify_amount_of_blocks(self, expected_amount):
        status = len(self.get_networks_blocks()) == expected_amount
        return Result(
            "Amount of blocks is {amount}. Amount is equal "
            "with expected: {status}".format(amount=len(
                self.get_networks_blocks()),
                                             status=status), status)

    def verify_visibility_vlan_manager_fields(self, value):
        rl = ResultList("Verify vlan manager fields "
                        "are visible: {value}".format(value=value))
        rl.push(VerifyBot().verify_visibility(
            NetworkSettingsView().vm_networks_number_of_networks.get_element(),
            value, "Number of networks"))
        rl.push(VerifyBot().verify_visibility(
            NetworkSettingsView().vm_networks_size_of_networks.get_element(),
            value, "Size of networks"))
        if value:
            rl.push(VerifyBot().verify_visibility(
                NetworkSettingsView().vm_networks_vlan_id_range_start.
                get_element(), value, "Start of VLAN ID range"))
            rl.push(VerifyBot().verify_visibility(
                NetworkSettingsView().vm_networks_vlan_id_range_end.
                get_element(), value, "End of VLAN ID range"))
        else:
            rl.push(VerifyBot().verify_visibility(
                NetworkSettingsView().vm_networks_vlan_id_range_start, value,
                "Start of VLAN ID range"))
            rl.push(VerifyBot().verify_visibility(
                NetworkSettingsView().vm_networks_vlan_id_range_end, value,
                "End of VLAN ID range"))
        return rl