mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-21 11:19:00 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -100,61 +100,64 @@ logical_interconnect_group:
|
|||
type: dict
|
||||
"""
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.oneview import OneViewModuleBase, OneViewModuleResourceNotFound
|
||||
from ansible_collections.community.general.plugins.module_utils.oneview import (
|
||||
OneViewModuleBase,
|
||||
OneViewModuleResourceNotFound,
|
||||
)
|
||||
|
||||
|
||||
class LogicalInterconnectGroupModule(OneViewModuleBase):
|
||||
MSG_CREATED = 'Logical Interconnect Group created successfully.'
|
||||
MSG_UPDATED = 'Logical Interconnect Group updated successfully.'
|
||||
MSG_DELETED = 'Logical Interconnect Group deleted successfully.'
|
||||
MSG_ALREADY_PRESENT = 'Logical Interconnect Group is already present.'
|
||||
MSG_ALREADY_ABSENT = 'Logical Interconnect Group is already absent.'
|
||||
MSG_INTERCONNECT_TYPE_NOT_FOUND = 'Interconnect Type was not found.'
|
||||
MSG_CREATED = "Logical Interconnect Group created successfully."
|
||||
MSG_UPDATED = "Logical Interconnect Group updated successfully."
|
||||
MSG_DELETED = "Logical Interconnect Group deleted successfully."
|
||||
MSG_ALREADY_PRESENT = "Logical Interconnect Group is already present."
|
||||
MSG_ALREADY_ABSENT = "Logical Interconnect Group is already absent."
|
||||
MSG_INTERCONNECT_TYPE_NOT_FOUND = "Interconnect Type was not found."
|
||||
|
||||
RESOURCE_FACT_NAME = 'logical_interconnect_group'
|
||||
RESOURCE_FACT_NAME = "logical_interconnect_group"
|
||||
|
||||
def __init__(self):
|
||||
argument_spec = dict(
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
data=dict(required=True, type='dict')
|
||||
state=dict(default="present", choices=["present", "absent"]), data=dict(required=True, type="dict")
|
||||
)
|
||||
|
||||
super().__init__(additional_arg_spec=argument_spec, validate_etag_support=True)
|
||||
self.resource_client = self.oneview_client.logical_interconnect_groups
|
||||
|
||||
def execute_module(self):
|
||||
resource = self.get_by_name(self.data['name'])
|
||||
resource = self.get_by_name(self.data["name"])
|
||||
|
||||
if self.state == 'present':
|
||||
if self.state == "present":
|
||||
return self.__present(resource)
|
||||
elif self.state == 'absent':
|
||||
elif self.state == "absent":
|
||||
return self.resource_absent(resource)
|
||||
|
||||
def __present(self, resource):
|
||||
scope_uris = self.data.pop('scopeUris', None)
|
||||
scope_uris = self.data.pop("scopeUris", None)
|
||||
|
||||
self.__replace_name_by_uris(self.data)
|
||||
result = self.resource_present(resource, self.RESOURCE_FACT_NAME)
|
||||
|
||||
if scope_uris is not None:
|
||||
result = self.resource_scopes_set(result, 'logical_interconnect_group', scope_uris)
|
||||
result = self.resource_scopes_set(result, "logical_interconnect_group", scope_uris)
|
||||
|
||||
return result
|
||||
|
||||
def __replace_name_by_uris(self, data):
|
||||
map_template = data.get('interconnectMapTemplate')
|
||||
map_template = data.get("interconnectMapTemplate")
|
||||
|
||||
if map_template:
|
||||
map_entry_templates = map_template.get('interconnectMapEntryTemplates')
|
||||
map_entry_templates = map_template.get("interconnectMapEntryTemplates")
|
||||
if map_entry_templates:
|
||||
for value in map_entry_templates:
|
||||
permitted_interconnect_type_name = value.pop('permittedInterconnectTypeName', None)
|
||||
permitted_interconnect_type_name = value.pop("permittedInterconnectTypeName", None)
|
||||
if permitted_interconnect_type_name:
|
||||
value['permittedInterconnectTypeUri'] = self.__get_interconnect_type_by_name(
|
||||
permitted_interconnect_type_name).get('uri')
|
||||
value["permittedInterconnectTypeUri"] = self.__get_interconnect_type_by_name(
|
||||
permitted_interconnect_type_name
|
||||
).get("uri")
|
||||
|
||||
def __get_interconnect_type_by_name(self, name):
|
||||
i_type = self.oneview_client.interconnect_types.get_by('name', name)
|
||||
i_type = self.oneview_client.interconnect_types.get_by("name", name)
|
||||
if i_type:
|
||||
return i_type[0]
|
||||
else:
|
||||
|
|
@ -165,5 +168,5 @@ def main():
|
|||
LogicalInterconnectGroupModule().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue