Beispiel #1
0
    def power_control_from_cfme(self, option, cancel=True, from_details=False):
        """Power controls a VM from within CFME

        Args:
            option: corresponds to option values under the power button
            cancel: Whether or not to cancel the power operation on confirmation
            from_details: Whether or not to perform action from instance details page

        Raises:
            OptionNotAvailable: option param is not visible or enabled
        """
        if (self.is_pwr_option_available_in_cfme(option=option,
                                                 from_details=from_details)):
            pwr_btn(option, invokes_alert=True)
            sel.handle_alert(cancel=cancel, check_present=True)
            logger.info(
                "Power control action of VM/instance %s, option %s, cancel %s executed",
                self.name, option, str(cancel))
        else:
            raise OptionNotAvailable(option + " is not visible or enabled")
    def create(self, name, description, profile_type, files=None, events=None, categories=None,
               registry=None, cancel=False):
        """Add Analysis Profile to appliance"""
        # The tab form values have to be dictionaries with the root key matching the tab widget name
        form_values = self.form_fill_args({
            'name': name,
            'description': description,
            'categories': categories,
            'files': files,
            'registry': registry,
            'events': events
        })

        if profile_type.lower() == 'vm':
            view = navigate_to(self, 'AddVmProfile')
        elif profile_type.lower() == 'host':
            view = navigate_to(self, 'AddHostProfile')
        else:
            raise OptionNotAvailable('Not such profile available')

        view.form.fill(form_values)

        if cancel:
            view.cancel.click()
        else:
            view.add.click()

        view.flush_widget_cache()
        view = self.create_view(AnalysisProfileAllView)

        assert view.is_displayed

        return self.instantiate(
            name=name,
            description=description,
            profile_type=profile_type,
            files=files,
            events=events,
            categories=categories,
            registry=registry
        )
Beispiel #3
0
    def power_control_from_provider(self, option):
        """Power control the instance from the provider

        Args:
            option: power control action to take against instance

        Raises:
            OptionNotAvailable: option param must have proper value
        """
        if option == AzureInstance.START:
            self.provider.mgmt.start_vm(self.name)
        elif option == AzureInstance.STOP:
            self.provider.mgmt.stop_vm(self.name)
        elif option == AzureInstance.RESTART:
            self.provider.mgmt.restart_vm(self.name)
        elif option == AzureInstance.SUSPEND:
            self.provider.mgmt.suspend_vm(self.name)
        elif option == AzureInstance.TERMINATE:
            self.provider.mgmt.delete_vm(self.name)
        else:
            raise OptionNotAvailable(option + " is not a supported action")
Beispiel #4
0
def _creating_skeleton(request,
                       rest_api,
                       col_name,
                       col_data,
                       col_action='create'):
    collection = getattr(rest_api.collections, col_name)
    try:
        action = getattr(collection.action, col_action)
    except AttributeError:
        raise OptionNotAvailable(
            "Action `{}` for {} is not implemented in this version".format(
                col_action, col_name))

    entities = action(*col_data)
    action_status = rest_api.response.status_code
    for entity in col_data:
        if entity.get('name', None):
            wait_for(lambda: collection.find_by(name=entity.get('name')),
                     num_sec=180,
                     delay=10)
        elif entity.get('description', None):
            wait_for(lambda: collection.find_by(description=entity.get(
                'description')),
                     num_sec=180,
                     delay=10)
        else:
            raise NotImplementedError

    @request.addfinalizer
    def _finished():
        collection.reload()
        ids = [e.id for e in entities]
        delete_entities = [e for e in collection if e.id in ids]
        if len(delete_entities) != 0:
            collection.action.delete(*delete_entities)

    # make sure action status code is preserved
    rest_api.response.status_code = action_status
    return entities
Beispiel #5
0
    def power_control_from_cfme(self, option, cancel=True, from_details=False):
        """Power controls a VM from within CFME

        Args:
            option: corresponds to option values under the power button
            cancel: Whether or not to cancel the power operation on confirmation
            from_details: Whether or not to perform action from instance details page

        Raises:
            OptionNotAvailable: option param is not visible or enabled
        """
        if from_details:
            view = navigate_to(self, 'Details', use_resetter=False)
        else:
            view = navigate_to(self.parent, 'All')

        if self.is_pwr_option_available_in_cfme(option=option, from_details=from_details):
            view.toolbar.power.item_select(option, handle_alert=not cancel)
            logger.info(
                "Power control action of VM/instance %s, option %s, cancel %s executed",
                self.name, option, str(cancel))
        else:
            raise OptionNotAvailable(option + " is not visible or enabled")
Beispiel #6
0
def test_object_attribute_type_in_automate_schedule(appliance):
    """
    Polarion:
        assignee: ghubale
        casecomponent: Automate
        initialEstimate: 1/15h
        startsin: 5.9
        tags: automate
        testSteps:
            1. Go to Configuration > settings > schedules
            2. Select 'Add a new schedule' from configuration drop down
            3. selecting 'Automation Tasks' under Action.
            4. Select a value from the drop down list of Object Attribute Type.
            5. Undo the selection by selecting "<Choose>" from the drop down.
        expectedResults:
            1.
            2.
            3.
            4. No pop-up window with Internal Server Error.
            5. No pop-up window with Internal Server Error.

    Bugzilla:
         1479570
         1686762
    """
    view = navigate_to(appliance.collections.system_schedules, 'Add')
    view.form.action_type.select_by_visible_text('Automation Tasks')
    all_options = view.form.object_type.all_options
    if len(all_options) < 2:
        # There should be more than one options available because <choose> is default option
        raise OptionNotAvailable("Options not available")
    for option in all_options:
        if not (BZ(1686762).blocks and option.text in ['Tenant', 'EVM Group']):
            view.form.object_type.select_by_visible_text(option.text)
            view.flash.assert_no_error()
            view.form.object_type.select_by_visible_text('<Choose>')
            view.flash.assert_no_error()