當前位置: 首頁>>代碼示例>>Python>>正文


Python VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs方法代碼示例

本文整理匯總了Python中vnc_api.vnc_api.VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs方法的具體用法?Python VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs怎麽用?Python VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vnc_api.vnc_api.VirtualMachineInterface的用法示例。


在下文中一共展示了VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_disable_port_security_with_empty_allowed_address_pair_list

# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine_interface_allowed_address_pairs [as 別名]
    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,代碼行數:35,代碼來源:test_virtual_machine_interface.py

示例2: test_subnet_type_validation

# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine_interface_allowed_address_pairs [as 別名]
    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,代碼行數:54,代碼來源:test_vnc_cfg_api_server.py


注:本文中的vnc_api.vnc_api.VirtualMachineInterface.set_virtual_machine_interface_allowed_address_pairs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。