diff --git a/plugins/module_utils/prism/subnets.py b/plugins/module_utils/prism/subnets.py index 1d110be7a..bbd64161a 100644 --- a/plugins/module_utils/prism/subnets.py +++ b/plugins/module_utils/prism/subnets.py @@ -140,7 +140,7 @@ def _get_default_dhcp_spec(self): ) -##### Helper functions ##### +# Helper functions def get_subnet_uuid(config, module): diff --git a/plugins/module_utils/prism/vpcs.py b/plugins/module_utils/prism/vpcs.py index 2bec2dd30..1be60cf2c 100644 --- a/plugins/module_utils/prism/vpcs.py +++ b/plugins/module_utils/prism/vpcs.py @@ -66,7 +66,9 @@ def _build_spec_routable_ips(self, payload, ips): return payload, None def _build_dns_servers(self, payload, dns_servers): - payload["spec"]["resources"]["common_domain_name_server_ip_list"] = dns_servers + payload["spec"]["resources"]["common_domain_name_server_ip_list"] = [ + {"ip": i} for i in dns_servers + ] return payload, None def _get_external_subnet_ref_spec(self, uuid): diff --git a/plugins/modules/ntnx_vpcs.py b/plugins/modules/ntnx_vpcs.py index c62db4e3a..179ce41f8 100644 --- a/plugins/modules/ntnx_vpcs.py +++ b/plugins/modules/ntnx_vpcs.py @@ -60,14 +60,41 @@ default: True name: description: vpc Name - required: False type: str vpc_uuid: - description: vpc UUID + description: vpc uuid type: str - - #TODO here should be additional arguments documentation - + dns_servers: + description: List of DNS servers IPs + type: list + elements: str + routable_ips: + description: Address space within the VPC which can talk externally without NAT. These are in effect when No-NAT External subnet is used. + type: list + elements: dict + suboptions: + network_ip: + description: ip address + type: str + network_prefix: + description: Subnet ip address prefix length + type: int + external_subnets: + description: A subnet with external connectivity + type: list + elements: dict + suboptions: + subnet_uuid: + description: Subnet UUID + type: str + subnet_name: + description: Subnet Name + type: str +author: + - Prem Karat (@premkarat) + - Gevorg Khachatryan (@Gevorg-Khachatryan-97) + - Alaa Bishtawi (@alaa-bish) + - Dina AbuHijleh (@dina-abuhijleh) """ EXAMPLES = r""" @@ -92,7 +119,8 @@ def get_module_spec(): network_ip=dict(type="str"), network_prefix=dict(type="str") ) module_args = dict( - name=dict(type="str", required=True), + name=dict(type="str"), + vpc_uuid=dict(type="str"), external_subnets=dict( type="list", elements="dict", @@ -169,7 +197,14 @@ def wait_for_task_completion(module, result): def run_module(): - module = BaseModule(argument_spec=get_module_spec(), supports_check_mode=True) + module = BaseModule( + argument_spec=get_module_spec(), + supports_check_mode=True, + required_if=[ + ("state", "present", ("name",)), + ("state", "absent", ("vpc_uuid",)), + ], + ) remove_param_with_none_value(module.params) result = { "changed": False, diff --git a/scripts/create_module.py b/scripts/create_module.py index f81cb7324..6b6548de5 100644 --- a/scripts/create_module.py +++ b/scripts/create_module.py @@ -217,14 +217,14 @@ def _get_default_spec(self): def create_module(name): - with open("plugins/modules/ntnx_{0}s.py".format(name), "w") as f: + with open("plugins/modules/ntnx_{0}s.py".format(name), "wb") as f: f.write( module_content.replace("object", name.lower()).replace( "Object", name.capitalize() ) ) - with open("plugins/module_utils/prism/{0}s.py".format(name), "w") as f: + with open("plugins/module_utils/prism/{0}s.py".format(name), "wb") as f: f.write( object_content.replace("object", name.lower()).replace( "Object", name.capitalize()