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

Python uuidutils.generate_uuid函数代码示例

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

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



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

示例1: test_list_router_routes

    def test_list_router_routes(self):
        t = uuidutils.generate_uuid()
        r = uuidutils.generate_uuid()

        router_path = "/tenants/%s/routers/%s" % (_ofc(t), _ofc(r))
        routes_path = router_path + "/routes"

        routes = [("10.1.1.0/24", "192.168.100.10"), ("10.2.2.0/20", "192.168.100.20")]
        data = {
            "routes": [
                {"id": self._get_route_id(route[0], route[1]), "destination": route[0], "nexthop": route[1]}
                for route in routes
            ]
        }
        self.do_request.return_value = data

        ret = self.driver.list_router_routes(router_path)
        self.do_request.assert_called_once_with("GET", routes_path)

        expected = [
            {
                "id": (routes_path + "/" + self._get_route_id(route[0], route[1])),
                "destination": route[0],
                "nexthop": route[1],
            }
            for route in routes
        ]
        self.assertEqual(len(routes), len(ret))
        self.assertEqual(data["routes"], expected)
开发者ID:armando-migliaccio,项目名称:neutron-1,代码行数:29,代码来源:test_pfc_driver.py


示例2: test_update_router_interface

    def test_update_router_interface(self):
        t = uuidutils.generate_uuid()
        r = uuidutils.generate_uuid()
        p = uuidutils.generate_uuid()

        router_path = "/tenants/%s/routers/%s" % (_ofc(t), _ofc(r))
        inf_path = "%s/interfaces/%s" % (router_path, _ofc(p))
        ip_address = '10.1.1.1/24'
        mac_address = '11:22:33:44:55:66'

        body = {'ip_address': ip_address,
                'mac_address': mac_address}
        ofc.OFCClient.do_request("PUT", inf_path, body=body)

        body = {'ip_address': ip_address}
        ofc.OFCClient.do_request("PUT", inf_path, body=body)

        body = {'mac_address': mac_address}
        ofc.OFCClient.do_request("PUT", inf_path, body=body)

        self.mox.ReplayAll()

        self.driver.update_router_interface(inf_path, ip_address, mac_address)
        self.driver.update_router_interface(inf_path, ip_address=ip_address)
        self.driver.update_router_interface(inf_path, mac_address=mac_address)
        self.mox.VerifyAll()
开发者ID:JoeMido,项目名称:neutron,代码行数:26,代码来源:test_pfc_driver.py


示例3: test_create_and_show_servicechain_instance

    def test_create_and_show_servicechain_instance(self):
        scs_id = self.create_servicechain_spec()['servicechain_spec']['id']
        policy_target_group_id = uuidutils.generate_uuid()
        classifier_id = uuidutils.generate_uuid()
        config_param_values = "{}"
        attrs = self._get_test_servicechain_instance_attrs(
            servicechain_spec=scs_id,
            provider_ptg_id=policy_target_group_id,
            consumer_ptg_id=policy_target_group_id,
            classifier_id=classifier_id,
            config_param_values=config_param_values)

        sci = self.create_servicechain_instance(
            servicechain_spec=scs_id,
            provider_ptg_id=policy_target_group_id,
            consumer_ptg_id=policy_target_group_id,
            classifier_id=classifier_id,
            config_param_values=config_param_values)
        for k, v in attrs.iteritems():
            self.assertEqual(sci['servicechain_instance'][k], v)

        self._test_show_resource('servicechain_instance',
                                 sci['servicechain_instance']['id'],
                                 attrs)
        req = self.new_delete_request('servicechain_instances',
                                      sci['servicechain_instance']['id'])
        req.get_response(self.ext_api)
开发者ID:yapengwu,项目名称:group-based-policy,代码行数:27,代码来源:test_servicechain_db.py


示例4: create_security_group

    def create_security_group(self, context, security_group, default_sg=False):
        """Create security group.

        If default_sg is true that means we are a default security group for
        a given tenant if it does not exist.
        """
        s = security_group["security_group"]
        kwargs = {"context": context, "security_group": s, "is_default": default_sg}
        # NOTE(armax): a callback exception here will prevent the request
        # from being processed. This is a hook point for backend's validation;
        # we raise to propagate the reason for the failure.
        try:
            registry.notify(resources.SECURITY_GROUP, events.BEFORE_CREATE, self, **kwargs)
        except exceptions.CallbackFailure as e:
            raise ext_sg.SecurityGroupConflict(reason=e)

        tenant_id = self._get_tenant_id_for_create(context, s)

        if not default_sg:
            self._ensure_default_security_group(context, tenant_id)

        with context.session.begin(subtransactions=True):
            security_group_db = SecurityGroup(
                id=s.get("id") or (uuidutils.generate_uuid()),
                description=s["description"],
                tenant_id=tenant_id,
                name=s["name"],
            )
            context.session.add(security_group_db)
            if default_sg:
                context.session.add(
                    DefaultSecurityGroup(security_group=security_group_db, tenant_id=security_group_db["tenant_id"])
                )
            for ethertype in ext_sg.sg_supported_ethertypes:
                if default_sg:
                    # Allow intercommunication
                    ingress_rule = SecurityGroupRule(
                        id=uuidutils.generate_uuid(),
                        tenant_id=tenant_id,
                        security_group=security_group_db,
                        direction="ingress",
                        ethertype=ethertype,
                        source_group=security_group_db,
                    )
                    context.session.add(ingress_rule)

                egress_rule = SecurityGroupRule(
                    id=uuidutils.generate_uuid(),
                    tenant_id=tenant_id,
                    security_group=security_group_db,
                    direction="egress",
                    ethertype=ethertype,
                )
                context.session.add(egress_rule)

        secgroup_dict = self._make_security_group_dict(security_group_db)

        kwargs["security_group"] = secgroup_dict
        registry.notify(resources.SECURITY_GROUP, events.AFTER_CREATE, self, **kwargs)
        return secgroup_dict
开发者ID:jocado,项目名称:neutron,代码行数:60,代码来源:securitygroups_db.py


示例5: test_update_servicechain_instance

    def test_update_servicechain_instance(self):
        name = "new_servicechain_instance"
        description = 'new desc'
        config_param_values = "{}"
        scs_id = self.create_servicechain_spec()['servicechain_spec']['id']
        provider_ptg_id = uuidutils.generate_uuid()
        consumer_ptg_id = uuidutils.generate_uuid()
        classifier_id = uuidutils.generate_uuid()
        attrs = self._get_test_servicechain_instance_attrs(
            name=name, description=description, servicechain_spec=scs_id,
            provider_ptg_id=provider_ptg_id, consumer_ptg_id=consumer_ptg_id,
            classifier_id=classifier_id,
            config_param_values=config_param_values)

        sci = self.create_servicechain_instance(
            servicechain_spec=scs_id, provider_ptg_id=provider_ptg_id,
            consumer_ptg_id=consumer_ptg_id, classifier_id=classifier_id,
            config_param_values=config_param_values)
        data = {'servicechain_instance': {'name': name,
                                          'description': description,
                                          'servicechain_spec': scs_id}}
        req = self.new_update_request('servicechain_instances', data,
                                      sci['servicechain_instance']['id'])
        res = self.deserialize(self.fmt, req.get_response(self.ext_api))
        for k, v in attrs.iteritems():
            self.assertEqual(res['servicechain_instance'][k], v)

        self._test_show_resource('servicechain_instance',
                                 sci['servicechain_instance']['id'], attrs)
        req = self.new_delete_request('servicechain_instances',
                                      sci['servicechain_instance']['id'])
        req.get_response(self.ext_api)
开发者ID:yapengwu,项目名称:group-based-policy,代码行数:32,代码来源:test_servicechain_db.py


示例6: create_qos

    def create_qos(self, context, qos):
        """ Create a qos and its default queue. """
        qos = qos['qos']
        default_queue = self._extract_default_queue_from_qos_param(qos)

        if qos['rate'] < default_queue['rate']:
            raise ext_qos.QosRateTooSmall(id=None, rate=qos['rate'])
        qos_target = self._check_qos_target(
            context, qos['target_type'], qos['target_id'], qos['direction'])

        tenant_id = self._get_tenant_id_for_create(context, qos)
        qos_id = qos.get('id', uuidutils.generate_uuid())
        default_queue_id = uuidutils.generate_uuid()

        with context.session.begin(subtransactions=True):
            qos_db = Qos(
                id=qos_id, tenant_id=tenant_id,
                name=qos['name'], description=qos['description'],
                direction=qos['direction'],
                port_id=qos_target['port_id'],
                router_id=qos_target['router_id'],
                rate=qos['rate'], burst=qos['burst'], cburst=qos['cburst'],
                default_queue_id=default_queue_id)
            qos_queue_db = QosQueue(
                id=default_queue_id, tenant_id=tenant_id,
                qos_id=qos_id, parent_id=None, prio=7,
                rate=default_queue['rate'], ceil=default_queue['ceil'],
                burst=default_queue['burst'], cburst=default_queue['cburst'])
            context.session.add(qos_db)
            context.session.add(qos_queue_db)

        return self._make_qos_dict(qos_db)
开发者ID:eayunstack,项目名称:neutron-qos,代码行数:32,代码来源:qos_db.py


示例7: create_net_partition

 def create_net_partition(self, params):
     fake_net_partition = {
         'nuage_entid': uuidutils.generate_uuid(),
         'l3dom_id': uuidutils.generate_uuid(),
         'l2dom_id': uuidutils.generate_uuid(),
     }
     return fake_net_partition
开发者ID:AsherBond,项目名称:quantum,代码行数:7,代码来源:fake_nuageclient.py


示例8: test_create_for_sg_rule

    def test_create_for_sg_rule(self):
        sg_id = uuidutils.generate_uuid()
        sg_name = 'test-sg'
        in_chain_id = uuidutils.generate_uuid()
        out_chain_id = uuidutils.generate_uuid()
        self.mock_api_cfg.chains_in = [
            _create_test_sg_in_chain(sg_id, sg_name, in_chain_id,
                                     self._tenant_id),
            _create_test_sg_out_chain(sg_id, sg_name, out_chain_id,
                                      self._tenant_id)]

        sg_rule_id = uuidutils.generate_uuid()
        sg_rule = _create_test_sg_rule(self._tenant_id, sg_id, sg_rule_id)

        props = {"os_sg_rule_id": sg_rule_id}
        calls = [mock.call.add_rule().port_group(None).type(
            'accept').nw_proto(6).nw_src_address(
                '192.168.1.0').nw_src_length(24).tp_src_start(
                    None).tp_src_end(None).tp_dst_start(1).tp_dst_end(
                        65535).properties(props).create()]

        self.client.create_for_sg_rule(sg_rule)

        # Egress chain rule added
        self.mock_api_cfg.chains_out[0].assert_has_calls(calls)
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:25,代码来源:test_midonet_lib.py


示例9: test_create_and_show_servicechain_instance

    def test_create_and_show_servicechain_instance(self):
        scs_id = self.create_servicechain_spec()["servicechain_spec"]["id"]
        policy_target_group_id = uuidutils.generate_uuid()
        classifier_id = uuidutils.generate_uuid()
        config_param_values = "{}"
        attrs = cm.get_create_servicechain_instance_default_attrs(
            servicechain_specs=[scs_id],
            provider_ptg_id=policy_target_group_id,
            consumer_ptg_id=policy_target_group_id,
            management_ptg_id=policy_target_group_id,
            classifier_id=classifier_id,
            config_param_values=config_param_values,
        )

        sci = self.create_servicechain_instance(
            servicechain_specs=[scs_id],
            provider_ptg_id=policy_target_group_id,
            consumer_ptg_id=policy_target_group_id,
            management_ptg_id=policy_target_group_id,
            classifier_id=classifier_id,
            config_param_values=config_param_values,
        )
        for k, v in attrs.iteritems():
            self.assertEqual(v, sci["servicechain_instance"][k])

        self._test_show_resource("servicechain_instance", sci["servicechain_instance"]["id"], attrs)
        req = self.new_delete_request("servicechain_instances", sci["servicechain_instance"]["id"])
        req.get_response(self.ext_api)
开发者ID:tbachman,项目名称:group-based-policy,代码行数:28,代码来源:test_servicechain_db.py


示例10: test_delete_router

    def test_delete_router(self):
        t = uuidutils.generate_uuid()
        r = uuidutils.generate_uuid()

        router_path = "/tenants/%s/routers/%s" % (_ofc(t), _ofc(r))

        self.driver.delete_router(router_path)
        self.do_request.assert_called_once_with("DELETE", router_path)
开发者ID:Doude,项目名称:neutron,代码行数:8,代码来源:test_pfc_driver.py


示例11: test_delete_neutron_ports

 def test_delete_neutron_ports(self):
     port1 = ovs_lib.VifPort("tap1234", 1, uuidutils.generate_uuid(), "ca:fe:de:ad:be:ef", "br")
     port2 = ovs_lib.VifPort("tap5678", 2, uuidutils.generate_uuid(), "ca:ee:de:ad:be:ef", "br")
     with mock.patch.object(self.br, "get_vif_ports", return_value=[port1, port2]) as get_ports:
         with mock.patch.object(self.br, "delete_port") as delete_port:
             self.br.delete_ports(all_ports=False)
     get_ports.assert_called_once_with()
     delete_port.assert_has_calls([mock.call("tap1234"), mock.call("tap5678")])
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:8,代码来源:test_ovs_lib.py


示例12: test_get_nsx_switch_and_port_id_from_db_mappings

 def test_get_nsx_switch_and_port_id_from_db_mappings(self):
     # This test is representative of the 'standard' case in which both the
     # switch and the port mappings were stored in the neutron db
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = exp_ls_uuid, exp_lp_uuid
     self._mock_port_mapping_db_calls(ret_value)
     self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
开发者ID:Taejun,项目名称:neutron,代码行数:8,代码来源:test_nsx_utils.py


示例13: create_router

 def create_router(self, neutron_router, router, params):
     nuage_router = {
         'nuage_userid': uuidutils.generate_uuid(),
         'nuage_groupid': uuidutils.generate_uuid(),
         'nuage_domain_id': uuidutils.generate_uuid(),
         'nuage_def_zone_id': uuidutils.generate_uuid(),
     }
     return nuage_router
开发者ID:AsherBond,项目名称:quantum,代码行数:8,代码来源:fake_nuageclient.py


示例14: get_ofc_item_random_params

 def get_ofc_item_random_params(self):
     """create random parameters for ofc_item test."""
     tenant_id = uuidutils.generate_uuid()
     network_id = uuidutils.generate_uuid()
     port_id = uuidutils.generate_uuid()
     mac = ":".join(["%x" % random.randint(0, 255) for i in moves.xrange(6)])
     portinfo = nmodels.PortInfo(id=port_id, datapath_id="0x123456789", port_no=1234, vlan_id=321, mac=mac)
     return tenant_id, network_id, portinfo
开发者ID:chrisacbr,项目名称:openstack-neutron,代码行数:8,代码来源:test_trema_driver.py


示例15: create_subnet

 def create_subnet(self, neutron_subnet, params):
     nuage_subnet = {
         'nuage_l2template_id': uuidutils.generate_uuid(),
         'nuage_userid': uuidutils.generate_uuid(),
         'nuage_groupid': uuidutils.generate_uuid(),
         'nuage_l2domain_id': uuidutils.generate_uuid()
     }
     return nuage_subnet
开发者ID:AsherBond,项目名称:quantum,代码行数:8,代码来源:fake_nuageclient.py


示例16: get_random_params

 def get_random_params(self):
     """create random parameters for portinfo test."""
     tenant = uuidutils.generate_uuid()
     network = uuidutils.generate_uuid()
     port = uuidutils.generate_uuid()
     _filter = uuidutils.generate_uuid()
     none = uuidutils.generate_uuid()
     return tenant, network, port, _filter, none
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:8,代码来源:test_ofc_manager.py


示例17: get_def_netpartition_data

 def get_def_netpartition_data(self, default_net_part):
     if default_net_part == 'default_test_np':
         fake_defnetpart_data = {
             'np_id': uuidutils.generate_uuid(),
             'l3dom_tid': uuidutils.generate_uuid(),
             'l2dom_tid': uuidutils.generate_uuid(),
         }
         return fake_defnetpart_data
开发者ID:AsherBond,项目名称:quantum,代码行数:8,代码来源:fake_nuageclient.py


示例18: test_redirect_to_chain

 def test_redirect_to_chain(self):
     classifier = self.create_policy_classifier(
         name="class1", protocol="tcp", direction="in", port_range="20:90")
     classifier_id = classifier['policy_classifier']['id']
     action = self.create_policy_action(
         name="action1", action_type=gconst.GP_ACTION_REDIRECT,
         action_value=uuidutils.generate_uuid())
     action_id = action['policy_action']['id']
     action_id_list = [action_id]
     policy_rule = self.create_policy_rule(
         name='pr1', policy_classifier_id=classifier_id,
         policy_actions=action_id_list)
     policy_rule_id = policy_rule['policy_rule']['id']
     policy_rule_list = [policy_rule_id]
     policy_rule_set = self.create_policy_rule_set(
         name="c1", policy_rules=policy_rule_list)
     policy_rule_set_id = policy_rule_set['policy_rule_set']['id']
     self.create_policy_target_group(
         name="ptg1", provided_policy_rule_sets={policy_rule_set_id: None})
     create_chain_instance = mock.patch.object(
         servicechain_plugin.ServiceChainPlugin,
         'create_servicechain_instance')
     create_chain_instance = create_chain_instance.start()
     chain_instance_id = uuidutils.generate_uuid()
     create_chain_instance.return_value = {'id': chain_instance_id}
     # TODO(Magesh):Add tests which verifies that provide/consumer PTGs
     # are set correctly for the SCI
     with mock.patch.object(
             resource_mapping.ResourceMappingDriver,
             '_set_rule_servicechain_instance_mapping') as set_rule:
         with mock.patch.object(servicechain_db.ServiceChainDbPlugin,
                                'get_servicechain_spec') as sc_spec_get:
             sc_spec_get.return_value = {'servicechain_spec': {}}
             consumer_ptg = self.create_policy_target_group(
                 name="ptg2",
                 consumed_policy_rule_sets={policy_rule_set_id: None})
             consumer_ptg_id = consumer_ptg['policy_target_group']['id']
             set_rule.assert_called_once_with(mock.ANY, policy_rule_id,
                                              chain_instance_id)
     with mock.patch.object(servicechain_plugin.ServiceChainPlugin,
                            'delete_servicechain_instance'):
         with mock.patch.object(
             resource_mapping.ResourceMappingDriver,
             '_get_rule_servicechain_mapping') as get_rule:
             r_sc_map = resource_mapping.RuleServiceChainInstanceMapping()
             r_sc_map.rule_id = policy_rule_id
             r_sc_map.servicechain_instance_id = chain_instance_id
             get_rule.return_value = r_sc_map
             get_chain_inst = mock.patch.object(
                 servicechain_db.ServiceChainDbPlugin,
                 'get_servicechain_instance')
             get_chain_inst.start()
             get_chain_inst.return_value = {
                 "servicechain_instance": {'id': chain_instance_id}}
             req = self.new_delete_request(
                 'policy_target_groups', consumer_ptg_id)
             res = req.get_response(self.ext_api)
             self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code)
开发者ID:yapengwu,项目名称:group-based-policy,代码行数:58,代码来源:test_resource_mapping.py


示例19: get_ofc_item_random_params

 def get_ofc_item_random_params(self):
     """create random parameters for ofc_item test."""
     tenant_id = uuidutils.generate_uuid()
     network_id = uuidutils.generate_uuid()
     port_id = uuidutils.generate_uuid()
     portinfo = nmodels.PortInfo(id=port_id, datapath_id="0x123456789",
                                 port_no=1234, vlan_id=321,
                                 mac="11:22:33:44:55:66")
     return tenant_id, network_id, portinfo
开发者ID:Doude,项目名称:neutron,代码行数:9,代码来源:test_pfc_driver.py


示例20: test_router_create_with_nuage_rtr_template

 def test_router_create_with_nuage_rtr_template(self):
     nuage_rtr_template = uuidutils.generate_uuid()
     data = {"router": {"tenant_id": uuidutils.generate_uuid()}}
     data["router"]["name"] = "router1"
     data["router"]["admin_state_up"] = True
     data["router"]["nuage_router_template"] = nuage_rtr_template
     router_req = self.new_create_request("routers", data, "json")
     router_res = router_req.get_response(self.ext_api)
     self.assertEqual(exc.HTTPCreated.code, router_res.status_int)
开发者ID:cboling,项目名称:SDNdbg,代码行数:9,代码来源:test_nuage_plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uuidutils.is_uuid_like函数代码示例发布时间:2022-05-27
下一篇:
Python timeutils.utcnow函数代码示例发布时间: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