Exemplo n.º 1
0
 def verify_no_data(self, provider, vm_name):
     vm_details = nav_to_vm_details(provider, vm_name)
     if vm_details.details.get_section("Security").get_item("Users").value != "0":
         logger.info("Analysis data already found, deleting/rediscovering vm...")
         vm_details.config_button.remove_from_vmdb()
         time.sleep(60)
         prov_pg = nav.infra_providers_pg()
         prov_pg.click_on_refresh_relationships([cfme_data["management_systems"][provider]["name"]])
         vm_details = nav_to_vm_details(provider, vm_name)
Exemplo n.º 2
0
def nav_to_vm_details(provider, vm_to_analyze):
    '''Helper nav function to get to vm details and avoid unneccessary navigation'''

    from pages.infrastructure_subpages.vms_subpages.details import VirtualMachineDetails
    page = VirtualMachineDetails(testsetup)
    if page.on_vm_details(vm_to_analyze):
        return page
    else:
        provider_details = nav.infra_providers_pg().load_provider_details(
            cfme_data["management_systems"][provider]["name"])
        return provider_details.all_vms().find_vm_page(vm_to_analyze, None, False, True, 6)
Exemplo n.º 3
0
 def verify_no_data(self, provider, vm_name):
     vm_details = nav_to_vm_details(provider, vm_name)
     if vm_details.details.get_section('Security').get_item(
             'Users').value != '0':
         logger.info(
             "Analysis data already found, deleting/rediscovering vm...")
         vm_details.config_button.remove_from_vmdb()
         time.sleep(60)
         prov_pg = nav.infra_providers_pg()
         prov_pg.click_on_refresh_relationships(
             [cfme_data["management_systems"][provider]['name']])
         vm_details = nav_to_vm_details(provider, vm_name)
Exemplo n.º 4
0
def nav_to_vm_details(provider, vm_to_analyze):
    '''Helper nav function to get to vm details and avoid unneccessary navigation'''

    from pages.infrastructure_subpages.vms_subpages.details import VirtualMachineDetails
    page = VirtualMachineDetails(testsetup)
    if page.on_vm_details(vm_to_analyze):
        return page
    else:
        provider_details = nav.infra_providers_pg().load_provider_details(
            cfme_data["management_systems"][provider]["name"])
        return provider_details.all_vms().find_vm_page(vm_to_analyze, None,
                                                       False, True, 6)
Exemplo n.º 5
0
def assign_policy_profile_to_infra_provider(policy_profile, provider):
    """ Assigns the Policy Profile to a provider

    """
    infra_providers_pg = nav.infra_providers_pg()
    try:
        infra_providers_pg.select_provider(cfme_data['management_systems'][provider]['name'])
    except Exception:
        return
    policy_pg = infra_providers_pg.click_on_manage_policies()
    if not policy_pg.policy_selected(policy_profile):
        policy_pg.select_profile_item(policy_profile)
        try:
            policy_pg.save(visible_timeout=10)
        except TimeoutException:
            pass
        else:
            assert policy_pg.flash.message == 'Policy assignments successfully changed',\
                'Save policy assignment flash message did not match'
Exemplo n.º 6
0
    def test_app_migration(self, backup_test, soft_assert):
        vm_name = "migtest_" + backup_test
        provider = cfme_data["basic_info"]["appliances_provider"]
        test_data = migration_tests["backup_tests"][backup_test]
        template = cfme_data['basic_info']['appliance_template_big_db_disk']

        # provision appliance and configure
        appliance = provision_appliance(
            vm_name_prefix=vm_name, template=template, provider_name=provider)
        logger.info("appliance IP address: " + str(appliance.address))
        appliance.enable_internal_db()
        appliance.wait_for_web_ui()

        # start restore and migration
        appliance_ssh = appliance.ssh_client()
        appliance_ssh.put_file("./scripts/restore.py", "/root")
        appliance_ssh.run_command("curl -o restore_scripts.gz " +
            cfme_data["basic_info"]["restore_scripts_url"])
        if "restore_fixes_url" in cfme_data["basic_info"].keys():
            appliance_ssh.run_command("curl -o fix_scripts.gz " +
                cfme_data["basic_info"]["restore_fixes_url"])
        appliance_ssh.run_command("curl -o backup.gz " + test_data['url'])
        logger.info("Running db restore/migration...")
        rc, output = appliance_ssh.run_command("/root/restore.py --scripts " +
            "/root/restore_scripts.gz --backupfile /root/backup.gz")
        soft_assert(rc == 0)

        # re-init the connection, times out over long migrations
        appliance_ssh.close()
        appliance_ssh = appliance.ssh_client()
        appliance_ssh.get_file("/root/output.log", ".")

        # Log the restore/migration output
        process = sub.Popen("cat ./output.log; rm -rf ./output.log",
            shell=True, stdout=sub.PIPE, stderr=sub.PIPE)
        output, error = process.communicate()
        logger.info("Running cmd:   cat ./output.log; rm -rf ./output.log")
        logger.info("Output: \n" + output)

        # get database table counts
        this_db = appliance.db
        session = this_db.session
        logger.info("Checking db table counts after migration...")
        db_counts = {}
        for table_name in sorted(test_data['counts'].keys()):
            db_counts[table_name] = session.query(this_db[table_name]).count()

        # start up evmserverd and poke ui
        appliance_ssh.run_command("service evmserverd start")
        appliance.wait_for_web_ui()
        with appliance.browser_session():
            nav.home_page_logged_in()
            nav_to_roles().edit_current_role_list("ems_inventory ems_operations")
            setup_provider(provider)
            provider_details = nav.infra_providers_pg().load_provider_details(
                cfme_data["management_systems"][provider]["name"])
            vm_details = provider_details.all_vms().find_vm_page(
                appliance.vm_name, None, False, True, 6)
            soft_assert(vm_details.on_vm_details(appliance.vm_name))

        # check table counts vs what we are expecting
        for table_name in sorted(test_data['counts'].keys()):
            expected_count = test_data['counts'][table_name]
            actual_count = db_counts[table_name]
            soft_assert(actual_count == expected_count, 'Table ' + table_name + '(' +
                str(actual_count) + ') not matching expected(' + str(expected_count) + ')')

        # delete appliance
        logger.info("Delete provisioned appliance: " + appliance.address)
        appliance.destroy()
Exemplo n.º 7
0
    def test_analyze_vm(self, provider, vm_to_analyze, fs_type, register_event):
        """Test scanning a VM"""
        vm_details = nav_to_vm_details(provider, vm_to_analyze)
        self.verify_no_data(provider, vm_to_analyze)
        last_analysis_time = vm_details.details.get_section('Lifecycle').get_item(
            'Last Analyzed').value
        register_event(cfme_data['management_systems'][provider]['type'], 'vm', vm_to_analyze,
            ['vm_analysis_request', 'vm_analysis_start', 'vm_analysis_complete'])
        logger.info('Initiating vm smart scan on ' + provider + ":" + vm_to_analyze)
        vm_details.config_button.perform_smart_state_analysis()
        Assert.true(vm_details.flash.message.startswith("Smart State Analysis initiated"))

        # wait for task to complete
        tasks_pg = nav.cnf_tasks_pg()
        self.is_vm_analysis_finished(tasks_pg, vm_to_analyze)

        # Then delete the tasks
        tasks_pg.task_buttons.delete_all()

        # back to vm_details
        logger.info('Checking vm details metadata...')
        vm_details = nav_to_vm_details(provider, vm_to_analyze)
        yaml_vm_os = cfme_data["test_vm_analysis"][provider][vm_to_analyze]["os"]

        # check users/group counts
        assert vm_details.details.get_section('Security').get_item('Users').value != '0',\
            'No users found in VM detail'

        assert vm_details.details.get_section('Security').get_item('Groups').value != '0',\
            'No groups found in VM detail'

        # check advanced settings
        if cfme_data['management_systems'][provider]['type'] == 'virtualcenter':
            assert vm_details.details.get_section('Properties').get_item(
                'Advanced Settings').value != "0"

        # assert last analyze time
        assert vm_details.details.get_section('Lifecycle').get_item(
            'Last Analyzed').value != last_analysis_time

        # drift history
        assert vm_details.details.get_section('Relationships').get_item(
            'Drift History').value == "1"

        # analysis history
        assert vm_details.details.get_section('Relationships').get_item(
            'Analysis History').value == "1"

        # check OS
        assert (vm_details.details.get_section('Properties').get_item('Operating System').value ==
            cfme_data["test_vm_analysis"][provider][vm_to_analyze]["os"])

        # check os specific values
        if "Fedora" in yaml_vm_os or "Linux" in yaml_vm_os:
            assert vm_details.details.get_section('Configuration').get_item(
                'Packages').value != "1"
            assert vm_details.details.get_section('Configuration').get_item(
                'Init Processes').value != "1"
        elif "Windows" in yaml_vm_os:
            assert vm_details.details.get_section('Security').get_item(
                'Patches').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Applications').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Win32 Services').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Kernel Drivers').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'File System Drivers').value != "0"

        logger.info('Checking vm operating system icons...')
        details_os_icon = vm_details.details.get_section('Properties').get_item(
            'Operating System').icon_href
        provider_details = nav.infra_providers_pg().load_provider_details(
            cfme_data["management_systems"][provider]["name"])
        all_vms = provider_details.all_vms()
        all_vms.find_vm_page(vm_to_analyze, None, False, False, 6)
        quadicon_os_icon = all_vms.quadicon_region.get_quadicon_by_title(
            vm_to_analyze).os

        # check os icon images
        yaml_vm_os = cfme_data["test_vm_analysis"][provider][vm_to_analyze]["os"]
        if "Red Hat Enterprise Linux" in yaml_vm_os:
            assert "os-linux_redhat.png" in details_os_icon
            assert "linux_redhat" in quadicon_os_icon
        elif "Windows" in yaml_vm_os:
            assert "os-windows_generic.png" in details_os_icon
            assert "windows_generic" in quadicon_os_icon
        elif "Fedora" in yaml_vm_os:
            assert "os-linux_fedora.png" in details_os_icon
            assert "linux_fedora" in quadicon_os_icon
Exemplo n.º 8
0
def nav_to_vm_details(provider, vm_name):
    '''Helper nav function to get to vm details and avoid unneccessary navigation'''

    provider_details = nav.infra_providers_pg().load_provider_details(
        cfme_data["management_systems"][provider]["name"])
    return provider_details.all_vms().find_vm_page(vm_name, None, False, True, 6)
Exemplo n.º 9
0
    def test_analyze_vm(self, provider, vm_to_analyze, fs_type,
                        register_event):
        """Test scanning a VM"""
        vm_details = nav_to_vm_details(provider, vm_to_analyze)
        self.verify_no_data(provider, vm_to_analyze)
        last_analysis_time = vm_details.details.get_section(
            'Lifecycle').get_item('Last Analyzed').value
        register_event(cfme_data['management_systems'][provider]['type'], 'vm',
                       vm_to_analyze, [
                           'vm_analysis_request', 'vm_analysis_start',
                           'vm_analysis_complete'
                       ])
        logger.info('Initiating vm smart scan on ' + provider + ":" +
                    vm_to_analyze)
        vm_details.config_button.perform_smart_state_analysis()
        Assert.true(
            vm_details.flash.message.startswith(
                "Smart State Analysis initiated"))

        # wait for task to complete
        tasks_pg = nav.cnf_tasks_pg()
        self.is_vm_analysis_finished(tasks_pg, vm_to_analyze)

        # Then delete the tasks
        tasks_pg.task_buttons.delete_all()

        # back to vm_details
        logger.info('Checking vm details metadata...')
        vm_details = nav_to_vm_details(provider, vm_to_analyze)
        yaml_vm_os = cfme_data["test_vm_analysis"][provider][vm_to_analyze][
            "os"]

        # check users/group counts
        assert vm_details.details.get_section('Security').get_item('Users').value != '0',\
            'No users found in VM detail'

        assert vm_details.details.get_section('Security').get_item('Groups').value != '0',\
            'No groups found in VM detail'

        # check advanced settings
        if cfme_data['management_systems'][provider][
                'type'] == 'virtualcenter':
            assert vm_details.details.get_section('Properties').get_item(
                'Advanced Settings').value != "0"

        # assert last analyze time
        assert vm_details.details.get_section('Lifecycle').get_item(
            'Last Analyzed').value != last_analysis_time

        # drift history
        assert vm_details.details.get_section('Relationships').get_item(
            'Drift History').value == "1"

        # analysis history
        assert vm_details.details.get_section('Relationships').get_item(
            'Analysis History').value == "1"

        # check OS
        assert (vm_details.details.get_section('Properties').get_item(
            'Operating System').value == cfme_data["test_vm_analysis"]
                [provider][vm_to_analyze]["os"])

        # check os specific values
        if "Fedora" in yaml_vm_os or "Linux" in yaml_vm_os:
            assert vm_details.details.get_section('Configuration').get_item(
                'Packages').value != "1"
            assert vm_details.details.get_section('Configuration').get_item(
                'Init Processes').value != "1"
        elif "Windows" in yaml_vm_os:
            assert vm_details.details.get_section('Security').get_item(
                'Patches').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Applications').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Win32 Services').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'Kernel Drivers').value != "0"
            assert vm_details.details.get_section('Configuration').get_item(
                'File System Drivers').value != "0"

        logger.info('Checking vm operating system icons...')
        details_os_icon = vm_details.details.get_section(
            'Properties').get_item('Operating System').icon_href
        provider_details = nav.infra_providers_pg().load_provider_details(
            cfme_data["management_systems"][provider]["name"])
        all_vms = provider_details.all_vms()
        all_vms.find_vm_page(vm_to_analyze, None, False, False, 6)
        quadicon_os_icon = all_vms.quadicon_region.get_quadicon_by_title(
            vm_to_analyze).os

        # check os icon images
        yaml_vm_os = cfme_data["test_vm_analysis"][provider][vm_to_analyze][
            "os"]
        if "Red Hat Enterprise Linux" in yaml_vm_os:
            assert "os-linux_redhat.png" in details_os_icon
            assert "linux_redhat" in quadicon_os_icon
        elif "Windows" in yaml_vm_os:
            assert "os-windows_generic.png" in details_os_icon
            assert "windows_generic" in quadicon_os_icon
        elif "Fedora" in yaml_vm_os:
            assert "os-linux_fedora.png" in details_os_icon
            assert "linux_fedora" in quadicon_os_icon