def selects(self): """Get dictionary of currently assigned templates for OS""" selects = {} for title in self.browser.elements( self.TITLES, check_visibility=True): selects[title.text] = FilteredDropdown( self, locator=self.SELECT % title.text, logger=self.logger) return selects
class primary(SatTab): name = TextInput(id='discovery_rule_name') search = AutoCompleteTextInput(id='search') host_group = FilteredDropdown(id='discovery_rule_hostgroup_id') hostname = TextInput(id='discovery_rule_hostname') hosts_limit = TextInput(id='discovery_rule_max_count') priority = TextInput(id='discovery_rule_priority') enabled = Checkbox(id='discovery_rule_enabled')
class ComputeResourceVMwareProfileStorageItem(GenericRemovableWidgetItem): """VMware Compute Resource Profile Storage Controller item widget""" controller = FilteredDropdown( locator= ".//div[@class='controller-header']//div[contains(@class, 'form-control')]" ) remove_button = Text(".//button[contains(@class, 'remove-controller')]") disks = ComputeResourceVMwareProfileControllerVolumeList()
class LibvirtResourceForm(View): cpus = TextInput(id='compute_attribute_vm_attrs_cpus') cpu_mode = FilteredDropdown( id='s2id_compute_attribute_vm_attrs_cpu_mode') memory = TextInput(id='compute_attribute_vm_attrs_memory') image = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_image_id') @View.nested class network_interfaces(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='network_interfaces']" ITEM_WIDGET_CLASS = ComputeResourceLibvirtProfileNetworkItem @View.nested class storage(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='storage_volumes']" ITEMS = "./div/div[contains(@class, 'removable-item')]" ITEM_WIDGET_CLASS = ComputeResourceLibvirtProfileStorageItem
class ResourceProviderProfileView(BaseLoggedInView): breadcrumb = BreadCrumb() compute_profile = FilteredDropdown( id='s2id_compute_attribute_compute_profile_id') compute_resource = FilteredDropdown( id='s2id_compute_attribute_compute_resource_id') flavor = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_flavor_id') image = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_image_id') availability_zone = FilteredDropdown( id='s2id_compute_attribute_vm_attrs_availability_zone') subnet = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_subnet_id') security_groups = MultiSelect( id='ms-compute_attribute_vm_attrs_security_group_ids') managed_ip = FilteredDropdown( id='s2id_compute_attribute_vm_attrs_managed_ip') submit = Text('//input[@name="commit"]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element( self.breadcrumb, exception=False) return ( breadcrumb_loaded and self.breadcrumb.locations[0] == 'Compute resources' and self.breadcrumb.locations[2] == 'Compute profiles' and self.breadcrumb.read().startswith('Edit ') )
class host_group(SatTab): TAB_NAME = 'Host Group' parent_name = FilteredDropdown(id='s2id_hostgroup_parent_id') name = TextInput(id='hostgroup_name') description = TextInput(id='hostgroup_description') lce = FilteredDropdown(id='hostgroup_lifecycle_environment') content_view = FilteredDropdown(id='hostgroup_content_view') content_source = FilteredDropdown(id='s2id_content_source_id') puppet_environment = FilteredDropdown(id='hostgroup_environment') deploy = FilteredDropdown(id='hostgroup_compute_resource') puppet_master = FilteredDropdown(id='hostgroup_puppet_proxy') puppet_ca = FilteredDropdown(id='hostgroup_puppet_ca_proxy') openscap_capsule = FilteredDropdown(id='hostgroup_openscap_proxy')
class EC2ProviderForm(View): http_proxy = TextInput(id='compute_resource_http_proxy_id') access_key = TextInput(id='compute_resource_user') secret_key = TextInput(id='compute_resource_password') load_regions = Text("//*[contains(@id,'test_connection_button')]") region = FilteredDropdown(id='s2id_compute_resource_region') def after_fill(self, was_change): self.load_regions.click()
class operating_system(SatTab): TAB_NAME = 'Operating System' architecture = FilteredDropdown(id='hostgroup_architecture') operating_system = FilteredDropdown(id='hostgroup_operatingsystem') media_type = RadioGroup(locator="//div[label[contains(., 'Media Selection')]]") media_content = ConditionalSwitchableView(reference='media_type') @media_content.register('All Media') class TypeMedium(View): media = FilteredDropdown(id='hostgroup_medium') @media_content.register('Synced Content') class TypeSynced(View): synced_content = FilteredDropdown(id='host_group_kickstart_repository') ptable = FilteredDropdown(id='hostgroup_ptable') root_password = TextInput(id='hostgroup_root_pass')
class smart_class_parameter(SatTab): TAB_NAME = 'Smart Class Parameter' filter = TextInput(locator="//input[@placeholder='Filter by name']") environment_filter = FilteredDropdown(id='environment_filter') parameter_list = ItemsList("//div[@id='smart_class_param']" "//ul[contains(@class, 'smart-var-tabs')]") parameter = SmartClassParameterContent( locator="//div[@id='smart_class_param']" "//div[@class='tab-pane fields active']")
class ldap_server(SatTab): TAB_NAME = 'LDAP server' name = TextInput(id='auth_source_ldap_name') host = TextInput(id='auth_source_ldap_host') text_connection = Text('//a[@id="test_connection_button"]') ldaps = Checkbox(id='auth_source_ldap_tls') port = TextInput(id='auth_source_ldap_port') server_type = FilteredDropdown(id='auth_source_ldap_server_type')
class external_registry(SatTab): TAB_NAME = 'External registry' registry = FilteredDropdown( id='s2id_docker_container_wizard_states_image_registry_id') search = TextInput( id='hub_docker_container_wizard_states_image_repository_name') tag = TextInput( id='hub_docker_container_wizard_states_image_tag') search_for_images = Text( "./a[contains(@id,'search_repository_button_registry')]")
class RHVResourceForm(View): cluster = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_cluster') template = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_template') instance_type = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_instance_type') cores = TextInput(id='compute_attribute_vm_attrs_cores') sockets = TextInput(id='compute_attribute_vm_attrs_sockets') memory = TextInput(id='compute_attribute_vm_attrs_memory') highly_available = Checkbox(id='compute_attribute_vm_attrs_ha') @View.nested class network_interfaces(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='network_interfaces']" ITEM_WIDGET_CLASS = ComputeResourceRHVProfileNetworkItem @View.nested class storage(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='storage_volumes']" ITEMS = "./div/div[contains(@class, 'removable-item')]" ITEM_WIDGET_CLASS = ComputeResourceRHVProfileStorageItem
class NutanixForm(View): server = TextInput( id='foreman_virt_who_configure_config_hypervisor_server') username = TextInput( id='foreman_virt_who_configure_config_hypervisor_username') password = TextInput( id='foreman_virt_who_configure_config_hypervisor_password') prism_flavor = FilteredDropdown( id='foreman_virt_who_configure_config_prism_flavor') filtering_content = ConditionalSwitchableView(reference='prism_flavor')
class virtual_machine(SatTab): TAB_NAME = 'Virtual Machine' cpus = TextInput(id='host_compute_attributes_cpus') cpu_mode = FilteredDropdown(id='s2id_host_compute_attributes_cpu_mode') memory = TextInput(id='host_compute_attributes_memory') startup = Checkbox(id='host_compute_attributes_start') @View.nested class storage(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='storage_volumes']" ITEMS = "./div/div[contains(@class, 'removable-item')]" ITEM_WIDGET_CLASS = ComputeResourceLibvirtProfileStorageItem
class ComputeResourceRHVProfileStorageItem(GenericRemovableWidgetItem): """RHV Compute Resource profile "Storage" item widget""" size = TextInput(locator=".//input[contains(@id, 'size_gb')]") storage_domain = FilteredDropdown(id="storage_domain") preallocate_disk = Checkbox(locator=".//input[contains(@id, 'preallocate')]") wipe_disk_after_delete = Checkbox(locator=".//input[contains(@id, 'wipe_after_delete')]") disk_interface = FilteredDropdown(id="interface") @View.nested class bootable(View): ROOT = ".//input[contains(@id, 'bootable')]" def _is_checked(self): return self.browser.get_attribute('checked', self) def read(self): return self.browser.is_selected(self) def fill(self, value): if value is True and not self.browser.is_selected(self): self.browser.click(self)
class SubnetDetailsView(BaseLoggedInView): name = TextInput(id='subnet_name') network_address = TextInput(id='subnet_network') network_prefix = TextInput(id='subnet_cidr') network_mask = TextInput(id='subnet_mask') boot_mode = FilteredDropdown(id='subnet_boot_mode') submit = Text('//input[@name="commit"]') @property def is_displayed(self): return self.browser.wait_for_element(self.name, exception=False) is not None
class HostRegisterView(BaseLoggedInView): breadcrumb = BreadCrumb() host_group = FilteredDropdown(id='s2id_host_group_id') operatingsystem = FilteredDropdown(id='s2id_operatingsystem_id') capsule = FilteredDropdown(id='s2id_smart_proxy') setup_insights = FilteredDropdown(id='s2id_setup_insights') remote_execution = FilteredDropdown(id='s2id_setup_remote_execution') token_lifetime = TextInput(id='jwt_expiration') remote_execution_interface = TextInput(id='remote_execution_interface') activation_keys = TextInput(id='activation_key') generate_command = TextInput(name='commit') registration_command = Text('//pre[@id="registration_command"]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) return ( breadcrumb_loaded and self.breadcrumb.locations[0] == 'Registrations' and self.breadcrumb.read() == 'Register Host' )
class VMwareResourceForm(View): cpus = TextInput(id='compute_attribute_vm_attrs_cpus') cores_per_socket = TextInput(id='compute_attribute_vm_attrs_corespersocket') memory = TextInput(id='compute_attribute_vm_attrs_memory_mb') firmware = RadioGroup( "//div[label[input[contains(@id, 'compute_attribute_vm_attrs_firmware')]]]") cluster = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_cluster') resource_pool = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_resource_pool') folder = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_path') guest_os = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_guest_id') virtual_hw_version = FilteredDropdown( id='s2id_compute_attribute_vm_attrs_hardware_version') memory_hot_add = Checkbox(id='compute_attribute_vm_attrs_memoryHotAddEnabled') cpu_hot_add = Checkbox(id='compute_attribute_vm_attrs_cpuHotAddEnabled') cdrom_drive = Checkbox(id='compute_attribute_vm_attrs_add_cdrom') annotation_notes = TextInput(id='compute_attribute_vm_attrs_annotation') image = FilteredDropdown(id='s2id_compute_attribute_vm_attrs_image_id') @View.nested class network_interfaces(RemovableWidgetsItemsListView): ROOT = "//fieldset[@id='network_interfaces']" ITEM_WIDGET_CLASS = ComputeResourceVMwareProfileNetworkItem @View.nested class storage(RemovableWidgetsItemsListView): ROOT = "//div[@id='scsi_controllers']" ITEMS = ".//div[@class='controller-container']" ITEM_WIDGET_CLASS = ComputeResourceVMwareProfileStorageItem add_item_button = Text(".//button[contains(@class, 'add-controller')]")
class ComputeResourceGenericImageCreateView(BaseLoggedInView): """A Generic Compute Resource Image create view.""" breadcrumb = BreadCrumb() name = TextInput(id='image_name') operating_system = FilteredDropdown(id='image_operatingsystem_id') architecture = FilteredDropdown(id='image_architecture_id') username = TextInput(id='image_username') user_data = Checkbox(id='image_user_data') password = TextInput(id='image_password') image = FilteredDropdown(id='image_uuid') submit = Text('//input[@name="commit"]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element( self.breadcrumb, exception=False, ensure_page_safe=True, timeout=10) return ( breadcrumb_loaded and self.breadcrumb.locations[0] == 'Compute Resources' and self.breadcrumb.locations[2] == 'Images' and self.breadcrumb.read() == 'Create image' )
class DiscoveredHostProvisionDialog(BaseLoggedInView): """Discovered host Provision action dialog view""" ROOT = ".//div[@class='modal-content']" title = Text(".//h4[text()='Select initial host properties']") host_group = FilteredDropdown(id='host_hostgroup_id') organization = FilteredDropdown(id='host_organization_id') location = FilteredDropdown(id='host_location_id') cancel = Text(".//button[@data-dismiss='modal']") customize_create = Text( ".//input[@type='submit'][not(@name='quick_submit')]") quick_create = Text(".//input[@type='submit'][@name='quick_submit']") @property def is_displayed(self): return self.browser.wait_for_element( self.title, exception=False) is not None and self.browser.is_displayed( self.title) @property def is_all_displayed(self): """Check that all the required dialog widgets fields are displayed""" return all([ self.is_displayed, self.host_group.is_displayed, self.organization.is_displayed, self.location.is_displayed, ]) def before_fill(self, values=None): """Before filling we have to wait and ensure that all the required dialog widgets fields are visible. """ wait_for(lambda: self.is_all_displayed, timeout=10, delay=1, logger=self.logger)
class RecurringExecutionForm(View): repeats = FilteredDropdown(id='input_type_selector') repeats_content = ConditionalSwitchableView(reference='repeats') @repeats_content.register('cronline') class CronlineForm(View): cron_line = TextInput(id='triggering_cronline') @repeats_content.register('monthly') class RepeatMonthlyForm(View): at_days = TextInput(id='triggering_days') at_hours = FilteredDropdown(id='triggering_time_time_4i') at_minutes = FilteredDropdown(id='triggering_time_time_5i') @repeats_content.register('weekly') class RepeatWeeklyForm(View): on_mon = Checkbox(id='triggering_days_of_week_1') on_tue = Checkbox(id='triggering_days_of_week_2') on_wed = Checkbox(id='triggering_days_of_week_3') on_thu = Checkbox(id='triggering_days_of_week_4') on_fri = Checkbox(id='triggering_days_of_week_5') on_sat = Checkbox(id='triggering_days_of_week_6') on_sun = Checkbox(id='triggering_days_of_week_7') at_hours = FilteredDropdown(id='triggering_time_time_4i') at_minutes = FilteredDropdown(id='triggering_time_time_5i') @repeats_content.register('daily', default=True) class RepeatDailyForm(View): at_hours = FilteredDropdown(id='triggering_time_time_4i') at_minutes = FilteredDropdown(id='triggering_time_time_5i') @repeats_content.register('hourly') class RepeatHourlyForm(View): at_minutes = FilteredDropdown(id='triggering_time_time_5i') repeat_n_times = TextInput(id='triggering_max_iteration') ends = RadioGroup(locator="//div[@id='end_time_limit_select']") ends_date_content = ConditionalSwitchableView(reference='ends') @ends_date_content.register('Never', default=True) class NoEndsDateForm(View): pass @ends_date_content.register('On') class EndsDateEnabledForm(View): at_year = FilteredDropdown(id='triggering_end_time_end_time_1i') at_month = FilteredDropdown(id='triggering_end_time_end_time_2i') at_day = FilteredDropdown(id='triggering_end_time_end_time_3i') at_hours = FilteredDropdown(id='triggering_end_time_end_time_4i') at_minutes = FilteredDropdown(id='triggering_end_time_end_time_5i')
class LocationCreateView(BaseLoggedInView): breadcrumb = BreadCrumb() parent_location = FilteredDropdown(id='location_parent_id') name = TextInput(id='location_name') description = TextInput(id='location_description') submit = Text('//input[@name="commit"]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) return (breadcrumb_loaded and self.breadcrumb.locations[0] == 'Locations' and self.breadcrumb.read() == 'New Location')
class ComputeResourceVMwareProfileControllerVolumeItem( GenericRemovableWidgetItem): """VMware Compute Resource Profile "Storage Controller Volume" item widget""" storage_pod = FilteredDropdown( locator= ".//div[label[contains(., 'Storage Pod')]]//div[contains(@class, 'form-control')]" ) data_store = FilteredDropdown( locator= ".//div[label[contains(., 'Data store')]]//div[contains(@class, 'form-control')]" ) disk_mode = FilteredDropdown( locator= ".//div[label[contains(., 'Disk Mode')]]//div[contains(@class, 'form-control')]" ) size = TextInput( locator=".//div[label[contains(., 'Size')]]/div/span/input") thin_provision = Checkbox( locator=".//div[label[contains(., 'Thin provision')]]/div/input") eager_zero = Checkbox( locator=".//div[label[contains(., 'Eager zero')]]/div/input") remove_button = Text(".//button[contains(@class, 'close')]")
class schedule(SatTab): period = FilteredDropdown(id='s2id_policy_period') period_selection = ConditionalSwitchableView(reference='period') @period_selection.register('Weekly') class WeeklyPeriodForm(View): weekday = FilteredDropdown(id='s2id_policy_weekday') @period_selection.register('Monthly') class MonthlyPeriodForm(View): day_of_month = FilteredDropdown(id='s2id_policy_day_of_month') @period_selection.register('Custom') class CustomPeriodForm(View): cron_line = TextInput(id='policy_cron_line')
class job(SatTab): job_category = TextInput(name='job_template[job_category]') description_format = TextInput(id='job_template_description_format') provider_type = FilteredDropdown(id='job_template_provider_type') timeout = TextInput(id='job_template_execution_timeout_interval') @View.nested class foreign_input_sets(RemovableWidgetsItemsListView): ROOT = "//div[div[contains(@class, 'foreign_input_sets')]]" ITEMS = ".//div[contains(@class, 'foreign_input_sets')]/following-sibling::div" ITEM_WIDGET_CLASS = JobTemplateForeignInputSetItem add_item_button = Text(".//a[@data-association='foreign_input_sets']") value = TextInput(id='job_template_effective_user_attributes_value') current_user = Checkbox(id='job_template_effective_user_attributes_current_user') overridable = Checkbox(id='job_template_effective_user_attributes_overridable')
class SubnetDetailsView(BaseLoggedInView): breadcrumb = BreadCrumb() name = TextInput(id='subnet_name') protocol = RadioGroup(locator="//div[label[contains(., 'Protocol')]]") network_address = TextInput(id='subnet_network') network_prefix = TextInput(id='subnet_cidr') network_mask = TextInput(id='subnet_mask') boot_mode = FilteredDropdown(id='subnet_boot_mode') submit = Text('//input[@name="commit"]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) return (breadcrumb_loaded and self.breadcrumb.locations[0] == 'Subnets' and self.breadcrumb.read().startswith('Edit '))
class ReportTemplateGenerateView(BaseLoggedInView): breadcrumb = BreadCrumb() email = Checkbox(id='report_template_report_send_mail') email_to = TextInput(id='report_template_report_mail_to') inputs = TextInputsGroup(locator='.//form') output_format = FilteredDropdown(id='s2id_report_template_report_format') generate_at = TextInput(id='report_template_report_generate_at') submit = Text('//input[@name="commit"]') generating = Text('//div[@id="template_generator"]/div/span[2]') @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) return (breadcrumb_loaded and self.breadcrumb.locations[0] == 'Report Templates' and self.breadcrumb.read() == 'Generate a Report')
class external_groups(SatTab): TAB_NAME = 'External Groups' table = Table('.//table', column_widgets={ 'Actions': Text('.//a[contains(@href, "refresh")]'), }) add_external_user_group = Text( './/a[@data-association="external_usergroups"]') name = TextInput(locator=( "(//input[starts-with(@name, 'usergroup[external_usergroups_attributes]')]" "[contains(@name, '[name]')])[last()]")) auth_source = FilteredDropdown(locator=( "//div[starts-with(@id, 's2id_usergroup_external_usergroups_attributes')]" "[contains(@id, 'auth_source_id')]")) def before_fill(self, values): self.add_external_user_group.click()
class schedule(BaseLoggedInView): next_step = Text("//input[contains(@value, 'Next')]") period = FilteredDropdown(id='s2id_policy_period') period_selection = ConditionalSwitchableView(reference='period') @period_selection.register('Weekly') class WeeklyPeriodForm(View): weekday = FilteredDropdown(id='s2id_policy_weekday') @period_selection.register('Monthly') class MonthlyPeriodForm(View): day_of_month = FilteredDropdown(id='s2id_policy_day_of_month') @period_selection.register('Custom') class CustomPeriodForm(View): cron_line = TextInput(id='policy_cron_line') def after_fill(self, was_change): self.next_step.click()
class TemplateInputItem(GenericRemovableWidgetItem): """Template Input item view""" remove_button = Text(".//a[contains(@class, 'remove_nested_fields')]") name = TextInput(locator=".//input[contains(@name, '[name]')]") required = Checkbox(locator=".//input[contains(@id, 'required')]") input_type = FilteredDropdown( locator=".//div[contains(@id, 'input_type')]") input_content = ConditionalSwitchableView(reference='input_type') @input_content.register('User input') class UserInputForm(View): advanced = Checkbox(locator=".//input[contains(@id, 'advanced')]") options = TextInput( locator=".//textarea[contains(@name, '[options]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Fact value') class FactValueForm(View): fact_name = TextInput( locator=".//input[contains(@name, '[fact_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Variable') class VariableValueForm(View): variable_name = TextInput( locator=".//input[contains(@name, '[variable_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]") @input_content.register('Puppet parameter') class PuppetParameterForm(View): puppet_class_name = TextInput( locator=".//input[contains(@name, '[puppet_class_name]')]") puppet_parameter_name = TextInput( locator=".//input[contains(@name, '[puppet_parameter_name]')]") description = TextInput( locator=".//textarea[contains(@name, '[description]')]")