from cfme.exceptions import DestinationNotFound, StackNotFound, CandidateNotFound
from cfme.web_ui import Quadicon, flash, Form, fill, form_buttons, paginator, toolbar as tb, \
    match_location, accordion
from cfme.exceptions import CFMEException, FlashMessageException
from utils.appliance import Navigatable
from utils.appliance.implementations.ui import navigator, navigate_to, CFMENavigateStep
from utils.pretty import Pretty
from utils.wait import wait_for

cfg_btn = partial(tb.select, "Configuration")
pol_btn = partial(tb.select, 'Policy')
lifecycle_btn = partial(tb.select, 'Lifecycle')

edit_tags_form = Form(fields=[(
    "select_tag",
    ui.Select("select#tag_cat")), ("select_value",
                                   ui.Select("select#tag_add"))])

match_page = partial(match_location,
                     controller='orchestration_stack',
                     title='Stacks')


class Stack(Pretty, Navigatable):
    _param_name = "Stack"
    pretty_attrs = ['name']

    def __init__(self, name, provider, quad_name=None, appliance=None):
        self.name = name
        self.quad_name = quad_name or 'stack'
        self.provider = provider
Exemple #2
0
basic_info_form = Form(fields=[(
    'name_text',
    "//input[@id='name']"), (
        'description_text', "//input[@id='description']"
    ), ('display_checkbox', "//input[@id='display']"
        ), ('select_catalog', Select("//select[@id='catalog_id']")
            ), ('select_dialog', Select("//select[@id='dialog_id']")
                ), ('edit_button', "//img[@alt='Save Changes']")])

detail_form = Form(fields=[('long_desc',
                            "//textarea[@id='long_description']")])

request_form = tabstrip.TabStripForm(tab_fields=OrderedDict(
    [('Catalog', [
        ('num_instances',
         web_ui.Select('//select[@id="service__number_of_vms"]')),
        ('instance_name', '//input[@name="service__vm_name"]'),
        ('instance_description', '//textarea[@id="service__vm_description"]'),
        ('catalog_name', web_ui.Table('//div[@id="prov_vm_div"]/table')),
    ]),
     ('Environment', [
         ('automatic_placement',
          '//input[@id="environment__placement_auto"]'),
         ('availability_zone',
          web_ui.Select(
              '//select[@id="environment__placement_availability_zone"]')),
         ('security_groups', prov.select_security_group),
         ('public_ip_address',
          web_ui.Select('//select[@id="environment__floating_ip_address"]')),
     ]),
     ('Properties', [
Exemple #3
0
# -*- coding: utf-8 -*-

from cfme import web_ui as ui
from cfme.fixtures import pytest_selenium as sel
from cfme.web_ui import Region, accordion, fill, flash, form_buttons
from cfme.web_ui.menu import nav

nav.add_branch(
    "reports", {
        "import_export":
        lambda ctx: accordion.tree("Import/Export", "Import / Export"),
    })

form = Region(locators=dict(
    export_select=ui.Select("//select[@id='choices_chosen']", multi=True),
    export_button=form_buttons.FormButton("Download Report to YAML"),
    import_overwrite=ui.Input('overwrite'),
    import_file=ui.Input('upload_file'),
    import_submit=ui.Input('upload_atags')))

export_select = ui.Select("//select[@id='choices_chosen']", multi=True)
export_button = form_buttons.FormButton("Download Report to YAML")


def export_reports(*custom_report_names):
    sel.force_navigate("import_export")
    fill(form.export_select, custom_report_names)
    sel.click(form.export_button)


def import_reports(filename, overwrite=False):
Exemple #4
0
from cfme.web_ui import Form, Region, CheckboxTable, fill, match_location
from utils.appliance import Navigatable
from utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to
from utils.log import logger
from utils.wait import wait_for, TimedOutError
from cfme.services import requests

buttons = Region(
    locators={
        'default': '//*[@id="buttons_off"]/a',
        'apply': '//*[@id="buttons_on"]/a[1]',
        'reset': '//*[@id="buttons_on"]/a[2]'
    })

filter_form = Form(fields=[
    ("zone", ui.Select("//select[@id='chosen_zone']")),
    ("user", ui.Select("//select[@id='user_choice']")),
    ("time_period", ui.Select("//select[@id='time_period']")),
    ("task_status_queued", ui.Input('queued')),
    ("task_status_running", ui.Input('running')),
    ("task_status_ok", ui.Input('ok')),
    ("task_status_error", ui.Input('error')),
    ("task_status_warn", ui.Input('warn')),
    ("task_state", ui.Select("//select[@id='state_choice']")),
])

table_loc = '//div[@id="records_div"]/table'

match_page = partial(match_location, controller='miq_task')

tasks_table = CheckboxTable(
Exemple #5
0
cfg_btn = partial(tb.select, "Configuration")
buttons_tree = partial(accordion.tree, "Buttons", "Object Types")

button_group_form = Form(
    fields=[
        ('btn_group_text', ui.Input('name')),
        ('btn_group_hvr_text', ui.Input('description')),
        ('add_button', form_buttons.add),
        ('save_button', form_buttons.save)
    ])

button_form = Form(
    fields=[
        ('btn_text', ui.Input('name')),
        ('btn_hvr_text', ui.Input('description')),
        ('select_dialog', ui.Select('select#dialog_id')),
        ('system_process', ui.Select('select#instance_name')),
        ('request', ui.Input('object_request')),
        ('add_button', form_buttons.add),
        ('save_button', form_buttons.save)
    ])


def _new_button_group(_context):
    cfg_btn('Add a new Button Group')
    sel.wait_for_element(button_group_form.btn_group_text)


def _new_button(_context):
    cfg_btn('Add a new Button')
    sel.wait_for_element(button_form.btn_text)
from cfme.fixtures import pytest_selenium as sel
from cfme.web_ui import accordion, menu, flash, Quadicon, Region, Form, fill, form_buttons
from cfme.web_ui import toolbar as tb
from utils.update import Updateable
from utils.wait import wait_for

lifecycle_btn = partial(tb.select, "Lifecycle")
reload_func = partial(tb.select, "Reload current display")
my_service_tree = partial(accordion.tree, "Services")
details_page = Region(infoblock_type='detail')
cfg_btn = partial(tb.select, "Configuration")
policy_btn = partial(tb.select, "Policy")

retirement_form = Form(
    fields=[('retirement_date', ui.Calendar('miq_date_1')
             ), ('retirement_warning', ui.Select("select#retirement_warn"))])

edit_service_form = Form(
    fields=[("name", ui.Input("name")), ("description",
                                         ui.Input("description"))])

set_ownership_form = Form(
    fields=[("select_owner", ui.Select("select#user_name")
             ), ("select_group", ui.Select("select#group_name"))])

edit_tags_form = Form(fields=[(
    "select_tag",
    ui.Select("select#tag_cat")), ("select_value",
                                   ui.Select("select#tag_add"))])

menu.nav.add_branch(
        click_remove()


def get_expression_as_text():
    """ Returns whole expression as represented visually.

    """
    return sel.text("//div[@id='exp_editor_div']/fieldset/div").encode(
        "utf-8").strip()


###
# Form handling
#
field_form = web_ui.Form(fields=[
    ("type", web_ui.Select("//select[@id='chosen_typ']")),
    ("field", web_ui.Select("//select[@id='chosen_field']")),
    ("key", web_ui.Select("//select[@id='chosen_key']")),
    ("value", "//*[@id='chosen_value']"),
    ("user_input", "//input[@id='user_input']"),
])

field_date_form = web_ui.Form(
    fields=[("dropdown_select", web_ui.Select("//select[@id='chosen_from_1']")
             ), ("input_select_date", web_ui.Calendar("miq_date_1_0")),
            ("input_select_time",
             web_ui.Select("//select[@id='miq_time_1_0']"))])

count_form = web_ui.Form(fields=[
    ("type", web_ui.Select("//select[@id='chosen_typ']")),
    ("count", web_ui.Select("//select[@id='chosen_count']")),
Exemple #8
0
            ('first_name', ui.Input('requester__owner_first_name')),
            ('last_name', ui.Input('requester__owner_last_name')),
            ('notes', ui.Input('requester__request_notes')),
            ('manager_name', ui.Input('requester__owner_manager'))
        ]),

        ('Purpose', [
            ('apply_tags', ui.CheckboxTree({
                version.LOWEST: '//div[@id="all_tags_treebox"]//table',
                "5.3": '//div[@id="all_tags_treebox"]//ul',
            }))
        ]),

        ('Catalog', [
            # Cloud
            ('num_instances', ui.Select('select#service__number_of_vms')),
            ('instance_name', '//input[@name="service__vm_name"]'),
            ('instance_description', ui.Input('service__vm_description')),

            # Infra
            ('vm_filter', ui.Select('select#service__vm_filter#')),
            ('num_vms', ui.Select('select#service__number_of_vms')),
            ('vm_name', '//input[@name="service__vm_name"]'),
            ('vm_description', ui.Input('service__vm_description')),
            ('catalog_name', ui.Table('//div[@id="prov_vm_div"]/table')),
            ('provision_type', ui.Select('select#service__provision_type')),
            ('linked_clone', ui.Input('service__linked_clone')),
            ('pxe_server', ui.Select('select#service__pxe_server_id')),
            ('pxe_image', ui.Table('//div[@id="prov_pxe_img_div"]/table')),
            ('iso_file', ui.Table('//div[@id="prov_iso_img_div"]/table'))
        ]),
Exemple #9
0
class StorageManager(Updateable):
    """Represents the Storage / Storage Managers object. Allows interaction

    Args:
        name: Name of the Storage Namager as it appears in the UI.
        type: Type of the Storage Manager (eg. StorageManager.NETAPP_RS, ...)
        hostname: Host name of the machine.
        ip: IP Address of the machine.
        port: Port of the machine.
        credentials: :py:class:`dict` or :py:class:`StorageManager.Credential`
    """
    class Credential(Updateable):
        def __init__(self, username=None, password=None):
            self.username = username
            self.password = password

    form = Form(fields=[
        ("name", ui.Input("name")),
        ("type", ui.Select("select#sm_type")),
        ("hostname", ui.Input("hostname")),
        ("ip", ui.Input("ipaddress")),
        ("port", ui.Input("port")),
        ("credentials",
         Form(fields=[("username", ui.Input("userid")),
                      ("password",
                       MultiFill(ui.Input("password"), ui.Input("verify")))])),
    ])

    validate = form_buttons.FormButton(
        "Validate the credentials by logging into the Server")
    add = form_buttons.FormButton("Add this Storage Manager")

    ##
    # Types constants. Extend if needed :)
    NETAPP_RS = "NetApp Remote Service"

    def __init__(self,
                 name=None,
                 type=None,
                 hostname=None,
                 ip=None,
                 port=None,
                 credentials=None):
        self.name = name
        self.type = type
        self.hostname = hostname
        self.ip = ip
        self.port = port
        self.credentials = credentials

    def create(self, validate=True, cancel=False):
        sel.force_navigate("storage_manager_new")
        fill(self.form, self)
        if validate:
            sel.click(self.validate)
        if cancel:
            sel.click(form_buttons.cancel)
        else:
            sel.click(self.add)
        flash.assert_no_errors()

    def update(self, updates, validate=True, cancel=False):
        sel.force_navigate("storage_manager_edit",
                           context={"storage_manager": self})
        fill(self.form, updates)
        if validate:
            sel.click(self.validate)
        if cancel:
            sel.click(form_buttons.cancel)
        else:
            sel.click(form_buttons.save)
        flash.assert_no_errors()

    def delete(self, cancel=False):
        self.navigate()
        cfg_btn("Remove this Storage Manager from the VMDB",
                invokes_alert=True)
        sel.handle_alert(cancel)
        flash.assert_no_errors()

    def navigate(self):
        sel.force_navigate("storage_manager",
                           context={"storage_manager": self})

    def refresh_inventory(self):
        self.navigate()
        cfg_btn("Refresh Inventory", invokes_alert=True)
        sel.handle_alert(cancel=False)
        flash.assert_no_errors()

    def refresh_status(self):
        self.navigate()
        cfg_btn("Refresh Status", invokes_alert=True)
        sel.handle_alert(cancel=False)
        flash.assert_no_errors()

    def wait_until_updated(self, num_sec=300):
        def _wait_func():
            self.navigate()
            return InfoBlock("Properties",
                             "Last Update Status").text.strip().lower() == "ok"

        wait_for(_wait_func, num_sec=num_sec, delay=5)

    @property
    def exists(self):
        try:
            self.navigate()
            return True
        except StorageManagerNotFound:
            return False