def main(): module = AnsibleModule(argument_spec=dict(host=dict(required=True, type='str'), username=dict(required=True, type='str'), password=dict(required=True, type='str', no_log='true'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), uuid=dict(required=True, type='str')), supports_check_mode=True) host = module.params['host'] port = module.params['port'] username = module.params['username'] password = module.params['password'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] uuid = module.params['uuid'] result = dict(changed=False) connect = UserAuthentication(port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password) token = connect.login() token_id = token.get('vmwareApiSessionId') if not token_id: module.fail_json(msg="No Token!") vp = ApplianceManagement(vp_user=username, vp_password=password, url=host, port=port) res = vp.get_sys_log(uuid=uuid, token=token_id) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)
def main(): module = AnsibleModule( argument_spec=dict( host=dict(required=True, type='str'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), ds_name=dict(required=True, type='str'), ds_type=dict(required=True, type='str'), host_ids=dict(required=True, type='str') ), supports_check_mode=True ) host = module.params['host'] port = module.params['port'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] ds_name = module.params['ds_name'] ds_type = module.params['ds_type'] host_ids = module.params['host_ids'] result = dict(changed=False) connect = UserAuthentication( port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password ) token = connect.login() token_id = token.get('vmwareApiSessionId') vp = Datastore( port=port, url=host, token=token_id ) res = vp.mount_datastore_on_additional_hosts( ds_name=ds_name, ds_type=ds_type, host_ids=host_ids ) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)
def main(): module = AnsibleModule( argument_spec=dict( host=dict(required=True, type='str'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), aggregate=dict(required=True, type='str'), cluster_id=dict(required=True, type='str') ), supports_check_mode=True ) host = module.params['host'] port = module.params['port'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] aggr = module.params['aggregate'] cluster_id = module.params['cluster_id'] result = dict(changed=False) connect = UserAuthentication( port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password ) token = connect.login() token_id = token.get('vmwareApiSessionId') if not token_id: module.fail_json(msg="No Token!") vp = StorageSystems( port=port, url=host, token=token_id ) res = vp.get_aggregate( cluster_id=cluster_id, aggregate=aggr ) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)
def main(): module = AnsibleModule( argument_spec=dict( host=dict(required=True, type='str'), password=dict(required=True, type='str', no_log='true'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), state=dict(required=True, type='str') ), supports_check_mode=True ) host = module.params['host'] password = module.params['password'] port = module.params['port'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] state = module.params['state'] if state == 'absent': state = False elif state == 'present': state = True result = dict(changed=False) connect = UserAuthentication( port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password ) token = connect.login() token_id = token.get('vmwareApiSessionId') vp = ProductCapability( port=port, url=host, token=token_id ) res = vp.set_vp_status(vp_password=password, state=state) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)
def main(): module = AnsibleModule(argument_spec=dict( host=dict(required=True, type='str'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), profile_name=dict(required=True, type='str'), profile_id=dict(required=True, type='str'), description=dict(required=True, type='str'), qos=dict(required=True, type='str'), compression=dict(required=True, type='bool'), deduplication=dict(required=True, type='bool'), encryption=dict(required=True, type='bool'), iops=dict(required=True, type='str'), platform=dict(required=True, type='str'), space_efficiency=dict(required=True, type='str'), tiering_policy=dict(required=True, type='str')), supports_check_mode=True) host = module.params['host'] port = module.params['port'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] profile_name = module.params['profile_name'] profile_id = module.params['profile_id'] description = module.params['description'] qos = module.params['qos'] compression = module.params['compression'] deduplication = module.params['deduplication'] encryption = module.params['encryption'] iops = module.params['iops'] platform = module.params['platform'] space_efficiency = module.params['space_efficiency'] tiering_policy = module.params['tiering_policy'] result = dict(changed=False) connect = UserAuthentication(port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password) token = connect.login() token_id = token.get('vmwareApiSessionId') if not token_id: module.fail_json(msg="No Token!") vp = StorageCapabilityProfile(port=port, url=host, vp_user=vc_user, vp_password=vc_password, token=token_id) res = vp.update_storage_capability_profile( profile_name=profile_name, description=description, qos=qos, compression=compression, deduplication=deduplication, encryption=encryption, iops=iops, platform=platform, space_efficiency=space_efficiency, tiering_policy=tiering_policy, profile_id=profile_id) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)
def main(): module = AnsibleModule( argument_spec=dict( host=dict(required=True, type='str'), vc_user=dict(required=True, type='str'), vc_password=dict(required=True, type='str', no_log='true'), port=dict(required=False, default='8143'), cluster_ip=dict(required=True, type='str'), ds_type=dict(required=False, default='VVOL'), scp=dict(required=True, type='str'), description=dict(required=True, type='str'), flexvol=dict(required=True, type='dict'), ds_name=dict(required=True, type='str'), protocol=dict(required=True, type='str'), target=dict(required=True, type='str'), vserver=dict(required=True, type='str') ), supports_check_mode=True ) host = module.params['host'] port = module.params['port'] vc_user = module.params['vc_user'] vc_password = module.params['vc_password'] cluster_ip = module.params['cluster_ip'] ds_type = module.params['ds_type'] scp = module.params['scp'] description = module.params['description'] flexvol = module.params['flexvol'] ds_name = module.params['ds_name'] protocol = module.params['protocol'] target = module.params['target'] vserver = module.params['vserver'] result = dict(changed=False) connect = UserAuthentication( port=port, url=host, vcenter_user=vc_user, vcenter_password=vc_password ) token = connect.login() token_id = token.get('vmwareApiSessionId') vp = Datastore( port=port, url=host, token=token_id ) res = vp.create_datastore( cluster_ip=cluster_ip, ds_type=ds_type, scp=scp, description=description, flexvol=flexvol, ds_name=ds_name, protocol=protocol, target=target, vserver=vserver ) try: if res['status_code'] == 200: result.update(result=res) result.update(changed=True) else: result.update(result=res) result.update(changed=False) result.update(failed=True) except BaseException as e: module.fail_json(message=e.message) module.exit_json(**result)