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


Python nsxlib._build_uri_path函数代码示例

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


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

示例1: _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:gkotton,项目名称:vmware-nsx-1,代码行数:15,代码来源:lsn.py

示例2: test_create_and_get_lqueue

 def test_create_and_get_lqueue(self):
     queue_id = queuelib.create_lqueue(self.fake_cluster, self.fake_queue)
     queue_res = nsxlib.do_request(
         "GET", nsxlib._build_uri_path("lqueue", resource_id=queue_id), cluster=self.fake_cluster
     )
     self.assertEqual(queue_id, queue_res["uuid"])
     self.assertEqual("fake_queue", queue_res["display_name"])
开发者ID:wubala,项目名称:vmware-nsx,代码行数:7,代码来源:test_queue.py

示例3: 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 nsxlib.do_request(
        HTTP_POST, nsxlib._build_uri_path(GWSERVICE_RESOURCE),
        jsonutils.dumps(gwservice_obj), cluster=cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:27,代码来源:l2gateway.py

示例4: test_update_security_profile_rules_summarize_subset

    def test_update_security_profile_rules_summarize_subset(self):
        sec_prof = secgrouplib.create_security_profile(
            self.fake_cluster, _uuid(), 'pippo', {'name': 'test'})
        ingress_rule = [{'ethertype': 'IPv4'}]
        egress_rules = [
            {'ethertype': 'IPv4', 'protocol': constants.PROTO_NUM_UDP,
             'port_range_min': 1, 'port_range_max': 1,
             'remote_ip_prefix': '1.1.1.1/20'},
            {'ethertype': 'IPv4', 'protocol': constants.PROTO_NUM_UDP,
             'port_range_min': 2, 'port_range_max': 2,
             'profile_uuid': 'xyz'},
            {'ethertype': 'IPv4', 'protocol': constants.PROTO_NUM_UDP}]
        new_rules = {'logical_port_egress_rules': egress_rules,
                     'logical_port_ingress_rules': [ingress_rule]}
        egress_rules_summarized = [
            {'ethertype': 'IPv4', 'protocol': constants.PROTO_NUM_UDP}]
        secgrouplib.update_security_group_rules(
            self.fake_cluster, sec_prof['uuid'], new_rules)
        sec_prof_res = nsxlib.do_request(
            nsxlib.HTTP_GET,
            nsxlib._build_uri_path('security-profile',
                                   resource_id=sec_prof['uuid']),
            cluster=self.fake_cluster)
        self.assertEqual(sec_prof['uuid'], sec_prof_res['uuid'])

        # Check for builtin rules
        self.assertEqual(len(sec_prof_res['logical_port_ingress_rules']), 1)
        self.assertEqual(sec_prof_res['logical_port_egress_rules'],
                         egress_rules_summarized)
        self.assertIn(ingress_rule,
                      sec_prof_res['logical_port_ingress_rules'])
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:31,代码来源:test_secgroup.py

示例5: 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:gkotton,项目名称:vmware-nsx-1,代码行数:7,代码来源:switch.py

示例6: plug_router_port_attachment

def plug_router_port_attachment(cluster, router_id, port_id,
                                attachment_uuid, nsx_attachment_type,
                                attachment_vlan=None):
    """Attach a router port to the given attachment.

    Current attachment types:
       - PatchAttachment [-> logical switch port uuid]
       - L3GatewayAttachment [-> L3GatewayService uuid]
    For the latter attachment type a VLAN ID can be specified as well.
    """
    uri = nsxlib._build_uri_path(LROUTERPORT_RESOURCE, port_id, router_id,
                                 is_attachment=True)
    attach_obj = {}
    attach_obj["type"] = nsx_attachment_type
    if nsx_attachment_type == "PatchAttachment":
        attach_obj["peer_port_uuid"] = attachment_uuid
    elif nsx_attachment_type == "L3GatewayAttachment":
        attach_obj["l3_gateway_service_uuid"] = attachment_uuid
        if attachment_vlan:
            attach_obj['vlan_id'] = attachment_vlan
    else:
        raise nsx_exc.InvalidAttachmentType(
            attachment_type=nsx_attachment_type)
    return nsxlib.do_request(
        HTTP_PUT, uri, jsonutils.dumps(attach_obj), cluster=cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:25,代码来源:router.py

示例7: query_lrouters

def query_lrouters(cluster, fields=None, filters=None):
    return nsxlib.get_all_query_pages(
        nsxlib._build_uri_path(LROUTER_RESOURCE,
                               fields=fields,
                               relations='LogicalRouterStatus',
                               filters=filters),
        cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:7,代码来源:router.py

示例8: update_router_lport

def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
                        tenant_id, neutron_port_id, display_name,
                        admin_status_enabled, ip_addresses):
    """Updates a logical port on the assigned logical router."""
    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),
        ip_addresses=ip_addresses,
        type="LogicalRouterPortConfig"
    )
    # Do not pass null items to NSX
    for key in lport_obj.keys():
        if lport_obj[key] is None:
            del lport_obj[key]
    path = nsxlib._build_uri_path(LROUTERPORT_RESOURCE,
                                  lrouter_port_uuid,
                                  parent_resource_id=lrouter_uuid)
    result = nsxlib.do_request(HTTP_PUT, path,
                               jsonutils.dumps(lport_obj),
                               cluster=cluster)
    LOG.debug("Updated logical port %(lport_uuid)s on "
              "logical router %(lrouter_uuid)s",
              {'lport_uuid': lrouter_port_uuid, 'lrouter_uuid': lrouter_uuid})
    return result
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:25,代码来源:router.py

示例9: query_lrouter_lports

def query_lrouter_lports(cluster, lr_uuid, fields="*",
                         filters=None, relations=None):
    uri = nsxlib._build_uri_path(LROUTERPORT_RESOURCE,
                                 parent_resource_id=lr_uuid,
                                 fields=fields, filters=filters,
                                 relations=relations)
    return nsxlib.do_request(HTTP_GET, uri, cluster=cluster)['results']
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:7,代码来源:router.py

示例10: create_router_lport

def create_router_lport(cluster, lrouter_uuid, tenant_id, neutron_port_id,
                        display_name, admin_status_enabled, ip_addresses,
                        mac_address=None):
    """Creates a logical port on the assigned logical router."""
    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),
        ip_addresses=ip_addresses,
        type="LogicalRouterPortConfig"
    )
    # Only add the mac_address to lport_obj if present. This is because
    # when creating the fake_ext_gw there is no mac_address present.
    if mac_address:
        lport_obj['mac_address'] = mac_address
    path = nsxlib._build_uri_path(LROUTERPORT_RESOURCE,
                                  parent_resource_id=lrouter_uuid)
    result = nsxlib.do_request(HTTP_POST, path, jsonutils.dumps(lport_obj),
                               cluster=cluster)

    LOG.debug("Created logical port %(lport_uuid)s on "
              "logical router %(lrouter_uuid)s",
              {'lport_uuid': result['uuid'],
               'lrouter_uuid': lrouter_uuid})
    return result
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:25,代码来源:router.py

示例11: get_lswitch_by_id

def get_lswitch_by_id(cluster, lswitch_id):
    try:
        lswitch_uri_path = nsxlib._build_uri_path(LSWITCH_RESOURCE, lswitch_id, relations="LogicalSwitchStatus")
        return nsxlib.do_request(HTTP_GET, lswitch_uri_path, cluster=cluster)
    except exception.NotFound:
        # FIXME(salv-orlando): this should not raise a neutron exception
        raise exception.NetworkNotFound(net_id=lswitch_id)
开发者ID:wubala,项目名称:vmware-nsx,代码行数:7,代码来源:switch.py

示例12: 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:gkotton,项目名称:vmware-nsx-1,代码行数:27,代码来源:queue.py

示例13: 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") % e
        LOG.exception(msg)
        raise nsx_exc.NsxPluginException(err_msg=msg)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:26,代码来源:router.py

示例14: get_lrouter

def get_lrouter(cluster, lrouter_id):
    return nsxlib.do_request(HTTP_GET,
                             nsxlib._build_uri_path(
                                 LROUTER_RESOURCE,
                                 resource_id=lrouter_id,
                                 relations='LogicalRouterStatus'),
                             cluster=cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:7,代码来源:router.py

示例15: 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:gkotton,项目名称:vmware-nsx-1,代码行数:30,代码来源:switch.py


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