class ConfigManagementAddForm(View): """Form to add a provider""" name = TextInput('name') provider_type = BootstrapSelect('provider_type') zone = TextInput('zone') url = TextInput('url') ssl = Checkbox('verify_ssl') username = VersionPick({Version.lowest(): TextInput('log_userid'), '5.9': TextInput('default_userid')}) password = VersionPick({Version.lowest(): TextInput('log_password'), '5.9': TextInput('default_password')}) confirm_password = TextInput('log_verify') validate = Button('Validate')
def create(self, name, storage_manager, tenant, size, provider): """Create new storage volume Args: name: volume name storage_manager: storage manager name tenant: tenant name size: volume size in GB provider: provider Returns: object for the :py:class: cfme.storage.volume.Volume """ view = navigate_to(self, 'Add') view.form.fill({ 'storage_manager': storage_manager, 'tenant': tenant, 'volume_name': name, 'size': size }) view.form.add.click() base_message = VersionPick({ Version.lowest(): 'Creating Cloud Volume "{}"', '5.8': 'Cloud Volume "{}" created' }).pick(self.appliance.version) view.flash.assert_success_message(base_message.format(name)) volume = self.instantiate(name, provider) wait_for(lambda: volume.exists, delay=20, timeout=500, fail_func=volume.refresh) return volume
class purpose(Tab): # noqa TAB_NAME = 'Purpose' apply_tags = VersionPick({ Version.lowest(): CheckboxSelect('//div[@id="all_tags_treebox"]//ul'), '5.7': BootstrapTreeview('all_tags_treebox') })
def InstanceEntity(): # noqa """ Temporary wrapper for Instance Entity during transition to JS based Entity """ return VersionPick({ Version.lowest(): NonJSInstanceEntity, '5.9': JSInstanceEntity, })
class ConfigManagementDetailsToolbar(View): """Toolbar on the details page""" history = Dropdown(title='History') refresh = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'})) lifecycle = Dropdown('Lifecycle') policy = Dropdown('Policy') download = Button(title='Download summary in PDF format') view_selector = View.nested(ItemsToolBarViewSelector)
class ConfigManagementToolbar(View): """Toolbar""" refresh = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'})) configuration = Dropdown('Configuration') lifecycle = Dropdown('Lifecycle') policy = Dropdown('Policy') download = Dropdown(title='Download') view_selector = View.nested(ItemsToolBarViewSelector)
class properties(Tab): # noqa TAB_NAME = 'Properties' instance_type = BootstrapSelect('hardware__instance_type') guest_keypair = BootstrapSelect('hardware__guest_access_key_pair') hardware_monitoring = BootstrapSelect('hardware__monitoring') boot_disk_size = BootstrapSelect('hardware__boot_disk_size') # GCE is_preemtible = VersionPick({ Version.lowest(): None, '5.7': Input(name='hardware__is_preemptible')})
class Volume(NavigatableMixin): # Navigation menu option nav = VersionPick({ Version.lowest(): ['Storage', 'Volumes'], '5.8': ['Storage', 'Block Storage', 'Volumes'] }) def __init__(self, name, provider, collection): self.name = name # TODO add storage provider parameter, needed for accurate details nav # the storage providers have different names then cloud providers # https://bugzilla.redhat.com/show_bug.cgi?id=1455270 self.provider = provider self.collection = collection self.appliance = self.collection.appliance def wait_for_disappear(self, timeout=300): def refresh(): self.provider.refresh_provider_relationships() self.browser.refresh() try: wait_for(lambda: not self.exists, timeout=timeout, message='Wait for cloud Volume to disappear', delay=20, fail_func=refresh) except TimedOutError: logger.error( 'Timed out waiting for Volume to disappear, continuing') def delete(self, wait=True): """Delete the Volume""" view = navigate_to(self, 'Details') view.toolbar.configuration.item_select('Delete this Cloud Volume', handle_alert=True) view.entities.flash.assert_success_message( 'Delete initiated for 1 Cloud Volume.') if wait: self.wait_for_disappear(500) @property def exists(self): view = navigate_to(self.collection, 'All') try: view.entities.get_entity(by_name=self.name, surf_pages=True) return True except ItemNotFound: return False
class VMToolbar(View): """ Toolbar view for vms/instances collection destinations """ "Refresh this page" reload = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'})) configuration = Dropdown('Configuration') policy = Dropdown('Policy') lifecycle = Dropdown('Lifecycle') power = Dropdown('Power Operations') # title download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
class Volume(Navigatable): # Navigation menu option nav = VersionPick({ Version.lowest(): ['Storage', 'Volumes'], '5.8': ['Storage', 'Block Storage', 'Volumes'] }) def __init__(self, name, provider, appliance=None): Navigatable.__init__(self, appliance=appliance) self.name = name # TODO add storage provider parameter, needed for accurate details nav # the storage providers have different names then cloud providers # https://bugzilla.redhat.com/show_bug.cgi?id=1455270 self.provider = provider
def delete(self, cancel=True): """ Deletes a PXE server from CFME Args: cancel: Whether to cancel the deletion, defaults to True """ view = navigate_to(self, 'Details') view.toolbar.configuration.item_select(VersionPick({ Version.lowest(): 'Remove this PXE Server', '5.9': 'Remove this PXE Server from Inventory'}).pick(self.appliance.version), handle_alert=not cancel) if not cancel: main_view = self.create_view(PXEServersView) main_view.flash.assert_no_error() else: navigate_to(self, 'Details')
class Volume(BaseEntity): # Navigation menu option nav = VersionPick({ Version.lowest(): ['Storage', 'Volumes'], '5.8': ['Storage', 'Block Storage', 'Volumes'] }) name = attr.ib() provider = attr.ib() def wait_for_disappear(self, timeout=300): def refresh(): self.provider.refresh_provider_relationships() self.browser.refresh() try: wait_for(lambda: not self.exists, timeout=timeout, message='Wait for cloud Volume to disappear', delay=20, fail_func=refresh) except TimedOutError: logger.error( 'Timed out waiting for Volume to disappear, continuing') def delete(self, wait=True): """Delete the Volume""" view = navigate_to(self, 'Details') view.toolbar.configuration.item_select('Delete this Cloud Volume', handle_alert=True) view.entities.flash.assert_success_message( 'Delete initiated for 1 Cloud Volume.') if wait: self.wait_for_disappear(500) @property def exists(self): view = navigate_to(self.collection, 'All') try: view.entities.get_entity(by_name=self.name, surf_pages=True) return True except ItemNotFound: return False
def VolumeEntity(): # noqa """Temporary wrapper for Volume Entity during transition to JS based Entity """ return VersionPick({ Version.lowest(): NonJSVolumeEntity, '5.9': JSBaseEntity, })
class Volume(BaseEntity): # Navigation menu option nav = VersionPick({ Version.lowest(): ['Storage', 'Volumes'], '5.8': ['Storage', 'Block Storage', 'Volumes'] }) name = attr.ib() provider = attr.ib() def wait_for_disappear(self, timeout=300): """Wait for disappear the volume""" try: wait_for(lambda: not self.exists, timeout=timeout, message='Wait for cloud Volume to disappear', delay=20, fail_func=self.refresh) except TimedOutError: logger.error( 'Timed out waiting for Volume to disappear, continuing') def edit(self, name): """Edit cloud volume""" view = navigate_to(self, 'Edit') view.volume_name.fill(name) view.save.click() # Wrong flash for 5.7[BZ-1506992]. As BZ clear 5.7 will consistence with 5.8 and 5.9. if self.appliance.version < "5.8": view.flash.assert_success_message( 'Updating Cloud Volume "{}"'.format(self.name)) else: view.flash.assert_success_message( 'Cloud Volume "{}" updated'.format(name)) self.name = name wait_for(lambda: self.exists, delay=20, timeout=500, fail_func=self.refresh) def delete(self, wait=True): """Delete the Volume""" view = navigate_to(self, 'Details') view.toolbar.configuration.item_select('Delete this Cloud Volume', handle_alert=True) view.entities.flash.assert_success_message( 'Delete initiated for 1 Cloud Volume.') if wait: self.wait_for_disappear(500) def refresh(self): """Refresh provider relationships and browser""" self.provider.refresh_provider_relationships() self.browser.refresh() def create_backup(self, name, incremental=None, force=None): """create backup of cloud volume""" view = navigate_to(self, 'Backup') view.backup_name.fill(name) view.incremental.fill(incremental) view.force.fill(force) view.save.click() view.flash.assert_success_message( 'Backup for Cloud Volume "{}" created'.format(self.name)) wait_for(lambda: self.backups > 0, delay=20, timeout=1000, fail_func=self.refresh) @property def exists(self): try: navigate_to(self, 'Details') return True except VolumeNotFoundError: return False @property def size(self): """ size of storage cloud volume. Returns: :py:class:`str' size of volume. """ view = navigate_to(self, 'Details') return view.entities.properties.get_text_of('Size') @property def tenant(self): """ cloud tenants for volume. Returns: :py:class:`str' respective tenants. """ view = navigate_to(self, 'Details') return view.entities.relationships.get_text_of('Cloud Tenants') @property def backups(self): """ number of available backups for volume. Returns: :py:class:`int' backup count. """ view = navigate_to(self, 'Details') return int( view.entities.relationships.get_text_of('Cloud Volume Backups'))
class PXEDetailsToolBar(PXEToolBar): """ represents the toolbar which appears when any pxe entity is clicked """ reload = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'}))