
    Vh)                     R    d Z dZdZddlmZ  G d de      Zd Zedk(  r e        y	y	)
a	  
---
module: network
short_description: Creates/removes networks from OpenStack
author: OpenStack Ansible SIG
description:
   - Add, update or remove network from OpenStack.
options:
   name:
     description:
        - Name to be assigned to the network.
     required: true
     type: str
   shared:
     description:
        - Whether this network is shared or not.
     type: bool
   admin_state_up:
     description:
        - Whether the state should be marked as up or down.
     type: bool
   external:
     description:
        - Whether this network is externally accessible.
     type: bool
   is_default:
     description:
        - Whether this network is default network or not. This is only effective
          with external networks.
     type: bool
   is_vlan_transparent:
     description:
        - Whether this network is vlan_transparent or not.
     type: bool
   state:
     description:
        - Indicate desired state of the resource.
     choices: ['present', 'absent']
     default: present
     type: str
   provider_physical_network:
     description:
        - The physical network where this network object is implemented.
     type: str
   provider_network_type:
     description:
        - The type of physical network that maps to this network resource.
     type: str
   provider_segmentation_id:
     description:
        - An isolated segment on the physical network. The I(network_type)
          attribute defines the segmentation model. For example, if the
          I(network_type) value is vlan, this ID is a vlan identifier. If
          the I(network_type) value is gre, this ID is a gre key.
     type: int
   project:
     description:
        - Project name or ID containing the network (name admin-only)
     type: str
   port_security_enabled:
     description:
        -  Whether port security is enabled on the network or not.
           Network will use OpenStack defaults if this option is
           not utilised.
     type: bool
   mtu:
     description:
       -  The maximum transmission unit (MTU) value to address fragmentation.
          Network will use OpenStack defaults if this option is
          not provided.
     type: int
     aliases: ['mtu_size']
   dns_domain:
     description:
       -  The DNS domain value to set.
          Network will use Openstack defaults if this option is
          not provided.
     type: str
extends_documentation_fragment:
- openstack.cloud.openstack
z
# Create an externally accessible network named 'ext_network'.
- openstack.cloud.network:
    cloud: mycloud
    state: present
    name: ext_network
    external: true
a	  
id:
    description: Id of network
    returned: On success when network exists.
    type: str
network:
    description: Dictionary describing the network.
    returned: On success when network exists.
    type: dict
    contains:
        availability_zone_hints:
            description: Availability zone hints
            type: str
        availability_zones:
            description: Availability zones
            type: str
        created_at:
            description: Created at timestamp
            type: str
        description:
            description: Description
            type: str
        dns_domain:
            description: Dns domain
            type: str
        id:
            description: Id
            type: str
        ipv4_address_scope_id:
            description: Ipv4 address scope id
            type: str
        ipv6_address_scope_id:
            description: Ipv6 address scope id
            type: str
        is_admin_state_up:
            description: Is admin state up
            type: str
        is_default:
            description: Is default
            type: str
        is_port_security_enabled:
            description: Is port security enabled
            type: str
        is_router_external:
            description: Is router external
            type: str
        is_shared:
            description: Is shared
            type: str
        is_vlan_transparent:
            description: Is vlan transparent
            type: str
        mtu:
            description: Mtu
            type: str
        name:
            description: Name
            type: str
        project_id:
            description: Project id
            type: str
        provider_network_type:
            description: Provider network type
            type: str
        provider_physical_network:
            description: Provider physical network
            type: str
        provider_segmentation_id:
            description: Provider segmentation id
            type: str
        qos_policy_id:
            description: Qos policy id
            type: str
        revision_number:
            description: Revision number
            type: str
        segments:
            description: Segments
            type: str
        status:
            description: Status
            type: str
        subnet_ids:
            description: Subnet ids
            type: str
        tags:
            description: Tags
            type: str
        updated_at:
            description: Updated at timestamp
            type: str
    )OpenStackModulec                       e Zd Z e ed       ed       ed       ed       ed       ed       e        e        ed       edddg       e        ed       edd	g
       e             Zd Zy)NetworkModuleT)requiredbool)typeintpresentabsent)defaultchoicesmtu_size)r   aliases)namesharedadmin_state_upexternal
is_defaultis_vlan_transparentprovider_physical_networkprovider_network_typeprovider_segmentation_idstateprojectport_security_enabledmtu
dns_domainc                    | j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d	   }	| j                   d
   }
| j                   d   }i }dD ]$  }| j                   |   | j                   |   ||<   & |1| j                  j                  j                  |d      }|d   }d|i}nd }i } | j                  j                  j
                  |fi |}|dk(  r5|r||d<   |	r|	|d	<   |
r|
|d
<   |||d<   |||d<   |||d<   |||d<   |||d<   |||d<   |s+ | j                  j                  j                  dd|i|}d}nd}i }d	dg}|D ]7  }||v s||   ||   k7  s| j                  ddj                  |      z         9 dD ]!  }||v s||   ||   ||   k7  s||   ||<   # |r3 | j                  j                  j                  |j                  fi |}d}|j                  d      }| j                  |||d          y |dk(  rP|s| j                  d       y | j                  j                  j                  |d          | j                  d       y y )Nr   r   r   r   r   r   r   r   r   r   r   )r   r   r   F)ignore_missingid
project_idr
   is_router_externalTz`The following parameters cannot be updated: %s. You will need to use state: absent and recreate.z, )msg)r   r   r"   r   r   r   r   )computed)changednetworkr    r   )r%    )paramsconnidentityfind_projectr&   find_networkcreate_network	fail_jsonjoinupdate_networkr    to_dictexitdelete_network)selfr   r   r   r   r   r   r   r   r   r   r   kwargsargprojr!   
net_kwargsnetr%   update_kwargsnon_updatabless                        k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/openstack/cloud/plugins/modules/network.pyrunzNetworkModule.run   sU   G${{6"X&%56;;z*[[.
"kk*?@$(KK0K$L! $,C D#';;/I#J ++i(A 	/C{{3+"kk#.s	/ 99%%227BG 3 IDdJ&
3JJJ,dii,,T@Z@I(6O23$2G./'5M12%'1|$!#)x )+9'(#/7+,%'1|$".0C,-6dii''66KDKFK "
 ,/" * Cf}C)@!,.2ii.G!H ' 8 
9C v"3K3"3K3s83-3C[c*
9 !:$))++::"/C #G++u+-CIIgss4yIAh		%	(		!!00T;		$	'     N)__name__
__module____qualname__dictargument_specr=   r'   r>   r<   r   r      s    4  (6"V$ f-"&&"f!%5!19x.CD"/ej\26M"d(r>   r   c                  &    t               }  |         y )N)r   )modules    r<   mainrF   =  s    _F
Hr>   __main__N)DOCUMENTATIONEXAMPLESRETURNBansible_collections.openstack.cloud.plugins.module_utils.openstackr   r   rF   r?   r'   r>   r<   <module>rL      sL   Pd[
z _w(O w(t
 zF r>   