예제 #1
0
def createHostSwitchList(module, stub_config):
    hs_list = []
    for hostswitch in module.params['host_switch']:
        pnic_list = []
        uplink_profile_id = getUplinkProfileId(module, stub_config,
                                               hostswitch['uplink_profile'])
        hsprof_list = []

        hsptie = HostSwitchProfileTypeIdEntry(
            key=HostSwitchProfileTypeIdEntry.KEY_UPLINKHOSTSWITCHPROFILE,
            value=uplink_profile_id)
        hsprof_list.append(hsptie)
        for key, value in hostswitch["pnics"].items():
            pnic = Pnic(device_name=value, uplink_name=key)
            pnic_list.append(pnic)

        pool_id = None
        if 'static_ip_pool_id' in hostswitch:
            pool_id = hostswitch["static_ip_pool_id"]
        hs = HostSwitch(host_switch_name=hostswitch["name"],
                        host_switch_profile_ids=hsprof_list,
                        pnics=pnic_list,
                        static_ip_pool_id=pool_id)

        hs_list.append(hs)
    return hs_list
예제 #2
0
def createHostSwitchList(module, stub_config):
    hs_list = []
    for hostswitch in module.params['host_switch']:
        pnic_list = []
        uplink_profile_id = getUplinkProfileId(module, stub_config,
                                               hostswitch['uplink_profile'])
        hsprof_list = []

        hsptie = HostSwitchProfileTypeIdEntry(
            key=HostSwitchProfileTypeIdEntry.KEY_UPLINKHOSTSWITCHPROFILE,
            value=uplink_profile_id)
        hsprof_list.append(hsptie)
        for key, value in hostswitch["pnics"].items():
            pnic = Pnic(device_name=value, uplink_name=key)
            pnic_list.append(pnic)

        ipAssignmentSpec = None
        if 'static_ip_pool_id' in hostswitch:
            ipAssignmentSpec = StaticIpPoolSpec(
                ip_pool_id=hostswitch["static_ip_pool_id"])
        else:
            ipAssignmentSpec = AssignedByDhcp()

        hs = StandardHostSwitch(cpu_config=None,
                                host_switch_name=hostswitch["name"],
                                host_switch_profile_ids=hsprof_list,
                                pnics=pnic_list,
                                ip_assignment_spec=ipAssignmentSpec)

        hs_list.append(hs)
    return hs_list
예제 #3
0
def migrateVmks(module, stub_config):
    node = getTransportNodeByName(module, stub_config)
    ls_list = module.params["vlan_logical_switches"].split(',')
    ls_ids = ""
    for ls in ls_list:
        ls_ids += (getLogicalSwitchIdByName(module, ls,
                                            stub_config)).strip() + ","
    ls_ids = ls_ids[:-1]
    tn_svc = TransportNodes(stub_config)

    try:
        rs = tn_svc.update(node.id, node, ls_ids, module.params["vmks"])
    except Error as ex:
        api_error = ex.data.convert_to(ApiError)
        module.fail_json(msg='API Error migratin VMKs on Trnaport Node: %s' %
                         (api_error.error_message))
    if module.params["pnics"]:
        pnic_list = []
        for key, value in module.params["pnics"].items():
            pnic = Pnic(device_name=value, uplink_name=key)
            pnic_list.append(pnic)
        migrated_node = getTransportNodeByName(module, stub_config)
        migrated_node.host_switches[0].pnics = pnic_list
        time.sleep(10)

        try:
            rs = tn_svc.update(migrated_node.id, migrated_node)
        except Error as ex:
            api_error = ex.data.convert_to(ApiError)
            module.fail_json(msg='API Error updating Trnaport Node: %s' %
                             (api_error.error_message))
        module.exit_json(
            changed=True,
            id=node.id,
            name=node.display_name,
            pnics="updated",
            message="%s migrated to %s" %
            (module.params["vmks"], module.params["vlan_logical_switches"]))

    module.exit_json(
        changed=True,
        id=node.id,
        name=node.display_name,
        pnics="not updated",
        message="%s migrated to %s" %
        (module.params["vmks"], module.params["vlan_logical_switches"]))
예제 #4
0
def createHostSwitchList(module, stub_config):
    hs_list= []
    for hostswitch in module.params['host_switch']:
        pnic_list = []
        uplink_profile_id=getUplinkProfileId(module, stub_config, hostswitch['uplink_profile'])
        hsprof_list = []

        hsptie=HostSwitchProfileTypeIdEntry(
            key=HostSwitchProfileTypeIdEntry.KEY_UPLINKHOSTSWITCHPROFILE,
            value=uplink_profile_id
        )
        hsprof_list.append(hsptie)
        given_pnics = hostswitch["pnics"]
        if isinstance(given_pnics, basestring) or isinstance(given_pnics, str):
            index=1
            for token in given_pnics.strip().split(','):
                pnic=Pnic(device_name=token, uplink_name='uplink-' + str(index))
                pnic_list.append(pnic)

        ipAssignmentSpec = None
        if 'static_ip_pool_id' in hostswitch:
            ipAssignmentSpec = StaticIpPoolSpec(
                 ip_pool_id = hostswitch["static_ip_pool_id"]
            )
        else:
            ipAssignmentSpec = AssignedByDhcp()

        hs=StandardHostSwitch(
            cpu_config=None,
            host_switch_name=hostswitch["name"],
            host_switch_profile_ids=hsprof_list,
            pnics=pnic_list,
            ip_assignment_spec=ipAssignmentSpec
        )

        hs_list.append(hs)
    return hs_list