コード例 #1
0
ファイル: __init__.py プロジェクト: grafuls/integration_tests
class MyService(Updateable, Navigatable, WidgetasticTaggable,
                sentaku.modeling.ElementMixin):
    """
        My Service main class to context switch between ui
        and ssui. All the below methods are implemented in both ui
        and ssui side .
    """

    update = sentaku.ContextualMethod()
    retire = sentaku.ContextualMethod()
    retire_on_date = sentaku.ContextualMethod()
    exists = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    set_ownership = sentaku.ContextualMethod()
    edit_tags = sentaku.ContextualMethod()
    check_vm_add = sentaku.ContextualMethod()
    download_file = sentaku.ContextualMethod()
    reconfigure_service = sentaku.ContextualMethod()

    def __init__(self, appliance, name=None, description=None, vm_name=None):
        self.appliance = appliance
        self.name = name
        self.description = description
        self.vm_name = vm_name
        self.parent = self.appliance.context
コード例 #2
0
class Zone(Pretty, BaseEntity, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = ['name', 'description', 'smartproxy_ip', 'ntp_servers', 'max_scans', 'user']

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()

    region = attr.ib(default=None)
    name = attr.ib(default="default")
    description = attr.ib(default="Default Zone")
    smartproxy_ip = attr.ib(default=None)
    ntp_servers = attr.ib(default=None)
    max_scans = attr.ib(default=None)
    user = attr.ib(default=None)

    # TODO we need to fix this set() addition
    def __attrs_post_init__(self):
        self.servers = []
        self.region = self.region or self.appliance.server.zone.region
        self.region.zones.append(self)

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ZoneCollectLog
        return ZoneCollectLog(self.appliance)
コード例 #3
0
ファイル: __init__.py プロジェクト: dgur/integration_tests
class Zone(Pretty, Navigatable, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = ['name', 'description', 'smartproxy_ip', 'ntp_servers',
                    'max_scans', 'user']

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()

    def __init__(self, appliance, region=None,
            name=None, description=None, smartproxy_ip=None, ntp_servers=None, max_scans=None,
            user=None):
        self.appliance = appliance
        self.servers = set()
        self.region = region or self.appliance.server.zone.region
        self.name = name or "default"
        self.description = description or "Default Zone"
        self.region.zones.add(self)

        self.smartproxy_ip = smartproxy_ip
        self.ntp_servers = ntp_servers
        self.max_scans = max_scans
        self.user = user
        self.parent = self.appliance.context
コード例 #4
0
class ServiceCatalogs(Navigatable, Taggable, Updateable,
                      sentaku.modeling.ElementMixin):
    """
        Service Catalogs main class to context switch between ui
        and ssui. All the below methods are implemented in both ui
        and ssui side .
    """

    order = sentaku.ContextualMethod()
    add_to_shopping_cart = sentaku.ContextualMethod()

    def __init__(self,
                 appliance,
                 catalog=None,
                 name=None,
                 stack_data=None,
                 dialog_values=None,
                 ansible_dialog_values=None):
        Navigatable.__init__(self, appliance=appliance)
        self.catalog = catalog
        self.name = name
        self.stack_data = stack_data
        self.dialog_values = dialog_values
        self.ansible_dialog_values = ansible_dialog_values
        self.parent = self.appliance.context
コード例 #5
0
class GenericObjectDefinition(BaseEntity, Updateable,
                              sentaku.modeling.ElementMixin):
    """Generic Objects Definition class to context switch between UI and REST.

    Read/Update/Delete functionality.
    """
    _collections = {
        'generic_objects': GenericObjectInstanceCollection,
        'generic_object_groups_buttons': GenericObjectButtonGroupsCollection,
        'generic_object_buttons': GenericObjectButtonsCollection
    }

    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    exists = sentaku.ContextualProperty()
    add_button = sentaku.ContextualMethod()
    add_button_group = sentaku.ContextualMethod()
    generic_objects = sentaku.ContextualProperty()
    instance_count = sentaku.ContextualProperty()

    name = attr.ib()
    description = attr.ib()
    attributes = attr.ib(default=None)  # e.g. {'address': 'string'}
    associations = attr.ib(default=None)  # e.g. {'services': 'Service'}
    methods = attr.ib(default=None)  # e.g. ['method1', 'method2']
    custom_image_file_path = attr.ib(default=None)
    rest_response = attr.ib(default=None, init=False)
コード例 #6
0
ファイル: spec.py プロジェクト: valaparthvi/Sentaku
class TodoCollection(sentaku.Collection):
    """domain object describing a todo list"""

    name = attr.ib()
    create_item = sentaku.ContextualMethod()
    get_by = sentaku.ContextualMethod()
    clear_completed = sentaku.ContextualMethod()
コード例 #7
0
class Search(sentaku.Element):
    """sentaku element for really simple pypi searching"""

    base_url = attr.ib(default="https://pypi.python.org/pypi")

    search = sentaku.ContextualMethod()
    open_page = sentaku.ContextualMethod()
コード例 #8
0
class GenericObjectDefinitionCollection(BaseCollection,
                                        sentaku.modeling.ElementMixin):

    ENTITY = GenericObjectDefinition

    create = sentaku.ContextualMethod()
    all = sentaku.ContextualMethod()
コード例 #9
0
class Zone(Pretty, BaseEntity, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = [
        'name', 'description', 'smartproxy_ip', 'ntp_servers', 'max_scans',
        'user'
    ]

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    region = sentaku.ContextualProperty()

    name = attr.ib(default="default")
    description = attr.ib(default="Default Zone")
    id = attr.ib(default=None)
    smartproxy_ip = attr.ib(default=None)
    ntp_servers = attr.ib(default=None)
    max_scans = attr.ib(default=None)
    user = attr.ib(default=None)
    _region = attr.ib(init=False, default=None)

    _collections = {'servers': ServerCollection}

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ZoneCollectLog
        return ZoneCollectLog(self.appliance)
コード例 #10
0
class Zone(Pretty, BaseEntity, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = ['name', 'description', 'smartproxy_ip', 'ntp_servers', 'max_scans', 'user']

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    # region = sentaku.ContextualProperty()

    name = attr.ib(default="default")
    description = attr.ib(default="Default Zone")
    id = attr.ib(default=None)
    smartproxy_ip = attr.ib(default=None)
    ntp_servers = attr.ib(default=None)
    max_scans = attr.ib(default=None)
    user = attr.ib(default=None)

    _collections = {'servers': ServerCollection}

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ZoneCollectLog
        return ZoneCollectLog(self.appliance)

    @property
    def region(self):
        zone_res = self.appliance.rest_api.collections.zones.find_by(id=self.id)
        zone = zone_res[0]
        zone.reload(attributes=['region_number'])
        region_obj = self.appliance.collections.regions.instantiate(number=zone.region_number)
        return region_obj

    @property
    def _api_settings_url(self):
        return '/'.join([self.appliance.rest_api.collections.zones._href, str(self.id), 'settings'])

    @property
    def advanced_settings(self):
        """"GET zones/:id/settings api endpoint to query zone configuration"""
        return self.appliance.rest_api.get(self._api_settings_url)

    def update_advanced_settings(self, settings_dict):
        """PATCH settings from the zone's api/zones/:id/settings endpoint

        Args:
            settings_dict: dictionary of the changes to be made to the yaml configuration
                       JSON dumps settings_dict to pass as raw hash data to rest_api session
        Raises:
            AssertionError: On an http result >=400 (RequestsResponse.ok)
        """
        # Calling the _session patch method because the core patch will wrap settings_dict in a list
        result = self.appliance.rest_api._session.patch(
            url=self._api_settings_url,
            data=json.dumps(settings_dict)
        )
        assert result.ok
コード例 #11
0
class ZoneCollection(BaseCollection, sentaku.modeling.ElementMixin):

    ENTITY = Zone

    region = attr.ib(default=None)

    create = sentaku.ContextualMethod()
    all = sentaku.ContextualMethod()
コード例 #12
0
class Server(Navigatable, sentaku.modeling.ElementMixin):
    def __init__(self, appliance, zone=None, name="EVM", sid=1):
        Navigatable.__init__(self, appliance=appliance)
        self.zone = zone or appliance.server.zone
        self.name = name
        self.sid = sid
        self.zone.servers.add(self)
        self.parent = self.appliance.context

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()

    @property
    def settings(self):
        from cfme.configure.configuration.server_settings import ServerInformation
        setting = ServerInformation(appliance=self.appliance)
        return setting

    @property
    def authentication(self):
        from cfme.configure.configuration.server_settings import AuthenticationSetting
        auth_settings = AuthenticationSetting(self.appliance)
        return auth_settings
コード例 #13
0
class Server(BaseEntity, sentaku.modeling.ElementMixin):
    name = attr.ib()
    sid = attr.ib(default=1)
    _zone = attr.ib(init=False, default=None)

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()

    zone = sentaku.ContextualProperty()

    @property
    def settings(self):
        from cfme.configure.configuration.server_settings import ServerInformation
        setting = ServerInformation(appliance=self.appliance)
        return setting

    @property
    def authentication(self):
        from cfme.configure.configuration.server_settings import AuthenticationSetting
        auth_settings = AuthenticationSetting(self.appliance)
        return auth_settings

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ServerCollectLog
        return ServerCollectLog(self.appliance)
コード例 #14
0
class ZoneCollection(BaseCollection, sentaku.modeling.ElementMixin):

    ENTITY = Zone

    region = attr.ib(default=None)

    create = sentaku.ContextualMethod()
    # all = sentaku.ContextualMethod()

    def all(self):
        zone_collection = self.appliance.rest_api.collections.zones
        zones = []
        parent = self.filters.get('parent')
        for zone in zone_collection:
            zone.reload(attributes=['region_number'])
            # starting in 5.11 there's a maintenance zone that is not shown in the UI but
            # is visible in API. We need to skip it for the correct navigation.
            # https://bugzilla.redhat.com/show_bug.cgi?id=1455145
            maintenance = 'Maintenance Zone'
            if (parent and zone.region_number != parent.number) or zone.description == maintenance:
                continue
            zones.append(self.instantiate(
                name=zone.name, description=zone.description, id=zone.id
            ))
        # TODO: This code needs a refactor once the attributes can be loaded from the collection
        return zones
コード例 #15
0
class GenericObjectDefinition(BaseEntity, Updateable,
                              sentaku.modeling.ElementMixin):
    """Generic Objects Definition class to context switch between UI and REST.

    Read/Update/Delete functionality.
    """
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    exists = sentaku.ContextualProperty()

    name = attr.ib()
    description = attr.ib()
    attributes = attr.ib(default=None)  # e.g. {'address': 'string'}
    associations = attr.ib(default=None)  # e.g. {'services': 'Service'}
    methods = attr.ib(default=None)  # e.g. ['method1', 'method2']
    rest_response = attr.ib(default=None, init=False)
コード例 #16
0
class GenericObjectInstance(BaseEntity, Updateable,
                            sentaku.modeling.ElementMixin):
    """Generic Objects class to context switch between REST and Automate.

    Read/Update/Delete functionality.
    """
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    exists = sentaku.ContextualProperty()

    name = attr.ib()
    definition = attr.ib()  # generic object definition
    attributes = attr.ib(default=None)  # e.g. {'address': 'Test Address'}
    associations = attr.ib(
        default=None)  # e.g. {'services': [myservice1, myservice2]}
    rest_response = attr.ib(default=None, init=False)
コード例 #17
0
ファイル: __init__.py プロジェクト: dgur/integration_tests
class ZoneCollection(Navigatable, sentaku.modeling.ElementMixin):

    create = sentaku.ContextualMethod()

    def __init__(self, appliance, region=None):
        self.appliance = appliance
        self.region = region or appliance.server.zone.region
        self.parent = self.appliance.context
コード例 #18
0
class Dashboard(Navigatable, sentaku.modeling.ElementMixin):
    """ Dashboard main class for SSUI."""

    num_of_rows = sentaku.ContextualMethod()
    total_services = sentaku.ContextualMethod()
    total_requests = sentaku.ContextualMethod()
    retiring_soon = sentaku.ContextualMethod()
    current_services = sentaku.ContextualMethod()
    retired_services = sentaku.ContextualMethod()
    monthly_charges = sentaku.ContextualMethod()
    pending_requests = sentaku.ContextualMethod()
    approved_requests = sentaku.ContextualMethod()
    denied_requests = sentaku.ContextualMethod()

    def __init__(self, appliance):
        self.appliance = appliance
        self.parent = self.appliance.context
コード例 #19
0
ファイル: __init__.py プロジェクト: iovadia/integration_tests
class Server(BaseEntity, sentaku.modeling.ElementMixin):
    _param_name = ParamClassName('name')

    name = attr.ib()
    sid = attr.ib(default=1)

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()
    current_group_name = sentaku.ContextualMethod()

    # zone = sentaku.ContextualProperty()
    # slave_servers = sentaku.ContextualProperty()

    @property
    def settings(self):
        from cfme.configure.configuration.server_settings import ServerInformation
        setting = ServerInformation(appliance=self.appliance)
        return setting

    @property
    def authentication(self):
        from cfme.configure.configuration.server_settings import AuthenticationSetting
        auth_settings = AuthenticationSetting(self.appliance)
        return auth_settings

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ServerCollectLog
        return ServerCollectLog(self.appliance)

    @property
    def zone(self):
        server_res = self.appliance.rest_api.collections.servers.find_by(
            id=self.sid)
        server = server_res[0]
        server.reload(attributes=['zone'])
        zone = server.zone
        zone_obj = self.appliance.collections.zones.instantiate(
            name=zone['name'], description=zone['description'], id=zone['id'])
        return zone_obj

    @property
    def slave_servers(self):
        return self.zone.collections.servers.filter({'slave': True}).all()
コード例 #20
0
class ZoneCollection(BaseCollection, sentaku.modeling.ElementMixin):

    ENTITY = Zone

    region = attr.ib(default=None)

    create = sentaku.ContextualMethod()

    def __attrs_post_init__(self):
        self.region = self.region or self.appliance.server.zone.region
コード例 #21
0
ファイル: __init__.py プロジェクト: iovadia/integration_tests
class Zone(Pretty, BaseEntity, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = [
        'name', 'description', 'smartproxy_ip', 'ntp_servers', 'max_scans',
        'user'
    ]

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    # region = sentaku.ContextualProperty()

    name = attr.ib(default="default")
    description = attr.ib(default="Default Zone")
    id = attr.ib(default=None)
    smartproxy_ip = attr.ib(default=None)
    ntp_servers = attr.ib(default=None)
    max_scans = attr.ib(default=None)
    user = attr.ib(default=None)

    _collections = {'servers': ServerCollection}

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ZoneCollectLog
        return ZoneCollectLog(self.appliance)

    @property
    def region(self):
        zone_res = self.appliance.rest_api.collections.zones.find_by(
            id=self.id)
        zone = zone_res[0]
        zone.reload(attributes=['region_number'])
        region_obj = self.appliance.collections.regions.instantiate(
            number=zone.region_number)
        return region_obj
コード例 #22
0
ファイル: spec.py プロジェクト: mshriver/Sentaku
class TodoAPI(sentaku.ImplementationContext):
    """example description for a simple todo application"""
    @classmethod
    def from_api(cls, api):
        """
        create an application description for the todo app,
        that based on the api can use either tha api or the ux for interaction
        """
        ux = TodoUX(api)
        from .pseudorpc import PseudoRpc
        rpc = PseudoRpc(api)

        return cls({ViaAPI: api, ViaUX: ux, ViaRPC: rpc})

    create_collection = sentaku.ContextualMethod()
コード例 #23
0
ファイル: __init__.py プロジェクト: dgur/integration_tests
class Server(Navigatable, sentaku.modeling.ElementMixin):
    def __init__(self, appliance, zone=None, name="EVM", sid=1):
        Navigatable.__init__(self, appliance=appliance)
        self.zone = zone or appliance.server.zone
        self.name = name
        self.sid = sid
        self.zone.servers.add(self)
        self.parent = self.appliance.context

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()
コード例 #24
0
ファイル: __init__.py プロジェクト: himdel/integration_tests
class ZoneCollection(BaseCollection, sentaku.modeling.ElementMixin):

    ENTITY = Zone

    region = attr.ib(default=None)

    create = sentaku.ContextualMethod()
    # all = sentaku.ContextualMethod()

    def all(self):
        zone_collection = self.appliance.rest_api.collections.zones
        zones = []
        parent = self.filters.get('parent')
        for zone in zone_collection:
            zone.reload(attributes=['region_number'])
            if parent and zone.region_number != parent.number:
                continue
            zones.append(self.instantiate(
                name=zone.name, description=zone.description, id=zone.id
            ))
        # TODO: This code needs a refactor once the attributes can be loaded from the collection
        return zones
コード例 #25
0
class RegionCollection(BaseCollection, sentaku.modeling.ElementMixin):
    all = sentaku.ContextualMethod()

    ENTITY = Region
コード例 #26
0
class Server(BaseEntity, sentaku.modeling.ElementMixin):
    _param_name = ParamClassName('name')

    name = attr.ib()
    sid = attr.ib(default=1)

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()
    current_group_name = sentaku.ContextualMethod()
    group_names = sentaku.ContextualMethod()

    # zone = sentaku.ContextualProperty()
    # slave_servers = sentaku.ContextualProperty()

    @property
    def settings(self):
        from cfme.configure.configuration.server_settings import ServerInformation
        setting = ServerInformation(appliance=self.appliance)
        return setting

    @property
    def authentication(self):
        from cfme.configure.configuration.server_settings import AuthenticationSetting
        auth_settings = AuthenticationSetting(self.appliance)
        return auth_settings

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ServerCollectLog
        return ServerCollectLog(self.appliance)

    @property
    def zone(self):
        server_res = self.appliance.rest_api.collections.servers.find_by(
            id=self.sid)
        server = server_res[0]
        server.reload(attributes=['zone'])
        zone = server.zone
        zone_obj = self.appliance.collections.zones.instantiate(
            name=zone['name'], description=zone['description'], id=zone['id'])
        return zone_obj

    @property
    def slave_servers(self):
        return self.zone.collections.servers.filter({'slave': True}).all()

    @property
    def _api_settings_url(self):
        return '/'.join([
            self.appliance.rest_api.collections.servers._href,
            str(self.sid), 'settings'
        ])

    @property
    def advanced_settings(self):
        """GET servers/:id/settings api endpoint to query server configuration"""
        return self.appliance.rest_api.get(url=self._api_settings_url)

    def update_advanced_settings(self, settings_dict):
        """PATCH settings from the server's api/server/:id/settings endpoint

        Args:
            settings_dict: dictionary of the changes to be made to the yaml configuration
                       JSON dumps settings_dict to pass as raw hash data to rest_api session
        Raises:
            AssertionError: On an http result >=400 (RequestsResponse.ok)
        """
        # Calling the _session patch method because the core patch will wrap settings_dict in a list
        # Failing with some settings_dict, like 'authentication'
        # https://bugzilla.redhat.com/show_bug.cgi?id=1553394
        result = self.appliance.rest_api._session.patch(
            url=self._api_settings_url, data=json.dumps(settings_dict))
        assert result.ok
コード例 #27
0
class Server(BaseEntity, sentaku.modeling.ElementMixin):
    _param_name = ParamClassName('name')

    sid = attr.ib(default=1)

    address = sentaku.ContextualMethod()
    login = sentaku.ContextualMethod()
    login_admin = sentaku.ContextualMethod()
    logout = sentaku.ContextualMethod()
    update_password = sentaku.ContextualMethod()
    logged_in = sentaku.ContextualMethod()
    current_full_name = sentaku.ContextualMethod()
    current_username = sentaku.ContextualMethod()
    current_group_name = sentaku.ContextualMethod()
    group_names = sentaku.ContextualMethod()
    intel_name = VersionPicker({"5.11": "Overview", Version.lowest(): "Cloud Intel"})

    # zone = sentaku.ContextualProperty()
    # slave_servers = sentaku.ContextualProperty()

    @property
    def name(self):
        """Fetch the name from the master server api entity

        Returns:
            string if entity has the name attribute
            None if its missing
        """
        # empty string default for string building w/o None
        return getattr(self.appliance._rest_api_server, 'name', '')

    @property
    def current_string(self):
        """Returns the string ' (current)' if the appliance serving the UI request
         matches this server instance. Used to generate the appropriate tree_path
         for navigating configuration accordion trees."""
        return ' (current)' if self.sid == self.appliance.server_id() else ''

    @property
    def tree_path(self):
        """Generate the path list for navigation purposes
        list elements follow the tree path in the configuration accordion

        Returns:
            list of path elements for tree navigation
        """
        name_string = f' {self.name} '.replace('  ', ' ')
        path = [
            self.zone.region.settings_string,
            "Zones",
            f"Zone: {self.zone.title_string()}",
            f"Server:{name_string}[{self.sid}]{self.current_string}"  # variables have needed spaces
        ]
        return path

    @property
    def diagnostics_tree_path(self):
        """Generate tree path list for the diagnostics tree in the configuration accordion"""
        path = self.tree_path
        path.remove("Zones")
        return path

    @property
    def settings(self):
        from cfme.configure.configuration.server_settings import ServerInformation
        setting = ServerInformation(appliance=self.appliance)
        return setting

    @property
    def authentication(self):
        from cfme.configure.configuration.server_settings import AuthenticationSetting
        auth_settings = AuthenticationSetting(self.appliance)
        return auth_settings

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ServerCollectLog
        return ServerCollectLog(self.appliance)

    @property
    def zone(self):
        entity = self.rest_api_entity
        entity.reload(attributes=['zone'])
        return self.appliance.collections.zones.instantiate(
            name=entity.zone['name'],
            description=entity.zone['description'],
            id=entity.zone['id']
        )

    @property
    def slave_servers(self):
        return self.zone.collections.servers.filter({'slave': True}).all()

    @property
    def is_slave(self):
        return self in self.slave_servers

    @property
    def secondary_servers(self):
        """ Find and return a list of all other servers in this server's zone. """
        return [s for s in self.zone.collections.servers.all() if s.sid != self.sid]

    @property
    def _api_settings_url(self):
        return '/'.join(
            [self.appliance.rest_api.collections.servers._href, str(self.sid), 'settings']
        )

    @property
    def rest_api_entity(self):
        try:
            return self.appliance.rest_api.collections.servers.get(id=self.sid)
        except ValueError:
            raise RestLookupError(f'No server rest entity found matching ID {self.sid}')

    @property
    def advanced_settings(self):
        """GET servers/:id/settings api endpoint to query server configuration"""
        return self.appliance.rest_api.get(self._api_settings_url)

    def update_advanced_settings(self, settings_dict):
        """PATCH settings from the server's api/server/:id/settings endpoint

        Args:
            settings_dict: dictionary of the changes to be made to the yaml configuration
                       JSON dumps settings_dict to pass as raw hash data to rest_api session
        Raises:
            AssertionError: On an http result >=400 (RequestsResponse.ok)
        """
        # Calling the _session patch method because the core patch will wrap settings_dict in a list
        # Failing with some settings_dict, like 'authentication'
        # https://bugzilla.redhat.com/show_bug.cgi?id=1553394
        result = self.appliance.rest_api._session.patch(
            url=self._api_settings_url,
            data=json.dumps(settings_dict)
        )
        assert result.ok

    def upload_custom_logo(self, file_type, file_data=None, enable=True):
        """
        This function can be used to upload custom logo or text and use them.

        Args:
            file_type (str) : Can be either of [logo, login_logo, brand, favicon, logintext]
            file_data (str) : Text data if file_type is logintext else image path to be uploaded
            enable (bool) : True to use the custom logo/text else False
        """
        view = navigate_to(self, "CustomLogos")
        try:
            logo_view = getattr(view.customlogos, file_type)
        except AttributeError:
            raise AttributeError(
                "File type not in ('logo', 'login_logo', 'brand', 'favicon', 'logintext)."
            )
        if file_data:
            if file_type == "logintext":
                logo_view.fill({"login_text": file_data})
            else:
                logo_view.fill({"image": file_data})
                logo_view.upload_button.click()
            view.flash.assert_no_error()
        logo_view.enable.fill(enable)
        view.customlogos.save_button.click()
        view.flash.assert_no_error()
コード例 #28
0
class Zone(Pretty, BaseEntity, sentaku.modeling.ElementMixin):
    """ Configure/Configuration/Region/Zones functionality

    Create/Read/Update/Delete functionality.
    """
    pretty_attrs = ['name', 'description', 'smartproxy_ip', 'ntp_servers', 'max_scans', 'user']

    exists = sentaku.ContextualProperty()
    update = sentaku.ContextualMethod()
    delete = sentaku.ContextualMethod()
    # region = sentaku.ContextualProperty()

    name = attr.ib(default="default")
    description = attr.ib(default="Default Zone")
    id = attr.ib(default=None)
    smartproxy_ip = attr.ib(default=None)
    ntp_servers = attr.ib(default=None)
    max_scans = attr.ib(default=None)
    user = attr.ib(default=None)

    _collections = {'servers': ServerCollection}

    @property
    def collect_logs(self):
        from cfme.configure.configuration.diagnostics_settings import ZoneCollectLog
        return ZoneCollectLog(self.appliance)

    @cached_property
    def region(self):
        possible_parent = parent_of_type(self, Region)
        if possible_parent:
            return possible_parent
        else:
            zone_res = self.appliance.rest_api.collections.zones.find_by(id=self.id)
            zone, = zone_res
            zone.reload(attributes=['region_number'])
            return self.appliance.collections.regions.instantiate(number=zone.region_number)

    @property
    def _api_settings_url(self):
        return '/'.join([self.appliance.rest_api.collections.zones._href, str(self.id), 'settings'])

    @property
    def advanced_settings(self):
        """"GET zones/:id/settings api endpoint to query zone configuration"""
        return self.appliance.rest_api.get(self._api_settings_url)

    @property
    def current_string(self):
        """Returns the string ' (current)' if the appliance serving the UI request is in this zone.
        Used to generate the appropriate tree_path for navigating configuration accordion trees."""
        return ' (current)' if (
            self.id == self.appliance.server.zone.id
        ) else ''

    def title_string(self, quote_str=''):
        """Used to generate the title.text for Zone-related views.

        Returns a string of the form:

        "Zone Description" (current)
        [or]
        "Zone Description"

        Args:
            quote_str: The optional string to include before and after the
                       zone description. To reproduce the title.text as shown
                       above, quote_str='"'.

                       In accordion trees, the zone appears in the form:

                       Zone Description (current)
                       [or]
                       Zone Description

                       (without the quotation marks surrounding the
                       description). In this case, we can pass
                       quote_str='' (the default).
        """
        return f"{quote_str}{self.description}{quote_str}{self.current_string}"

    @property
    def tree_path(self):
        """Generate the tree path list for the settings tree in the configuration accordion

        Returns:
            list of path elements for tree navigation
        """
        path = [
            self.region.settings_string,
            "Zones",
            f"Zone: {self.title_string()}"
        ]
        return path

    @property
    def diagnostics_tree_path(self):
        """Generate tree path list for the diagnostics tree in the configuration accordion"""
        path = self.tree_path
        path.remove("Zones")
        return path

    def update_advanced_settings(self, settings_dict):
        """PATCH settings from the zone's api/zones/:id/settings endpoint

        Args:
            settings_dict: dictionary of the changes to be made to the yaml configuration
                       JSON dumps settings_dict to pass as raw hash data to rest_api session
        Raises:
            AssertionError: On an http result >=400 (RequestsResponse.ok)
        """
        # Calling the _session patch method because the core patch will wrap settings_dict in a list
        result = self.appliance.rest_api._session.patch(
            url=self._api_settings_url,
            data=json.dumps(settings_dict)
        )
        assert result.ok
コード例 #29
0
ファイル: __init__.py プロジェクト: xlab-si/integration_tests
class GenericObjectInstanceCollection(BaseCollection, sentaku.modeling.ElementMixin):

    ENTITY = GenericObjectInstance

    create = sentaku.ContextualMethod()
コード例 #30
0
class ServerCollection(BaseCollection, sentaku.modeling.ElementMixin):
    ENTITY = Server

    all = sentaku.ContextualMethod()
    get_master = sentaku.ContextualMethod()