How to use the zhmcclient._resource.BaseResource function in zhmcclient

To help you get started, we’ve selected a few zhmcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhmcclient / python-zhmcclient / zhmcclient / _user.py View on Github external
:exc:`~zhmcclient.ConnectionError`
        """
        result = self.session.post(self.console.uri + '/users',
                                   body=properties)
        # There should not be overlaps, but just in case there are, the
        # returned props should overwrite the input props:
        props = copy.deepcopy(properties)
        props.update(result)
        name = props.get(self._name_prop, None)
        uri = props[self._uri_prop]
        user = User(self, uri, name, props)
        self._name_uri_cache.update(name, uri)
        return user


class User(BaseResource):
    """
    Representation of a :term:`User`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.UserManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.UserManager`):
        #     Manager object for this resource object.
        #   uri (string):
github zhmcclient / python-zhmcclient / zhmcclient / _storage_volume.py View on Github external
email_insert)

        result = self.session.post(
            self.storage_group.uri + '/operations/modify',
            body=body)
        uri = result['element-uris'][0]

        storage_volume = self.resource_object(uri, properties)

        # The name is not guaranteed to be unique, so we don't maintain
        # a name-to-uri cache for storage volumes.

        return storage_volume


class StorageVolume(BaseResource):
    """
    Representation of a :term:`storage volume`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.StorageVolumeManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.StorageVolumeManager`):
        #     Manager object for this resource object.
        #   uri (string):
github zhmcclient / python-zhmcclient / zhmcclient / _port.py View on Github external
resource_obj = self.resource_class(
                manager=self,
                uri=uri,
                name=None,
                properties=None)

            if self._matches_filters(resource_obj, filter_args):
                resource_obj_list.append(resource_obj)
                if full_properties:
                    resource_obj.pull_full_properties()

        self._name_uri_cache.update_from(resource_obj_list)
        return resource_obj_list


class Port(BaseResource):
    """
    Representation of a :term:`Port`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    For the properties of a Port, see section
    'Data model - Port Element Object' in section 'Adapter object' in the
    :term:`HMC API` book.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.PortManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
github zhmcclient / python-zhmcclient / zhmcclient / _partition.py View on Github external
:exc:`~zhmcclient.ConnectionError`
        """
        result = self.session.post(self.cpc.uri + '/partitions',
                                   body=properties)
        # There should not be overlaps, but just in case there are, the
        # returned props should overwrite the input props:
        props = copy.deepcopy(properties)
        props.update(result)
        name = props.get(self._name_prop, None)
        uri = props[self._uri_prop]
        part = Partition(self, uri, name, props)
        self._name_uri_cache.update(name, uri)
        return part


class Partition(BaseResource):
    """
    Representation of a :term:`Partition`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.PartitionManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.PartitionManager`):
        #     Manager object for this resource object.
        #   uri (string):
github zhmcclient / python-zhmcclient / zhmcclient / _unmanaged_cpc.py View on Github external
for props in props_list:

                    resource_obj = self.resource_class(
                        manager=self,
                        uri=props[self._uri_prop],
                        name=props.get(self._name_prop, None),
                        properties=props)

                    if self._matches_filters(resource_obj, client_filters):
                        resource_obj_list.append(resource_obj)

        self._name_uri_cache.update_from(resource_obj_list)
        return resource_obj_list


class UnmanagedCpc(BaseResource):
    """
    Representation of an unmanaged :term:`CPC`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.UnmanagedCpcManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.UnmanagedCpcManager`):
        #     Manager object for this resource object.
        #   uri (string):
github zhmcclient / python-zhmcclient / zhmcclient / _hba.py View on Github external
:exc:`~zhmcclient.ConnectionError`
        """
        result = self.session.post(self.partition.uri + '/hbas',
                                   body=properties)
        # There should not be overlaps, but just in case there are, the
        # returned props should overwrite the input props:
        props = copy.deepcopy(properties)
        props.update(result)
        name = props.get(self._name_prop, None)
        uri = props[self._uri_prop]
        hba = Hba(self, uri, name, props)
        self._name_uri_cache.update(name, uri)
        return hba


class Hba(BaseResource):
    """
    Representation of an :term:`HBA`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    For the properties of an HBA resource, see section
    'Data model - HBA Element Object' in section 'Partition object' in the
    :term:`HMC API` book.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.HbaManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
github zhmcclient / python-zhmcclient / zhmcclient / _cpc.py View on Github external
resource_obj = self.resource_class(
                        manager=self,
                        uri=props[self._uri_prop],
                        name=props.get(self._name_prop, None),
                        properties=props)

                    if self._matches_filters(resource_obj, client_filters):
                        resource_obj_list.append(resource_obj)
                        if full_properties:
                            resource_obj.pull_full_properties()

        self._name_uri_cache.update_from(resource_obj_list)
        return resource_obj_list


class Cpc(BaseResource):
    """
    Representation of a managed :term:`CPC`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.CpcManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.CpcManager`):
        #     Manager object for this resource object.
        #   uri (string):
github zhmcclient / python-zhmcclient / zhmcclient / _adapter.py View on Github external
:exc:`~zhmcclient.AuthError`
          :exc:`~zhmcclient.ConnectionError`
        """
        result = self.session.post(self.cpc.uri + '/adapters', body=properties)
        # There should not be overlaps, but just in case there are, the
        # returned props should overwrite the input props:
        props = copy.deepcopy(properties)
        props.update(result)
        name = props.get(self._name_prop, None)
        uri = props[self._uri_prop]
        adapter = Adapter(self, uri, name, props)
        self._name_uri_cache.update(name, uri)
        return adapter


class Adapter(BaseResource):
    """
    Representation of an :term:`Adapter`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    For the properties of an Adapter, see section 'Data model' in section
    'Adapter object' in the :term:`HMC API` book.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.AdapterManager`).
    """

    # Name of property for port URIs, dependent on adapter family
    port_uris_prop_by_family = {
github zhmcclient / python-zhmcclient / zhmcclient / _metrics.py View on Github external
:exc:`~zhmcclient.AuthError`
          :exc:`~zhmcclient.ConnectionError`
        """
        result = self.session.post('/api/services/metrics/context',
                                   body=properties)
        mc_properties = properties.copy()
        mc_properties.update(result)
        new_metrics_context = MetricsContext(self,
                                             result['metrics-context-uri'],
                                             None,
                                             mc_properties)
        self._metrics_contexts.append(new_metrics_context)
        return new_metrics_context


class MetricsContext(BaseResource):
    """
    Representation of a :term:`Metrics Context` resource.

    A :term:`Metrics Context` resource specifies a list of metrics groups for
    which the current metric values can be retrieved using the
    :meth:`~zhmcclient.MetricsContext.get_metrics` method.

    The properties of this resource are the response fields described for the
    'Create Metrics Context' operation in the :term:`HMC API` book.

    This class is derived from :class:`~zhmcclient.BaseResource`; see there
    for common methods and attributes.

    Objects of this class can be created by the user with the
    :meth:`zhmcclient.MetricsContextManager.create` method.
    """
github zhmcclient / python-zhmcclient / zhmcclient / _storage_group.py View on Github external
if template is not None:
            properties['template-uri'] = template.uri

        result = self.session.post(self._base_uri, body=properties)
        # There should not be overlaps, but just in case there are, the
        # returned props should overwrite the input props:
        props = copy.deepcopy(properties)
        props.update(result)
        name = props.get(self._name_prop, None)
        uri = props[self._uri_prop]
        storage_group = StorageGroup(self, uri, name, props)
        self._name_uri_cache.update(name, uri)
        return storage_group


class StorageGroup(BaseResource):
    """
    Representation of a :term:`storage group`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
    methods and attributes.

    Objects of this class are not directly created by the user; they are
    returned from creation or list functions on their manager object
    (in this case, :class:`~zhmcclient.StorageGroupManager`).
    """

    def __init__(self, manager, uri, name=None, properties=None):
        # This function should not go into the docs.
        #   manager (:class:`~zhmcclient.StorageGroupManager`):
        #     Manager object for this resource object.
        #   uri (string):