def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict( state=dict(default='present', choices=['present', 'absent']), vol=dict(required=True), pool=dict(), size=dict() ) ) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) # required args volume = xcli_client.cmd.vol_list( vol=module.params.get('vol')).as_single_element state = module.params['state'] state_changed = False if state == 'present' and not volume: state_changed = execute_pyxcli_command( module, 'vol_create', xcli_client) elif state == 'absent' and volume: state_changed = execute_pyxcli_command( module, 'vol_delete', xcli_client) module.exit_json(changed=state_changed)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict(state=dict(default='present', choices=['present', 'absent']), vol=dict(required=True), lun=dict(), cluster=dict(), host=dict(), override=dict())) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) # required args mapping = False try: mapped_hosts = xcli_client.cmd.vol_mapping_list( vol=module.params.get('vol')).as_list for host in mapped_hosts: if host['host'] == module.params.get("host", ""): mapping = True except Exception: pass state = module.params['state'] state_changed = False if state == 'present' and not mapping: state_changed = execute_pyxcli_command(module, 'map_vol', xcli_client) if state == 'absent' and mapping: state_changed = execute_pyxcli_command(module, 'unmap_vol', xcli_client) module.exit_json(changed=state_changed)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict(state=dict(default='present', choices=['present', 'absent']), pool=dict(required=True), size=dict(), snapshot_size=dict(), domain=dict(), perf_class=dict())) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) pool = xcli_client.cmd.pool_list( pool=module.params['pool']).as_single_element state = module.params['state'] state_changed = False if state == 'present' and not pool: state_changed = execute_pyxcli_command(module, 'pool_create', xcli_client) if state == 'absent' and pool: state_changed = execute_pyxcli_command(module, 'pool_delete', xcli_client) module.exit_json(changed=state_changed)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict(state=dict(default='present', choices=['present', 'absent']), host=dict(required=True), cluster=dict(), domain=dict(), iscsi_chap_name=dict(), iscsi_chap_secret=dict())) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) host = xcli_client.cmd.host_list( host=module.params['host']).as_single_element state = module.params['state'] state_changed = False if state == 'present' and not host: state_changed = execute_pyxcli_command(module, 'host_define', xcli_client) elif state == 'absent' and host: state_changed = execute_pyxcli_command(module, 'host_delete', xcli_client) module.exit_json(changed=state_changed)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict( state=dict(default='present', choices=['present', 'absent']), domain=dict(required=True), size=dict(), max_dms=dict(), max_cgs=dict(), ldap_id=dict(), max_mirrors=dict(), max_pools=dict(), max_volumes=dict(), perf_class=dict(), hard_capacity=dict(), soft_capacity=dict() ) ) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) domain = xcli_client.cmd.domain_list( domain=module.params['domain']).as_single_element state = module.params['state'] state_changed = False msg = 'Domain \'{0}\''.format(module.params['domain']) if state == 'present' and not domain: state_changed = execute_pyxcli_command( module, 'domain_create', xcli_client) msg += " created successfully." elif state == 'absent' and domain: state_changed = execute_pyxcli_command( module, 'domain_delete', xcli_client) msg += " deleted successfully." else: msg += " state unchanged." module.exit_json(changed=state_changed, msg=msg)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict(state=dict(default='present', choices=['present', 'absent']), host=dict(required=True), iscsi_name=dict(), fcaddress=dict(), num_of_visible_targets=dict())) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) # required args ports = [] try: ports = xcli_client.cmd.host_list_ports( host=module.params.get('host')).as_list except Exception: pass state = module.params['state'] port_exists = False ports = [port.get('port_name') for port in ports] fc_ports = (module.params.get('fcaddress') if module.params.get('fcaddress') else []) iscsi_ports = (module.params.get('iscsi_name') if module.params.get('iscsi_name') else []) for port in ports: if port in iscsi_ports or port in fc_ports: port_exists = True break state_changed = False if state == 'present' and not port_exists: state_changed = execute_pyxcli_command(module, 'host_add_port', xcli_client) if state == 'absent' and port_exists: state_changed = execute_pyxcli_command(module, 'host_remove_port', xcli_client) module.exit_json(changed=state_changed)
def main(): argument_spec = spectrum_accelerate_spec() argument_spec.update( dict(state=dict(default='present', choices=['present', 'absent']), user=dict(required=True), domain=dict(), category=dict(choices=[ 'applicationadmin', 'readonly', 'securityadmin', 'storageadmin', 'storageintegrationadmin' ]), user_pass=dict(no_log=True))) module = AnsibleModule(argument_spec) is_pyxcli_installed(module) xcli_client = connect_ssl(module) # required args user = xcli_client.cmd.user_list( user=module.params.get('user')).as_single_element state = module.params['state'] if state == 'present': module.params.pop('password') module.params['password'] = module.params.get('user_pass') module.params['password_verify'] = module.params.get('user_pass') module.params.pop('user_pass') state_changed = False if state == 'present' and not user: state_changed = execute_pyxcli_command(module, 'user_define', xcli_client, user_module=True) elif state == 'absent' and user: state_changed = execute_pyxcli_command(module, 'user_delete', xcli_client) module.exit_json(changed=state_changed)