mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #25266 from ruzarowski/2015.8-SourceDestCheck
cloud: EC2 eni property SourceDestCheck is a AttributeBooleanValue
This commit is contained in:
commit
06347f3900
1 changed files with 32 additions and 2 deletions
|
@ -1172,8 +1172,7 @@ def _create_eni_if_necessary(interface):
|
|||
params = {'SubnetId': interface['SubnetId']}
|
||||
|
||||
for k in ('Description', 'PrivateIpAddress',
|
||||
'SecondaryPrivateIpAddressCount',
|
||||
'SourceDestCheck'):
|
||||
'SecondaryPrivateIpAddressCount'):
|
||||
if k in interface:
|
||||
params[k] = interface[k]
|
||||
|
||||
|
@ -1210,6 +1209,9 @@ def _create_eni_if_necessary(interface):
|
|||
)
|
||||
)
|
||||
|
||||
if 'SourceDestCheck' in interface:
|
||||
_modify_interface_source_dest_check(eni_id, interface['SourceDestCheck'])
|
||||
|
||||
if interface.get('associate_eip'):
|
||||
_associate_eip_with_interface(eni_id, interface.get('associate_eip'))
|
||||
elif interface.get('allocate_new_eip'):
|
||||
|
@ -1251,6 +1253,34 @@ def _list_interface_private_addresses(eni_desc):
|
|||
return addresses
|
||||
|
||||
|
||||
def _modify_interface_source_dest_check(eni_id, source_dest_check=True):
|
||||
'''
|
||||
Change the state of SourceDestCheck Flag in the interface
|
||||
with id eni_id to the value of source_dest_check
|
||||
'''
|
||||
params = {'Action': 'ModifyNetworkInterfaceAttribute',
|
||||
'NetworkInterfaceId': eni_id,
|
||||
'SourceDestCheck.Value': source_dest_check}
|
||||
|
||||
retries = 5
|
||||
while retries > 0:
|
||||
retries = retries - 1
|
||||
|
||||
result = query(params, return_root=True)
|
||||
if isinstance(result, dict) and result.get('error'):
|
||||
time.sleep(1)
|
||||
continue
|
||||
|
||||
return None
|
||||
|
||||
raise SaltCloudException(
|
||||
'Could not change SourceDestCheck attribute '
|
||||
'interface=<{0}> SourceDestCheck=<{1}>'.format(
|
||||
eni_id, source_dest_check
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _associate_eip_with_interface(eni_id, eip_id, private_ip=None):
|
||||
'''
|
||||
Accept the id of a network interface, and the id of an elastic ip
|
||||
|
|
Loading…
Add table
Reference in a new issue