11.0.0
This commit is contained in:
@@ -10,6 +10,8 @@ description: See L(Module Documentation,https://repository.basistech.ru/BASIS/de
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.decort_utils import DecortController
|
||||
|
||||
from dynamix_sdk import exceptions as sdk_exceptions
|
||||
|
||||
|
||||
class DecortTrunk(DecortController):
|
||||
def __init__(self):
|
||||
@@ -28,19 +30,31 @@ class DecortTrunk(DecortController):
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
@DecortController.handle_sdk_exceptions
|
||||
def run(self):
|
||||
self.get_info()
|
||||
self.exit()
|
||||
|
||||
def get_info(self):
|
||||
self.facts = self.trunk_get(id=self.id)
|
||||
self.facts['account_ids'] = self.facts.pop('accountIds')
|
||||
self.facts['created_timestamp'] = self.facts.pop('created_at')
|
||||
self.facts['deleted_timestamp'] = self.facts.pop('deleted_at')
|
||||
self.facts['updated_timestamp'] = self.facts.pop('updated_at')
|
||||
self.facts['native_vlan_id'] = self.facts.pop('nativeVlanId')
|
||||
self.facts['ovs_bridge'] = self.facts.pop('ovsBridge')
|
||||
self.facts['vlan_ids'] = self.facts.pop('trunkTags')
|
||||
try:
|
||||
trunk_model = self.api.cloudapi.trunk.get(
|
||||
id=self.id
|
||||
)
|
||||
except sdk_exceptions.RequestException as e:
|
||||
if (
|
||||
e.orig_exception.response
|
||||
and e.orig_exception.response.status_code == 404
|
||||
):
|
||||
self.message(
|
||||
self.MESSAGES.obj_not_found(
|
||||
obj='trunk',
|
||||
id=self.id,
|
||||
)
|
||||
)
|
||||
self.exit(fail=True)
|
||||
raise e
|
||||
|
||||
self.facts = trunk_model.model_dump()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user