File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/neutron.cpython-310.pyc
Back
o ;j�� � @ s� d Z ddlZzddlm m mZ dZW n ey* Z zdZW Y dZ [ ndZ [ ww e� e�ZddiZ dd� Zd�d d �Zd�dd�Zd�d d�Zd�dd�Z d�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd �Zd�d!d"�Zd�d#d$�Z d�d%d&�Zd�d'd(�Zd�d)d*�Zd�d+d,�Z d�d-d.�Z!d�d0d1�Z"d�d2d3�Z#d�d4d5�Z$d�d6d7�Z%d�d8d9�Z&d�d:d;�Z'd�d<d=�Z(d�d>d?�Z)d�d@dA�Z*d�dBdC�Z+d�dDdE�Z,d�dFdG�Z-d�dHdI�Z.d�dJdK�Z/d�dLdM�Z0d�dNdO�Z1d�dPdQ�Z2d�dRdS�Z3d�dTdU�Z4d�dVdW�Z5d�dXdY�Z6d�dZd[�Z7d�d\d]�Z8d�d^d_�Z9 ` a d�dbdc�Z:d�ddde�Z;d�dfdg�Z<d�dhdi�Z=d�djdk�Z>d�dldm�Z?d�dndo�Z@d�dpdq�ZAd�drds�ZB d�dtdu�ZCd�dvdw�ZDd�dxdy�ZEd�dzd{�ZFd�d|d}�ZGd�d~d�ZHd�d�d��ZId�d�d��ZJd�d�d��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZP d�d�d��ZQd�d�d��ZRd�d�d��ZSd�d�d��ZTd�d�d��ZUdS )�a� Module for handling OpenStack Neutron calls :depends: - neutronclient Python module :configuration: This module is not usable until the user, password, tenant, and auth URL are specified either in a pillar or in the minion's config file. For example:: keystone.user: 'admin' keystone.password: 'password' keystone.tenant: 'admin' keystone.auth_url: 'http://127.0.0.1:5000/v2.0/' keystone.region_name: 'RegionOne' keystone.service_type: 'network' If configuration for multiple OpenStack accounts is required, they can be set up as different configuration profiles: For example:: openstack1: keystone.user: 'admin' keystone.password: 'password' keystone.tenant: 'admin' keystone.auth_url: 'http://127.0.0.1:5000/v2.0/' keystone.region_name: 'RegionOne' keystone.service_type: 'network' openstack2: keystone.user: 'admin' keystone.password: 'password' keystone.tenant: 'admin' keystone.auth_url: 'http://127.0.0.2:5000/v2.0/' keystone.region_name: 'RegionOne' keystone.service_type: 'network' With this configuration in place, any of the neutron functions can make use of a configuration profile by declaring it explicitly. For example:: salt '*' neutron.network_list profile=openstack1 To use keystoneauth1 instead of keystoneclient, include the `use_keystoneauth` option in the pillar or minion config. .. note:: this is required to use keystone v3 as for authentication. .. code-block:: yaml keystone.user: admin keystone.password: verybadpass keystone.tenant: admin keystone.auth_url: 'http://127.0.0.1:5000/v3/' keystone.region_name: 'RegionOne' keystone.service_type: 'network' keystone.use_keystoneauth: true keystone.verify: '/path/to/custom/certs/ca-bundle.crt' Note: by default the neutron module will attempt to verify its connection utilizing the system certificates. If you need to verify against another bundle of CA certificates or want to skip verification altogether you will need to specify the `verify` option. You can specify True or False to verify (or not) against system certificates, a path to a bundle or CA certs to check against, or None to allow keystoneauth to search for the certificates on its own.(defaults to True) � NTFZlist_�listc C s t S )zK Only load this module if neutron is installed on this minion. )�HAS_NEUTRON� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/neutron.py�__virtual__S s r c C s4 | r7t d | �}|d }|d }|d }|d }|�dd�}|�dd �}|�d d�}|�dd�} |�d d�} n6t d d�}t d d�}t d d�}t d d�}t d d�}t d d�}t d d �}t d d�} t d d �} | du r�|d }|d }|||||||| | ||d�} n |||||||d�} tjdi | ��S )z$ Set up neutron credentials z config.optionz keystone.userzkeystone.passwordzkeystone.tenantzkeystone.auth_urlzkeystone.region_nameNzkeystone.service_type�networkzkeystone.os_auth_systemzkeystone.use_keystoneauthFzkeystone.verifyTzkeystone.project_domain_namezkeystone.user_domain_name)�username�password�tenant_name�auth_url�region_name�service_type�os_auth_plugin�use_keystoneauth�verify�project_domain_name�user_domain_name)r r r r r r r r )Z__salt__�get�suoneuZSaltNeutron)�profileZcredentials�userr Ztenantr r r Zos_auth_systemr r r r �kwargsr r r �_auth[ sX �� r c C � t | �}|�� S )a9 Fetches tenant info in server's context for following quota operation CLI Example: .. code-block:: bash salt '*' neutron.get_quotas_tenant salt '*' neutron.get_quotas_tenant profile=openstack1 :param profile: Profile to build on (Optional) :return: Quotas information )r �get_quotas_tenant�r �connr r r r � s r c C r )z� Fetches all tenants quotas CLI Example: .. code-block:: bash salt '*' neutron.list_quotas salt '*' neutron.list_quotas profile=openstack1 :param profile: Profile to build on (Optional) :return: List of quotas )r �list_quotasr r r r r � � r c C � t |�}|�| �S )aL Fetches information of a certain tenant's quotas CLI Example: .. code-block:: bash salt '*' neutron.show_quota tenant-id salt '*' neutron.show_quota tenant-id profile=openstack1 :param tenant_id: ID of tenant :param profile: Profile to build on (Optional) :return: Quota information )r � show_quota�� tenant_idr r r r r r � � r c C s t |�} | �| |||||||�S )a� Update a tenant's quota CLI Example: .. code-block:: bash salt '*' neutron.update_quota tenant-id subnet=40 router=50 network=10 floatingip=30 port=30 :param tenant_id: ID of tenant :param subnet: Value of subnet quota (Optional) :param router: Value of router quota (Optional) :param network: Value of network quota (Optional) :param floatingip: Value of floatingip quota (Optional) :param port: Value of port quota (Optional) :param security_group: Value of security group (Optional) :param security_group_rule: Value of security group rule (Optional) :param profile: Profile to build on (Optional) :return: Value of updated quota )r �update_quota) r"