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


Python nsxlib.do_request函数代码示例

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


在下文中一共展示了do_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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") % e
        LOG.exception(msg)
        raise nsx_exc.NsxPluginException(err_msg=msg)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:26,代码来源:router.py

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

示例3: 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 as e:
        LOG.error(_LE("Port or Network not found, Error: %s"), str(e))
        raise exception.PortNotFoundOnNetwork(net_id=switch, port_id=port)
    except api_exc.NsxApiException:
        raise exception.NeutronException()
开发者ID:wubala,项目名称:vmware-nsx,代码行数:9,代码来源: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 = 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:gkotton,项目名称:vmware-nsx-1,代码行数:9,代码来源:router.py

示例5: _lsn_port_host_action

def _lsn_port_host_action(
    cluster, lsn_id, lsn_port_id, host_obj, extra_action, action):
    nsxlib.do_request(HTTP_POST,
                      nsxlib._build_uri_path(LSERVICESNODEPORT_RESOURCE,
                                             parent_resource_id=lsn_id,
                                             resource_id=lsn_port_id,
                                             extra_action=extra_action,
                                             filters={"action": action}),
                      jsonutils.dumps(host_obj),
                      cluster=cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:10,代码来源:lsn.py

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

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

示例8: 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(_LW("Unable to find security profile %s on NSX backend"),
                     spid)
开发者ID:wubala,项目名称:vmware-nsx,代码行数:10,代码来源:secgroup.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:gkotton,项目名称:vmware-nsx-1,代码行数:10,代码来源:queue.py

示例10: update_default_gw_explicit_routing_lrouter

def update_default_gw_explicit_routing_lrouter(cluster, router_id, next_hop):
    default_route = get_default_route_explicit_routing_lrouter(cluster,
                                                               router_id)
    if next_hop != default_route["next_hop_ip"]:
        new_default_route = {"action": "accept",
                             "next_hop_ip": next_hop,
                             "prefix": "0.0.0.0/0",
                             "protocol": "static"}
        nsxlib.do_request(HTTP_PUT,
                          nsxlib._build_uri_path(
                              LROUTERRIB_RESOURCE,
                              resource_id=default_route['uuid'],
                              parent_resource_id=router_id),
                          jsonutils.dumps(new_default_route),
                          cluster=cluster)
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:15,代码来源:router.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:gkotton,项目名称:vmware-nsx-1,代码行数:15,代码来源:lsn.py

示例12: update_security_group_rules

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

    # Allow all dhcp responses in
    rules['logical_port_egress_rules'].append(
        {'ethertype': 'IPv4', 'protocol': constants.PROTO_NUM_UDP,
         'port_range_min': constants.DHCP_RESPONSE_PORT,
         'port_range_max': constants.DHCP_RESPONSE_PORT,
         'ip_prefix': '0.0.0.0/0'})
    # If there are no ingress rules add bunk rule to drop all ingress traffic
    if not rules['logical_port_ingress_rules']:
        rules['logical_port_ingress_rules'].append(
            {'ethertype': 'IPv4', 'ip_prefix': '127.0.0.1/32'})
    try:
        body = mk_body(
            logical_port_ingress_rules=summarize_security_group_rules(rules[
                'logical_port_ingress_rules']),
            logical_port_egress_rules=summarize_security_group_rules(rules[
                'logical_port_egress_rules']))
        rsp = nsxlib.do_request(HTTP_PUT, path, body, cluster=cluster)
    except exceptions.NotFound as e:
        LOG.error(nsxlib.format_exception("Unknown", e, locals()))
        #FIXME(salvatore-orlando): This should not raise NeutronException
        raise exceptions.NeutronException()
    LOG.debug("Updated Security Profile: %s", rsp)
    return rsp
开发者ID:wubala,项目名称:vmware-nsx,代码行数:26,代码来源:secgroup.py

示例13: 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

示例14: 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

示例15: 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


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