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


Python vnc_api.VirtualMachineInterface类代码示例

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


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

示例1: test_virtual_port_group_delete

    def test_virtual_port_group_delete(self):
        proj_obj = Project('%s-project' % (self.id()))
        self.api.project_create(proj_obj)

        vn = VirtualNetwork('vn-%s' % (self.id()), parent_obj=proj_obj)
        self.api.virtual_network_create(vn)

        vpg_name = "vpg-" + self.id()
        vpg_obj = VirtualPortGroup(vpg_name)
        self.api.virtual_port_group_create(vpg_obj)

        vmi_id_list = []
        for i in range(self.VMI_NUM):
            vmi_obj = VirtualMachineInterface(self.id() + str(i),
                                              parent_obj=proj_obj)
            vmi_obj.set_virtual_network(vn)
            vmi_id_list.append(
                self.api.virtual_machine_interface_create(vmi_obj))
            vpg_obj.add_virtual_machine_interface(vmi_obj)
            self.api.virtual_port_group_update(vpg_obj)
            self.api.ref_relax_for_delete(vpg_obj.uuid, vmi_id_list[i])

        # Make sure when VPG doesn't get deleted, since associated VMIs
        # still refers it.
        with ExpectedException(BadRequest):
            self.api.virtual_port_group_delete(id=vpg_obj.uuid)

        # Cleanup
        for i in range(self.VMI_NUM):
            self.api.virtual_machine_interface_delete(id=vmi_id_list[i])

        self.api.virtual_port_group_delete(id=vpg_obj.uuid)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:32,代码来源:test_virtual_port_group.py

示例2: test_disable_port_security_with_empty_allowed_address_pair_list

    def test_disable_port_security_with_empty_allowed_address_pair_list(self):
        project = Project('%s-project' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        self._vnc_lib.virtual_network_create(vn)
        addr_pair = AllowedAddressPairs()

        vmi1 = VirtualMachineInterface(
            'vmi1-%s' % self.id(),
            parent_obj=project,
            port_security_enabled=False,
            virtual_machine_interface_allowed_address_pairs=addr_pair)
        vmi1.set_virtual_network(vn)
        self._vnc_lib.virtual_machine_interface_create(vmi1)

        addr_pair = AllowedAddressPairs(
            allowed_address_pair=[
                AllowedAddressPair(ip=SubnetType('1.1.1.0', 24),
                                   mac='02:ce:1b:d7:a6:e7')])
        vmi2 = VirtualMachineInterface(
            'vmi2-%s' % self.id(),
            parent_obj=project,
            port_security_enabled=True,
            virtual_machine_interface_allowed_address_pairs=addr_pair)
        vmi2.set_virtual_network(vn)
        self._vnc_lib.virtual_machine_interface_create(vmi2)

        addr_pair = AllowedAddressPairs()
        vmi2.set_virtual_machine_interface_allowed_address_pairs(addr_pair)
        self._vnc_lib.virtual_machine_interface_update(vmi2)

        vmi2.set_port_security_enabled(False)
        self._vnc_lib.virtual_machine_interface_update(vmi2)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:33,代码来源:test_virtual_machine_interface.py

示例3: test_dedicated_tag_and_refs_deleted

    def test_dedicated_tag_and_refs_deleted(self):
        vn = VirtualNetwork('%s-vn' % self.id(), parent_obj=self.project)
        self._vnc_lib.virtual_network_create(vn)
        vmi_ids = []
        for i in range(3):
            vmi = VirtualMachineInterface(
                '%s-vmi%d' % (self.id(), i), parent_obj=self.project)
            vmi.add_virtual_network(vn)
            vmi_ids.append(self._vnc_lib.virtual_machine_interface_create(vmi))
        neutron_fg = self.create_resource(
            'firewall_group',
            self.project_id,
            extra_res_fields={
                'ports': vmi_ids,
            },
        )

        tag_fq_name = self._get_tag_fq_name(neutron_fg, self.project)
        try:
            self._vnc_lib.tag_read(tag_fq_name)
        except NoIdError:
            msg = ("Dedicated Tag %s for firewall group %s was not created" %
                   (':'.join(tag_fq_name), neutron_fg['id']))
            self.fail(msg)

        self.delete_resource('firewall_group', self.project_id,
                             neutron_fg['id'])
        self.assertRaises(NoIdError, self._vnc_lib.tag_read, tag_fq_name)
开发者ID:rombie,项目名称:contrail-controller,代码行数:28,代码来源:test_firewall.py

示例4: test_firewall_group_port_association

    def test_firewall_group_port_association(self):
        vn = VirtualNetwork('%s-vn' % self.id(), parent_obj=self.project)
        self._vnc_lib.virtual_network_create(vn)
        vmi_ids = []
        for i in range(3):
            vmi = VirtualMachineInterface(
                '%s-vmi%d' % (self.id(), i), parent_obj=self.project)
            vmi.add_virtual_network(vn)
            vmi_ids.append(self._vnc_lib.virtual_machine_interface_create(vmi))

        neutron_fg = self.create_resource(
            'firewall_group',
            self.project_id,
            extra_res_fields={
                'ports': vmi_ids[:-1],
            },
        )
        self.assertEquals(set(neutron_fg['ports']), set(vmi_ids[:-1]))

        neutron_fg = self.update_resource(
            'firewall_group',
            neutron_fg['id'],
            self.project_id,
            extra_res_fields={
                'ports': vmi_ids[1:],
            },
        )
        self.assertEquals(set(neutron_fg['ports']), set(vmi_ids[1:]))
开发者ID:rombie,项目名称:contrail-controller,代码行数:28,代码来源:test_firewall.py

示例5: test_valid_sub_interface_vlan_tag_id

    def test_valid_sub_interface_vlan_tag_id(self):
        project = Project('%s-project' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('%s-vn' % self.id(), parent_obj=project)
        self.api.virtual_network_create(vn)

        test_suite = [
            (None, None),
            (VMIPT(None), None),
            (VMIPT(sub_interface_vlan_tag=None), None),
            (VMIPT(sub_interface_vlan_tag=-42), BadRequest),
            (VMIPT(sub_interface_vlan_tag=4095), BadRequest),
            (VMIPT(sub_interface_vlan_tag='fo'), BadRequest),
            (VMIPT(sub_interface_vlan_tag='42'), None),
            (VMIPT(sub_interface_vlan_tag=42), None),
        ]

        for (vmipt, result) in test_suite:
            vmi = VirtualMachineInterface('%s-vmi' % self.id(),
                                          parent_obj=project)
            vmi.set_virtual_network(vn)
            vmi.set_virtual_machine_interface_properties(vmipt)
            if result and issubclass(result, Exception):
                self.assertRaises(result,
                                  self.api.virtual_machine_interface_create,
                                  vmi)
            else:
                self.api.virtual_machine_interface_create(vmi)
                self.api.virtual_machine_interface_delete(id=vmi.uuid)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:29,代码来源:test_virtual_machine_interface.py

示例6: _create_virtual_interface

    def _create_virtual_interface(self, project, vip_id, subnet_id,
                                  ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.set_virtual_network(vnet)

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        iip_obj = InstanceIp(name=vip_id)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(iip_obj)
        iip = self._api.instance_ip_read(id=iip_obj.uuid)
        vip_address = iip.get_instance_ip_address()

        return vmi, vip_address
开发者ID:leonstack,项目名称:contrail-neutron-plugin,代码行数:25,代码来源:virtual_ip.py

示例7: test_create_pool

    def test_create_pool(self):
        tenant_id = _uuid()
        pool_id = _uuid()
        vip_id = _uuid()
        subnet_id = _uuid()

        api = self.api_server

        project = Project(name='test')
        project.uuid = tenant_id
        template = ServiceTemplate('lb-test', project)
        template.uuid = _uuid()

        pool_attrs = LoadbalancerPoolType()
        pool_attrs.subnet_id = subnet_id
        pool = LoadbalancerPool(
            pool_id, project, loadbalancer_pool_properties=pool_attrs)
        pool.uuid = pool_id

        vip_attrs = VirtualIpType()
        vip_attrs.subnet_id = subnet_id
        vip_attrs.address = '127.0.0.1'
        vip = VirtualIp(vip_id, project, virtual_ip_properties=vip_attrs)
        vip.uuid = vip_id
        vip.set_loadbalancer_pool(pool)

        vnet = VirtualNetwork('test', project)
        vnet.uuid = _uuid()

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.uuid = _uuid()
        vmi.set_virtual_network(vnet)
        iip = InstanceIp(vip_id, instance_ip_address='127.0.0.1')
        iip.uuid = _uuid()
        iip.set_virtual_machine_interface(vmi)

        iip_refs = [
            {'to': iip.get_fq_name(), 'uuid': iip.uuid}
        ]
        vmi.get_instance_ip_back_refs = mock.Mock()
        vmi.get_instance_ip_back_refs.return_value = iip_refs

        vip.set_virtual_machine_interface(vmi)

        api.virtual_service_template_read = template
        api.loadbalancer_pool_read.return_value = pool
        api.virtual_ip_read.return_value = vip
        api.kv_retrieve.return_value = '%s %s' % (vnet.uuid, subnet_id)
        api.virtual_machine_interface_read.return_value = vmi
        api.instance_ip_read.return_value = iip
        api.service_instance_read.side_effect = NoIdError('404')

        context = {}
        pool_data = {
            'id': pool_id,
            'vip_id': vip_id
        }
        self.driver.create_pool(context, pool_data)
        api.service_instance_create.assert_called_with(mock.ANY)
开发者ID:achanda,项目名称:contrail-neutron-plugin,代码行数:59,代码来源:test_driver.py

示例8: test_firewall_group_status

    def test_firewall_group_status(self):
        neutron_fg = self.create_resource(
            'firewall_group',
            self.project_id,
            extra_res_fields={
                'admin_state_up': False,
            },
        )
        self.assertEquals(neutron_fg['status'], constants.DOWN)

        neutron_fg = self.update_resource(
            'firewall_group',
            neutron_fg['id'],
            self.project_id,
            extra_res_fields={
                'admin_state_up': True,
            },
        )
        self.assertEquals(neutron_fg['status'], constants.INACTIVE)

        vn = VirtualNetwork('%s-vn' % self.id(), parent_obj=self.project)
        self._vnc_lib.virtual_network_create(vn)
        vmi = VirtualMachineInterface(
            '%s-vmi' % self.id(), parent_obj=self.project)
        vmi.add_virtual_network(vn)
        self._vnc_lib.virtual_machine_interface_create(vmi)
        neutron_fg = self.update_resource(
            'firewall_group',
            neutron_fg['id'],
            self.project_id,
            extra_res_fields={
                'ports': [vmi.uuid],
            },
        )
        self.assertEquals(neutron_fg['status'], constants.INACTIVE)

        fp = FirewallPolicy('%s-fp' % self.id(), parent_obj=self.project)
        self._vnc_lib.firewall_policy_create(fp)
        neutron_fg = self.update_resource(
            'firewall_group',
            neutron_fg['id'],
            self.project_id,
            extra_res_fields={
                'egress_firewall_policy_id': fp.uuid,
            },
        )
        self.assertEquals(neutron_fg['status'], constants.ACTIVE)

        neutron_fg = self.update_resource(
            'firewall_group',
            neutron_fg['id'],
            self.project_id,
            extra_res_fields={
                'ports': [],
            },
        )
        self.assertEquals(neutron_fg['status'], constants.INACTIVE)
开发者ID:rombie,项目名称:contrail-controller,代码行数:57,代码来源:test_firewall.py

示例9: test_asn

    def test_asn(self):
        # create  vn1
        vn1_name = self.id() + 'vn1'
        vn1_obj = self.create_virtual_network(vn1_name, '10.0.0.0/24')
        ident_name = self.get_obj_imid(vn1_obj)
        gevent.sleep(2)
        ifmap_ident = self.assertThat(FakeIfmapClient._graph, Contains(ident_name))

        self.check_ri_asn(self.get_ri_name(vn1_obj), 'target:64512:8000001')

        # create router1
        r1_name = self.id() + 'router1'
        router1 = self.create_bgp_router(r1_name, 'contrail')
        self.check_bgp_asn(router1.get_fq_name(), 64512)

        # create virtual machine interface
        vmi_name = self.id() + 'vmi1'
        vmi = VirtualMachineInterface(vmi_name, parent_type='project',
                                      fq_name=['default-domain',
                                               'default-project', vmi_name])
        vmi.add_virtual_network(vn1_obj)
        self._vnc_lib.virtual_machine_interface_create(vmi)

        # create logical router
        lr_name = self.id() + 'lr1'
        lr = LogicalRouter(lr_name)
        lr.add_virtual_machine_interface(vmi)
        self._vnc_lib.logical_router_create(lr)
        self.check_lr_asn(lr.get_fq_name(), 'target:64512:8000002')

        #update global system config but dont change asn value for equality path
        gs = self._vnc_lib.global_system_config_read(
            fq_name=['default-global-system-config'])
        gs.set_autonomous_system(64512)
        self._vnc_lib.global_system_config_update(gs)

        # check route targets
        self.check_ri_asn(self.get_ri_name(vn1_obj), 'target:64512:8000001')
        self.check_bgp_asn(router1.get_fq_name(), 64512)
        self.check_lr_asn(lr.get_fq_name(), 'target:64512:8000002')

        #update ASN value
        gs = self._vnc_lib.global_system_config_read(
            fq_name=[u'default-global-system-config'])
        gs.set_autonomous_system(50000)
        self._vnc_lib.global_system_config_update(gs)

        # check new route targets
        self.check_ri_asn(self.get_ri_name(vn1_obj), 'target:50000:8000001')
        self.check_bgp_asn(router1.get_fq_name(), 50000)
        self.check_lr_asn(lr.get_fq_name(), 'target:50000:8000002')

        self._vnc_lib.logical_router_delete(id=lr.uuid)
        self._vnc_lib.virtual_machine_interface_delete(id=vmi.uuid)
        self._vnc_lib.virtual_network_delete(id=vn1_obj.uuid)
        self.check_ri_is_deleted(fq_name=vn1_obj.fq_name+[vn1_obj.name])
        self._vnc_lib.bgp_router_delete(id=router1.uuid)
开发者ID:Pojen-Huang,项目名称:contrail-controller,代码行数:57,代码来源:test_bgp.py

示例10: test_asn

    def test_asn(self):
        # create  vn1
        vn1_name = self.id() + 'vn1'
        vn1_obj = self.create_virtual_network(vn1_name, '10.0.0.0/24')
        self.assertTill(self.vnc_db_has_ident, obj=vn1_obj)

        ri_target = self.check_ri_target(self.get_ri_name(vn1_obj))

        # create router1
        r1_name = self.id() + 'router1'
        router1 = self.create_bgp_router(r1_name, 'contrail')
        self.check_bgp_asn(router1.get_fq_name(), 64512)

        # create virtual machine interface
        vmi_name = self.id() + 'vmi1'
        vmi = VirtualMachineInterface(vmi_name, parent_type='project',
                                      fq_name=['default-domain',
                                               'default-project', vmi_name])
        vmi.add_virtual_network(vn1_obj)
        self._vnc_lib.virtual_machine_interface_create(vmi)

        # create logical router
        lr_name = self.id() + 'lr1'
        lr = LogicalRouter(lr_name)
        lr.add_virtual_machine_interface(vmi)
        self._vnc_lib.logical_router_create(lr)
        lr_target = self.check_lr_target(lr.get_fq_name())

        #update global system config but dont change asn value for equality path
        gs = self._vnc_lib.global_system_config_read(
            fq_name=['default-global-system-config'])
        gs.set_autonomous_system(64512)
        self._vnc_lib.global_system_config_update(gs)

        # check route targets
        self.check_ri_target(self.get_ri_name(vn1_obj), ri_target)
        self.check_bgp_asn(router1.get_fq_name(), 64512)
        self.check_lr_target(lr.get_fq_name(), lr_target)

        #update ASN value
        gs = self._vnc_lib.global_system_config_read(
            fq_name=[u'default-global-system-config'])
        gs.set_autonomous_system(50000)
        self._vnc_lib.global_system_config_update(gs)

        # check new route targets
        self.check_ri_target(self.get_ri_name(vn1_obj), ri_target.replace('64512', '50000'))
        self.check_bgp_asn(router1.get_fq_name(), 50000)
        self.check_lr_target(lr.get_fq_name(), lr_target.replace('64512', '50000'))

        self._vnc_lib.logical_router_delete(id=lr.uuid)
        self._vnc_lib.virtual_machine_interface_delete(id=vmi.uuid)
        self._vnc_lib.virtual_network_delete(id=vn1_obj.uuid)
        self.check_ri_is_deleted(fq_name=vn1_obj.fq_name+[vn1_obj.name])
        self._vnc_lib.bgp_router_delete(id=router1.uuid)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:55,代码来源:test_bgp.py

示例11: _create_vmi

    def _create_vmi(self, pod_task_id, vm_obj, vn_obj):
        proj_fq_name = vnc_mesos_config.cluster_project_fq_name('default')
        proj_obj = self._vnc_lib.project_read(fq_name=proj_fq_name)

        vmi_prop = None
        obj_uuid = str(uuid.uuid1())
        vmi_obj = VirtualMachineInterface(
            name=vm_obj.name, parent_obj=proj_obj,
            virtual_machine_interface_properties=vmi_prop,
            display_name=vm_obj.name)

        vmi_obj.uuid = obj_uuid
        vmi_obj.set_virtual_network(vn_obj)
        vmi_obj.set_virtual_machine(vm_obj)
        vmi_obj.add_annotations(KeyValuePair(key='index', value='0/1'))
        vmi_obj.port_security_enabled = True
        VirtualMachineInterfaceMM.add_annotations(self, vmi_obj, pod_task_id)

        try:
            vmi_uuid = self._vnc_lib.virtual_machine_interface_create(vmi_obj)
        except RefsExistError:
            vmi_uuid = self._vnc_lib.virtual_machine_interface_update(vmi_obj)

        VirtualMachineInterfaceMM.locate(vmi_uuid)
        return vmi_uuid
开发者ID:Juniper,项目名称:contrail-controller,代码行数:25,代码来源:vnc_pod_task.py

示例12: test_subnet_type_validation

    def test_subnet_type_validation(self):
        test_suite = [
            (SubnetType('0', 0), ('0.0.0.0', 0)),
            (SubnetType('1.1.1.1'), BadRequest),
            (SubnetType('1.1.1.1', 24), ('1.1.1.0', 24)),
            (SubnetType('1.1.1.1', '24'), ('1.1.1.0', 24)),
            (SubnetType('1.1.1.1', 32), ('1.1.1.1', 32)),
            (SubnetType('1.1.1.e', 32), BadRequest),
            (SubnetType('1.1.1.1', '32e'), BadRequest),
            (SubnetType('1.1.1.0,2.2.2.0', 24), BadRequest),
            (SubnetType(''), BadRequest),
            (SubnetType('', 30), BadRequest),
            (SubnetType('::', 0), ('::', 0)),
            (SubnetType('::'), BadRequest),
            (SubnetType('dead::beef', 128), ('dead::beef', 128)),
            (SubnetType('dead::beef', '128'), ('dead::beef', 128)),
            (SubnetType('dead::beef', 96), ('dead::', 96)),
            (SubnetType('dead::beez', 96), BadRequest),
            (SubnetType('dead::beef', '96e'), BadRequest),
            (SubnetType('dead::,beef::', 64), BadRequest),
        ]

        project = Project('%s-project' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        self.api.virtual_network_create(vn)
        vmi = VirtualMachineInterface('vmi-%s' % self.id(), parent_obj=project)
        vmi.set_virtual_network(vn)
        self.api.virtual_machine_interface_create(vmi)

        for subnet, expected_result in test_suite:
            aaps = AllowedAddressPairs(
                allowed_address_pair=[AllowedAddressPair(ip=subnet)])
            vmi.set_virtual_machine_interface_allowed_address_pairs(aaps)
            if (type(expected_result) == type and
                    issubclass(expected_result, Exception)):
                self.assertRaises(
                    expected_result,
                    self.api.virtual_machine_interface_update,
                    vmi)
            else:
                self.api.virtual_machine_interface_update(vmi)
                vmi = self.api.virtual_machine_interface_read(id=vmi.uuid)
                returned_apps = vmi.\
                    get_virtual_machine_interface_allowed_address_pairs().\
                    get_allowed_address_pair()
                self.assertEqual(len(returned_apps), 1)
                returned_subnet = returned_apps[0].get_ip()
                self.assertEqual(returned_subnet.ip_prefix,
                                 expected_result[0])
                self.assertEqual(returned_subnet.ip_prefix_len,
                                 expected_result[1])
开发者ID:Juniper,项目名称:contrail-controller,代码行数:52,代码来源:test_vnc_cfg_api_server.py

示例13: create_virtual_machine

 def create_virtual_machine(self, name, vn, ipaddress):
     vm_instance = VirtualMachine(name)
     self._vnc_lib.virtual_machine_create(vm_instance)
     fq_name = [name, '0']
     vmi = VirtualMachineInterface(parent_type='virtual-machine', fq_name=fq_name)
     vmi.set_virtual_network(vn)
     self._vnc_lib.virtual_machine_interface_create(vmi)
     ip = InstanceIp(vm_instance.name + '.0')
     ip.set_virtual_machine_interface(vmi)
     ip.set_virtual_network(vn)
     ip.set_instance_ip_address(ipaddress)
     self._vnc_lib.instance_ip_create(ip)
     return vm_instance
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:13,代码来源:test_case.py

示例14: test_port_security_and_allowed_address_pairs

    def test_port_security_and_allowed_address_pairs(self):
        project = Project('%s-project' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        self._vnc_lib.virtual_network_create(vn)
        addr_pair = AllowedAddressPairs(
            allowed_address_pair=[
                AllowedAddressPair(ip=SubnetType('1.1.1.0', 24),
                                   mac='02:ce:1b:d7:a6:e7')])
        msg = (r"^Allowed address pairs are not allowed when port security is "
               "disabled$")

        vmi = VirtualMachineInterface(
            'vmi-%s' % self.id(),
            parent_obj=project,
            port_security_enabled=False,
            virtual_machine_interface_allowed_address_pairs=addr_pair)
        vmi.set_virtual_network(vn)
        with self.assertRaisesRegexp(BadRequest, msg):
            self._vnc_lib.virtual_machine_interface_create(vmi)

        vmi = VirtualMachineInterface('vmi-%s' % self.id(), parent_obj=project,
                                      port_security_enabled=False)
        vmi.set_virtual_network(vn)
        self._vnc_lib.virtual_machine_interface_create(vmi)

        # updating a port with allowed address pair should throw an exception
        # when port security enabled is set to false
        vmi.virtual_machine_interface_allowed_address_pairs = addr_pair
        with self.assertRaisesRegexp(BadRequest, msg):
            self._vnc_lib.virtual_machine_interface_update(vmi)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:31,代码来源:test_virtual_machine_interface.py

示例15: _create_virtual_interface

    def _create_virtual_interface(self, project, vip_id, subnet_id,
                                  ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.set_virtual_network(vnet)
        try:
            vmi.set_virtual_machine_interface_device_owner(n_constants.DEVICE_OWNER_LOADBALANCER)
        except AttributeError:
            # DEVICE_OWNER_LOADBALANCER is only supported from JUNO onwards
            pass

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        iip_obj = InstanceIp(name=vip_id)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(iip_obj)
        iip = self._api.instance_ip_read(id=iip_obj.uuid)
        vip_address = iip.get_instance_ip_address()

        return vmi, vip_address
开发者ID:tcpcloud,项目名称:contrail-neutron-plugin,代码行数:30,代码来源:virtual_ip.py


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