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


Python uuidutils.generate_uuid函数代码示例

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


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


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