def set_additional_tenants(view, tenants):
        """ Sets additional tenants

        Args:
            view: AddCatalogItemView or EditCatalogItemView
            tenants: list of tenants with options to select

        Usage:
            set True to the path which needs to be checked
            and False for the path that needs to be unchecked

        catalog_item = appliance.collections.catalog_items.create(
            catalog_item_class,
            additional_tenants=[
                (("All Tenants"), False),
                (("All Tenants", "My Company"), True),
                (("All Tenants", "My Company", "Child", "Grandchild"), True),
            ],
            *args,
            **kwargs
        )
        """
        if tenants is not None and isinstance(tenants, (list, tuple, set)):
            changes = [
                view.fill({
                    "additional_tenants":
                    CheckableBootstrapTreeview.CheckNode(path)
                    if option else CheckableBootstrapTreeview.UncheckNode(path)
                }) for path, option in tenants
            ]
            return True in changes
        else:
            return False
def test_provision_with_tag(appliance, vm_name, tag, provider, request):
    """ Tests tagging instance using provisioning dialogs.

    Steps:
        * Open the provisioning dialog.
        * Apart from the usual provisioning settings, pick a tag.
        * Submit the provisioning request and wait for it to finish.
        * Visit instance page, it should display the selected tags
    Metadata:
        test_flag: provision

    Polarion:
        assignee: anikifor
        casecomponent: Tagging
        initialEstimate: 1/4h
    """
    inst_args = {
        'purpose': {
            'apply_tags':
            Check_tree.CheckNode(
                ['{} *'.format(tag.category.display_name), tag.display_name])
        }
    }
    collection = appliance.provider_based_collection(provider)
    instance = collection.create(vm_name, provider, form_values=inst_args)
    request.addfinalizer(instance.cleanup_on_provider)
    assert tag in instance.get_tags(
    ), 'Provisioned instance does not have expected tag'
示例#3
0
class HostDriftAnalysis(ComputeInfrastructureHostsView):
    apply_button = Button("Apply")
    drift_sections = CheckableBootstrapTreeview(tree_id="all_sectionsbox")

    @ParametrizedView.nested
    class drift_analysis(ParametrizedView):  # noqa
        PARAMETERS = ("drift_section", )
        CELLS = "../td//i"
        row = Text(ParametrizedLocator(".//div[@id='compare-grid']/"
                                       "/th[normalize-space(.)={drift_section|quote}]"))

        @property
        def is_changed(self):
            cells = self.browser.elements(self.CELLS, parent=self.row)
            attrs = [self.browser.get_attribute("class", cell) for cell in cells]
            return "drift-delta" in attrs

    @View.nested
    class toolbar(View):  # noqa
        all_attributes = Button(title="All attributes")
        different_values_attributes = Button(title="Attributes with different")
        same_values_attributes = Button(title="Attributes with same values")
        details_mode = Button(title="Details Mode")
        exists_mode = Button(title="Exists Mode")

    @property
    def is_displayed(self):
        return (
            self.in_compute_infrastructure_hosts and
            self.title.text == "'{}' Drift Analysis".format(self.context["object"].name)
        )
示例#4
0
def test_provision_with_tag(appliance, vm_name, tag, provider):
    """ Tests tagging instance using provisioning dialogs.

    Steps:
        * Open the provisioning dialog.
        * Apart from the usual provisioning settings, pick a tag.
        * Submit the provisioning request and wait for it to finish.
        * Visit instance page, it should display the selected tags
    Metadata:
        test_flag: provision
    """

    inst_args = {
        'purpose': {
            'apply_tags':
            Check_tree.CheckNode(
                ['{} *'.format(tag.category.display_name), tag.display_name])
        }
    }
    collection = appliance.provider_based_collection(provider)
    instance = collection.create(vm_name, provider, form_values=inst_args)
    tags = instance.get_tags()
    assert any(instance_tag.category.display_name == tag.category.display_name
               and instance_tag.display_name == tag.display_name
               for instance_tag in tags), ("{}: {} not in ({})".format(
                   tag.category.display_name, tag.display_name, str(tags)))
示例#5
0
    def update(self, updates):
        """
        Args:
            updates: Dictionary containing 'filters' key. Values are tuples of ([path], bool)
                Where bool is whether to check or uncheck the filter

        Returns: None
        """
        view = navigate_to(self, 'All')
        for path, check in updates['filters']:
            fill_value = CbTree.CheckNode(
                path) if check else CbTree.UncheckNode(path)
            if view.tree.fill(fill_value):
                view.save.click()
            else:
                logger.info('No change to filter on update, not saving form.')
class BasicInfoForm(ServicesCatalogView):
    title = Text('#explorer_title_text')

    # Filling dropdowns first to avoid selenium field reset bug
    select_catalog = BootstrapSelect('catalog_id')
    select_dialog = BootstrapSelect('dialog_id')

    select_provider = BootstrapSelect('manager_id')
    select_orch_template = BootstrapSelect('template_id')
    select_config_template = BootstrapSelect('template_id')

    name = Input(name='name')
    description = Input(name='description')
    display = Checkbox(name='display')

    subtype = BootstrapSelect('generic_subtype')
    provisioning_entry_point = EntryPoint(name='fqname',
                                          tree_id="automate_catalog_treebox")
    retirement_entry_point = EntryPoint(name='retire_fqname',
                                        tree_id="automate_catalog_treebox")
    reconfigure_entry_point = EntryPoint(name='reconfigure_fqname',
                                         tree_id="automate_catalog_treebox")
    select_resource = BootstrapSelect('resource_id')
    additional_tenants = CheckableBootstrapTreeview(tree_id="tenants_treebox")
    zone = BootstrapSelect("zone_id")
    currency = BootstrapSelect("currency")
    price_per_month = Input(name="price")

    @View.nested
    class modal(View):  # noqa
        tree = ManageIQTree('automate_treebox')
        include_domain = Checkbox(id='include_domain_prefix_chk')
        apply = Button('Apply')
        cancel = Button('Cancel')
def test_tag(provisioner, prov_data, provider, vm_name):
    """ Tests tagging VMs using provisioning dialogs.

    Prerequisites:
        * A provider set up, supporting provisioning in CFME

    Steps:
        * Open the provisioning dialog.
        * Apart from the usual provisioning settings, pick a tag.
        * Submit the provisioning request and wait for it to finish.
        * Visit th page of VM, it should display the selected tags


    Metadata:
        test_flag: provision

    Polarion:
        assignee: anikifor
        initialEstimate: 1/8h
    """
    prov_data['catalog']['vm_name'] = vm_name
    prov_data['purpose']["apply_tags"] = CbTree.CheckNode(path=("Service Level *", "Gold"))
    template_name = provider.data['provisioning']['template']

    vm = provisioner(template_name, prov_data)

    tags = vm.get_tags()
    assert any(
        tag.category.display_name == "Service Level" and tag.display_name == "Gold"
        for tag in tags
    ), "Service Level: Gold not in tags ({})".format(tags)
示例#8
0
class RoleForm(ConfigurationView):
    """ Role Form for CFME UI """
    name_txt = Input(name='name')
    vm_restriction_select = BootstrapSelect(id='vm_restriction')
    product_features_tree = CheckableBootstrapTreeview("features_treebox")

    cancel_button = Button('Cancel')
示例#9
0
 class my_company_tags(Tab):     # noqa
     """ Represents 'My company tags' tab in Group Form """
     TAB_NAME = "My Company Tags"
     tree_locator = VersionPick({
         Version.lowest(): 'tagsbox',
         '5.8': 'tags_treebox'}
     )
     tree = CheckableBootstrapTreeview(tree_locator)
示例#10
0
def test_service_select_tenants(appliance, request, tenant):
    """
    Bugzilla:
        1678123

    Polarion:
        assignee: nansari
        casecomponent: Services
        initialEstimate: 1/6h
        startsin: 5.11
        setup:
            1. Create a tenant.
        testSteps:
            1. Create catalog item with the given tenant
        expectedResults:
            1.  Catalog item is created successfully
                and tenant is visible under catalog items's Details page
    """
    tenants_path = ("All Tenants", "My Company", tenant.name)
    data = {
        "name":
        fauxfactory.gen_alphanumeric(start="cat_item_", length=15),
        "description":
        fauxfactory.gen_alphanumeric(start="cat_item_desc_", length=20),
        "zone":
        "Default Zone",
        "currency":
        "$ [Australian Dollar]",
        "price_per_month":
        100,
        "additional_tenants": [(tenants_path, True)],
    }

    catalog_item = appliance.collections.catalog_items.create(
        appliance.collections.catalog_items.GENERIC, **data)
    request.addfinalizer(catalog_item.delete)

    view = navigate_to(catalog_item, "Details")

    # Defining this widget so that we can expand the required tenants path
    additional_tenants = CheckableBootstrapTreeview(view,
                                                    tree_id="tenants_treebox")
    # Make sure the required path is visible i.e not collapsed
    additional_tenants.expand_path(*tenants_path)
    assert tenant.name in view.basic_info.get_text_of("Additional Tenants")
示例#11
0
class ManagePoliciesView(BaseLoggedInPage):
    """
    Manage policies page
    """
    policy_profiles = CheckableBootstrapTreeview(tree_id='protectbox')
    breadcrumb = BreadCrumb()  # some views have breadcrumb, some not
    entities = View.nested(BaseNonInteractiveEntitiesView)
    save = Button('Save')
    reset = Button('Reset')
    cancel = Button('Cancel')

    is_displayed = displayed_not_implemented
示例#12
0
class HostDriftAnalysis(ComputeInfrastructureHostsView):
    apply_button = Button("Apply")
    drift_sections = CheckableBootstrapTreeview(tree_id="all_sectionsbox")
    drift_analysis = DriftComparison(locator=".//div[@id='compare-grid']")

    @View.nested
    class toolbar(View):  # noqa
        all_attributes = Button(title="All attributes")
        different_values_attributes = Button(
            title="Attributes with different values")
        same_values_attributes = Button(title="Attributes with same values")
        details_mode = Button(title="Details Mode")
        exists_mode = Button(title="Exists Mode")

    @property
    def is_displayed(self):
        return (self.in_compute_infrastructure_hosts and self.title.text
                == "'{}' Drift Analysis".format(self.context["object"].name))
示例#13
0
class DriftAnalysis(BaseLoggedInPage):
    title = Text('#explorer_title_text')
    apply_button = Button("Apply")
    drift_sections = CheckableBootstrapTreeview(tree_id="all_sectionsbox")
    drift_analysis = DriftComparison(locator=".//div[@id='compare-grid']")

    @View.nested
    class toolbar(View):  # noqa
        all_attributes = Button(title="All attributes")
        different_values_attributes = Button(
            title="Attributes with different values")
        same_values_attributes = Button(title="Attributes with same values")
        details_mode = Button(title="Details Mode")
        exists_mode = Button(title="Exists Mode")

    @property
    def is_displayed(self):
        return (self.title.text == 'Drift for VM or Template "{}"'.format(
            self.context["object"].name))
示例#14
0
class AlertProfilesEditAssignmentsView(ControlExplorerView):
    title = Text("#explorer_title_text")
    assign_to = BootstrapSelect("chosen_assign_to")
    tag_category = BootstrapSelect("chosen_cat")
    selections = CheckableBootstrapTreeview(
        VersionPick({
            Version.lowest(): "obj_treebox",
            "5.9": "object_treebox"
        }))
    header = Text("//div[@id='alert_profile_assign_div']/h3")
    based_on = Text('//label[normalize-space(.)="Based On"]/../div')

    save_button = Button("Save")
    reset_button = Button("Reset")
    cancel_button = Button("Cancel")

    @property
    def is_displayed(self):
        return (self.in_control_explorer
                and self.title.text == 'Alert Profile "{}"'.format(
                    self.context["object"].description)
                and self.header.text == "Assignments"
                and self.based_on == self.context["object"].TYPE)
示例#15
0
class DefaultFilterForm(MySettingsView):
    tree = CheckableBootstrapTreeview('df_treebox')
    save = Button('Save')
示例#16
0
 class vms_and_templates(Tab):  # noqa
     """ Represents 'VM's and Templates' tab in Group Form """
     TAB_NAME = "VMs & Templates"
     vms_templates_tree = CheckableBootstrapTreeview('vat_treebox')
示例#17
0
 class hosts_and_clusters(Tab):  # noqa
     """ Represents 'Hosts and Clusters' tab in Group Form """
     TAB_NAME = "Hosts & Clusters"
     hosts_clusters_tree = CheckableBootstrapTreeview('hac_treebox')
示例#18
0
 class my_company_tags(Tab):  # noqa
     """ Represents 'My company tags' tab in Group Form """
     TAB_NAME = "My Company Tags"
     tag_tree = CheckableBootstrapTreeview('tags_treebox')
def testing_instance(request, setup_provider, provider, provisioning, vm_name, tag):
    """ Fixture to prepare instance parameters for provisioning
    """
    image = provisioning['image']['name']
    note = ('Testing provisioning from image {} to vm {} on provider {}'.format(
        image, vm_name, provider.key))

    instance = Instance.factory(vm_name, provider, image)

    inst_args = dict()

    # Base instance info
    inst_args['request'] = {
        'email': '*****@*****.**',
        'first_name': 'Image',
        'last_name': 'Provisioner',
        'notes': note,
    }
    # TODO Move this into helpers on the provider classes
    recursive_update(inst_args, {'catalog': {'vm_name': vm_name}})

    # Check whether auto-selection of environment is passed
    auto = False  # By default provisioning will be manual
    try:
        parameter = request.param
        if parameter == 'tag':
            inst_args['purpose'] = {
                'apply_tags': Check_tree.CheckNode(
                    ['{} *'.format(tag.category.display_name), tag.display_name])
            }
        else:
            auto = parameter
    except AttributeError:
        # in case nothing was passed just skip
        pass

    recursive_update(inst_args, {
        'environment': {
            'availability_zone': provisioning.get('availability_zone', None),
            'security_groups': [provisioning.get('security_group', None)],
            'cloud_network': provisioning.get('cloud_network', None),
            'cloud_subnet': provisioning.get('cloud_subnet', None),
            'resource_groups': provisioning.get('resource_group', None)
        },
        'properties': {
            'instance_type': partial_match(provisioning.get('instance_type', None)),
            'guest_keypair': provisioning.get('guest_keypair', None)}
    })
    # GCE specific
    if provider.one_of(GCEProvider):
        recursive_update(inst_args, {
            'properties': {
                'boot_disk_size': provisioning['boot_disk_size'],
                'is_preemptible': True}
        })

    # Azure specific
    if provider.one_of(AzureProvider):
        # Azure uses different provisioning keys for some reason
        try:
            template = provider.data.templates.small_template
            vm_user = credentials[template.creds].username
            vm_password = credentials[template.creds].password
        except AttributeError:
            pytest.skip('Could not find small_template or credentials for {}'.format(provider.name))
        recursive_update(inst_args, {
            'customize': {
                'admin_username': vm_user,
                'root_password': vm_password}})
    if auto:
        inst_args.update({'environment': {'automatic_placement': auto}})
    yield instance, inst_args, image

    logger.info('Fixture cleanup, deleting test instance: %s', instance.name)
    try:
        instance.delete_from_provider()
    except Exception as ex:
        logger.warning('Exception while deleting instance fixture, continuing: {}'
                       .format(ex.message))
示例#20
0
class DefaultFiltersForm(View):
    tree = CheckableBootstrapTreeview('df_treebox')
    save = Button('Save')
    reset = Button('Reset')
示例#21
0
 class comparison_sections(Accordion):  # noqa
     ACCORDION_NAME = 'Comparison Sections'
     tree = CheckableBootstrapTreeview()
示例#22
0
 class purpose(Tab):  # noqa
     TAB_NAME = 'Purpose'
     apply_tags = CheckableBootstrapTreeview('all_tags_treebox')