当前位置: 首页>>代码示例>>Python>>正文


Python ApiSession.get_session方法代码示例

本文整理汇总了Python中avi.sdk.avi_api.ApiSession.get_session方法的典型用法代码示例。如果您正苦于以下问题:Python ApiSession.get_session方法的具体用法?Python ApiSession.get_session怎么用?Python ApiSession.get_session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在avi.sdk.avi_api.ApiSession的用法示例。


在下文中一共展示了ApiSession.get_session方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def main(args):

    if args:

        # If not specified on the command-line, prompt the user for the
        # controller IP address and/or password

        controller_ip = args.controller
        user = args.user
        password = args.password

    api = ApiSession.get_session(
        controller_ip, user, password, tenant=args.tenant, api_version=args.api_version)
    cloud = args.cloud
    switchto_cloud(api, cloud)

    all_vs = get_all_vs(api)

    alb_rule_count = {}
    for vs in all_vs:

        az = vs.get('azure_availability_set')
        if az:
            for service in vs['services']:
                alb_rule_count[az] = alb_rule_count.get(az, 0) + service['port_range_end'] - service['port'] + 1
    print alb_rule_count
开发者ID:avinetworks,项目名称:sdk,代码行数:28,代码来源:alb_rules.py

示例2: test_reuse_api_session

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
 def test_reuse_api_session(self):
     api2 = ApiSession.get_session(api.controller_ip, api.username,
                                   api.password, tenant=api.tenant,
                                   tenant_uuid=api.tenant_uuid,
                                   api_version=api.api_version,
                                   verify=False)
     assert api == api2
开发者ID:ypraveen,项目名称:sdk,代码行数:9,代码来源:test_avi_api.py

示例3: main

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def main(args):
    api = ApiSession.get_session(args.controller, args.username, args.password,
                                 tenant="*")
    if args.vs:
        get_config_logs_for_vs(api, args.vs)
    else:
        get_config_logs_for_all_vses(api)
开发者ID:avinetworks,项目名称:sdk,代码行数:9,代码来源:get_config_logs.py

示例4: convert

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def convert(meta, gslb_config_dict, controller_ip, user_name,
            password, tenant_name, vs_state, output_dir, version,
            report_name, vs_level_status):
    vip_cluster_map = None
    # If controller ip present then only get configuration from controller.
    if controller_ip:
        session = ApiSession.get_session(controller_ip, user_name, password)
        resp = session.get('configuration/export?full_system=true')
        avi_config = json.loads(resp.text)
        sites = avi_config['Gslb'][0]['sites']
        vip_cluster_map = get_vip_cluster_map(sites)
    avi_gslb_config = None
    try:
        avi_gslb_config = dict()
        avi_gslb_config['META'] = meta
        gslb_vs_converter = GslbVsConverter()
        avi_config = gslb_vs_converter.convert(
            gslb_config_dict, avi_gslb_config, vs_state, vip_cluster_map)

        ns_util.add_complete_conv_status(
            gslb_config_dict, output_dir, avi_config, report_name, vs_level_status)

    except:
        update_count('error')
        LOG.error('Error in config conversion', exc_info=True)

    return avi_gslb_config
开发者ID:avinetworks,项目名称:sdk,代码行数:29,代码来源:gslb_config_converter.py

示例5: create_avi_endpoint

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def create_avi_endpoint(tenant):
    controller_config = get_avi_controller_config()
    print ('Connecting to Avi Controller %s...'%(controller_config['ip']))
    print ('User : %s Tenant : %s' %(controller_config['username'],tenant))
    return ApiSession.get_session(controller_config['ip'],
                       controller_config['username'], 
                       controller_config['password'], tenant=tenant)
开发者ID:DanGreenwell,项目名称:sdk,代码行数:9,代码来源:apic_tenant.py

示例6: setupApiSession

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
 def setupApiSession(self):
     self.api = None
     api = ApiSession.get_session(self.controller_ip, self.user, self.password,
                            tenant=self.tenant)
     server_cert, server_key, _, _ = get_sample_ssl_params()
     ApiUtils(api).import_ssl_certificate('MyCert', server_key, server_cert)
     self.api = api
     return api
开发者ID:DanGreenwell,项目名称:sdk,代码行数:10,代码来源:autoscaler.py

示例7: create_segroup

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def create_segroup(controller_ip, username, password, segroup_name):
     session = ApiSession.get_session(controller_ip, username, password)
     data = {"name": segroup_name}
     json_data = json.dumps(data)
     path = "/serviceenginegroup"
     rsp1 = session.post(path, data=json_data)
     print rsp1
     return rsp1
开发者ID:avinetworks,项目名称:sdk,代码行数:10,代码来源:test_tenant_cloud.py

示例8: create_vrf_context

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def create_vrf_context(controller_ip, username, password, vrf_name):
    session = ApiSession.get_session(controller_ip, username, password)
    data = {"name": vrf_name}
    json_data = json.dumps(data)
    path = "/vrfcontext"
    rsp1 = session.post(path, data=json_data)
    print rsp1
    return rsp1
开发者ID:avinetworks,项目名称:sdk,代码行数:10,代码来源:test_tenant_cloud.py

示例9: getAviApiSession

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def getAviApiSession(tenant='admin'):
    """
    create session to avi controller
    """
    token = os.environ.get('API_TOKEN')
    user = os.environ.get('USER')
    # tenant=os.environ.get('TENANT')
    return ApiSession.get_session("localhost", user, token=token,
                                  tenant=tenant)
开发者ID:avinetworks,项目名称:sdk,代码行数:11,代码来源:samplescaleout.py

示例10: getAviApiSession

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def getAviApiSession():
    """
    create session to avi controller
    """
    global API
    if not API:
        API = ApiSession.get_session(
                '127.0.0.1', 'admin', 'avi123', tenant='admin')
    return API
开发者ID:mitchchen,项目名称:sdk,代码行数:11,代码来源:vmware_samplescaleout.py

示例11: get_vip_cluster_map

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def get_vip_cluster_map(sites):
    vip_map=dict()
    for site in sites:
        session = ApiSession.get_session(
            site['ip_addresses'][0]['addr'], site['username'], site['password'])
        resp = session.get('virtualservice', api_version='17.1.1')
        vs_list = json.loads(resp.text)['results']
        for vs in vs_list:
            vip_map.update(create_map_for_vs(vs, vip_map, site))
    return vip_map
开发者ID:avinetworks,项目名称:sdk,代码行数:12,代码来源:gslb_config_converter.py

示例12: main

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def main():
    argument_specs = dict(
        old_password=dict(type='str', required=True, no_log=True)
    )
    argument_specs.update(avi_common_argument_spec())
    module = AnsibleModule(argument_spec=argument_specs)

    if not HAS_AVI:
        return module.fail_json(msg=(
            'Avi python API SDK (avisdk) is not installed. '
            'For more details visit https://github.com/avinetworks/sdk.'))

    api_creds = AviCredentials()
    api_creds.update_from_ansible_module(module)
    password_updated = False
    old_password = module.params.get('old_password')
    data = {
        'old_password': old_password,
        'password': api_creds.password
    }
    password_changed = False
    try:
        api = ApiSession.get_session(
            api_creds.controller, api_creds.username,
            password=api_creds.password, timeout=api_creds.timeout,
            tenant=api_creds.tenant, tenant_uuid=api_creds.tenant_uuid,
            token=api_creds.token, port=api_creds.port)
        password_changed = True
        return ansible_return(module, None, False, req=data)
    except:
        pass

    if not password_changed:
        api = ApiSession.get_session(
            api_creds.controller, api_creds.username, password=old_password,
            timeout=api_creds.timeout, tenant=api_creds.tenant,
            tenant_uuid=api_creds.tenant_uuid, token=api_creds.token,
            port=api_creds.port)
        rsp = api.put('useraccount', data=data)
        if rsp:
            return ansible_return(module, rsp, True, req=data)
        return module.exit_json(changed=False, obj=data)
开发者ID:awiddersheim,项目名称:ansible,代码行数:44,代码来源:avi_useraccount.py

示例13: create_tenant

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def create_tenant(controller_ip, username, password, name):
    """"
        Create non default tenant on the given Controller.
    """
    session = ApiSession.get_session (controller_ip, username, password)
    data = {'local': True, 'name': name}
    json_data = json.dumps (data)
    path = "/tenant?"
    rsp = session.post (path, data=json_data)
    print rsp
    return
开发者ID:avinetworks,项目名称:sdk,代码行数:13,代码来源:test_tenant_cloud.py

示例14: create_cloud

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def create_cloud(controller_ip, username, password, cloud_name):
    """"
    Create non default cloud name on the
    given Controller.
    """
    session = ApiSession.get_session (controller_ip, username, password)
    data = {"vtype": "CLOUD_NONE","name": cloud_name}
    json_data = json.dumps (data)
    path = "/cloud?include_name"
    rsp1 = session.post (path, data=json_data)
    print rsp1
    return json.loads (rsp1.content)
开发者ID:avinetworks,项目名称:sdk,代码行数:14,代码来源:test_tenant_cloud.py

示例15: verify_controller_is_up

# 需要导入模块: from avi.sdk.avi_api import ApiSession [as 别名]
# 或者: from avi.sdk.avi_api.ApiSession import get_session [as 别名]
def verify_controller_is_up(controller_ip, username, password):
    """""
    Verify the given Controller is running by getting it's
    CLUSTER_UP_HA_ACTIVE, CLUSTER_UP_NO_HA states using AVI API.
    """
    session = ApiSession.get_session (controller_ip, username, password)
    cluster_up_states = ["CLUSTER_UP_HA_ACTIVE", "CLUSTER_UP_NO_HA"]
    data = session.get('cluster/runtime')
    data = json.loads (data.content)
    if data['cluster_state']['state'] in cluster_up_states:
        print "Node is active. We can use controller for further process."
        return True
    return False
开发者ID:avinetworks,项目名称:sdk,代码行数:15,代码来源:test_clean_reboot.py


注:本文中的avi.sdk.avi_api.ApiSession.get_session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。