コード例 #1
0
def aggr_hybrid(module):

    aggr = module.params['aggr']
    hybrid = module.params['hybrid']

    results = {}

    results['changed'] = False

    args = NaElement("args")

    args.child_add(NaElement("arg", "aggregate"))
    args.child_add(NaElement("arg", "modify"))
    args.child_add(NaElement("arg", aggr))
    args.child_add(NaElement("arg", "-hybrid-enabled"))
    args.child_add(NaElement("arg", hybrid))

    systemCli = NaElement("system-cli")
    systemCli.child_add(args)
    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(systemCli)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #2
0
def ifgrp_add_port(module):

    node = module.params['node']
    ifgrp = module.params['ifgrp']
    port = module.params['port']

    results = {}
    results['changed'] = False

    api = NaElement("net-port-ifgrp-add-port")
    api.child_add_string("ifgrp-name", ifgrp)
    api.child_add_string("node", node)
    api.child_add_string("port", port)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #3
0
ファイル: port_flow.py プロジェクト: raghava4u/netapp-ansible
def port_flow(module):

    node = module.params['node']
    port = module.params['port']
    flow_admin = module.params['flow_admin']

    results = {}
    results['changed'] = False

    api = NaElement("net-port-modify")
    api.child_add_string("administrative-flowcontrol", flow_admin)
    api.child_add_string("node", node)
    api.child_add_string("port", port)


    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if(xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #4
0
def broadcast_domain_create(module):

    bc_domain = module.params['bc_domain']
    mtu = module.params['mtu']
    ports = module.params['ports']

    results = {}
    results['changed'] = False

    api = NaElement("net-port-broadcast-domain-create")
    api.child_add_string("broadcast-domain", bc_domain)
    api.child_add_string("mtu", mtu)

    xi = NaElement("ports")
    api.child_add(xi)

    for port in ports:
        xi.child_add_string("net-qualified-port-name", port)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #5
0
ファイル: vol_size.py プロジェクト: raghava4u/netapp-ansible
def vol_size(module):

    volume = module.params['volume']
    size = module.params['size']
    vserver = module.params['vserver']

    results = {}
    results['changed'] = False

    api = NaElement("volume-size")
    api.child_add_string("volume", volume)
    api.child_add_string("new-size", size)

    connection = ntap_util.connect_to_api(module, vserver=vserver)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #6
0
def port_mtu(module):

    node = module.params['node']
    port = module.params['port']
    mtu = module.params['mtu']

    results = {}
    results['changed'] = False

    api = NaElement("net-port-modify")
    api.child_add_string("mtu", mtu)
    api.child_add_string("node", node)
    api.child_add_string("port", port)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #7
0
def asup_invoke(module):

    node = module.params['node']
    message = module.params['message']
    asup_type = module.params['asup_type']
    uri = module.params['uri']

    results = {}
    results['changed'] = False

    api = NaElement("autosupport-invoke")
    api.child_add_string("node-name", node)
    api.child_add_string("type", asup_type)

    if module.params['message']:
        api.child_add_string("message", message)

    if module.params['uri']:
        api.child_add_string("uri", uri)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #8
0
def license_add(module):

    license_keys = module.params['license_keys']

    results = {}
    results['changed'] = False

    api = NaElement("license-v2-add")
    xi = NaElement("codes")

    api.child_add(xi)

    for key in license_keys:
        xi.child_add_string("license-code-v2", key)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #9
0
def ifgrp_create(module):

    node = module.params['node']
    ifgrp = module.params['ifgrp']
    mode = module.params['mode']
    dist_func = module.params['dist_func']

    results = {}
    results['changed'] = False

    api = NaElement("net-port-ifgrp-create")
    api.child_add_string("distribution-function", dist_func)
    api.child_add_string("ifgrp-name", ifgrp)
    api.child_add_string("mode", mode)
    api.child_add_string("node", node)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #10
0
def dns_create(module):

    domains = module.params['domains']
    dns_servers = module.params['dns_servers']
    vserver = module.params['vserver']

    results = {}
    results['changed'] = False

    args = NaElement("args")

    args.child_add(NaElement("arg", "dns"))
    args.child_add(NaElement("arg", "create"))
    args.child_add(NaElement("arg", "-vserver"))
    args.child_add(NaElement("arg", vserver))
    args.child_add(NaElement("arg", "-domains"))
    args.child_add(NaElement("arg", domains))
    args.child_add(NaElement("arg", "-name-servers"))
    args.child_add(NaElement("arg", dns_servers))

    systemCli = NaElement("system-cli")
    systemCli.child_add(args)
    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(systemCli)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #11
0
def vlan_create(module):

    node = module.params['node']
    int_name = module.params['int_name']
    vlanid = module.params['vlanid']

    results = {}
    results['changed'] = False

    api = NaElement("net-vlan-create")

    xi = NaElement("vlan-info")
    api.child_add(xi)

    xi.child_add_string('node', node)
    xi.child_add_string('parent-interface', int_name)
    xi.child_add_string('vlanid', vlanid)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #12
0
def cluster_peer_create(module):

    remote_user = module.params['remote_user']
    remote_pass = module.params['remote_pass']
    peer_addrs = module.params['peer_addrs']

    results = {}
    results['changed'] = False

    api = NaElement("cluster-peer-create")
    if module.params['remote_user']:
        api.child_add_string("user-name", remote_user)
        api.child_add_string("password", remote_pass)

        xi = NaElement("peer-addresses")
        api.child_add(xi)

    for ip in peer_addrs:
        xi.child_add_string("remote-inet-address", ip)


    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if(xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #13
0
ファイル: sp_modify.py プロジェクト: raghava4u/netapp-ansible
def sp_modify(module):

    node = module.params['node']
    addr_family = module.params['addr_family']
    dhcp = module.params['dhcp']
    ip = module.params['ip']
    netmask = module.params['netmask']
    gateway = module.params['gateway']
    enabled = module.params['enabled']

    results = {}
    results['changed'] = False

    api = NaElement("service-processor-network-modify")
    api.child_add_string("address-type", addr_family)
    api.child_add_string("dhcp", dhcp)
    api.child_add_string("node", node)
    api.child_add_string("ip-address", ip)
    api.child_add_string("netmask", netmask)
    api.child_add_string("gateway-ip-address", gateway)
    api.child_add_string("is-enabled", enabled)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #14
0
def asup_modify(module):

    from_addr = module.params['from_addr']
    is_node_subject = module.params['is_node_subject']
    mail_host = module.params['mail_host']
    node = module.params['node']
    partner = module.params['partner']
    to_addr = module.params['to_addr']
    transport = module.params['transport']
    enabled = module.params['enabled']

    results = {}
    results['changed'] = False

    api = NaElement("autosupport-config-modify")
    api.child_add_string("node-name", node)

    if module.params['from_addr']:
        api.child_add_string("from", from_addr)

    if module.params['enabled']:
        api.child_add_string("is-enabled", enabled)

    if module.params['is_node_subject']:
        api.child_add_string("is-node-in-subject", is_node_subject)

    if module.params['mail_host']:
        xi3 = NaElement("mail-hosts")
        api.child_add(xi3)
        for smtp in mail_host:
            xi3.child_add_string("string", smtp)

    if module.params['partner']:
        xi1 = NaElement("partner-address")
        api.child_add(xi1)
        for addr in partner:
            xi1.child_add_string("mail-address", addr)

    if module.params['to_addr']:
        xi2 = NaElement("to")
        api.child_add(xi2)
        for addr in to_addr:
            xi2.child_add_string("mail-address", addr)

    if module.params['transport']:
        api.child_add_string("transport", transport)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #15
0
def int_create(module):

    lif = module.params['lif']
    role = module.params['role']
    data_proto = module.params['data_proto']
    port = module.params['port']
    ip = module.params['ip']
    node = module.params['node']
    netmask = module.params['netmask']
    subnet = module.params['subnet']
    vserver = module.params['vserver']
    status_admin = module.params['status_admin']
    failover_group = module.params['failover_group']
    failover_policy = module.params['failover_policy']

    results = {}
    results['changed'] = False

    api = NaElement('net-interface-create')
    api.child_add_string('address', ip)

    xi = NaElement('data-protocols')
    api.child_add(xi)
    if module.params['data_proto']:
        for proto in data_proto:
            xi.child_add_string('data-protocol', proto)
    api.child_add_string('home-node', node)
    api.child_add_string('home-port', port)
    api.child_add_string('interface-name', lif)
    api.child_add_string('netmask', netmask)
    api.child_add_string('role', role)
    api.child_add_string('vserver', vserver)
    if module.params['subnet']:
        api.child_add_string('subnet-name', subnet)
    if module.params['status_admin']:
        api.child_add_string('administrative-status', status_admin)
    if module.params['failover_group']:
        api.child_add_string('failover-group', failover_group)
    if module.params['failover_policy']:
        api.child_add_string('failover-policy', failover_policy)

    connection = ntap_util.connect_to_api(module, vserver=vserver)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #16
0
def vserver_create(module):

    vserver_name = module.params['vserver_name']
    comment = module.params['comment']
    ipspace = module.params['ipspace']
    language = module.params['language']
    root_vol = module.params['root_vol']
    root_vol_aggr = module.params['root_vol_aggr']
    security = module.params['security']
    vserver_sub = module.params['vserver_sub']
    ns_switch = module.params['ns_switch']

    results = {}
    results['changed'] = False

    api = NaElement('vserver-create')
    api.child_add_string('comment', comment)
    api.child_add_string('ipspace', ipspace)
    api.child_add_string('language', language)
    api.child_add_string('vserver-name', vserver_name)
    api.child_add_string('root-volume', root_vol)
    api.child_add_string('root-volume-aggregate', root_vol_aggr)
    api.child_add_string('root-volume-security-style', security)
    api.child_add_string('vserver-subtype', vserver_sub)

    if module.params['ns_switch']:
        xi = NaElement("name-server-switch")
        xi.child_add_string("nsswitch", ns_switch)
        api.child_add(xi)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #17
0
ファイル: aggr_add.py プロジェクト: raghava4u/netapp-ansible
def aggr_add(module):

    disk_type = module.params['disk_type']
    aggr = module.params['aggr']
    disk_count = module.params['disk_count']
    disk_size = module.params['disk_size']
    storage_pool = module.params['storage_pool']
    allocation_units = module.params['allocation_units']
    raid_type = module.params['raid_type']

    results = {}

    results['changed'] = False

    api = NaElement("aggr-add")
    if module.params['disk_type']:
        api.child_add_string("disk-type", disk_type)
    api.child_add_string("aggregate", aggr)
    if module.params['disk_count']:
        api.child_add_string("disk-count", disk_count)
    if module.params['disk_size']:
        api.child_add_string("disk-size-with-unit", disk_size)
    if module.params['storage_pool']:
        api.child_add_string("storage-pool", storage_pool)
    if module.params['allocation_units']:
        api.child_add_string("allocation-units", allocation_units)
    if module.params['raid_type']:
        api.child_add_string("cache-raid-type", raid_type)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #18
0
def ntp_create(module):

    ntp_server = module.params['ntp_server']

    results = {}
    results['changed'] = False

    api = NaElement("ntp-server-create")
    api.child_add_string("server-name", ntp_server)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #19
0
def aggr_create(module):

    node = module.params['node']
    disk_type = module.params['disk_type']
    aggr = module.params['aggr']
    disk_count = module.params['disk_count']
    disk_size = module.params['disk_size']
    raid_size = module.params['raid_size']
    raid_type = module.params['raid_type']

    results = {}

    results['changed'] = False

    api = NaElement("aggr-create")
    api.child_add_string("disk-type", disk_type)
    api.child_add_string("aggregate", aggr)
    api.child_add_string("disk-count", disk_count)
    api.child_add_string("disk-size-with-unit", disk_size)
    api.child_add_string("raid-size", raid_size)
    api.child_add_string("raid-type", raid_type)

    xi = NaElement("nodes")
    api.child_add(xi)
    xi.child_add_string("node-name", node)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(systemCli)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #20
0
def aggr_rename(module):

    aggr = module.params['aggr']
    new_aggr_name = module.params['new_aggr_name']

    results = {}
    results['changed'] = False

    api = NaElement("aggr-rename")
    api.child_add_string("aggregate", aggr)
    api.child_add_string("new-aggregate-name", new_aggr_name)
    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #21
0
ファイル: date_time.py プロジェクト: raghava4u/netapp-ansible
def date_time(module):

    timezone = module.params['timezone']
    date = module.params['date']


    results = {}

    results['changed'] = False


    args = NaElement("args")

    args.child_add(NaElement("arg", "cluster"))
    args.child_add(NaElement("arg", "date"))
    args.child_add(NaElement("arg", "modify"))
    if module.params['timezone']:
        args.child_add(NaElement("arg", "-timezone"))
        args.child_add(NaElement("arg", timezone))
    if module.params['date']:
        args.child_add(NaElement("arg", "-date"))
        args.child_add(NaElement("arg", date))

    systemCli = NaElement("system-cli")
    systemCli.child_add(args)
    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(systemCli)

    if(xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results
コード例 #22
0
def subnet_create(module):

    subnet_name = module.params['subnet_name']
    subnet = module.params['subnet']
    ip_ranges = module.params['ip_ranges']
    bc_domain = module.params['bc_domain']
    gateway = module.params['gateway']

    results = {}
    results['changed'] = False

    api = NaElement("net-subnet-create")
    api.child_add_string("broadcast-domain", bc_domain)
    api.child_add_string("subnet-name", subnet_name)
    api.child_add_string("subnet", subnet)

    if module.params['gateway']:
        api.child_add_string("gateway", gateway)

    xi = NaElement("ip-ranges")
    api.child_add(xi)
    for ip in ip_ranges:
        xi.child_add_string("ip-range", ip)

    connection = ntap_util.connect_to_api(module)
    xo = connection.invoke_elem(api)

    if (xo.results_errno() != 0):
        r = xo.results_reason()
        module.fail_json(msg=r)
        results['changed'] = False

    else:
        results['changed'] = True

    return results