• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nsxlib.do_request函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.plugins.vmware.nsxlib.do_request函数的典型用法代码示例。如果您正苦于以下问题:Python do_request函数的具体用法?Python do_request怎么用?Python do_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: update_lrouter_port_ips

def update_lrouter_port_ips(cluster, lrouter_id, lport_id,
                            ips_to_add, ips_to_remove):
    uri = nsxlib._build_uri_path(LROUTERPORT_RESOURCE, lport_id, lrouter_id)
    try:
        port = nsxlib.do_request(HTTP_GET, uri, cluster=cluster)
        # TODO(salvatore-orlando): Enforce ips_to_add intersection with
        # ips_to_remove is empty
        ip_address_set = set(port['ip_addresses'])
        ip_address_set = ip_address_set - set(ips_to_remove)
        ip_address_set = ip_address_set | set(ips_to_add)
        # Set is not JSON serializable - convert to list
        port['ip_addresses'] = list(ip_address_set)
        nsxlib.do_request(HTTP_PUT, uri, jsonutils.dumps(port),
                          cluster=cluster)
    except exception.NotFound:
        # FIXME(salv-orlando):avoid raising different exception
        data = {'lport_id': lport_id, 'lrouter_id': lrouter_id}
        msg = (_("Router Port %(lport_id)s not found on router "
                 "%(lrouter_id)s") % data)
        LOG.exception(msg)
        raise nsx_exc.NsxPluginException(err_msg=msg)
    except api_exc.NsxApiException as e:
        msg = _("An exception occurred while updating IP addresses on a "
                "router logical port:%s") % str(e)
        LOG.exception(msg)
        raise nsx_exc.NsxPluginException(err_msg=msg)
开发者ID:absolutarin,项目名称:neutron,代码行数:26,代码来源:router.py


示例2: delete_router_lport

def delete_router_lport(cluster, lrouter_uuid, lport_uuid):
    """Creates a logical port on the assigned logical router."""
    path = nsxlib._build_uri_path(LROUTERPORT_RESOURCE, lport_uuid, lrouter_uuid)
    nsxlib.do_request(HTTP_DELETE, path, cluster=cluster)
    LOG.debug(
        "Delete logical router port %(lport_uuid)s on " "logical router %(lrouter_uuid)s",
        {"lport_uuid": lport_uuid, "lrouter_uuid": lrouter_uuid},
    )
开发者ID:noironetworks,项目名称:neutron2,代码行数:8,代码来源:router.py


示例3: delete_networks

def delete_networks(cluster, net_id, lswitch_ids):
    for ls_id in lswitch_ids:
        path = "/ws.v1/lswitch/%s" % ls_id
        try:
            nsxlib.do_request(HTTP_DELETE, path, cluster=cluster)
        except exception.NotFound as e:
            LOG.error(_LE("Network not found, Error: %s"), str(e))
            raise exception.NetworkNotFound(net_id=ls_id)
开发者ID:absolutarin,项目名称:neutron,代码行数:8,代码来源:switch.py


示例4: delete_router_lport

def delete_router_lport(cluster, lrouter_uuid, lport_uuid):
    """Creates a logical port on the assigned logical router."""
    path = _build_uri_path(LROUTERPORT_RESOURCE, lport_uuid, lrouter_uuid)
    do_request(HTTP_DELETE, path, cluster=cluster)
    LOG.debug(_("Delete logical router port %(lport_uuid)s on "
                "logical router %(lrouter_uuid)s"),
              {'lport_uuid': lport_uuid,
               'lrouter_uuid': lrouter_uuid})
开发者ID:mnagamori,项目名称:neutron,代码行数:8,代码来源:router.py


示例5: _lsn_configure_action

def _lsn_configure_action(cluster, lsn_id, action, is_enabled, obj):
    lsn_obj = {"enabled": is_enabled}
    lsn_obj.update(obj)
    nsxlib.do_request(
        HTTP_PUT,
        nsxlib._build_uri_path(LSERVICESNODE_RESOURCE, resource_id=lsn_id, extra_action=action),
        jsonutils.dumps(lsn_obj),
        cluster=cluster,
    )
开发者ID:noironetworks,项目名称:neutron2,代码行数:9,代码来源:lsn.py


示例6: delete_port

def delete_port(cluster, switch, port):
    uri = "/ws.v1/lswitch/" + switch + "/lport/" + port
    try:
        nsxlib.do_request(HTTP_DELETE, uri, cluster=cluster)
    except exception.NotFound:
        LOG.exception(_LE("Port or Network not found"))
        raise exception.PortNotFoundOnNetwork(
            net_id=switch, port_id=port)
    except api_exc.NsxApiException:
        raise exception.NeutronException()
开发者ID:absolutarin,项目名称:neutron,代码行数:10,代码来源:switch.py


示例7: delete_security_profile

def delete_security_profile(cluster, spid):
    path = "/ws.v1/security-profile/%s" % spid

    try:
        nsxlib.do_request(HTTP_DELETE, path, cluster=cluster)
    except exceptions.NotFound:
        with excutils.save_and_reraise_exception():
            # This is not necessarily an error condition
            LOG.warn(_("Unable to find security profile %s on NSX backend"),
                     spid)
开发者ID:ArifovicH,项目名称:neutron,代码行数:10,代码来源:secgroup.py


示例8: lsn_port_host_entries_update

def lsn_port_host_entries_update(cluster, lsn_id, lsn_port_id, conf, hosts_data):
    hosts_obj = {"hosts": hosts_data}
    nsxlib.do_request(
        HTTP_PUT,
        nsxlib._build_uri_path(
            LSERVICESNODEPORT_RESOURCE, parent_resource_id=lsn_id, resource_id=lsn_port_id, extra_action=conf
        ),
        jsonutils.dumps(hosts_obj),
        cluster=cluster,
    )
开发者ID:noironetworks,项目名称:neutron2,代码行数:10,代码来源:lsn.py


示例9: delete_lqueue

def delete_lqueue(cluster, queue_id):
    try:
        nsxlib.do_request(HTTP_DELETE,
                          nsxlib._build_uri_path(LQUEUE_RESOURCE,
                                                 resource_id=queue_id),
                          cluster=cluster)
    except Exception:
        # FIXME(salv-orlando): This should not raise NeutronException
        with excutils.save_and_reraise_exception():
            raise exception.NeutronException()
开发者ID:ArifovicH,项目名称:neutron,代码行数:10,代码来源:queue.py


示例10: _lsn_port_host_action

def _lsn_port_host_action(
    cluster, lsn_id, lsn_port_id, host_obj, extra_action, action):
    do_request(HTTP_POST,
               _build_uri_path(LSERVICESNODEPORT_RESOURCE,
                               parent_resource_id=lsn_id,
                               resource_id=lsn_port_id,
                               extra_action=extra_action,
                               filters={"action": action}),
               json.dumps(host_obj),
               cluster=cluster)
开发者ID:50infivedays,项目名称:neutron,代码行数:10,代码来源:lsn.py


示例11: _lsn_port_configure_action

def _lsn_port_configure_action(cluster, lsn_id, lsn_port_id, action, is_enabled, obj):
    nsxlib.do_request(
        HTTP_PUT,
        nsxlib._build_uri_path(LSERVICESNODE_RESOURCE, resource_id=lsn_id, extra_action=action),
        jsonutils.dumps({"enabled": is_enabled}),
        cluster=cluster,
    )
    nsxlib.do_request(
        HTTP_PUT,
        nsxlib._build_uri_path(
            LSERVICESNODEPORT_RESOURCE, parent_resource_id=lsn_id, resource_id=lsn_port_id, extra_action=action
        ),
        jsonutils.dumps(obj),
        cluster=cluster,
    )
开发者ID:noironetworks,项目名称:neutron2,代码行数:15,代码来源:lsn.py


示例12: create_lport

def create_lport(cluster, lswitch_uuid, tenant_id, neutron_port_id,
                 display_name, device_id, admin_status_enabled,
                 mac_address=None, fixed_ips=None, port_security_enabled=None,
                 security_profiles=None, queue_id=None,
                 mac_learning_enabled=None, allowed_address_pairs=None):
    """Creates a logical port on the assigned logical switch."""
    display_name = utils.check_and_truncate(display_name)
    lport_obj = dict(
        admin_status_enabled=admin_status_enabled,
        display_name=display_name,
        tags=utils.get_tags(os_tid=tenant_id,
                            q_port_id=neutron_port_id,
                            vm_id=utils.device_id_to_vm_id(device_id))
    )

    _configure_extensions(lport_obj, mac_address, fixed_ips,
                          port_security_enabled, security_profiles,
                          queue_id, mac_learning_enabled,
                          allowed_address_pairs)

    path = nsxlib._build_uri_path(LSWITCHPORT_RESOURCE,
                                  parent_resource_id=lswitch_uuid)
    result = nsxlib.do_request(HTTP_POST, path, jsonutils.dumps(lport_obj),
                               cluster=cluster)

    LOG.debug("Created logical port %(result)s on logical switch %(uuid)s",
              {'result': result['uuid'], 'uuid': lswitch_uuid})
    return result
开发者ID:absolutarin,项目名称:neutron,代码行数:28,代码来源:switch.py


示例13: update_port

def update_port(cluster, lswitch_uuid, lport_uuid, neutron_port_id, tenant_id,
                display_name, device_id, admin_status_enabled,
                mac_address=None, fixed_ips=None, port_security_enabled=None,
                security_profiles=None, queue_id=None,
                mac_learning_enabled=None, allowed_address_pairs=None):
    lport_obj = dict(
        admin_status_enabled=admin_status_enabled,
        display_name=utils.check_and_truncate(display_name),
        tags=utils.get_tags(os_tid=tenant_id,
                            q_port_id=neutron_port_id,
                            vm_id=utils.device_id_to_vm_id(device_id)))

    _configure_extensions(lport_obj, mac_address, fixed_ips,
                          port_security_enabled, security_profiles,
                          queue_id, mac_learning_enabled,
                          allowed_address_pairs)

    path = "/ws.v1/lswitch/" + lswitch_uuid + "/lport/" + lport_uuid
    try:
        result = nsxlib.do_request(HTTP_PUT, path, jsonutils.dumps(lport_obj),
                                   cluster=cluster)
        LOG.debug("Updated logical port %(result)s "
                  "on logical switch %(uuid)s",
                  {'result': result['uuid'], 'uuid': lswitch_uuid})
        return result
    except exception.NotFound as e:
        LOG.error(_LE("Port or Network not found, Error: %s"), str(e))
        raise exception.PortNotFoundOnNetwork(
            port_id=lport_uuid, net_id=lswitch_uuid)
开发者ID:absolutarin,项目名称:neutron,代码行数:29,代码来源:switch.py


示例14: create_lqueue

def create_lqueue(cluster, queue_data):
    params = {
        'name': 'display_name',
        'qos_marking': 'qos_marking',
        'min': 'min_bandwidth_rate',
        'max': 'max_bandwidth_rate',
        'dscp': 'dscp'
    }
    queue_obj = dict(
        (nsx_name, queue_data.get(api_name))
        for api_name, nsx_name in params.iteritems()
        if attr.is_attr_set(queue_data.get(api_name))
    )
    if 'display_name' in queue_obj:
        queue_obj['display_name'] = utils.check_and_truncate(
            queue_obj['display_name'])

    queue_obj['tags'] = utils.get_tags()
    try:
        return nsxlib.do_request(HTTP_POST,
                                 nsxlib._build_uri_path(LQUEUE_RESOURCE),
                                 jsonutils.dumps(queue_obj),
                                 cluster=cluster)['uuid']
    except api_exc.NsxApiException:
        # FIXME(salv-orlando): This should not raise NeutronException
        with excutils.save_and_reraise_exception():
            raise exception.NeutronException()
开发者ID:ArifovicH,项目名称:neutron,代码行数:27,代码来源:queue.py


示例15: create_gateway_device

def create_gateway_device(
    cluster, tenant_id, display_name, neutron_id, tz_uuid, connector_type, connector_ip, client_certificate
):
    body = _build_gateway_device_body(
        tenant_id, display_name, neutron_id, connector_type, connector_ip, client_certificate, tz_uuid
    )
    return do_request(HTTP_POST, _build_uri_path(TRANSPORTNODE_RESOURCE), json.dumps(body), cluster=cluster)
开发者ID:raceli,项目名称:neutron,代码行数:7,代码来源:l2gateway.py


示例16: update_security_profile

def update_security_profile(cluster, spid, name):
    return do_request(HTTP_PUT,
                      _build_uri_path(SECPROF_RESOURCE, resource_id=spid),
                      json.dumps({
                          "display_name": utils.check_and_truncate(name)
                      }),
                      cluster=cluster)
开发者ID:50infivedays,项目名称:neutron,代码行数:7,代码来源:secgroup.py


示例17: plug_interface

def plug_interface(cluster, lswitch_id, lport_id, att_obj):
    return nsxlib.do_request(HTTP_PUT,
                             nsxlib._build_uri_path(LSWITCHPORT_RESOURCE,
                                                    lport_id, lswitch_id,
                                                    is_attachment=True),
                             jsonutils.dumps(att_obj),
                             cluster=cluster)
开发者ID:absolutarin,项目名称:neutron,代码行数:7,代码来源:switch.py


示例18: get_lswitches

def get_lswitches(cluster, neutron_net_id):

    def lookup_switches_by_tag():
        # Fetch extra logical switches
        lswitch_query_path = nsxlib._build_uri_path(
            LSWITCH_RESOURCE,
            fields="uuid,display_name,tags,lport_count",
            relations="LogicalSwitchStatus",
            filters={'tag': neutron_net_id,
                     'tag_scope': 'quantum_net_id'})
        return nsxlib.get_all_query_pages(lswitch_query_path, cluster)

    lswitch_uri_path = nsxlib._build_uri_path(LSWITCH_RESOURCE, neutron_net_id,
                                              relations="LogicalSwitchStatus")
    results = []
    try:
        ls = nsxlib.do_request(HTTP_GET, lswitch_uri_path, cluster=cluster)
        results.append(ls)
        for tag in ls['tags']:
            if (tag['scope'] == "multi_lswitch" and
                tag['tag'] == "True"):
                results.extend(lookup_switches_by_tag())
    except exception.NotFound:
        # This is legit if the neutron network was created using
        # a post-Havana version of the plugin
        results.extend(lookup_switches_by_tag())
    if results:
        return results
    else:
        raise exception.NetworkNotFound(net_id=neutron_net_id)
开发者ID:absolutarin,项目名称:neutron,代码行数:30,代码来源:switch.py


示例19: create_l2_gw_service

def create_l2_gw_service(cluster, tenant_id, display_name, devices):
    """Create a NSX Layer-2 Network Gateway Service.

        :param cluster: The target NSX cluster
        :param tenant_id: Identifier of the Openstack tenant for which
        the gateway service.
        :param display_name: Descriptive name of this gateway service
        :param devices: List of transport node uuids (and network
        interfaces on them) to use for the network gateway service
        :raise NsxApiException: if there is a problem while communicating
        with the NSX controller
    """
    # NOTE(salvatore-orlando): This is a little confusing, but device_id in
    # NSX is actually the identifier a physical interface on the gateway
    # device, which in the Neutron API is referred as interface_name
    gateways = [{"transport_node_uuid": device['id'],
                 "device_id": device['interface_name'],
                 "type": "L2Gateway"} for device in devices]
    gwservice_obj = {
        "display_name": utils.check_and_truncate(display_name),
        "tags": utils.get_tags(os_tid=tenant_id),
        "gateways": gateways,
        "type": "L2GatewayServiceConfig"
    }
    return do_request(
        "POST", _build_uri_path(GWSERVICE_RESOURCE),
        json.dumps(gwservice_obj), cluster=cluster)
开发者ID:Doude,项目名称:neutron,代码行数:27,代码来源:l2gateway.py


示例20: get_port_by_neutron_tag

def get_port_by_neutron_tag(cluster, lswitch_uuid, neutron_port_id):
    """Get port by neutron tag.

    Returns the NSX UUID of the logical port with tag q_port_id equal to
    neutron_port_id or None if the port is not Found.
    """
    uri = nsxlib._build_uri_path(LSWITCHPORT_RESOURCE,
                                 parent_resource_id=lswitch_uuid,
                                 fields='uuid',
                                 filters={'tag': neutron_port_id,
                                          'tag_scope': 'q_port_id'})
    LOG.debug("Looking for port with q_port_id tag '%(neutron_port_id)s' "
              "on: '%(lswitch_uuid)s'",
              {'neutron_port_id': neutron_port_id,
               'lswitch_uuid': lswitch_uuid})
    res = nsxlib.do_request(HTTP_GET, uri, cluster=cluster)
    num_results = len(res["results"])
    if num_results >= 1:
        if num_results > 1:
            LOG.warn(_LW("Found '%(num_ports)d' ports with "
                         "q_port_id tag: '%(neutron_port_id)s'. "
                         "Only 1 was expected."),
                     {'num_ports': num_results,
                      'neutron_port_id': neutron_port_id})
        return res["results"][0]
开发者ID:absolutarin,项目名称:neutron,代码行数:25,代码来源:switch.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nsxlib.get_all_query_pages函数代码示例发布时间:2022-05-27
下一篇:
Python nsxlib._build_uri_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap