Skip to content

Commit

Permalink
Merge branch 'release/1.9.3' into imprv/lint-fixes-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
george-ghawali committed Oct 2, 2024
2 parents b2f4c72 + 854442f commit 2b203c6
Show file tree
Hide file tree
Showing 102 changed files with 488 additions and 391 deletions.
194 changes: 97 additions & 97 deletions README.md

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions examples/vm_update_cdrom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
########################### UPDATE_VM_CDROM ################################
---
- name: Create a VM with empty CD ROM and Update that disk with image
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
vm_uuid: ""
disk_uuid: ""

- name: Create VM with empty CD ROM
nutanix.ncp.ntnx_vms:
name: "VM with empty CD ROM"
cluster:
name: "{{ cluster.name }}"
categories:
Environment:
- Production
disks:
- type: "CDROM"
bus: "IDE"
empty_cdrom: true
register: result

- name: Update VM by cloning image into CD ROM
nutanix.ncp.ntnx_vms:
vm_uuid: "{{ result.vm_uuid }}"
name: "VM with CD ROM updated"
disks:
- type: "CDROM"
uuid: "{{ result.response.spec.resources.disk_list[0].uuid }}"
clone_image:
name: "{{ iso_image_name }}"
register: result
4 changes: 2 additions & 2 deletions plugins/doc_fragments/ntnx_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

class ModuleDocFragment(object):

# Plugin options for ntnx CRUD opperations
# Plugin options for ntnx CRUD operations
DOCUMENTATION = r"""
options:
state:
description:
- Specify state
- If C(state) is set to C(present) then the opperation will be create the item
- If C(state) is set to C(present) then the operation will be create the item
- >-
If C(state) is set to C(absent) and if the item exists, then
item is removed.
Expand Down
2 changes: 1 addition & 1 deletion plugins/doc_fragments/ntnx_vms_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ModuleDocFragment(object):
- absent
subnet:
description:
- Name or UUID of the subnet to which the VM should be connnected
- Name or UUID of the subnet to which the VM should be connected
type: dict
suboptions:
name:
Expand Down
2 changes: 1 addition & 1 deletion plugins/inventory/ntnx_prism_vm_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def jsonify(self, data):


class InventoryModule(BaseInventoryPlugin, Constructable):
"""Nutanix VM dynamic invetory module for ansible"""
"""Nutanix VM dynamic inventory module for ansible"""

NAME = "nutanix.ncp.ntnx_prism_vm_inventory"

Expand Down
17 changes: 11 additions & 6 deletions plugins/module_utils/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def list(

return resp

# "params" can be used to override module.params to create spec by other modules backened
# "params" can be used to override module.params to create spec by other modules backends
def get_spec(self, old_spec=None, params=None, **kwargs):
spec = copy.deepcopy(old_spec) or self._get_default_spec()

Expand Down Expand Up @@ -344,7 +344,7 @@ def _build_url_with_query(self, url, query):
def _fetch_url(
self, url, method, data=None, raise_error=True, no_response=False, timeout=30
):
# only jsonify if content-type supports, added to avoid incase of form-url-encodeded type data
# only jsonify if content-type supports, added to avoid in case of form-url-encodeded type data
if self.headers["Content-Type"] == "application/json" and data is not None:
data = self.module.jsonify(data)

Expand All @@ -362,10 +362,10 @@ def _fetch_url(

body = None

# buffer size with ref. to max read size of http.client.HTTPResponse.read() defination
# buffer size with ref. to max read size of http.client.HTTPResponse.read() definition
buffer_size = 65536

# From ansible-core>=2.13, incase of http error, urllib.HTTPError object is returned in resp
# From ansible-core>=2.13, in case of http error, urllib.HTTPError object is returned in resp
# as per the docs of ansible we need to use body in that case.
if not resp or status_code >= 400:
# get body containing error
Expand Down Expand Up @@ -411,8 +411,13 @@ def _fetch_url(
return {"status_code": status_code}

if resp_json is None:
if info.get("msg"):
resp_json_msg = "{}".format(info.get("msg"))
else:
resp_json_msg = "Failed to convert API response to json"

self.module.fail_json(
msg="Failed to convert API response to json",
msg=resp_json_msg,
status_code=status_code,
error=body,
response=resp_json,
Expand Down Expand Up @@ -500,7 +505,7 @@ def _filter_entities(entities, custom_filters):
return filtered_entities


# Read files in chunks and yeild it
# Read files in chunks and yield it
class CreateChunks(object):
def __init__(self, filename, chunk_size=1 << 13):
self.filename = filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def build_spec_db_instance_register_action_arguments(self, payload, config):

def build_spec_db_server_vm_register_action_arguments(self, payload, config):
"""
Implement this method to add database engine specific properties for registeration database server vm
Implement this method to add database engine specific properties for registration database server vm
"""
return payload, None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_engine_type(module):
if type in module.params:
return type, None

return None, "Input doesn't conatains config for allowed engine types of databases"
return None, "Input doesn't contains config for allowed engine types of databases"


def create_db_engine(module, engine_type=None, db_architecture=None):
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/ndb/database_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_engine_type(self):

return (
None,
"Input doesn't conatains config for allowed engine types of databases",
"Input doesn't contains config for allowed engine types of databases",
)

def get_db_engine_spec(self, payload, params=None, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions plugins/module_utils/ndb/db_server_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def get_spec_registered_vm_for_db_instance_registration(
if not vm_info.get("ipAddresses", []):
return None, "No IP address found for given db server vm"

# picking first IP of db server vm for registraion
# picking first IP of db server vm for registration
payload["vmIp"] = vm_info["ipAddresses"][0]

elif params.get("ip"):
Expand Down Expand Up @@ -572,7 +572,7 @@ def build_spec_software_profile(self, payload, profile):
return payload, None

def build_spec_network_profile(self, payload, profile):
# set network prfile
# set network profile
network_profile = NetworkProfile(self.module)
uuid, err = network_profile.get_profile_uuid(profile)
if err:
Expand Down Expand Up @@ -631,7 +631,7 @@ def build_spec_vms(self, payload, vms, **kwargs): # noqa: C901
cluster = Cluster(self.module)
clusters = cluster.get_all_clusters_name_uuid_map()

# spec with default vlaues
# spec with default values
spec = {
"properties": [],
"vmName": "",
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/ndb/profiles/profile_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _build_spec_multi_networks(self, payload, vlans):
cluster_name = clusters_uuid_name_map[cluster_uuid]

if not cluster_name:
return None, "Pleae provide uuid or name for getting cluster info"
return None, "Please provide uuid or name for getting cluster info"

properties_map["CLUSTER_NAME_" + str(i)] = cluster_name
properties_map["CLUSTER_ID_" + str(i)] = clusters_name_uuid_map[
Expand Down Expand Up @@ -485,7 +485,7 @@ def get_profile_type(module):
if type in module.params:
return type, None

return None, "Input doesn't conatains config for allowed profile types of databases"
return None, "Input doesn't contains config for allowed profile types of databases"


def get_profile_type_obj(module, profile_type=None): # -> tuple[Profile, str]:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/ndb/time_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get_spec(self, old_spec, params=None, **kwargs):
if err:
return None, err

# set destination clusters incase of HA instance
# set destination clusters in case of HA instance
if params.get("clusters"):
cluster_uuids = []

Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/acps.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def build_role_permissions_based_context(self, role_uuid):
if permission.get("name"):
role_permissions_names.append(permission["name"])

# Get predefined premissions to entity access expressions from constants
# Get predefined permissions to entity access expressions from constants
expressions_dict = CONSTANTS.EntityFilterExpressionList.PERMISSION_TO_ACCESS_MAP
permission_names = expressions_dict.keys()

Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, module, upload_image=False):
"Accept": "application/json",
}

# add checksum headers if given incase of local upload
# add checksum headers if given in case of local upload
checksum = module.params.get("checksum")
if checksum and module.params.get("source_path"):
additional_headers["X-Nutanix-Checksum-Type"] = checksum[
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_uuid(self, value, key="name", raise_error=True, no_response=False):
if entity["spec"]["name"] == value:
return entity["metadata"]["uuid"]

# Incase there are more entities to check
# In case there are more entities to check
while resp["total_matches"] > resp["length"] + resp["offset"]:
filter_spec["length"] = self.entities_limitation
filter_spec["offset"] = filter_spec["offset"] + self.entities_limitation
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/projects_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _build_spec_role_mappings(self, payload, role_mappings):
_acp = ACP(self.module)

# First check existing acps of project w.r.t to role mapping, if UPDATE/DELETE of acp is required
# Incase its a UPDATE acp for role we pop the entry from role_user_groups_map,
# In case its a UPDATE acp for role we pop the entry from role_user_groups_map,
# so that we are left with roles for which new acps are to be created.
for acp in payload["spec"]["access_control_policy_list"]:

Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/protection_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _build_spec_schedules(self, payload, schedules):
):
return (
None,
"rpo, rpo_unit, snapshot_type and atleast one policy are required fields for aysynchronous snapshot schedule",
"rpo, rpo_unit, snapshot_type and at least one policy are required fields for aysynchronous snapshot schedule",
)

spec["recovery_point_objective_secs"], err = convert_to_secs(
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/static_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _build_default_route_spec(self, payload, next_hop):
return payload, None

def _build_spec_static_routes(self, payload, inp_static_routes):
# since static route list has to be overriden
# since static route list has to be overridden
if payload["spec"]["resources"].get("default_route_nexthop"):
payload["spec"]["resources"].pop("default_route_nexthop")
static_routes_list = []
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get_subnet_uuid(config, module):
name = config.get("name") or config.get("subnet_name")
uuid = ""

# incase subnet of particular cluster is needed
# in case subnet of particular cluster is needed
if config.get("cluster_uuid"):
filter_spec = {"filter": "{0}=={1}".format("name", name)}
resp = subnet.list(data=filter_spec)
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/prism/user_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _build_spec_project(self, payload, config):
return payload, None

def _build_spec_user_distinguished_name(self, payload, config):
if "ou=" in config:
if config[0:3] == "ou=":
payload["spec"]["resources"]["directory_service_ou"] = {
"distinguished_name": config
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/module_utils/prism/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ def _generate_disk_spec(
if error:
return None, error

disk["data_source_reference"]["uuid"] = uuid
disk.setdefault("data_source_reference", {})["uuid"] = uuid
disk.setdefault("data_source_reference", {})["kind"] = "image"

if (
not disk.get("storage_config", {})
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ntnx_acps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DOCUMENTATION = r"""
---
module: ntnx_acps
short_description: acp module which suports acp Create, update and delete operations
short_description: acp module which supports acp Create, update and delete operations
version_added: 1.4.0
description: 'Create, Update, Delete acp'
options:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ntnx_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
options:
remove_values:
description:
- it indicates to remove all values of the specfied category
- it indicates to remove all values of the specified category
- This attribute can be only used with C(state) is absent
- This attribute is mutually exclusive with C(values) when state is absent
type: bool
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/ntnx_floating_ips_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DOCUMENTATION = r"""
---
module: ntnx_floating_ips_info
short_description: Floting ips info module
short_description: Floating ips info module
version_added: 1.0.0
description: 'Get floating_ip info'
options:
Expand All @@ -21,7 +21,7 @@
default: floating_ip
fip_uuid:
description:
- Floting ip UUID
- Floating ip UUID
type: str
extends_documentation_fragment:
- nutanix.ncp.ntnx_credentials
Expand Down
Loading

0 comments on commit 2b203c6

Please sign in to comment.