Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sanity and add doc: Gihub issue 78 #79

Merged
merged 5 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _get_default_dhcp_spec(self):
)


##### Helper functions #####
# Helper functions


def get_subnet_uuid(config, module):
Expand Down
4 changes: 3 additions & 1 deletion plugins/module_utils/prism/vpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
49 changes: 42 additions & 7 deletions plugins/modules/ntnx_vpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions scripts/create_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down