Esempio n. 1
0
def _dlr_create(client_session, vccontent, datacenter_name, edge_datastore,
                edge_cluster, **kwargs):
    if not (kwargs['dlr_name'] and kwargs['dlr_pwd'] and kwargs['dlr_size']
            and datacenter_name and kwargs['ha_ls_name']
            and kwargs['uplink_ls_name'] and kwargs['uplink_ip']
            and kwargs['uplink_subnet'] and edge_datastore and edge_cluster):
        print(
            'You are missing a mandatory parameter, those are [-n NAME] [-p DLRPASSWORD] [-s DLRSIZE] '
            '[--ha_ls HA_LS] [--uplink_ls UPLINK_LS] [--uplink_ip UPLINK_IP] [--uplink_subnet UPLINK_SUBNET] '
            'and the ini file options datacenter_name,edge_datastore and edge_cluster'
        )
        return None
    dlr_name = kwargs['dlr_name']
    dlr_pwd = kwargs['dlr_pwd']
    dlr_size = kwargs['dlr_size']

    datacentermoid = get_datacentermoid(vccontent, datacenter_name)
    datastoremoid = get_datastoremoid(vccontent, edge_datastore)
    resourcepoolid = get_edgeresourcepoolmoid(vccontent, edge_cluster)

    ha_ls_name = kwargs['ha_ls_name']
    # find ha_ls_id in vDS port groups or NSX logical switches
    ha_ls_id = get_vdsportgroupid(vccontent, ha_ls_name)
    if not ha_ls_id:
        ha_ls_id, ha_ls_switch_params = get_logical_switch(
            client_session, ha_ls_name)
        if not ha_ls_id:
            print 'ERROR: DLR HA switch {} does NOT exist as VDS port group nor NSX logical switch'.format(
                ha_ls_name)
            return None

    uplink_ls_name = kwargs['uplink_ls_name']
    uplink_ip = kwargs['uplink_ip']
    uplink_subnet = kwargs['uplink_subnet']
    uplink_dgw = kwargs['uplink_dgw']
    # find uplink_ls_id in vDS port groups or NSX logical switches
    uplink_ls_id = get_vdsportgroupid(vccontent, uplink_ls_name)
    if not uplink_ls_id:
        uplink_ls_id, uplink_ls_switch_params = get_logical_switch(
            client_session, uplink_ls_name)
        if not uplink_ls_id:
            print 'ERROR: DLR uplink switch {} does NOT exist as VDS port group ' \
                  'nor NSX logical switch'.format(uplink_ls_name)
            return None

    dlr_id, dlr_params = dlr_create(client_session, dlr_name, dlr_pwd,
                                    dlr_size, datacentermoid, datastoremoid,
                                    resourcepoolid, ha_ls_id, uplink_ls_id,
                                    uplink_ip, uplink_subnet, uplink_dgw)
    if kwargs['verbose']:
        print dlr_params
    else:
        print 'Distributed Logical Router {} created with the Edge-ID {}'.format(
            dlr_name, dlr_id)
Esempio n. 2
0
def _dlr_create(client_session, vccontent, datacenter_name, edge_datastore, edge_cluster, **kwargs):
    if not (kwargs['dlr_name'] and kwargs['dlr_pwd'] and kwargs['dlr_size'] and datacenter_name
            and kwargs['ha_ls_name'] and kwargs['uplink_ls_name'] and kwargs['uplink_ip'] and kwargs['uplink_subnet']
            and edge_datastore and edge_cluster):
        print ('You are missing a mandatory parameter, those are [-n NAME] [-p DLRPASSWORD] [-s DLRSIZE] '
               '[--ha_ls HA_LS] [--uplink_ls UPLINK_LS] [--uplink_ip UPLINK_IP] [--uplink_subnet UPLINK_SUBNET] '
               'and the ini file options datacenter_name,edge_datastore and edge_cluster')
        return None
    dlr_name = kwargs['dlr_name']
    dlr_pwd = kwargs['dlr_pwd']
    dlr_size = kwargs['dlr_size']

    datacentermoid = get_datacentermoid(vccontent, datacenter_name)
    datastoremoid = get_datastoremoid(vccontent, edge_datastore)
    resourcepoolid = get_edgeresourcepoolmoid(vccontent, edge_cluster)

    ha_ls_name = kwargs['ha_ls_name']
    # find ha_ls_id in vDS port groups or NSX logical switches
    ha_ls_id = get_vdsportgroupid(vccontent, ha_ls_name)
    if not ha_ls_id:
        ha_ls_id, ha_ls_switch_params = get_logical_switch(client_session, ha_ls_name)
        if not ha_ls_id:
            print 'ERROR: DLR HA switch {} does NOT exist as VDS port group nor NSX logical switch'.format(ha_ls_name)
            return None

    uplink_ls_name = kwargs['uplink_ls_name']
    uplink_ip = kwargs['uplink_ip']
    uplink_subnet = kwargs['uplink_subnet']
    uplink_dgw = kwargs['uplink_dgw']
    # find uplink_ls_id in vDS port groups or NSX logical switches
    uplink_ls_id = get_vdsportgroupid(vccontent, uplink_ls_name)
    if not uplink_ls_id:
        uplink_ls_id, uplink_ls_switch_params = get_logical_switch(client_session, uplink_ls_name)
        if not uplink_ls_id:
            print 'ERROR: DLR uplink switch {} does NOT exist as VDS port group ' \
                  'nor NSX logical switch'.format(uplink_ls_name)
            return None

    dlr_id, dlr_params = dlr_create(client_session, dlr_name, dlr_pwd, dlr_size, datacentermoid, datastoremoid,
                                    resourcepoolid, ha_ls_id, uplink_ls_id, uplink_ip, uplink_subnet, uplink_dgw)
    if kwargs['verbose']:
        print dlr_params
    else:
        print 'Distributed Logical Router {} created with the Edge-ID {}'.format(dlr_name, dlr_id)
Esempio n. 3
0
def _esg_create(client_session, vccontent, **kwargs):
    needed_params = ['esg_name', 'esg_size', 'esg_pwd', 'datacenter_name', 'edge_datastore', 'edge_cluster',
                     'portgroup']
    if not check_for_parameters(needed_params, kwargs):
        return None
    datacentermoid = get_datacentermoid(vccontent, kwargs['datacenter_name'])
    datastoremoid = get_datastoremoid(vccontent, kwargs['edge_datastore'])
    resourcepoolid = get_edgeresourcepoolmoid(vccontent, kwargs['edge_cluster'])
    portgroupmoid = get_networkid(vccontent, kwargs['portgroup'])

    esg_id, esg_params = esg_create(client_session, kwargs['esg_name'], kwargs['esg_pwd'], kwargs['esg_size'],
                                    datacentermoid, datastoremoid, resourcepoolid, portgroupmoid,
                                    esg_remote_access=kwargs['esg_remote_access'])
    if kwargs['verbose'] and esg_id:
        edge_id, esg_details = esg_read(client_session, esg_id)
        print json.dumps(esg_details)
    elif esg_id:
        print 'Edge Service Gateway {} created with the ID {}'.format(kwargs['esg_name'], esg_id)
    else:
        print 'Edge Service Gateway {} creation failed'.format(kwargs['esg_name'])
Esempio n. 4
0
def _esg_create(client_session, vccontent, **kwargs):
    needed_params = ['esg_name', 'esg_size', 'esg_pwd', 'datacenter_name', 'edge_datastore', 'edge_cluster',
                     'portgroup']
    if not check_for_parameters(needed_params, kwargs):
        return None
    datacentermoid = get_datacentermoid(vccontent, kwargs['datacenter_name'])
    datastoremoid = get_datastoremoid(vccontent, kwargs['edge_datastore'])
    resourcepoolid = get_edgeresourcepoolmoid(vccontent, kwargs['edge_cluster'])
    portgroupmoid = get_vdsportgroupid(vccontent, kwargs['portgroup'])

    esg_id, esg_params = esg_create(client_session, kwargs['esg_name'], kwargs['esg_pwd'], kwargs['esg_size'],
                                    datacentermoid, datastoremoid, resourcepoolid, portgroupmoid,
                                    esg_remote_access=kwargs['esg_remote_access'])
    if kwargs['verbose'] and esg_id:
        edge_id, esg_details = esg_read(client_session, esg_id)
        print json.dumps(esg_details)
    elif esg_id:
        print 'Edge Service Gateway {} created with the ID {}'.format(kwargs['esg_name'], esg_id)
    else:
        print 'Edge Service Gateway {} creation failed'.format(kwargs['esg_name'])