Esempio n. 1
0
def modify_iface(module, blade):
    """Modify Network Interface IP address"""
    changed = False
    iface = get_iface(module, blade)
    iface_new = []
    iface_new.append(module.params['name'])
    if module.params['address'] != iface.address:
        try:
            blade.network_interfaces.update_network_interfaces(names=iface_new,
                                                               network_interface=NetworkInterface(address=module.params['address']))
            changed = True
        except Exception:
            changed = False
    module.exit_json(changed=changed)
Esempio n. 2
0
def create_iface(module, blade):
    """Create Network Interface"""

    iface = []
    services = []
    iface.append(module.params['name'])
    services.append(module.params['services'])
    try:
        blade.network_interfaces.create_network_interfaces(names=iface,
                                                           network_interface=NetworkInterface(address=module.params['address'],
                                                                                              services=services,
                                                                                              type=module.params['itype']
                                                                                              )
                                                           )
        changed = True
    except Exception:
        module.fail_json(msg='Interface creation failed. Check valid subnet exists for IP address {0}'.format(module.params['address']))
        changed = False
    module.exit_json(changed=changed)
def modify_iface(module, blade):
    """Modify Network Interface IP address"""
    changed = True
    if not module.check_mode:
        changed = False
        iface = get_iface(module, blade)
        iface_new = []
        iface_new.append(module.params['name'])
        if module.params['address'] != iface.address:
            try:
                blade.network_interfaces.update_network_interfaces(
                    names=iface_new,
                    network_interface=NetworkInterface(
                        address=module.params['address']))
                changed = True
            except Exception:
                module.fail_json(msg='Failed to modify Interface {0}'.format(
                    module.params['name']))
    module.exit_json(changed=changed)
Esempio n. 4
0
def create_iface(module, blade):
    """Create Network Interface"""
    changed = True
    if not module.check_mode:
        iface = []
        services = []
        iface.append(module.params["name"])
        services.append(module.params["services"])
        try:
            blade.network_interfaces.create_network_interfaces(
                names=iface,
                network_interface=NetworkInterface(
                    address=module.params["address"],
                    services=services,
                    type=module.params["itype"],
                ),
            )
        except Exception:
            module.fail_json(
                msg="Interface creation failed. Check subnet exists for {0}".
                format(module.params["address"]))
    module.exit_json(changed=changed)