class ApplianceDeviceReadCommunity(object):
    """
    ApplianceDeviceReadCommunity API client.
    The device read community string is used by the appliance to establish SNMP communication with devices managed by the appliance.
    """
    URI = '/rest/appliance/device-read-community-string'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get(self):
        """
        Retrieves the global community string.

        Returns:
            dict: ApplianceDeviceReadCommunity
        """
        return self._client.get(self.URI)

    def update(self, resource, timeout=-1):
        """
        Update the device read community string.
        This results in an update of the community string on all servers being managed/monitored by this OneView instance.

        Args:
            resource (dict): Object to update.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Updated appliance SNMPv1 read community string.
        """
        return self._client.update(resource, timeout=timeout)
class ApplianceNodeInformation(object):
    """
    ApplianceNodeInformation API client.

    """
    URI = '/rest/appliance/nodeinfo'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get_status(self):
        """
        Retrieves node's status information

        Returns:
            dict: Node's status information
        """
        uri = self.URI + '/status'
        return self._client.get(uri)

    def get_version(self):
        """
        Retrieves node's version information

        Returns:
            dict: Node's version information
        """
        uri = self.URI + '/version'
        return self._client.get(uri)
    def get_all_without_ethernet(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a paginated collection of logical downlinks without ethernet. The collection is
        based on optional sorting and filtering and is constrained by start and count parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            dict
        """
        without_ethernet_client = ResourceClient(
            self._connection, "/rest/logical-downlinks/withoutEthernet")
        return without_ethernet_client.get_all(start,
                                               count,
                                               filter=filter,
                                               sort=sort)
Ejemplo n.º 4
0
class Roles(object):
    """
    Roles API client.
    """

    URI = '/rest/roles'
    RESOURCES_PATH = '/resources'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a list of roles based on optional sorting and filtering and is constrained by start
        and count parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of roles.
        """
        return self._client.get_all(start=start,
                                    count=count,
                                    filter=filter,
                                    sort=sort)

    def get(self, name_or_uri):
        """
        Get the role by its URI or Name.

        Args:
            name_or_uri:
                Can be either the Name or the URI.

        Returns:
            dict: Role
        """
        name_or_uri = quote(name_or_uri)
        return self._client.get(name_or_uri)
Ejemplo n.º 5
0
    def __init__(self, type, con):

        uri = ""
        if type == 'vmac':
            uri = '/rest/id-pools/vmac/ranges'
        elif type == 'vsn':
            uri = '/rest/id-pools/vsn/ranges'
        elif type == 'vwwn':
            uri = '/rest/id-pools/vwwn/ranges'
        else:
            raise HPEOneViewValueError(
                "Invalid type: {0}, types allowed: vmac, vsn, vwwn, ".format(
                    type))

        self._client = ResourceClient(con, uri)
Ejemplo n.º 6
0
class Endpoints(object):
    """
    Endpoints API client.

    """
    URI = '/rest/fc-sans/endpoints'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, query='', sort=''):
        """
        Retrieves the list of endpoints known by the appliance.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items. The actual number of items in
                the response may differ from the requested count if the sum of start and count exceed the total number
                of items.
            query:
                A general query string to narrow the list of resources returned.
                The default is no query - all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: The endpoints known by the appliance.
        """
        return self._client.get_all(start=start, count=count, query=query, sort=sort)
Ejemplo n.º 7
0
class FirmwareBundles(object):
    """
    Firmware Bundles API client.

    """
    URI = '/rest/firmware-bundles'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def upload(self, file_path, timeout=-1):
        """
        Upload an SPP ISO image file or a hotfix file to the appliance.
        The API supports upload of one hotfix at a time into the system.
        For the successful upload of a hotfix, ensure its original name and extension are not altered.

        Args:
            file_path: Full path to firmware.
            timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
          dict: Information about the updated firmware bundle.
        """
        return self._client.upload(file_path, timeout=timeout)
class CertificateAuthority(object):
    """
    Certificate Authority API client.
    """

    URI = '/rest/certificates/ca'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get(self):
        """
        Retrieves the certificate of the internal CA in the form of a string.

        Returns:
            str: The Internal CA Certificate.
        """
        return self._client.get(self.URI)

    def get_crl(self):
        """
        Retrieves the contents of the CRL file maintained by the internal CA; in Base-64 encoded format, in the form
        of a string.

        Returns:
            str: The Certificate Revocation List
        """
        crl_url = self.URI + "/crl"
        return self._client.get(crl_url)

    def delete(self, alias_name, timeout=-1):
        """
        Revokes a certificate signed by the internal CA. If client certificate to be revoked is RabbitMQ_readonly,
        then the internal CA root certificate, RabbitMQ client certificate and RabbitMQ server certificate will be
        regenerated. This will invalidate the previous version of RabbitMQ client certificate and the RabbitMQ server
        will be restarted to read the latest certificates.

        Args:
            alias_name (str): Alias name.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.
        """
        uri = self.URI + "/" + alias_name
        return self._client.delete(uri, timeout=timeout)
Ejemplo n.º 9
0
class ApplianceTimeAndLocaleConfiguration(object):
    """
    ApplianceTimeAndLocaleConfiguration API client.

    """
    URI = '/rest/appliance/configuration/time-locale'

    DEFAULT_VALUES = {
        '200': {
            "type": "TimeAndLocale"
        },
        '300': {
            "type": "TimeAndLocale"
        }
    }

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get(self):
        """
        Gets the appliance time and locale configuration.

        Returns:
            dict: ApplianceTimeAndLocaleConfiguration
        """
        return self._client.get(self.URI)

    def update(self, resource, timeout=-1):
        """
        Updates the appliance time and locale configuration.

        Args:
            resource (dict): Object to update.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Updated appliance time and locale configuration.

        """
        return self._client.create(resource,
                                   timeout=timeout,
                                   default_values=self.DEFAULT_VALUES)
Ejemplo n.º 10
0
class LoginDetails(object):
    """
    list login details.

    """

    URI = '/rest/logindetails'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_login_details(self):
        """
        List the login details

        Returns:
            dict: login details.
        """
        return self._client.get(self.URI)
Ejemplo n.º 11
0
class Versions(object):
    """
    Version API client. It indicates the range of API versions supported by the appliance.

    """
    URI = '/rest/version'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get_version(self):
        """
        Returns the range of possible API versions supported by the appliance.
        The response contains the current version and the minimum version.
        The current version is the recommended version to specify in the REST header.
        The other versions are supported for backward compatibility, but might not support the most current features.

        Returns:
            dict: The minimum and maximum supported API versions.
        """
        version = self._client.get(self.URI)
        return version
Ejemplo n.º 12
0
class Connections(object):
    """
    Connections API client.

    """

    URI = '/rest/connections'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort='', view='', fields=''):
        """
        Gets a paginated collection of connections based on optional sorting and filtering,
        and constrained by start and count parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.
            fields:
                Specifies which fields should be returned in the result set.
            view:
                 Returns a specific subset of the attributes of the resource or collection, by
                 specifying the name of a predefined view. The default view is expand (show
                 all attributes of the resource and all elements of collections of resources).

        Returns:
            list: A list of connections.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort, view=view, fields=fields)

    def get_by(self, field, value):
        """
        Gets all connections that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of connections.
        """
        return self._client.get_by(field, value)

    def get(self, id_or_uri):
        """
        Returns the connection with the specified ID or URI.

        Args:
            id: ID or URI of connection

        Returns:
            dict
        """
        return self._client.get(id_or_uri)
Ejemplo n.º 13
0
 def __init__(self, con):
     self._client = ResourceClient(con, self.URI)
     self._task_monitor = TaskMonitor(con)
     self.__default_values = {
         'type': 'GoldenImage',
     }
Ejemplo n.º 14
0
class Switches(object):
    """
    Switches API client.

    Note:
        This resource is only available on C7000 enclosures.

    """
    URI = '/rest/switches'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_statistics(self, id_or_uri, port_name=''):
        """
        Gets statistics for a switch.

        Args:
            id_or_uri: Can be either the switch id or the switch uri.
            port_name: switch port number (optional)

        Returns:
            dict
        """
        uri = self._client.build_uri(id_or_uri) + "/statistics"

        if port_name:
            uri += "/" + port_name

        return self._client.get(uri)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a list of top of rack switches.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of rack switches.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get(self, id_or_uri):
        """
        Gets a switch by ID or by URI.

        Args:
            id_or_uri: Can be either the switch ID or URI.

        Returns:
            dict: Switch
        """
        return self._client.get(id_or_uri)

    def delete(self, resource, force=False, timeout=-1):
        """
        Deletes a migrated switch.

        Args:
            resource (dict): Object to delete.
            force (bool):
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully deleted.
        """
        return self._client.delete(resource, force=force, timeout=timeout)

    def get_environmental_configuration(self, id_or_uri):
        """
        Gets the environmental configuration for a switch.

        Args:
            id_or_uri: Can be either the resource ID or URI.

        Returns:
            dict: environmental configuration
        """
        uri = self._client.build_uri(id_or_uri) + "/environmentalConfiguration"
        return self._client.get(uri)

    def get_by(self, field, value):
        """
        Gets all switches that match the filter.

        The search is case-insensitive.

        Args:
            field: field name to filter
            value: value to filter

        Returns:
            list: A list of rack switches.
        """
        return self._client.get_by(field, value)

    def update_ports(self, ports, id_or_uri):
        """
        Updates the switch ports. Only the ports under the management of OneView and those that are unlinked are
        supported for update.

        Note:
            This method is available for API version 300 or later.

        Args:
            ports: List of Switch Ports.
            id_or_uri: Can be either the switch id or the switch uri.

        Returns:
            dict: Switch
        """
        ports = merge_default_values(ports, {'type': 'port'})

        uri = self._client.build_uri(id_or_uri) + "/update-ports"
        return self._client.update(uri=uri, resource=ports)

    def patch(self, id_or_uri, operation, path, value, timeout=-1):
        """
        Uses the PATCH to update a resource for a given logical switch.

        Only one operation can be performed in each PATCH call.

        Args:
            id_or_uri: Can be either the resource ID or the resource URI.
            operation: Patch operation
            path: Path
            value: Value
            timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: Updated resource.
        """
        return self._client.patch(id_or_uri,
                                  operation,
                                  path,
                                  value,
                                  timeout=timeout)
Ejemplo n.º 15
0
class GoldenImages(object):
    URI = '/rest/golden-images'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)
        self._task_monitor = TaskMonitor(con)
        self.__default_values = {
            'type': 'GoldenImage',
        }

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Retrieves a list of Golden Image resources as per the specified parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.

                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of Golden Images.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def create(self, resource, timeout=-1):
        """
        Creates a Golden Image resource from the deployed OS Volume as per the attributes specified.

        Args:
            resource (dict): Object to create.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView, it just stops waiting for its completion.

        Returns:
            dict: Golden Image created.
        """
        data = self.__default_values.copy()
        data.update(resource)
        return self._client.create(data, timeout=timeout)

    def upload(self, file_path, golden_image_info):
        """
        Adds a Golden Image resource from the file that is uploaded from a local drive. Only the .zip format file can
        be used for the upload.

        Args:
            file_path (str): File name to upload.
            golden_image_info (dict): Golden Image information.

        Returns:
            dict: Golden Image.
        """
        uri = "{0}?name={1}&description={2}".format(
            self.URI, quote(golden_image_info.get('name', '')),
            quote(golden_image_info.get('description', '')))

        return self._client.upload(file_path, uri)

    def download_archive(self, id_or_uri, file_path):
        """
        Download the details of the Golden Image capture logs, which has been archived based on the specific attribute
        ID.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path (str): File name to save the archive.

        Returns:
            bool: Success.
        """
        uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)

    def download(self, id_or_uri, file_path):
        """
        Downloads the content of the selected Golden Image as per the specified attributes.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path(str): Destination file path.

        Returns:
            bool: Successfully downloaded.
        """
        uri = self.URI + "/download/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)

    def get(self, id_or_uri):
        """
        Retrieves the overview details of the selected Golden Image as per the specified attributes.

        Args:
            id_or_uri: ID or URI of the Golden Image.

        Returns:
            dict: The Golden Image.
        """
        return self._client.get(id_or_uri)

    def update(self, resource, timeout=-1):
        """
        Updates the properties of the Golden Image.

        Args:
            resource (dict): Object to update.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView, it just stops waiting for its completion.

        Returns:
            dict: Updated resource.

        """
        return self._client.update(resource, timeout=timeout)

    def delete(self, resource, force=False, timeout=-1):
        """
        Deletes the Golden Image specified.

        Args:
            resource: dict object to delete
            force:
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully deleted.

        """
        return self._client.delete(resource, force=force, timeout=timeout)

    def get_by(self, field, value):
        """
        Gets all Golden Images that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of Golden Images.
        """
        return self._client.get_by(field, value)
Ejemplo n.º 16
0
class SanManagers(object):
    """
    SAN Managers API client.

    """
    URI = '/rest/fc-sans/device-managers'
    PROVIDER_URI = '/rest/fc-sans/providers'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)
        self._provider_client = ResourceClient(con, self.PROVIDER_URI)

    def get_all(self, start=0, count=-1, query='', sort=''):
        """
        Retrieves the list of registered SAN Managers.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items. The actual number of items in
                the response may differ from the requested count if the sum of start and count exceed the total number
                of items.
            query:
                A general query string to narrow the list of resources returned.
                The default is no query - all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of SAN managers.

        """
        return self._client.get_all(start=start,
                                    count=count,
                                    query=query,
                                    sort=sort)

    def get(self, id_or_uri):
        """
        Retrieves a single registered SAN Manager by ID or URI.

        Args:
            id_or_uri: Can be either the SAN Manager resource ID or URI.

        Returns:
            dict: The SAN Manager resource.
        """
        return self._client.get(id_or_uri=id_or_uri)

    def update(self, resource, id_or_uri):
        """
        Updates a registered Device Manager.

        Args:
            resource (dict): Object to update.
            id_or_uri: Can be either the Device manager ID or URI.

        Returns:
            dict: The device manager resource.
        """
        return self._client.update(resource=resource, uri=id_or_uri)

    def add(self, resource, provider_uri_or_id, timeout=-1):
        """
        Adds a Device Manager under the specified provider.

        Args:
            resource (dict): Object to add.
            provider_uri_or_id: ID or URI of provider.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Added SAN Manager.
        """
        uri = self._provider_client.build_uri(
            provider_uri_or_id) + "/device-managers"
        return self._client.create(resource=resource, uri=uri, timeout=timeout)

    def get_provider_uri(self, provider_display_name):
        """
        Gets uri for a specific provider.

        Args:
            provider_display_name: Display name of the provider.

        Returns:
            uri
        """
        providers = self._provider_client.get_by('displayName',
                                                 provider_display_name)
        return providers[0]['uri'] if providers else None

    def get_default_connection_info(self, provider_name):
        """
        Gets default connection info for a specific provider.

        Args:
            provider_name: Name of the provider.

        Returns:
            dict: Default connection information.
        """
        provider = self._provider_client.get_by_name(provider_name)
        if provider:
            return provider['defaultConnectionInfo']
        else:
            return {}

    def remove(self, resource, timeout=-1):
        """
        Removes a registered SAN Manager.

        Args:
            resource (dict): Object to delete.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully removed.
        """
        return self._client.delete(resource, timeout=timeout)

    def get_by_name(self, name):
        """
        Gets a SAN Manager by name.

        Args:
            name: Name of the SAN Manager

        Returns:
            dict: SAN Manager.
        """
        san_managers = self._client.get_all()
        result = [x for x in san_managers if x['name'] == name]
        return result[0] if result else None

    def get_by_provider_display_name(self, provider_display_name):
        """
        Gets a SAN Manager by provider display name.

        Args:
            provider_display_name: Name of the Provider Display Name

        Returns:
            dict: SAN Manager.
        """
        san_managers = self._client.get_all()
        result = [
            x for x in san_managers
            if x['providerDisplayName'] == provider_display_name
        ]
        return result[0] if result else None
class ApplianceDeviceSNMPv3TrapDestinations(object):
    """
    ApplianceDeviceSNMPv3TrapDestinations API client.
    The appliance has the ability to forward events received from monitored or managed server hardware to the specified destinations as SNMPv3 traps.
    """
    URI = '/rest/appliance/snmpv3-trap-forwarding/destinations'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def create(self, resource, timeout=-1):
        """
        Adds the specified trap forwarding destination.
        The trap destination associated with the specified id will be created if trap destination with that id does not exists.
        The id can only be an integer greater than 0.

        Args:
            resource (dict): Object to create.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Created resource.

        """
        return self._client.create(resource, timeout=timeout)

    def get(self, id_or_uri):
        """
        Returns the SNMPv3 trap forwarding destination with the specified ID, if it exists.

        Args:
            id_or_uri: ID or URI of SNMPv3 trap destination.

        Returns:
            dict: Appliance SNMPv3 trap destination.
        """
        return self._client.get(id_or_uri)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Retrieves all SNMPv3 trap forwarding destinations.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.

                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of SNMPv3 Trap Destionations.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get_by(self, field, value):
        """
        Gets all SNMPv3 trap forwarding destinations that match the filter.
        The search is case-insensitive.

        Args:
            field: field name to filter
            value: value to filter

        Returns:
            list: A list of SNMPv3 Trap Destionations.
        """
        return self._client.get_by(field, value)

    def delete(self, id_or_uri, timeout=-1):
        """
        Deletes SNMPv3 trap forwarding destination based on {Id} only if no User is assigned to it.

        Args:
            id_or_uri: dict object to delete
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully deleted.

        """
        return self._client.delete(id_or_uri, timeout=timeout)

    def update(self, resource, timeout=-1):
        """
        Updates SNMPv3 trap forwarding destination based on Id.

        Args:
            resource: dict object with changes.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Updated appliance SNMPv3 trap destinations.
        """
        return self._client.update(resource, timeout=timeout)
Ejemplo n.º 18
0
class Fabrics(object):
    """
    Fabrics API client.

    """
    URI = '/rest/fabrics'

    DEFAULT_VALUES = {
        '300': {
            'type': 'vlan-pool'
        },
        '500': {
            'type': 'vlan-pool'
        }
    }

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a paginated collection of all fabrics based on the specified parameters.

        Filters can be used in the URL to control the number of fabrics that are returned.
        With no filters specified, the API returns all supported fabrics.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of fabrics.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get(self, id_or_uri):
        """
        Gets the fabric with the specified ID.

        Args:
            id_or_uri: ID or URI of fabric.

        Returns:
            dict: The fabric.
        """
        return self._client.get(id_or_uri)

    def get_by(self, field, value):
        """
        Gets all fabrics that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of fabrics.
        """
        return self._client.get_by(field, value)

    def get_reserved_vlan_range(self, id_or_uri):
        """
        Gets the reserved vlan ID range for the fabric.

        Note:
            This method is only available on HPE Synergy.

        Args:
            id_or_uri: ID or URI of fabric.

        Returns:
            dict: vlan-pool
        """
        uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range"
        return self._client.get(uri)

    def update_reserved_vlan_range(self, id_or_uri, vlan_pool, force=False):
        """
        Updates the reserved vlan ID range for the fabric.

        Note:
            This method is only available on HPE Synergy.

        Args:
            id_or_uri: ID or URI of fabric.
            vlan_pool (dict): vlan-pool data to update.
            force:  If set to true, the operation completes despite any problems with network connectivity or errors
                on the resource itself. The default is false.

        Returns:
            dict: The fabric
        """
        uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range"
        return self._client.update(resource=vlan_pool,
                                   uri=uri,
                                   force=force,
                                   default_values=self.DEFAULT_VALUES)
Ejemplo n.º 19
0
class Backups(object):
    """
    Backups API client.
    """

    URI = '/rest/backups'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get_all(self):
        """
        Retrieves the details for any current appliance backup. Only one backup file is present on the appliance at any
        time.

        Returns:
            list: A list of Backups.
        """
        return self._client.get_collection(self.URI)

    def get(self, id_or_uri):
        """
        Gets the details of the specified backup.

        Args:
            id_or_uri: ID or URI of the backup

        Returns:
            dict: Details of the specified backup.
        """
        return self._client.get(id_or_uri)

    def create(self, timeout=-1):
        """
        Starts backing up the appliance. After completion, the backup file must be downloaded and saved off-appliance.
        Appliance backups can be started at any time, and do not require any special setup to prepare the appliance for
        the backup.

        Args:
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Details of the created backup.

        """
        return self._client.create_with_zero_body(timeout=timeout)

    def download(self, id_or_uri, file_path):
        """
        Downloads a backup archive previously created on the appliance. Uploaded backup files cannot be downloaded.

        Args:
            id_or_uri: ID or URI of the Artifact Bundle.
            file_path(str): Destination file path.

        Returns:
            bool: Successfully downloaded.
        """
        return self._client.download(id_or_uri, file_path)

    def upload(self, file_path):
        """
        Uploads an appliance backup file in preparation of a restore. Any existing backup on the appliance is removed.

        After the backup file is uploaded and validated, its details are returned. The URI of the backup can be used to
        start a restore.

        Args:
            file_path (str): The local backup filepath

        Returns:
            dict: Details of the uploaded backup.
        """
        return self._client.upload(file_path, self.URI + '/archive')

    def get_config(self):
        """
        Retrieves the details of the backup configuration for the remote server and automatic backup schedule.

        Args:
            id_or_uri: ID or URI of the backup

        Returns:
            dict: Details of the backup configuration for the remote server and automatic backup schedule.
        """
        return self._client.get('config')

    def update_config(self, config, timeout=-1):
        """
        Updates the remote server configuration and the automatic backup schedule for backup.

        Args:
            config (dict): Object to update.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Backup details.

        """
        return self._client.update(config,
                                   uri=self.URI + "/config",
                                   timeout=timeout)

    def update_remote_archive(self, save_uri, timeout=-1):
        """
        Saves a backup of the appliance to a previously-configured remote location.

        Args:
            save_uri (dict): The URI for saving the backup to a previously configured location.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Backup details.

        """
        return self._client.update_with_zero_body(uri=save_uri,
                                                  timeout=timeout)
Ejemplo n.º 20
0
class BuildPlans(object):
    URI = '/rest/build-plans'

    DEFAULT_VALUES = {
        '300': {
            'type': 'OeBuildPlan'
        },
        '500': {
            'type': 'OeBuildPlanV5'
        },
        '600': {
            'type': 'OeBuildPlanV5'
        }
    }

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a list of OS Build Plan resources based on optional sorting and filtering, and constrained by start and
        count parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of OS Build Plan.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get_by(self, field, value):
        """
        Gets all OS Build Plans that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of OS Build Plans.
        """
        return self._client.get_by(field, value)

    def get(self, id_or_uri):
        """
        Retrieves a specific OS Build Plan resource based on the ID or URI provided.

        Args:
            id_or_uri: ID or URI of the Build Plan.

        Returns:
            dict: The OS Build Plan.
        """
        return self._client.get(id_or_uri)

    def create(self, resource, timeout=-1):
        """
        Creates an OS Build Plan using the information provided. The OS Build Plan can be one of the following types -
        Deploy or Capture.

        Args:
            resource (dict): Object to create.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView, it just stops waiting for its completion.

        Returns:
            dict: Created OS Build Plan.

        """
        return self._client.create(resource,
                                   timeout=timeout,
                                   default_values=self.DEFAULT_VALUES)

    def update(self, resource, timeout=-1):
        """
        Updates the properties of the OS Build Plan.

        Args:
            resource (dict): Object to update.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView, it just stops waiting for its completion.

        Returns:
            dict: Updated OS Build Plan.

        """
        return self._client.update(resource, timeout=timeout)

    def delete(self, resource, force=False, timeout=-1):
        """
        Deletes an OS Build Plan resource.

        Args:
            resource: dict object to delete
            force:
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully deleted.

        """
        return self._client.delete(resource, force=force, timeout=timeout)
Ejemplo n.º 21
0
class UnmanagedDevices(object):
    URI = '/rest/unmanaged-devices'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', query='', sort=''):
        """
        Gets a set of unmanaged device resources according to the specified parameters. Filters can be used to get a
        specific set of unmanaged devices. With no filters specified, the API returns a potentially paginated list of
        all the unmanaged device resources subject to start/count/sort parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            query:
                 A general query string to narrow the list of resources returned. The default
                 is no query - all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
             list: Unmanaged Devices
        """
        return self._client.get_all(start, count, filter=filter, sort=sort, query=query)

    def get(self, id_or_uri):
        """
        Gets a single Unmanaged Device resource based upon its uri or id.

        Args:
            id_or_uri:
                Can be either the Unmanaged Device id or the uri

        Returns:
            dict: The Unmanaged Device
        """
        return self._client.get(id_or_uri)

    def add(self, information, timeout=-1):
        """
        Adds an unmanaged device resource based upon the attributes specified. Use this method to create an unmanaged
        device to represent resources that consume space within a rack, or consume power from a power delivery device
        but cannot otherwise be represented by the management appliance.

        Args:
            information:
                Unmanaged Device information
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: Added Unmanaged Device
        """
        return self._client.create(information, timeout=timeout)

    def remove(self, resource, force=False, timeout=-1):
        """
        Deletes the resource specified.

        Args:
            resource:
                 Dict object to remove
            force:
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                 Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                 in OneView; it just stops waiting for its completion.

        Returns:
             bool: operation success
        """
        return self._client.delete(resource, force=force, timeout=timeout)

    def remove_all(self, filter, force=False, timeout=-1):
        """
        Deletes the set of unmanaged-devices according to the specified parameters. A filter is required to identify
        the set of resources to be deleted.

        Args:
            filter:
                 A general filter/query string to narrow the list of items that will be removed.
            force:
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                 Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                 in OneView; it just stops waiting for its completion.

        Returns:
             bool: operation success
        """
        return self._client.delete_all(filter=filter, force=force, timeout=timeout)

    def update(self, resource, timeout=-1):
        """
        Updates the resource for the specified. The properties that are omitted (not included as part of the the
        request body) are reset to their respective default values. The id and uuid properties are required and cannot
        be changed.

        Args:
            resource (dict): Object to update
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: Updated Unmanaged Devices
        """
        return self._client.update(resource, timeout=timeout)

    def get_environmental_configuration(self, id_or_uri):
        """
        Returns a description of the environmental configuration (supported feature set, calibrated minimum & maximum
        power, location & dimensions, ...) of the resource.

        Args:
            id_or_uri:
                Can be either the Unmanaged Device id or the uri

        Returns:
            dict:
                EnvironmentalConfiguration
        """
        uri = self._client.build_uri(id_or_uri) + "/environmentalConfiguration"
        return self._client.get(uri)

    def get_by(self, field, value):
        """
        Gets all Unmanaged Devices that match the filter
        The search is case-insensitive

        Args:
            field: field name to filter
            value: value to filter

        Returns:
            dict: Unmanaged Devices
        """
        return self._client.get_by(field, value)
Ejemplo n.º 22
0
 def __init__(self, con):
     self._connection = con
     self._client = ResourceClient(con, self.URI)
     self._provider_client = ResourceClient(con, self.PROVIDER_URI)
Ejemplo n.º 23
0
class ApplianceDeviceSNMPv3Users(object):
    """
    ApplianceDeviceSNMPv3Users API client [Available only since API 600].

    As part of SNMPv3 trap forwarding support, the appliance provides APIs for creating User-based Security Model (USM) and forwarding destinations.
    The following protocols are supported while defining USM.

    Authentication protocols: MD5 / SHA1 / SHA256 / SHA384 / SHA512
    Privacy protocols: AES / DES
    The security levels supported while defining USM are None, Authentication only and both Authentication and Privacy.

    """
    URI = '/rest/appliance/snmpv3-trap-forwarding/users'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def create(self, resource, timeout=-1):
        """
        Creates a new SNMPv3 user.
        This user will be used for sending the SNMPv3 trap to the associated destinations.
        One user can be assigned to multiple destinations.

        Args:
            resource (dict): Object to create.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Created resource.

        """
        return self._client.create(resource, timeout=timeout)

    def get(self, id_or_uri):
        """
        Returns the SNMPv3 user with the specified ID, if it exists.

        Args:
            id_or_uri: ID or URI of SNMPv3 user.

        Returns:
            dict: Appliance SNMPv3 user.
        """
        return self._client.get(id_or_uri)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Lists all SNMPv3 Users.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.

                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of SNMPv3 Users.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get_by(self, field, value):
        """
        Gets all SNMPv3 users that match the filter.
        The search is case-insensitive.

        Args:
            field: field name to filter
            value: value to filter

        Returns:
            list: A list of SNMPv3 Users.
        """
        return self._client.get_by(field, value)

    def delete_all(self, filter=None, timeout=-1):
        """
        Delete an SNMPv3 User based on User name specified in filter. The user will be deleted only if it has no associated destinations.

        Args:
            username: ID or URI of SNMPv3 user.
            filter: A general filter/query string to narrow the list of items returned.
                    The default is no filter - all resources are returned.

        Returns:
            bool: Indicates if the resource was successfully deleted.
        """
        return self._client.delete_all(filter=filter, timeout=timeout)

    def delete(self, id_or_uri, timeout=-1):
        """
        Delete an SNMPv3 User based on User Id specified in {Id}.
        The user will be deleted only if it has no associated destinations.

        Args:
            id_or_uri: dict object to delete
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            bool: Indicates if the resource was successfully deleted.

        """
        return self._client.delete(id_or_uri, timeout=timeout)

    def update(self, resource, timeout=-1):
        """
        Updates SNMPv3 User based on User Id as specified in {Id}

        Args:
            resource: dict object with changes.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Updated appliance SNMPv3 user.
        """
        return self._client.update(resource, timeout=timeout)
Ejemplo n.º 24
0
class Datacenters(object):
    """
    Datacenters API client.

    """
    URI = '/rest/datacenters'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', query='', sort=''):
        """
        Gets a set of data center resources according to the specified parameters. Filters can be used to get a specific
        set of data centers.

        Args:
            start:
                The first item to return, using 0-based indexing.

                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            query:
                 A general query string to narrow the list of resources returned. The default
                 is no query - all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: List of data centers.
        """
        return self._client.get_all(start,
                                    count,
                                    filter=filter,
                                    sort=sort,
                                    query=query)

    def get(self, id_or_uri):
        """
        Gets a single data center resource based upon its ID or URI.

        Args:
            id_or_uri:
                Can be either the data center id or the data center uri.

        Returns:
            dict: The data center.
        """
        return self._client.get(id_or_uri)

    def get_visual_content(self, id_or_uri):
        """
        Gets a list of visual content objects describing each rack within the data center. The response aggregates data
        center and rack data with a specified metric (peak24HourTemp) to provide simplified access to display data for
        the data center.

        Args:
            id_or_uri: Can be either the resource ID or the resource URI.

        Return:
            list: List of visual content objects.
        """
        uri = self._client.build_uri(id_or_uri) + "/visualContent"
        return self._client.get(uri)

    def get_by(self, field, value):
        """
        Gets all data centers that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: List of data centers.

        """
        return self._client.get_by(field, value)

    def remove(self, resource, force=False, timeout=-1):
        """
        Deletes the resource specified.

        Args:
            resource (dict): Object to remove.
            force:
                 If set to true, the operation completes despite any problems with network connectivity or errors on the
                 resource itself. The default is false.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns: Result status.
        """
        return self._client.delete(resource, force=force, timeout=timeout)

    def add(self, information, timeout=-1):
        """
        Adds a data center resource based upon the attributes specified.

        Args:
            information: Data center information
            timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: Added data center.
        """
        return self._client.create(information, timeout=timeout)

    def update(self, resource, timeout=-1):
        """
        Updates the specified data center resource.

        Args:
            resource (dict): Object to update.
            timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: Updated data center.
        """
        return self._client.update(resource, timeout=timeout)

    def remove_all(self, filter, force=False, timeout=-1):
        """
        Deletes the set of datacenters according to the specified parameters. A filter is required to identify the set
        of resources to be deleted.

        Args:
            filter:
                 A general filter/query string to narrow the list of items that will be removed.
            force:
                 If set to true, the operation completes despite any problems with
                 network connectivity or errors on the resource itself. The default is false.
            timeout:
                 Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                 in OneView; it just stops waiting for its completion.

        Returns:
             bool: operation success
        """
        return self._client.delete_all(filter=filter,
                                       force=force,
                                       timeout=timeout)
class SasLogicalJbodAttachments(object):
    """
    SAS Logical JBOD Attachments API client.

    Note:
        This resource is only available on HPE Synergy

    """
    URI = '/rest/sas-logical-jbod-attachments'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a paginated collection of SAS Logical JBOD Attachments. The collection is based on optional
        sorting and filtering and is constrained by start and count parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of SAS Logical JBOD Attachments.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get(self, id_or_uri):
        """
        Gets the SAS Logical JBOD Attachment with the specified ID or URI.

        Args:
            id_or_uri: ID or URI of the SAS Logical JBOD Attachment.

        Returns:
            dict: SAS Logical JBOD Attachment
        """
        return self._client.get(id_or_uri)

    def get_by(self, field, value):
        """
        Gets all SAS Logical JBOD Attachments that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of SAS Logical JBOD Attachments.
        """
        return self._client.get_by(field, value)
class DeploymentGroups(object):

    URI = '/rest/deployment-groups'

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a list of the Deployment Group based on optional sorting and filtering, and constrained by start and count
        parameters.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.

                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of Deployment Group.
        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get(self, id_or_uri):
        """
        Retrieves the overview details of the selected Deployment Group as per the selected attributes.

        Args:
            id_or_uri: ID or URI of the Deployment Group.

        Returns:
            dict: The Deployment Group.
        """
        return self._client.get(id_or_uri)

    def get_by(self, field, value):
        """
        Gets all Deployment Groups that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of Deployment Group.
        """
        return self._client.get_by(field, value)

    def get_by_name(self, name):
        """
        Gets a Deployment Group by name.

        Args:
            name: Name of the Deployment Group.

        Returns:
            dict: The Deployment Group.
        """
        return self._client.get_by_name(name)
Ejemplo n.º 27
0
class CertificateRabbitMQ(object):
    URI = '/rest/certificates/client/rabbitmq'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def generate(self, information, timeout=-1):
        """
        Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients.

        Args:
            information (dict): Information to generate the certificate for RabbitMQ clients.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView; it just stops waiting for its completion.

        Returns:
            dict: RabbitMQ certificate generated
        """
        return self._client.create(information, timeout=timeout)

    def get(self, alias_name):
        """
        Retrieves the base-64 encoded certificate associated with the RabbitMQ user.

        Args:
            alias_name: Key pair associated with the RabbitMQ

        Returns:
            dict: RabbitMQ certificate
        """
        return self._client.get(alias_name)

    def get_key_pair(self, alias_name):
        """
        Retrieves the public and private key pair associated with the specified alias name.

        Args:
            alias_name: Key pair associated with the RabbitMQ

        Returns:
            dict: RabbitMQ certificate
        """
        uri = self.URI + "/keypair/" + alias_name
        return self._client.get(uri)

    def get_keys(self, alias_name, key_format):
        """
        Retrieves the contents of PKCS12 file in the format specified.
        This PKCS12 formatted file contains both the certificate as well as the key file data.
        Valid key formats are Base64 and PKCS12.

        Args:
            alias_name: Key pair associated with the RabbitMQ
            key_format: Valid key formats are Base64 and PKCS12.
        Returns:
            dict: RabbitMQ certificate
        """
        uri = self.URI + "/keys/" + alias_name + "?format=" + key_format
        return self._client.get(uri)
Ejemplo n.º 28
0
class Events(object):
    URI = '/rest/events'

    DEFAULT_VALUES = {
        '200': {"type": "EventResourceV3"},
        '300': {"type": "EventResourceV3"}
    }

    def __init__(self, con):
        self._client = ResourceClient(con, self.URI)

    def get(self, id_or_uri):
        """
        Retrieve an event by its URI or ID.

        Args:
            id_or_uri: event ID or URI.

        Returns:
            dict: The event.

        """

        event = self._client.get(id_or_uri)
        return event

    def get_all(self, start=0, count=-1, filter='', query='', sort='', view=''):
        """
        Gets all the events based upon filters provided.

        Args:
            start:
                 The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the
                 first available item.
            count:
                The number of resources to return. A count of -1 requests all items. The actual number of items in
                the response may differ from the requested count if the sum of start and count exceed the total number
                of items.
            filter (list or str):
                 A general filter/query string to narrow the list of items returned. The default is no filter; all
                 resources are returned.
            query:
                 A general query string to narrow the list of resources returned. The default is no query (all
                 resources are returned).
            sort:
                The sort order of the returned data set. By default, the sort order is based on create time, with the
                oldest entry first.
            view:
                 Returns a specific subset of the attributes of the resource or collection, by specifying the name of a
                 predefined view. The default view is expand (show all attributes of the resource and all elements of
                 collections of resources).

        Returns:
            list: A list of events.
        """
        return self._client.get_all(start=start, count=count, filter=filter, query=query, sort=sort, view=view)

    def get_by(self, field, value):
        """
        Gets all events that match the filter.

        The search is case-insensitive.

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: List of events.

        """
        return self._client.get_by(field, value)

    def create(self, resource, timeout=-1):
        """
        Creates an Event.

        Args:
            resource (dict): Object to create.
            timeout:
                Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
                in OneView, just stop waiting for its completion.

        Returns:
            dict: Created resource.

        """
        return self._client.create(resource, timeout=timeout, default_values=self.DEFAULT_VALUES)
Ejemplo n.º 29
0
 def __init__(self, con):
     self._connection = con
     self._client = ResourceClient(con, self.URI)
Ejemplo n.º 30
0
class InterconnectLinkTopologies(object):
    """
    Interconnect Link Topologies API client.

    Note:
        This resource is only available on HPE Synergy.

    """

    URI = '/rest/interconnect-link-topologies'

    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, self.URI)

    def get_all(self, start=0, count=-1, filter='', sort=''):
        """
        Gets a paginated collection of all the interconnect link topologies based on the specified parameters.

        Filters can be used in the URL to control the number of interconnect link topologies that are returned.
        With no filters specified, the API returns all interconnect link toplogies.

        Args:
            start:
                The first item to return, using 0-based indexing.
                If not specified, the default is 0 - start with the first available item.
            count:
                The number of resources to return. A count of -1 requests all items.
                The actual number of items in the response might differ from the requested
                count if the sum of start and count exceeds the total number of items.
            filter (list or str):
                A general filter/query string to narrow the list of items returned. The
                default is no filter; all resources are returned.
            sort:
                The sort order of the returned data set. By default, the sort order is based
                on create time with the oldest entry first.

        Returns:
            list: A list of interconnect link topologies.

        """
        return self._client.get_all(start, count, filter=filter, sort=sort)

    def get(self, id_or_uri):
        """
        Gets an interconnect link topology by ID or by URI.

        Args:
            id_or_uri: Can be either the interconnect type id or the interconnect type uri.

        Returns:
            dict: The interconnect link topology.
        """
        return self._client.get(id_or_uri)

    def get_by(self, field, value):
        """
        Gets all interconnect link topologies that match the filter.
        The search is case-insensitive

        Args:
            field: Field name to filter.
            value: Value to filter.

        Returns:
            list: A list of interconnect link topologies.
        """
        return self._client.get_by(field, value)