File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/models.tar
Back
secrets.py 0000644 00000003465 15027745625 0006613 0 ustar 00 from ..api import APIClient from .resource import Collection, Model class Secret(Model): """A secret.""" id_attribute = 'ID' def __repr__(self): return f"<{self.__class__.__name__}: '{self.name}'>" @property def name(self): return self.attrs['Spec']['Name'] def remove(self): """ Remove this secret. Raises: :py:class:`docker.errors.APIError` If secret failed to remove. """ return self.client.api.remove_secret(self.id) class SecretCollection(Collection): """Secrets on the Docker server.""" model = Secret def create(self, **kwargs): obj = self.client.api.create_secret(**kwargs) obj.setdefault("Spec", {})["Name"] = kwargs.get("name") return self.prepare_model(obj) create.__doc__ = APIClient.create_secret.__doc__ def get(self, secret_id): """ Get a secret. Args: secret_id (str): Secret ID. Returns: (:py:class:`Secret`): The secret. Raises: :py:class:`docker.errors.NotFound` If the secret does not exist. :py:class:`docker.errors.APIError` If the server returns an error. """ return self.prepare_model(self.client.api.inspect_secret(secret_id)) def list(self, **kwargs): """ List secrets. Similar to the ``docker secret ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Secret`): The secrets. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ resp = self.client.api.secrets(**kwargs) return [self.prepare_model(obj) for obj in resp] swarm.py 0000644 00000020142 15027745625 0006263 0 ustar 00 from docker.api import APIClient from docker.errors import APIError from .resource import Model class Swarm(Model): """ The server's Swarm state. This a singleton that must be reloaded to get the current state of the Swarm. """ id_attribute = 'ID' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if self.client: try: self.reload() except APIError as e: # FIXME: https://github.com/docker/docker/issues/29192 if e.response.status_code not in (406, 503): raise @property def version(self): """ The version number of the swarm. If this is not the same as the server, the :py:meth:`update` function will not work and you will need to call :py:meth:`reload` before calling it again. """ return self.attrs.get('Version').get('Index') def get_unlock_key(self): return self.client.api.get_unlock_key() get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__ def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377', force_new_cluster=False, default_addr_pool=None, subnet_size=None, data_path_addr=None, data_path_port=None, **kwargs): """ Initialize a new swarm on this Engine. Args: advertise_addr (str): Externally reachable address advertised to other nodes. This can either be an address/port combination in the form ``192.168.1.1:4567``, or an interface followed by a port number, like ``eth0:4567``. If the port number is omitted, the port number from the listen address is used. If not specified, it will be automatically detected when possible. listen_addr (str): Listen address used for inter-manager communication, as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP). This can either be an address/port combination in the form ``192.168.1.1:4567``, or an interface followed by a port number, like ``eth0:4567``. If the port number is omitted, the default swarm listening port is used. Default: ``0.0.0.0:2377`` force_new_cluster (bool): Force creating a new Swarm, even if already part of one. Default: False default_addr_pool (list of str): Default Address Pool specifies default subnet pools for global scope networks. Each pool should be specified as a CIDR block, like '10.0.0.0/8'. Default: None subnet_size (int): SubnetSize specifies the subnet size of the networks created from the default subnet pool. Default: None data_path_addr (string): Address or interface to use for data path traffic. For example, 192.168.1.1, or an interface, like eth0. data_path_port (int): Port number to use for data path traffic. Acceptable port range is 1024 to 49151. If set to ``None`` or 0, the default port 4789 will be used. Default: None task_history_retention_limit (int): Maximum number of tasks history stored. snapshot_interval (int): Number of logs entries between snapshot. keep_old_snapshots (int): Number of snapshots to keep beyond the current snapshot. log_entries_for_slow_followers (int): Number of log entries to keep around to sync up slow followers after a snapshot is created. heartbeat_tick (int): Amount of ticks (in seconds) between each heartbeat. election_tick (int): Amount of ticks (in seconds) needed without a leader to trigger a new election. dispatcher_heartbeat_period (int): The delay for an agent to send a heartbeat to the dispatcher. node_cert_expiry (int): Automatic expiry for nodes certificates. external_ca (dict): Configuration for forwarding signing requests to an external certificate authority. Use ``docker.types.SwarmExternalCA``. name (string): Swarm's name labels (dict): User-defined key/value metadata. signing_ca_cert (str): The desired signing CA certificate for all swarm node TLS leaf certificates, in PEM format. signing_ca_key (str): The desired signing CA key for all swarm node TLS leaf certificates, in PEM format. ca_force_rotate (int): An integer whose purpose is to force swarm to generate a new signing CA certificate and key, if none have been specified. autolock_managers (boolean): If set, generate a key and use it to lock data stored on the managers. log_driver (DriverConfig): The default log driver to use for tasks created in the orchestrator. Returns: (str): The ID of the created node. Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> client.swarm.init( advertise_addr='eth0', listen_addr='0.0.0.0:5000', force_new_cluster=False, default_addr_pool=['10.20.0.0/16], subnet_size=24, snapshot_interval=5000, log_entries_for_slow_followers=1200 ) """ init_kwargs = { 'advertise_addr': advertise_addr, 'listen_addr': listen_addr, 'force_new_cluster': force_new_cluster, 'default_addr_pool': default_addr_pool, 'subnet_size': subnet_size, 'data_path_addr': data_path_addr, 'data_path_port': data_path_port, } init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs) node_id = self.client.api.init_swarm(**init_kwargs) self.reload() return node_id def join(self, *args, **kwargs): return self.client.api.join_swarm(*args, **kwargs) join.__doc__ = APIClient.join_swarm.__doc__ def leave(self, *args, **kwargs): return self.client.api.leave_swarm(*args, **kwargs) leave.__doc__ = APIClient.leave_swarm.__doc__ def reload(self): """ Inspect the swarm on the server and store the response in :py:attr:`attrs`. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ self.attrs = self.client.api.inspect_swarm() def unlock(self, key): return self.client.api.unlock_swarm(key) unlock.__doc__ = APIClient.unlock_swarm.__doc__ def update(self, rotate_worker_token=False, rotate_manager_token=False, rotate_manager_unlock_key=False, **kwargs): """ Update the swarm's configuration. It takes the same arguments as :py:meth:`init`, except ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``. In addition, it takes these arguments: Args: rotate_worker_token (bool): Rotate the worker join token. Default: ``False``. rotate_manager_token (bool): Rotate the manager join token. Default: ``False``. rotate_manager_unlock_key (bool): Rotate the manager unlock key. Default: ``False``. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ # this seems to have to be set if kwargs.get('node_cert_expiry') is None: kwargs['node_cert_expiry'] = 7776000000000000 return self.client.api.update_swarm( version=self.version, swarm_spec=self.client.api.create_swarm_spec(**kwargs), rotate_worker_token=rotate_worker_token, rotate_manager_token=rotate_manager_token, rotate_manager_unlock_key=rotate_manager_unlock_key ) volumes.py 0000644 00000005440 15027745625 0006630 0 ustar 00 from ..api import APIClient from .resource import Collection, Model class Volume(Model): """A volume.""" id_attribute = 'Name' @property def name(self): """The name of the volume.""" return self.attrs['Name'] def remove(self, force=False): """ Remove this volume. Args: force (bool): Force removal of volumes that were already removed out of band by the volume driver plugin. Raises: :py:class:`docker.errors.APIError` If volume failed to remove. """ return self.client.api.remove_volume(self.id, force=force) class VolumeCollection(Collection): """Volumes on the Docker server.""" model = Volume def create(self, name=None, **kwargs): """ Create a volume. Args: name (str): Name of the volume. If not specified, the engine generates a name. driver (str): Name of the driver used to create the volume driver_opts (dict): Driver options as a key-value dictionary labels (dict): Labels to set on the volume Returns: (:py:class:`Volume`): The volume created. Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> volume = client.volumes.create(name='foobar', driver='local', driver_opts={'foo': 'bar', 'baz': 'false'}, labels={"key": "value"}) """ obj = self.client.api.create_volume(name, **kwargs) return self.prepare_model(obj) def get(self, volume_id): """ Get a volume. Args: volume_id (str): Volume name. Returns: (:py:class:`Volume`): The volume. Raises: :py:class:`docker.errors.NotFound` If the volume does not exist. :py:class:`docker.errors.APIError` If the server returns an error. """ return self.prepare_model(self.client.api.inspect_volume(volume_id)) def list(self, **kwargs): """ List volumes. Similar to the ``docker volume ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Volume`): The volumes. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ resp = self.client.api.volumes(**kwargs) if not resp.get('Volumes'): return [] return [self.prepare_model(obj) for obj in resp['Volumes']] def prune(self, filters=None): return self.client.api.prune_volumes(filters=filters) prune.__doc__ = APIClient.prune_volumes.__doc__ __pycache__/nodes.cpython-310.pyc 0000644 00000007263 15027745625 0012612 0 ustar 00 o �hp � @ s4 d dl mZmZ G dd� de�ZG dd� de�ZdS )� )� Collection�Modelc @ s2 e Zd ZdZdZedd� �Zdd� Zddd �Zd S )�NodezA node in a swarm.�IDc C s | j �d��d�S )z� The version number of the service. If this is not the same as the server, the :py:meth:`update` function will not work and you will need to call :py:meth:`reload` before calling it again. �Version�Index)�attrs�get��self� r �I/usr/local/CyberPanel/lib/python3.10/site-packages/docker/models/nodes.py�version s zNode.versionc C s | j j�| j| j|�S )a� Update the node's configuration. Args: node_spec (dict): Configuration settings to update. Any values not provided will be removed. Default: ``None`` Returns: `True` if the request went through. Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> node_spec = {'Availability': 'active', 'Name': 'node-name', 'Role': 'manager', 'Labels': {'foo': 'bar'} } >>> node.update(node_spec) )�client�api�update_node�idr )r � node_specr r r �update s zNode.updateFc C s | j jj| j|d�S )a� Remove this node from the swarm. Args: force (bool): Force remove an active node. Default: `False` Returns: `True` if the request was successful. Raises: :py:class:`docker.errors.NotFound` If the node doesn't exist in the swarm. :py:class:`docker.errors.APIError` If the server returns an error. )�force)r r �remove_noder )r r r r r �remove, s zNode.removeN)F) �__name__� __module__�__qualname__�__doc__�id_attribute�propertyr r r r r r r r s r c @ s$ e Zd ZdZeZdd� Zdd� ZdS )�NodeCollectionzNodes on the Docker server.c C s | � | jj�|��S )a Get a node. Args: node_id (string): ID of the node to be inspected. Returns: A :py:class:`Node` object. Raises: :py:class:`docker.errors.APIError` If the server returns an error. )� prepare_modelr r �inspect_node)r �node_idr r r r D s zNodeCollection.getc s"