1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

na_elementsw_cluster was using wrong username/password (#54622)

* Bug fix

* Bug fix
This commit is contained in:
Chris Archibald 2019-04-01 09:18:43 -07:00 committed by John R Barker
parent bcdd1dc951
commit 03e18e4e1f

View file

@ -63,6 +63,7 @@ options:
description: description:
- Storage IP (SIP) addresses of the initial set of nodes making up the cluster. - Storage IP (SIP) addresses of the initial set of nodes making up the cluster.
- nodes IP must be in the list. - nodes IP must be in the list.
required: true
attributes: attributes:
description: description:
@ -81,8 +82,6 @@ EXAMPLES = """
management_virtual_ip: 10.226.108.32 management_virtual_ip: 10.226.108.32
storage_virtual_ip: 10.226.109.68 storage_virtual_ip: 10.226.109.68
replica_count: 2 replica_count: 2
cluster_admin_username: admin
cluster_admin_password: netapp123
accept_eula: true accept_eula: true
nodes: nodes:
- 10.226.109.72 - 10.226.109.72
@ -114,20 +113,20 @@ class ElementSWCluster(object):
def __init__(self): def __init__(self):
self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec = netapp_utils.ontap_sf_host_argument_spec()
self.argument_spec.update( self.argument_spec.update(dict(
management_virtual_ip=dict(type='str', required=True), management_virtual_ip=dict(required=True, type='str'),
storage_virtual_ip=dict(type='str', required=True), storage_virtual_ip=dict(required=True, type='str'),
replica_count=dict(type='str', default='2'), replica_count=dict(required=False, type='str', default='2'),
cluster_admin_username=dict(type='str'), cluster_admin_username=dict(required=False, type='str'),
cluster_admin_password=dict(type='str', no_log=True), cluster_admin_password=dict(required=False, type='str', no_log=True),
accept_eula=dict(type='bool', required=True), accept_eula=dict(required=False, type='bool'),
nodes=dict(type='list'), nodes=dict(required=True, type=list),
attributes=dict(type='list'), attributes=dict(required=False, type='dict', default=None)
) ))
self.module = AnsibleModule( self.module = AnsibleModule(
argument_spec=self.argument_spec, argument_spec=self.argument_spec,
supports_check_mode=True, supports_check_mode=True
) )
input_params = self.module.params input_params = self.module.params
@ -135,24 +134,16 @@ class ElementSWCluster(object):
self.management_virtual_ip = input_params['management_virtual_ip'] self.management_virtual_ip = input_params['management_virtual_ip']
self.storage_virtual_ip = input_params['storage_virtual_ip'] self.storage_virtual_ip = input_params['storage_virtual_ip']
self.replica_count = input_params['replica_count'] self.replica_count = input_params['replica_count']
self.accept_eula = input_params['accept_eula'] self.accept_eula = input_params.get('accept_eula')
self.attributes = input_params['attributes'] self.attributes = input_params.get('attributes')
self.nodes = input_params['nodes'] self.nodes = input_params['nodes']
self.cluster_admin_username = input_params.get('cluster_admin_username')
if input_params['cluster_admin_username'] is None: self.cluster_admin_password = input_params.get('cluster_admin_password')
self.cluster_admin_username = self.username
else:
self.cluster_admin_username = input_params['cluster_admin_username']
if input_params['cluster_admin_password']:
self.cluster_admin_password = self.password
else:
self.cluster_admin_password = input_params['cluster_admin_password']
if HAS_SF_SDK is False: if HAS_SF_SDK is False:
self.module.fail_json(msg="Unable to import the SolidFire Python SDK") self.module.fail_json(msg="Unable to import the SolidFire Python SDK")
else: else:
self.sfe = netapp_utils.create_sf_connection(module=self.module, port=442) self.sfe = netapp_utils.create_sf_connection(module=self.module)
self.elementsw_helper = NaElementSWModule(self.sfe) self.elementsw_helper = NaElementSWModule(self.sfe)
@ -166,15 +157,20 @@ class ElementSWCluster(object):
""" """
Create Cluster Create Cluster
""" """
options = {
'mvip': self.management_virtual_ip,
'svip': self.storage_virtual_ip,
'rep_count': self.replica_count,
'accept_eula': self.accept_eula,
'nodes': self.nodes,
'attributes': self.attributes
}
if self.cluster_admin_username is not None:
options['username'] = self.cluster_admin_username
if self.cluster_admin_password is not None:
options['password'] = self.cluster_admin_password
try: try:
self.sfe.create_cluster(mvip=self.management_virtual_ip, self.sfe.create_cluster(**options)
svip=self.storage_virtual_ip,
rep_count=self.replica_count,
username=self.cluster_admin_username,
password=self.cluster_admin_password,
accept_eula=self.accept_eula,
nodes=self.nodes,
attributes=self.attributes)
except Exception as exception_object: except Exception as exception_object:
self.module.fail_json(msg='Error create cluster %s' % (to_native(exception_object)), self.module.fail_json(msg='Error create cluster %s' % (to_native(exception_object)),
exception=traceback.format_exc()) exception=traceback.format_exc())