Пример #1
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='vflow-table-profile-modify')

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str', choices=state_map.keys()),
            pn_profile=dict(required=False,
                            type='str',
                            choices=['application', 'ipv6', 'qos']),
            pn_hw_tbl=dict(
                required=False,
                type='str',
                choices=['switch-main', 'switch-hash', 'npu-main',
                         'npu-hash']),
            pn_enable=dict(required=False, type='bool'),
        ),
        required_if=(['state', 'update', ['pn_profile', 'pn_hw_tbl']], ),
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    profile = module.params['pn_profile']
    hw_tbl = module.params['pn_hw_tbl']
    enable = module.params['pn_enable']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'vflow-table-profile-modify':
        cli += ' %s ' % command
        if profile:
            cli += ' profile ' + profile
        if hw_tbl:
            cli += ' hw-tbl ' + hw_tbl

        cli += booleanArgs(enable, 'enable', 'disable')

    run_cli(module, cli, state_map)
Пример #2
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='stp-modify')

    module = AnsibleModule(argument_spec=dict(
        pn_cliswitch=dict(required=False, type='str'),
        state=dict(required=True, type='str', choices=state_map.keys()),
        pn_hello_time=dict(required=False, type='str', default='2'),
        pn_enable=dict(required=False, type='bool'),
        pn_root_guard_wait_time=dict(required=False, type='str', default='20'),
        pn_bpdus_bridge_ports=dict(required=False, type='bool'),
        pn_mst_max_hops=dict(required=False, type='str', default='20'),
        pn_bridge_id=dict(required=False, type='str'),
        pn_max_age=dict(required=False, type='str', default='20'),
        pn_stp_mode=dict(required=False, type='str', choices=['rstp', 'mstp']),
        pn_mst_config_name=dict(required=False, type='str'),
        pn_forwarding_delay=dict(required=False, type='str', default='15'),
        pn_bridge_priority=dict(required=False, type='str', default='32768'),
    ),
                           required_one_of=[[
                               'pn_enable', 'pn_hello_time',
                               'pn_root_guard_wait_time',
                               'pn_bpdus_bridge_ports', 'pn_mst_max_hops',
                               'pn_bridge_id', 'pn_max_age', 'pn_stp_mode',
                               'pn_mst_config_name', 'pn_forwarding_delay',
                               'pn_bridge_priority'
                           ]])

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    hello_time = module.params['pn_hello_time']
    enable = module.params['pn_enable']
    root_guard_wait_time = module.params['pn_root_guard_wait_time']
    bpdus_bridge_ports = module.params['pn_bpdus_bridge_ports']
    mst_max_hops = module.params['pn_mst_max_hops']
    bridge_id = module.params['pn_bridge_id']
    max_age = module.params['pn_max_age']
    stp_mode = module.params['pn_stp_mode']
    mst_config_name = module.params['pn_mst_config_name']
    forwarding_delay = module.params['pn_forwarding_delay']
    bridge_priority = module.params['pn_bridge_priority']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'stp-modify':
        cli += ' %s ' % command
        if hello_time:
            cli += ' hello-time ' + hello_time
        if root_guard_wait_time:
            cli += ' root-guard-wait-time ' + root_guard_wait_time
        if mst_max_hops:
            cli += ' mst-max-hops ' + mst_max_hops
        if bridge_id:
            cli += ' bridge-id ' + bridge_id
        if max_age:
            cli += ' max-age ' + max_age
        if stp_mode:
            cli += ' stp-mode ' + stp_mode
        if mst_config_name:
            cli += ' mst-config-name ' + mst_config_name
        if forwarding_delay:
            cli += ' forwarding-delay ' + forwarding_delay
        if bridge_priority:
            cli += ' bridge-priority ' + bridge_priority

        cli += booleanArgs(enable, 'enable', 'disable')
        cli += booleanArgs(bpdus_bridge_ports, 'bpdus-bridge-ports',
                           'bpdus-all-ports')

    run_cli(module, cli, state_map)
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='stp-port-modify')

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str', choices=state_map.keys()),
            pn_priority=dict(required=False, type='str', default='128'),
            pn_cost=dict(required=False, type='str', default='2000'),
            pn_root_guard=dict(required=False, type='bool'),
            pn_filter=dict(required=False, type='bool'),
            pn_edge=dict(required=False, type='bool'),
            pn_bpdu_guard=dict(required=False, type='bool'),
            pn_port=dict(required=False, type='str'),
            pn_block=dict(required=False, type='bool'),
        ),
        required_if=(["state", "update", ["pn_port"]], ),
        required_one_of=([
            'pn_cost', 'pn_root_guard', 'pn_filter', 'pn_edge',
            'pn_bpdu_guard', 'pn_block'
        ], ),
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    priority = module.params['pn_priority']
    cost = module.params['pn_cost']
    root_guard = module.params['pn_root_guard']
    pn_filter = module.params['pn_filter']
    edge = module.params['pn_edge']
    bpdu_guard = module.params['pn_bpdu_guard']
    port = module.params['pn_port']
    block = module.params['pn_block']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'stp-port-modify':
        cli += ' %s ' % command
        if priority and (int(priority) % 16 == 0 and int(priority) < 240):
            cli += ' priority ' + priority
        else:
            module.fail_json(
                failed=True,
                msg=
                'Priority must be increment of 16 and should be less that 240')
        if cost and (int(cost) < 200000000):
            cli += ' cost ' + cost
        else:
            module.fail_json(failed=True,
                             msg='cost must be between 1 and 200000000')
        if port:
            cli += ' port ' + port

        cli += booleanArgs(root_guard, 'root-guard', 'no-root-guard')
        cli += booleanArgs(pn_filter, 'filter', 'no-filter')
        cli += booleanArgs(edge, 'edge', 'no-edge')
        cli += booleanArgs(bpdu_guard, 'bpdu-guard', 'no-bpdu-guard')
        cli += booleanArgs(block, 'block', 'no-block')

    run_cli(module, cli, state_map)
Пример #4
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(present='snmp-vacm-create',
                     absent='snmp-vacm-delete',
                     update='snmp-vacm-modify')

    module = AnsibleModule(argument_spec=dict(
        pn_cliswitch=dict(required=False, type='str'),
        state=dict(required=True, type='str', choices=state_map.keys()),
        pn_oid_restrict=dict(required=False, type='str'),
        pn_priv=dict(required=False, type='bool'),
        pn_auth=dict(required=False, type='bool'),
        pn_user_type=dict(required=False,
                          type='str',
                          choices=['rouser', 'rwuser']),
        pn_user_name=dict(required=False, type='str'),
    ),
                           required_if=(["state", "present", ["pn_user_name"]],
                                        ["state", "absent", ["pn_user_name"]],
                                        ["state", "update", ["pn_user_name"]]))

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    oid_restrict = module.params['pn_oid_restrict']
    priv = module.params['pn_priv']
    auth = module.params['pn_auth']
    user_type = module.params['pn_user_type']
    user_name = module.params['pn_user_name']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    USER_EXISTS = check_cli(module, cli)
    cli += ' %s user-name %s ' % (command, user_name)

    if command == 'snmp-vacm-modify':
        if USER_EXISTS is None:
            module.fail_json(failed=True,
                             msg='snmp user with name %s does not exists' %
                             user_name)
        if USER_EXISTS is False:
            module.fail_json(failed=True,
                             msg='snmp vacm with name %s does not exists' %
                             user_name)

    if command == 'snmp-vacm-delete':
        if USER_EXISTS is None:
            module.fail_json(failed=True,
                             msg='snmp user with name %s does not exists' %
                             user_name)

        if USER_EXISTS is False:
            module.exit_json(skipped=True,
                             msg='snmp vacm with name %s does not exist' %
                             user_name)

    if command == 'snmp-vacm-create':
        if USER_EXISTS is None:
            module.fail_json(failed=True,
                             msg='snmp user with name %s does not exists' %
                             user_name)
        if USER_EXISTS is True:
            module.exit_json(skipped=True,
                             msg='snmp vacm with name %s already exists' %
                             user_name)

    if command != 'snmp-vacm-delete':
        if oid_restrict:
            cli += ' oid-restrict ' + oid_restrict
        if user_type:
            cli += ' user-type ' + user_type

        cli += booleanArgs(auth, 'auth', 'no-auth')
        cli += booleanArgs(priv, 'priv', 'no-priv')

    run_cli(module, cli, state_map)
Пример #5
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(present='role-create',
                     absent='role-delete',
                     update='role-modify')

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str', choices=state_map.keys()),
            pn_scope=dict(required=False,
                          type='str',
                          choices=['local', 'fabric']),
            pn_access=dict(required=False,
                           type='str',
                           choices=['read-only', 'read-write']),
            pn_shell=dict(required=False, type='bool'),
            pn_sudo=dict(required=False, type='bool'),
            pn_running_config=dict(required=False, type='bool'),
            pn_name=dict(required=False, type='str'),
            pn_delete_from_users=dict(required=False, type='bool'),
        ),
        required_if=(
            ["state", "present", ["pn_name", "pn_scope"]],
            ["state", "absent", ["pn_name"]],
            ["state", "update", ["pn_name"]],
        ),
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    scope = module.params['pn_scope']
    access = module.params['pn_access']
    shell = module.params['pn_shell']
    sudo = module.params['pn_sudo']
    running_config = module.params['pn_running_config']
    name = module.params['pn_name']
    delete_from_users = module.params['pn_delete_from_users']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    ROLE_EXISTS = check_cli(module, cli)
    cli += ' %s name %s ' % (command, name)

    if shell is (False or '') and sudo is True:
        module.fail_json(failed=True, msg='sudo access requires shell access')

    if command == 'role-modify':
        if ROLE_EXISTS is False:
            module.fail_json(failed=True,
                             msg='Role with name %s does not exist' % name)

    if command == 'role-delete':
        if ROLE_EXISTS is False:
            module.exit_json(skipped=True,
                             msg='Role with name %s does not exist' % name)

    if command == 'role-create':
        if ROLE_EXISTS is True:
            module.exit_json(skipped=True,
                             msg='Role with name %s already exists' % name)

        if scope:
            cli += ' scope ' + scope

    if command != 'role-delete':
        if access:
            cli += ' access ' + access

        cli += booleanArgs(shell, 'shell', 'no-shell')
        cli += booleanArgs(sudo, 'sudo', 'no-sudo')
        cli += booleanArgs(running_config, 'running-config',
                           'no-running-config')

    if command == 'role-modify':
        if delete_from_users:
            cli += ' delete-from-users ' + delete_from_users

    run_cli(module, cli, state_map)
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='port-config-modify')

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str', choices=['update']),
            pn_intf=dict(required=False, type='str'),
            pn_crc_check_enable=dict(required=False, type='bool'),
            pn_dscp_map=dict(required=False, type='str'),
            pn_autoneg=dict(required=False, type='bool'),
            pn_speed=dict(required=False,
                          type='str',
                          choices=[
                              'disable', '10m', '100m', '1g', '2.5g', '10g',
                              '25g', '40g', '50g', '100g'
                          ]),
            pn_port=dict(required=False, type='str'),
            pn_vxlan_termination=dict(required=False, type='bool'),
            pn_pause=dict(required=False, type='bool'),
            pn_loopback=dict(required=False, type='bool'),
            pn_loop_vlans=dict(required=False, type='str'),
            pn_routing=dict(required=False, type='bool'),
            pn_edge_switch=dict(required=False, type='bool'),
            pn_enable=dict(required=False, type='bool'),
            pn_description=dict(required=False, type='str'),
            pn_host_enable=dict(required=False, type='bool'),
            pn_allowed_tpid=dict(required=False,
                                 type='str',
                                 choices=['vlan', 'q-in-q', 'q-in-q-old']),
            pn_mirror_only=dict(required=False, type='bool'),
            pn_reflect=dict(required=False, type='bool'),
            pn_jumbo=dict(required=False, type='bool'),
            pn_egress_rate_limit=dict(required=False, type='str'),
            pn_eth_mode=dict(
                required=False,
                type='str',
                choices=['1000base-x', 'sgmii', 'disabled', 'GMII']),
            pn_fabric_guard=dict(required=False, type='bool'),
            pn_local_switching=dict(required=False, type='bool'),
            pn_lacp_priority=dict(required=False, type='str'),
            pn_send_port=dict(required=False, type='str'),
            pn_port_mac_address=dict(required=False, type='str'),
            pn_defer_bringup=dict(required=False, type='bool'),
        ),
        required_if=(['state', 'update', ['pn_port']], ),
        required_one_of=[[
            'pn_intf', 'pn_crc_check_enable', 'pn_dscp_map', 'pn_speed',
            'pn_autoneg', 'pn_vxlan_termination', 'pn_pause', 'pn_fec',
            'pn_loopback', 'pn_loop_vlans', 'pn_routing', 'pn_edge_switch',
            'pn_enable', 'pn_description', 'pn_host_enable', 'pn_allowed_tpid',
            'pn_mirror_only', 'pn_reflect', 'pn_jumbo', 'pn_egress_rate_limit',
            'pn_eth_mode', 'pn_fabric_guard', 'pn_local_switching',
            'pn_lacp_priority', 'pn_send_port', 'pn_port_mac_address',
            'pn_defer_bringup'
        ]],
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    intf = module.params['pn_intf']
    crc_check_enable = module.params['pn_crc_check_enable']
    dscp_map = module.params['pn_dscp_map']
    autoneg = module.params['pn_autoneg']
    speed = module.params['pn_speed']
    port = module.params['pn_port']
    vxlan_termination = module.params['pn_vxlan_termination']
    pause = module.params['pn_pause']
    loopback = module.params['pn_loopback']
    loop_vlans = module.params['pn_loop_vlans']
    routing = module.params['pn_routing']
    edge_switch = module.params['pn_edge_switch']
    enable = module.params['pn_enable']
    description = module.params['pn_description']
    host_enable = module.params['pn_host_enable']
    allowed_tpid = module.params['pn_allowed_tpid']
    mirror_only = module.params['pn_mirror_only']
    reflect = module.params['pn_reflect']
    jumbo = module.params['pn_jumbo']
    egress_rate_limit = module.params['pn_egress_rate_limit']
    eth_mode = module.params['pn_eth_mode']
    fabric_guard = module.params['pn_fabric_guard']
    local_switching = module.params['pn_local_switching']
    lacp_priority = module.params['pn_lacp_priority']
    send_port = module.params['pn_send_port']
    port_mac_address = module.params['pn_port_mac_address']
    defer_bringup = module.params['pn_defer_bringup']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if dscp_map:
        NAME_EXISTS = check_cli(module, cli)

    if command == 'port-config-modify':
        cli += ' %s ' % command
        if dscp_map:
            if NAME_EXISTS is False:
                module.fail_json(
                    failed=True,
                    msg='Create dscp map with name %s before updating' %
                    dscp_map)

            cli += ' dscp-map ' + dscp_map
        if intf:
            cli += ' intf ' + intf
        if speed:
            cli += ' speed ' + speed
        if port:
            cli += ' port ' + port
        if allowed_tpid:
            cli += ' allowed-tpid ' + allowed_tpid
        if egress_rate_limit:
            cli += ' egress-rate-limit ' + egress_rate_limit
        if eth_mode:
            cli += ' eth-mode ' + eth_mode
        if lacp_priority:
            cli += ' lacp-priority ' + lacp_priority
        if send_port:
            cli += ' send-port ' + send_port
        if port_mac_address:
            cli += ' port-mac-address ' + port_mac_address

        cli += booleanArgs(crc_check_enable, 'crc-check-enable',
                           'crc-check-disable')
        cli += booleanArgs(autoneg, 'autoneg', 'no-autoneg')
        cli += booleanArgs(vxlan_termination, 'vxlan-termination',
                           'no-vxlan-termination')
        cli += booleanArgs(pause, 'pause', 'no-pause')
        cli += booleanArgs(loopback, 'loopback', 'no-loopback')
        cli += booleanArgs(routing, 'routing', 'no-routing')
        cli += booleanArgs(edge_switch, 'edge-switch', 'no-edge-switch')
        cli += booleanArgs(enable, 'enable', 'disable')
        cli += booleanArgs(host_enable, 'host-enable', 'host-disable')
        cli += booleanArgs(mirror_only, 'mirror-only',
                           'no-mirror-receive-only')
        cli += booleanArgs(reflect, 'reflect', 'no-reflect')
        cli += booleanArgs(jumbo, 'jumbo', 'no-jumbo')
        cli += booleanArgs(fabric_guard, 'fabric-guard', 'no-fabric-guard')
        cli += booleanArgs(local_switching, 'local-switching',
                           'no-local-switching')
        cli += booleanArgs(defer_bringup, 'defer-bringup', 'no-defer-bringup')

    run_cli(module, cli, state_map)
def main():
    """ This section is for arguments parsing """

    state_map = dict(
        update='switch-setup-modify'
    )

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str',
                       choices=['update']),
            pn_force=dict(required=False, type='bool'),
            pn_dns_ip=dict(required=False, type='str'),
            pn_mgmt_netmask=dict(required=False, type='str'),
            pn_gateway_ip6=dict(required=False, type='str'),
            pn_in_band_ip6_assign=dict(required=False, type='str',
                                       choices=['none', 'autoconf']),
            pn_domain_name=dict(required=False, type='str'),
            pn_timezone=dict(required=False, type='str'),
            pn_in_band_netmask=dict(required=False, type='str'),
            pn_in_band_ip6=dict(required=False, type='str'),
            pn_in_band_netmask_ip6=dict(required=False, type='str'),
            pn_motd=dict(required=False, type='str'),
            pn_loopback_ip6=dict(required=False, type='str'),
            pn_mgmt_ip6_assignment=dict(required=False, type='str',
                                        choices=['none', 'autoconf']),
            pn_ntp_secondary_server=dict(required=False, type='str'),
            pn_in_band_ip=dict(required=False, type='str'),
            pn_eula_accepted=dict(required=False, type='str',
                                  choices=['true', 'false']),
            pn_mgmt_ip=dict(required=False, type='str'),
            pn_ntp_server=dict(required=False, type='str'),
            pn_mgmt_ip_assignment=dict(required=False, type='str',
                                       choices=['none', 'dhcp']),
            pn_date=dict(required=False, type='str'),
            pn_password=dict(required=False, type='str', no_log=True),
            pn_banner=dict(required=False, type='str'),
            pn_loopback_ip=dict(required=False, type='str'),
            pn_dns_secondary_ip=dict(required=False, type='str'),
            pn_switch_name=dict(required=False, type='str'),
            pn_eula_timestamp=dict(required=False, type='str'),
            pn_mgmt_netmask_ip6=dict(required=False, type='str'),
            pn_enable_host_ports=dict(required=False, type='bool'),
            pn_mgmt_ip6=dict(required=False, type='str'),
            pn_analytics_store=dict(required=False, type='str',
                                    choices=['default', 'optimized']),
            pn_gateway_ip=dict(required=False, type='str'),
        ),
        required_one_of=[['pn_force', 'pn_dns_ip', 'pn_mgmt_netmask',
                          'pn_gateway_ip6', 'pn_in_band_ip6_assign',
                          'pn_domain_name', 'pn_timezone',
                          'pn_in_band_netmask', 'pn_in_band_ip6',
                          'pn_in_band_netmask_ip6', 'pn_motd',
                          'pn_loopback_ip6', 'pn_mgmt_ip6_assignment',
                          'pn_ntp_secondary_server', 'pn_in_band_ip',
                          'pn_eula_accepted', 'pn_mgmt_ip',
                          'pn_ntp_server', 'pn_mgmt_ip_assignment',
                          'pn_date', 'pn_password',
                          'pn_banner', 'pn_loopback_ip',
                          'pn_dns_secondary_ip', 'pn_switch_name',
                          'pn_eula_timestamp', 'pn_mgmt_netmask_ip6',
                          'pn_enable_host_ports', 'pn_mgmt_ip6',
                          'pn_analytics_store', 'pn_gateway_ip']],
        required_together=[['pn_in_band_ip6', 'pn_in_band_netmask_ip6'],
                           ['pn_in_band_ip', 'pn_in_band_netmask'],
                           ['pn_mgmt_ip', 'pn_mgmt_netmask'],
                           ['pn_mgmt_ip6', 'pn_mgmt_netmask_ip6']],
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    force = module.params['pn_force']
    dns_ip = module.params['pn_dns_ip']
    mgmt_netmask = module.params['pn_mgmt_netmask']
    gateway_ip6 = module.params['pn_gateway_ip6']
    in_band_ip6_assign = module.params['pn_in_band_ip6_assign']
    domain_name = module.params['pn_domain_name']
    timezone = module.params['pn_timezone']
    in_band_netmask = module.params['pn_in_band_netmask']
    in_band_ip6 = module.params['pn_in_band_ip6']
    in_band_netmask_ip6 = module.params['pn_in_band_netmask_ip6']
    motd = module.params['pn_motd']
    loopback_ip6 = module.params['pn_loopback_ip6']
    mgmt_ip6_assignment = module.params['pn_mgmt_ip6_assignment']
    ntp_secondary_server = module.params['pn_ntp_secondary_server']
    in_band_ip = module.params['pn_in_band_ip']
    eula_accepted = module.params['pn_eula_accepted']
    mgmt_ip = module.params['pn_mgmt_ip']
    ntp_server = module.params['pn_ntp_server']
    mgmt_ip_assignment = module.params['pn_mgmt_ip_assignment']
    date = module.params['pn_date']
    password = module.params['pn_password']
    banner = module.params['pn_banner']
    loopback_ip = module.params['pn_loopback_ip']
    dns_secondary_ip = module.params['pn_dns_secondary_ip']
    switch_name = module.params['pn_switch_name']
    eula_timestamp = module.params['pn_eula_timestamp']
    mgmt_netmask_ip6 = module.params['pn_mgmt_netmask_ip6']
    enable_host_ports = module.params['pn_enable_host_ports']
    mgmt_ip6 = module.params['pn_mgmt_ip6']
    analytics_store = module.params['pn_analytics_store']
    gateway_ip = module.params['pn_gateway_ip']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'switch-setup-modify':
        cli += ' %s ' % command
        if dns_ip:
            cli += ' dns-ip ' + dns_ip
        if mgmt_netmask:
            cli += ' mgmt-netmask ' + mgmt_netmask
        if gateway_ip6:
            cli += ' gateway-ip6 ' + gateway_ip6
        if in_band_ip6_assign:
            cli += ' in-band-ip6-assign ' + in_band_ip6_assign
        if domain_name:
            cli += ' domain-name ' + domain_name
        if timezone:
            cli += ' timezone ' + timezone
        if in_band_netmask:
            cli += ' in-band-netmask ' + in_band_netmask
        if in_band_ip6:
            cli += ' in-band-ip6 ' + in_band_ip6
        if in_band_netmask_ip6:
            cli += ' in-band-netmask-ip6 ' + in_band_netmask_ip6
        if motd:
            cli += ' motd ' + motd
        if loopback_ip6:
            cli += ' loopback-ip6 ' + loopback_ip6
        if mgmt_ip6_assignment:
            cli += ' mgmt-ip6-assignment ' + mgmt_ip6_assignment
        if ntp_secondary_server:
            cli += ' ntp-secondary-server ' + ntp_secondary_server
        if in_band_ip:
            cli += ' in-band-ip ' + in_band_ip
        if eula_accepted:
            cli += ' eula-accepted ' + eula_accepted
        if mgmt_ip:
            cli += ' mgmt-ip ' + mgmt_ip
        if ntp_server:
            cli += ' ntp-server ' + ntp_server
        if mgmt_ip_assignment:
            cli += ' mgmt-ip-assignment ' + mgmt_ip_assignment
        if date:
            cli += ' date ' + date
        if password:
            cli += ' password ' + password
        if banner:
            cli += ' banner ' + banner
        if loopback_ip:
            cli += ' loopback-ip ' + loopback_ip
        if dns_secondary_ip:
            cli += ' dns-secondary-ip ' + dns_secondary_ip
        if switch_name:
            cli += ' switch-name ' + switch_name
        if eula_timestamp:
            cli += ' eula_timestamp ' + eula_timestamp
        if mgmt_netmask_ip6:
            cli += ' mgmt-netmask-ip6 ' + mgmt_netmask_ip6
        if mgmt_ip6:
            cli += ' mgmt-ip6 ' + mgmt_ip6
        if analytics_store:
            cli += ' analytics-store ' + analytics_store
        if gateway_ip:
            cli += ' gateway-ip ' + gateway_ip

        cli += booleanArgs(force, 'force', 'no-force')
        cli += booleanArgs(enable_host_ports, 'enable-host-ports', 'disable-host-ports')

    run_cli(module, cli, state_map)
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='connection-stats-settings-modify')

    module = AnsibleModule(
        argument_spec=dict(
            pn_cliswitch=dict(required=False, type='str'),
            state=dict(required=True, type='str', choices=state_map.keys()),
            pn_enable=dict(required=False, type='bool'),
            pn_connection_backup_enable=dict(required=False, type='bool'),
            pn_client_server_stats_max_memory=dict(required=False, type='str'),
            pn_connection_stats_log_disk_space=dict(required=False,
                                                    type='str'),
            pn_client_server_stats_log_enable=dict(required=False,
                                                   type='bool'),
            pn_service_stat_max_memory=dict(required=False, type='str'),
            pn_connection_stats_log_interval=dict(required=False, type='str'),
            pn_fabric_connection_backup_interval=dict(required=False,
                                                      type='str'),
            pn_connection_backup_interval=dict(required=False, type='str'),
            pn_connection_stats_log_enable=dict(required=False, type='bool'),
            pn_fabric_connection_max_memory=dict(required=False, type='str'),
            pn_fabric_connection_backup_enable=dict(required=False,
                                                    type='bool'),
            pn_client_server_stats_log_disk_space=dict(required=False,
                                                       type='str'),
            pn_connection_max_memory=dict(required=False, type='str'),
            pn_connection_stats_max_memory=dict(required=False, type='str'),
            pn_client_server_stats_log_interval=dict(required=False,
                                                     type='str'),
        ),
        required_one_of=[[
            'pn_enable', 'pn_connection_backup_enable',
            'pn_client_server_stats_max_memory',
            'pn_connection_stats_log_disk_space',
            'pn_client_server_stats_log_enable', 'pn_service_stat_max_memory',
            'pn_connection_stats_log_interval',
            'pn_connection_backup_interval', 'pn_connection_stats_log_enable',
            'pn_fabric_connection_max_memory',
            'pn_fabric_connection_backup_enable',
            'pn_client_server_stats_log_disk_space',
            'pn_connection_max_memory', 'pn_connection_stats_max_memory',
            'pn_client_server_stats_log_interval'
        ]])

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    enable = module.params['pn_enable']
    connection_backup_enable = module.params['pn_connection_backup_enable']
    client_server_stats_max_memory = module.params[
        'pn_client_server_stats_max_memory']
    connection_stats_log_disk_space = module.params[
        'pn_connection_stats_log_disk_space']
    client_server_stats_log_enable = module.params[
        'pn_client_server_stats_log_enable']
    service_stat_max_memory = module.params['pn_service_stat_max_memory']
    connection_stats_log_interval = module.params[
        'pn_connection_stats_log_interval']
    fabric_connection_backup_interval = module.params[
        'pn_fabric_connection_backup_interval']
    connection_backup_interval = module.params['pn_connection_backup_interval']
    connection_stats_log_enable = module.params[
        'pn_connection_stats_log_enable']
    fabric_connection_max_memory = module.params[
        'pn_fabric_connection_max_memory']
    fabric_connection_backup_enable = module.params[
        'pn_fabric_connection_backup_enable']
    client_server_stats_log_disk_space = module.params[
        'pn_client_server_stats_log_disk_space']
    connection_max_memory = module.params['pn_connection_max_memory']
    connection_stats_max_memory = module.params[
        'pn_connection_stats_max_memory']
    client_server_stats_log_interval = module.params[
        'pn_client_server_stats_log_interval']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'connection-stats-settings-modify':
        cli += ' %s ' % command

        cli += booleanArgs(enable, 'enable', 'disable')
        cli += booleanArgs(connection_backup_enable,
                           'connection-backup-enable',
                           'connection-backup-disable')
        cli += booleanArgs(client_server_stats_log_enable,
                           'client-server-stats-log-enable',
                           'client-server-stats-log-disable')
        cli += booleanArgs(connection_stats_log_enable,
                           'connection-stats-log-enable',
                           'connection-stats-log-disable')
        cli += booleanArgs(fabric_connection_backup_enable,
                           'fabric-connection-backup-enable',
                           'fabric-connection-backup-disable')

        if client_server_stats_max_memory:
            cli += ' client-server-stats-max-memory ' + client_server_stats_max_memory
        if connection_stats_log_disk_space:
            cli += ' connection-stats-log-disk-space ' + connection_stats_log_disk_space
        if service_stat_max_memory:
            cli += ' service-stat-max-memory ' + service_stat_max_memory
        if connection_stats_log_interval:
            cli += ' connection-stats-log-interval ' + connection_stats_log_interval
        if fabric_connection_backup_interval:
            cli += ' fabric-connection-backup-interval ' + fabric_connection_backup_interval
        if connection_backup_interval:
            cli += ' connection-backup-interval ' + connection_backup_interval
        if fabric_connection_max_memory:
            cli += ' fabric-connection-max-memory ' + fabric_connection_max_memory
        if client_server_stats_log_disk_space:
            cli += ' client-server-stats-log-disk-space ' + client_server_stats_log_disk_space
        if connection_max_memory:
            cli += ' connection-max-memory ' + connection_max_memory
        if connection_stats_max_memory:
            cli += ' connection-stats-max-memory ' + connection_stats_max_memory
        if client_server_stats_log_interval:
            cli += ' client-server-stats-log-interval ' + client_server_stats_log_interval

    run_cli(module, cli, state_map)
Пример #9
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='admin-service-modify')

    module = AnsibleModule(argument_spec=dict(
        pn_cliswitch=dict(required=False, type='str'),
        state=dict(required=True, type='str', choices=state_map.keys()),
        pn_web=dict(required=False, type='bool'),
        pn_web_ssl=dict(required=False, type='bool'),
        pn_snmp=dict(required=False, type='bool'),
        pn_web_port=dict(required=False, type='str'),
        pn_web_ssl_port=dict(required=False, type='str'),
        pn_nfs=dict(required=False, type='bool'),
        pn_ssh=dict(required=False, type='bool'),
        pn_web_log=dict(required=False, type='bool'),
        pn__if=dict(required=False, type='str', choices=['mgmt', 'data']),
        pn_icmp=dict(required=False, type='bool'),
        pn_net_api=dict(required=False, type='bool'),
    ),
                           required_if=([['state', 'update', ['pn__if']]]),
                           required_one_of=[[
                               'pn_web', 'pn_web_ssl', 'pn_snmp',
                               'pn_web_port', 'pn_web_ssl_port', 'pn_nfs',
                               'pn_ssh', 'pn_web_log', 'pn_icmp', 'pn_net_api'
                           ]])

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    web = module.params['pn_web']
    web_ssl = module.params['pn_web_ssl']
    snmp = module.params['pn_snmp']
    web_port = module.params['pn_web_port']
    web_ssl_port = module.params['pn_web_ssl_port']
    nfs = module.params['pn_nfs']
    ssh = module.params['pn_ssh']
    web_log = module.params['pn_web_log']
    _if = module.params['pn__if']
    icmp = module.params['pn_icmp']
    net_api = module.params['pn_net_api']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'admin-service-modify':
        cli += ' %s ' % command

        if _if:
            cli += ' if ' + _if
        if web_port:
            cli += ' web-port ' + web_port
        if web_ssl_port:
            cli += ' web-ssl-port ' + web_ssl_port

        cli += booleanArgs(web, 'web', 'no-web')
        cli += booleanArgs(web_ssl, 'web-ssl', 'no-web-ssl')
        cli += booleanArgs(snmp, 'snmp', 'no-snmp')
        cli += booleanArgs(nfs, 'nfs', 'no-nfs')
        cli += booleanArgs(ssh, 'ssh', 'no-ssh')
        cli += booleanArgs(icmp, 'icmp', 'no-icmp')
        cli += booleanArgs(net_api, 'net-api', 'no-net-api')
        cli += booleanArgs(web_log, 'web-log', 'no-web-log')

    run_cli(module, cli, state_map)
def main():
    """ This section is for arguments parsing """

    state_map = dict(present='vrouter-bgp-add',
                     absent='vrouter-bgp-remove',
                     update='vrouter-bgp-modify')

    argument_spec = dict(
        pn_cliswitch=dict(required=False, type='str'),
        state=dict(required=False,
                   type='str',
                   choices=state_map.keys(),
                   default='present'),
        pn_neighbor=dict(required=True, type='str'),
        pn_vrouter_name=dict(required=True, type='str'),
        pn_send_community=dict(required=False, type='bool'),
        pn_weight=dict(required=False, type='str'),
        pn_multi_protocol=dict(required=False,
                               type='str',
                               choices=['ipv4-unicast', 'ipv6-unicast']),
        pn_prefix_list_in=dict(required=False, type='str'),
        pn_route_reflector_client=dict(required=False, type='bool'),
        pn_default_originate=dict(required=False, type='bool'),
        pn_neighbor_holdtime=dict(required=False, type='str'),
        pn_connect_retry_interval=dict(required=False, type='str'),
        pn_advertisement_interval=dict(required=False, type='str'),
        pn_route_map_out=dict(required=False, type='str'),
        pn_update_source=dict(required=False, type='str'),
        pn_bfd=dict(required=False, type='bool', default=False),
        pn_next_hop_self=dict(required=False, type='bool'),
        pn_allowas_in=dict(required=False, type='bool'),
        pn_neighbor_keepalive_interval=dict(required=False, type='str'),
        pn_max_prefix=dict(required=False, type='str'),
        pn_bfd_multihop=dict(required=False, type='bool'),
        pn_interface=dict(required=False, type='str'),
        pn_password=dict(required=False, type='str', no_log=True),
        pn_route_map_in=dict(required=False, type='str'),
        pn_soft_reconfig_inbound=dict(required=False, type='bool'),
        pn_override_capability=dict(required=False, type='bool'),
        pn_max_prefix_warn_only=dict(required=False, type='bool'),
        pn_ebgp_multihop=dict(required=False, type='str'),
        pn_remote_as=dict(required=False, type='str'),
        pn_prefix_list_out=dict(required=False, type='str'),
        pn_no_route_map_out=dict(required=False, type='str'),
        pn_no_route_map_in=dict(required=False, type='str'),
    )

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_if=([
            "state", "present",
            ["pn_vrouter_name", "pn_neighbor", "pn_remote_as"]
        ], ["state", "absent", ["pn_vrouter_name", "pn_neighbor"]],
                     ["state", "update", ["pn_vrouter_name", "pn_neighbor"]]),
        required_one_of=[[
            'pn_send_community', 'pn_weight', 'pn_multi_protocol',
            'pn_prefix_list_in', 'pn_route_reflector_client',
            'pn_default_originate', 'pn_neighbor_holdtime',
            'pn_connect_retry_interval', 'pn_advertisement_interval',
            'pn_route_map_out', 'pn_update_source', 'pn_bfd',
            'pn_next_hop_self', 'pn_allowas_in',
            'pn_neighbor_keepalive_interval', 'pn_max_prefix',
            'pn_bfd_multihop', 'pn_interface', 'pn_password',
            'pn_route_map_in', 'pn_soft_reconfig_inbound',
            'pn_override_capability', 'pn_max_prefix_warn_only',
            'pn_ebgp_multihop', 'pn_remote_as', 'pn_prefix_list_out',
            'pn_no_route_map_out', 'pn_no_route_map_in'
        ]],
    )

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    neighbor = module.params['pn_neighbor']
    vrouter_name = module.params['pn_vrouter_name']
    send_community = module.params['pn_send_community']
    weight = module.params['pn_weight']
    multi_protocol = module.params['pn_multi_protocol']
    prefix_list_in = module.params['pn_prefix_list_in']
    route_reflector_client = module.params['pn_route_reflector_client']
    default_originate = module.params['pn_default_originate']
    neighbor_holdtime = module.params['pn_neighbor_holdtime']
    connect_retry_interval = module.params['pn_connect_retry_interval']
    advertisement_interval = module.params['pn_advertisement_interval']
    route_map_out = module.params['pn_route_map_out']
    update_source = module.params['pn_update_source']
    bfd = module.params['pn_bfd']
    next_hop_self = module.params['pn_next_hop_self']
    allowas_in = module.params['pn_allowas_in']
    neighbor_keepalive_interval = module.params[
        'pn_neighbor_keepalive_interval']
    max_prefix = module.params['pn_max_prefix']
    bfd_multihop = module.params['pn_bfd_multihop']
    interface = module.params['pn_interface']
    password = module.params['pn_password']
    route_map_in = module.params['pn_route_map_in']
    soft_reconfig_inbound = module.params['pn_soft_reconfig_inbound']
    override_capability = module.params['pn_override_capability']
    max_prefix_warn_only = module.params['pn_max_prefix_warn_only']
    ebgp_multihop = module.params['pn_ebgp_multihop']
    remote_as = module.params['pn_remote_as']
    prefix_list_out = module.params['pn_prefix_list_out']
    no_route_map_out = module.params['pn_no_route_map_out']
    no_route_map_in = module.params['pn_no_route_map_in']

    command = state_map[state]

    if weight and weight != 'none':
        if int(weight) < 1 or int(weight) > 65535:
            module.fail_json(failed=True,
                             msg='Valid weight range is 1 to 65535')

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)
    VROUTER_EXISTS, NEIGHBOR_EXISTS = check_cli(module, cli)

    if state:
        if VROUTER_EXISTS is False:
            module.exit_json(skipped=True,
                             msg='vRouter %s does not exist' % vrouter_name)

    if command == 'vrouter-bgp-remove' or command == 'vrouter-bgp-modify':
        if NEIGHBOR_EXISTS is False:
            module.exit_json(
                skipped=True,
                msg='BGP neighbor with IP %s does not exist on %s' %
                (neighbor, vrouter_name))

    if command == 'vrouter-bgp-add':
        if NEIGHBOR_EXISTS is True:
            module.exit_json(
                skipped=True,
                msg='BGP neighbor with IP %s already exists on %s' %
                (neighbor, vrouter_name))

    cli += ' %s vrouter-name %s neighbor %s ' % (command, vrouter_name,
                                                 neighbor)

    if command == 'vrouter-bgp-add' or command == 'vrouter-bgp-modify':
        if weight:
            cli += ' weight ' + weight
        if multi_protocol:
            cli += ' multi-protocol ' + multi_protocol
        if prefix_list_in:
            cli += ' prefix-list-in ' + prefix_list_in
        if neighbor_holdtime:
            is_valid(module, 'neighbor holdtime', neighbor_holdtime, '0',
                     '65535')
            cli += ' neighbor-holdtime ' + neighbor_holdtime
        if connect_retry_interval:
            is_valid(module, 'connect retry interval', connect_retry_interval,
                     '0', '65535')
            cli += ' connect-retry-interval ' + connect_retry_interval
        if advertisement_interval:
            is_valid(module, 'advertisement interval', advertisement_interval,
                     '0', '65535')
            cli += ' advertisement-interval ' + advertisement_interval
        if route_map_out:
            cli += ' route-map-out ' + route_map_out
        if update_source:
            cli += ' update-source ' + update_source
        if neighbor_keepalive_interval:
            is_valid(module, 'neighbor keepalive interval',
                     neighbor_keepalive_interval, '0', '65535')
            cli += ' neighbor-keepalive-interval ' + neighbor_keepalive_interval
        if max_prefix:
            cli += ' max-prefix ' + max_prefix
        if interface:
            cli += ' interface ' + interface
        if password:
            cli += ' password ' + password
        if route_map_in:
            cli += ' route-map-in ' + route_map_in
        if ebgp_multihop:
            is_valid(module, 'ebgp_multihop', ebgp_multihop, '1', '255')
            cli += ' ebgp-multihop ' + ebgp_multihop
        if remote_as:
            cli += ' remote-as ' + remote_as
        if prefix_list_out:
            cli += ' prefix-list-out ' + prefix_list_out
        cli += booleanArgs(send_community, 'send-community',
                           'no-send-community')
        cli += booleanArgs(route_reflector_client, 'route-reflector-client',
                           'no-route-reflector-client')
        cli += booleanArgs(default_originate, 'default-originate',
                           'no-default-originate')
        cli += booleanArgs(bfd, 'bfd', 'no-bfd')
        cli += booleanArgs(next_hop_self, 'next-hop-self', 'no-next-hop-self')
        cli += booleanArgs(allowas_in, 'allowas-in', 'no-allowas-in')
        cli += booleanArgs(bfd_multihop, 'bfd-multihop', 'no-bfd-multihop')
        cli += booleanArgs(soft_reconfig_inbound, 'soft-reconfig-inbound',
                           'no-soft-reconfig-inbound')
        cli += booleanArgs(override_capability, 'override-capability',
                           'no-override-capability')
        cli += booleanArgs(max_prefix_warn_only, 'max-prefix-warn-only',
                           'no-max-prefix-warn-only')

    if command == 'vrouter-bgp-modify':
        if no_route_map_out:
            cli += ' no-route-map-out ' + no_route_map_out
        if no_route_map_in:
            cli += ' no-route-map-in ' + no_route_map_in

    run_cli(module, cli, state_map)
Пример #11
0
def main():
    """ This section is for arguments parsing """

    state_map = dict(update='igmp-snooping-modify')

    module = AnsibleModule(argument_spec=dict(
        pn_cliswitch=dict(required=False, type='str'),
        state=dict(required=True, type='str', choices=state_map.keys()),
        pn_enable=dict(required=False, type='bool'),
        pn_query_interval=dict(required=False, type='str'),
        pn_igmpv2_vlans=dict(required=False, type='str'),
        pn_igmpv3_vlans=dict(required=False, type='str'),
        pn_enable_vlans=dict(required=False, type='str'),
        pn_vxlan=dict(required=False, type='bool'),
        pn_query_max_response_time=dict(required=False, type='str'),
        pn_scope=dict(required=False, type='str', choices=['local', 'fabric']),
        pn_no_snoop_linklocal_vlans=dict(required=False, type='str'),
        pn_snoop_linklocal_vlans=dict(required=False, type='str'),
    ),
                           required_one_of=[[
                               'pn_enable', 'pn_query_interval',
                               'pn_igmpv2_vlans', 'pn_igmpv3_vlans',
                               'pn_enable_vlans', 'pn_vxlan',
                               'pn_query_max_response_time', 'pn_scope',
                               'pn_no_snoop_linklocal_vlans',
                               'pn_snoop_linklocal_vlans'
                           ]])

    # Accessing the arguments
    cliswitch = module.params['pn_cliswitch']
    state = module.params['state']
    enable = module.params['pn_enable']
    query_interval = module.params['pn_query_interval']
    igmpv2_vlans = module.params['pn_igmpv2_vlans']
    igmpv3_vlans = module.params['pn_igmpv3_vlans']
    enable_vlans = module.params['pn_enable_vlans']
    vxlan = module.params['pn_vxlan']
    query_max_response_time = module.params['pn_query_max_response_time']
    scope = module.params['pn_scope']
    no_snoop_linklocal_vlans = module.params['pn_no_snoop_linklocal_vlans']
    snoop_linklocal_vlans = module.params['pn_snoop_linklocal_vlans']

    command = state_map[state]

    # Building the CLI command string
    cli = pn_cli(module, cliswitch)

    if command == 'igmp-snooping-modify':
        cli += ' %s ' % command

        cli += booleanArgs(enable, 'enable', 'disable')
        cli += booleanArgs(vxlan, 'vxlan', 'no-vxlan')

        if query_interval:
            cli += ' query-interval ' + query_interval
        if igmpv2_vlans:
            cli += ' igmpv2-vlans ' + igmpv2_vlans
        if igmpv3_vlans:
            cli += ' igmpv3-vlans ' + igmpv3_vlans
        if enable_vlans:
            cli += ' enable-vlans ' + enable_vlans
        if query_max_response_time:
            cli += ' query-max-response-time ' + query_max_response_time
        if scope:
            cli += ' scope ' + scope
        if no_snoop_linklocal_vlans:
            cli += ' no-snoop-linklocal-vlans ' + no_snoop_linklocal_vlans
        if snoop_linklocal_vlans:
            cli += ' snoop-linklocal-vlans ' + snoop_linklocal_vlans

    run_cli(module, cli, state_map)