na_elementsw_cluster was using wrong username/password (#54622)

* Bug fix

* Bug fix
pull/54689/head
Chris Archibald 6 years ago committed by John R Barker
parent bcdd1dc951
commit 03e18e4e1f

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

Loading…
Cancel
Save