diff --git a/cfme/base/ui.py b/cfme/base/ui.py index d09e46ef34..7deced4ab3 100644 --- a/cfme/base/ui.py +++ b/cfme/base/ui.py @@ -25,6 +25,7 @@ from cfme.base import ZoneCollection from cfme.base.credential import Credential from cfme.base.login import BaseLoggedInPage +from cfme.cloud_insights.services import CloudInsightsServicesView from cfme.configure.about import AboutView from cfme.configure.configuration.server_settings import ServerAuthenticationView from cfme.configure.configuration.server_settings import ServerInformationView @@ -1741,3 +1742,13 @@ class AutomateSimulation(CFMENavigateStep): def step(self, *args, **kwargs): self.prerequisite_view.navigation.select(*["Automation", "Automate", "Simulation"]) + + +# Red Hat Cloud - Insights +@navigator.register(Server, "Insights") +class CloudInsightsServices(CFMENavigateStep): + VIEW = CloudInsightsServicesView + prerequisite = NavigateToSibling("LoggedIn") + + def step(self, *args, **kwargs): + self.view.navigation.select("Red Hat Cloud", "Services") diff --git a/cfme/cloud_insights/__init__.py b/cfme/cloud_insights/__init__.py new file mode 100644 index 0000000000..6b33126575 --- /dev/null +++ b/cfme/cloud_insights/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +"""This is a directory of modules, each one represents one menu sub-item. + + * :py:mod:`cfme.cloud_insights.services` + * :py:mod:`cfme.cloud_insights.providers` +""" diff --git a/cfme/cloud_insights/providers.py b/cfme/cloud_insights/providers.py new file mode 100644 index 0000000000..617f46ba0e --- /dev/null +++ b/cfme/cloud_insights/providers.py @@ -0,0 +1,76 @@ +""" A model of an Infrastructure Provider in CFME +""" +import attr +from navmazing import NavigateToAttribute +from widgetastic.widget import Checkbox +from widgetastic.widget import Text +from widgetastic_patternfly import Button +from widgetastic_patternfly import Input +from widgetastic_patternfly import SelectorDropdown + +from cfme.base.login import BaseLoggedInPage +from cfme.infrastructure.host import HostsCollection +from cfme.modeling.base import BaseCollection +from cfme.modeling.base import BaseEntity +from cfme.utils.appliance.implementations.ui import CFMENavigateStep +from cfme.utils.appliance.implementations.ui import navigate_to +from cfme.utils.appliance.implementations.ui import navigator +from widgetastic_manageiq import Table +# from cfme.exceptions import displayed_not_implemented + + +class CloudInsightsProvidersView(BaseLoggedInPage): + """Basic view for Red Hat Cloud/Services page.""" + + global_sync_title = Text(locator='.//h1[normalize-space(.)="Global Synchronization"]') + global_sync_subtext = Text(locator='.//p[@id="red_hat_cloud_providers_global_info"') + sync_platform_button = Button("Synchronize this Platform to Cloud") + provider_sync_title = Text(locator='.//h1[normalize-space(.)="Provider Synchronization"]') + provider_sync_subtext = Text('.//p[@id="red_hat_cloud_services_table_info"') + filter_dropdown = SelectorDropdown("id", "filter_input") + filter_input_field = Input(id='filter_input') + sync_table_button = Button(id="Synchronize") + provider_sync_table = Table( + './/table[@id="red_hat_cloud_providers_table")]', + column_widgets={ + 0: Checkbox(locator=".//input[@type='checkbox']"), + "Action": Button(location='.//td/button[normalize-space(text())="Synchronize"]'), + }, + ) + + @property + def is_displayed(self): + return (self.global_sync_title.text == "Global Synchronization" + and self.sync_platform_button.is_displayed + and self.provider_sync_title == "Provider Synchronization" + and self.provider_sync_table.is_displayed) + + +@attr.s +class CloudInsightsProviders(BaseEntity): + + provider = attr.ib(default=None) + + _collections = {'hosts': HostsCollection} + + +@attr.s +class CloudInsightsProvidersCollection(BaseCollection): + + ENTITY = CloudInsightsProviders + + def all(self): + view = navigate_to(self, "All") + providers = [self.collections.instantiate(name=row.name.text) for row in + view.provider_sync_table.rows()] + return providers + + +# Red Hat Cloud - Insights +@navigator.register(CloudInsightsProvidersCollection, "All") +class CloudInsightsServices(CFMENavigateStep): + VIEW = CloudInsightsProvidersView + prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn') + + def step(self, *args, **kwargs): + self.view.navigation.select("Red Hat Cloud", "Providers") diff --git a/cfme/cloud_insights/services.py b/cfme/cloud_insights/services.py new file mode 100644 index 0000000000..fb7cfdadb8 --- /dev/null +++ b/cfme/cloud_insights/services.py @@ -0,0 +1,17 @@ +from widgetastic.widget import Text +from widgetastic_patternfly import Button + +from cfme.base.login import BaseLoggedInPage + + +class CloudInsightsServicesView(BaseLoggedInPage): + """Basic view for Red Hat Cloud/Services page.""" + title = Text('//div[@id="red_hat_cloud_services_redirect"]//h1') + subtext = Text(locator='.//p[@id="red_hat_cloud_services_redirect_info"') + take_me_button = Button("Take me there") + + @property + def is_displayed(self): + return ( + self.title.text == "Services" and self.take_me_button.is_displayed + ) diff --git a/entry_points.txt b/entry_points.txt index 6a30d493a8..ff57c875d1 100644 --- a/entry_points.txt +++ b/entry_points.txt @@ -33,6 +33,7 @@ cloud_av_zones = cfme.cloud.availability_zone:AvailabilityZoneCollection cloud_flavors = cfme.cloud.flavor:FlavorCollection cloud_host_aggregates = cfme.cloud.host_aggregates:HostAggregatesCollection cloud_images = cfme.cloud.instance.image:ImageCollection +cloud_insights_providers = cfme.cloud_insights.providers:CloudInsightsProvidersCollection cloud_instances = cfme.cloud.instance:InstanceCollection cloud_keypairs = cfme.cloud.keypairs:KeyPairCollection cloud_networks = cfme.networks.cloud_network:CloudNetworkCollection