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


Python platform.Platform類代碼示例

本文整理匯總了Python中pyvcloud.vcd.platform.Platform的典型用法代碼示例。如果您正苦於以下問題:Python Platform類的具體用法?Python Platform怎麽用?Python Platform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_0010_update

    def test_0010_update(self):
        """Test the method Platform.update_external_network()

        Update name and description of the external network created by setup.
        Verifies name and description after update completes. Reset the name
        and description to original.

        This test passes if name and description are updated successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        new_name = 'updated_' + TestExtNet._name
        new_description = 'Updated ' + TestExtNet._description

        ext_net = platform.update_external_network(TestExtNet._name, new_name,
                                                   new_description)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug('Updated external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(new_name)
        self.assertIsNotNone(ext_net)
        self.assertEqual(new_description,
                         ext_net['{' + NSMAP['vcloud'] + '}Description'].text)

        # Reset the name and description to original
        ext_net = platform.update_external_network(new_name, self._name,
                                                   self._description)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:33,代碼來源:extnet_tests.py

示例2: test_0020_add_subnet

    def test_0020_add_subnet(self):
        """Test the method externalNetwork.add_subnet()

        Add subnet to the existing external network

        This test passes if subnet is added successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        ext_net_resource = platform.get_external_network(self._name)
        extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                     resource=ext_net_resource)

        ext_net = extnet_obj.add_subnet(self._name,
                                        TestExtNet._gateway2,
                                        TestExtNet._netmask,
                                        [TestExtNet._ip_range2],
                                        TestExtNet._dns1,
                                        TestExtNet._dns2,
                                        TestExtNet._dns_suffix)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Added subnet to external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        new_subnet = config.IpScopes.IpScope[-1]
        self.assertEqual(TestExtNet._gateway2, new_subnet.Gateway.text)
        self.assertEqual(TestExtNet._netmask, new_subnet.Netmask.text)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:33,代碼來源:extnet_tests.py

示例3: test_0060_attach_port_group

    def test_0060_attach_port_group(self):
        """Attach a portgroup to an external network
       This test passes if the portgroup from another vCenter is added
       to external network successfully.
       """
        if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
            return
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        vc_name = TestExtNet._config['vc2']['vcenter_host_name']
        portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = portgrouphelper.get_available_portgroup_name(
            vc_name, TestExtNet._portgroupType)

        ext_net = self._get_ext_net(platform).attach_port_group(
            vc_name,
            pg_name)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Attach a portgroup to an external network'
            + TestExtNet._name + '.')
        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        vc_record = platform.get_vcenter(vc_name)
        vc_href = vc_record.get('href')
        vim_port_group_refs = \
            ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
        vc_href_found = False
        for vim_obj_ref in vim_port_group_refs.VimObjectRef:
            if vim_obj_ref.VimServerRef.get('href') == vc_href:
                vc_href_found = True
                break
        self.assertTrue(vc_href_found)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:35,代碼來源:extnet_tests.py

示例4: test_0055_delete_ip_range

    def test_0055_delete_ip_range(self):
        """Test the method externalNetwork.delete_ip_range()
       Delete ip range of a subnet in external network
       This test passes if the ip range for a subnet is
       deleted successfully.
       """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        ext_net = self._get_ext_net(platform).delete_ip_range(
            TestExtNet._gateway2,
            [TestExtNet._ip_range4])

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Deleted ip-range of a subnet in external network'
            + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        ip_scope = config.IpScopes.IpScope
        for scope in ip_scope:
            if scope.Gateway == TestExtNet._gateway2:
                ip_scope = scope
                break
        self.assertIsNotNone(ip_scope)
        self.assertFalse(self.__validate_ip_range(ip_scope,
                                                  TestExtNet._ip_range4))
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:30,代碼來源:extnet_tests.py

示例5: test_0030_enable_subnet

    def test_0030_enable_subnet(self):
        """Test the method externalNetwork.enable_subnet()

        Enable subnet of external network

        This test passes if subnet is enabled successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)

        ext_net = self._get_ext_net(platform).enable_subnet(
            TestExtNet._gateway2, True)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Enabled subnet of external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        ip_scope = config.IpScopes.IpScope
        for scope in ip_scope:
            if scope.Gateway == TestExtNet._gateway2:
                ip_scope = scope
                break
        self.assertIsNotNone(ip_scope)
        self.assertEqual(ip_scope.IsEnabled, True)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:29,代碼來源:extnet_tests.py

示例6: test_0021_list_available_port_group_names

 def test_0021_list_available_port_group_names(self):
     """Test the method Platform.list_port_group_names, this method fetches
     list of portgroup name for a particular vCenter"""
     platform = Platform(TestVC._client)
     port_group_names = \
         platform.list_available_port_group_names(TestVC._vcenter_host_name)
     self.assertTrue(len(port_group_names) > 0)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:7,代碼來源:vc_tests.py

示例7: test_0061_detach_port_group

    def test_0061_detach_port_group(self):
        """Detach a portgroup from an external network
       This test passes if the portgroup from another vCenter is removed
       from external network successfully.
       """
        if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
            return
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        vc_name = TestExtNet._config['vc2']['vcenter_host_name']
        port_group_helper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = port_group_helper.get_ext_net_portgroup_name(vc_name,
                                                               self._name)

        ext_net = self._get_ext_net(platform).detach_port_group(vc_name,
                                                                pg_name)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Detach a portgroup from an external network' + TestExtNet._name)
        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        vc_record = platform.get_vcenter(vc_name)
        vc_href = vc_record.get('href')
        vim_port_group_ref = ext_net.VimPortGroupRef
        vc_href_found = False

        if vim_port_group_ref.VimServerRef.get('href') == vc_href:
            vc_href_found = True
        self.assertFalse(vc_href_found)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:31,代碼來源:extnet_tests.py

示例8: list_vcenters

def list_vcenters(ctx):
    try:
        restore_session(ctx)
        platform = Platform(ctx.obj['client'])
        stdout(platform.list_vcenters(), ctx)
    except Exception as e:
        stderr(e, ctx)
開發者ID:vmware,項目名稱:vca-cli,代碼行數:7,代碼來源:vc.py

示例9: info

def info(ctx, name):
    try:
        restore_session(ctx)
        platform = Platform(ctx.obj['client'])
        stdout(platform.get_vcenter(name=name), ctx)
    except Exception as e:
        stderr(e, ctx)
開發者ID:vmware,項目名稱:vca-cli,代碼行數:7,代碼來源:vc.py

示例10: create_external_network

    def create_external_network(cls):
        """Creates an external network by the name specified in the config file.

        Skips creating one, if such a network already exists. Also stores the
        href and name of the network as class variables for future use.
        """
        cls._basic_check()
        net_name = cls._config['external_network']['name']

        platform = Platform(cls._sys_admin_client)

        net_refs = platform.list_external_networks()
        if net_name is not '*':
            for net_ref in net_refs:
                if net_ref.get('name').lower() == net_name.lower():
                    cls._logger.debug('Reusing existing ' + net_name)
                    cls._external_network_href = net_ref.get('href')
                    cls._external_network_name = net_name
                    return
            cls._logger.debug('Creating new external network' + net_name)
            ext_nw = cls._create_external_network()
            cls._external_network_href = ext_nw.get('href')
            cls._external_network_name = net_name
            cls._logger.debug('Created external network ' + net_name)
        else:
            if len(net_refs) > 0:
                cls._logger.debug('Defaulting to first network : ' +
                                  net_refs[0].get('name'))
                cls._external_network_href = net_refs[0].get('href')
                cls._external_network_name = net_refs[0].get('name')
            else:
                cls._logger.debug('No usable network found. Aborting test.')
                raise Exception('Test Aborted. No usable external network.')
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:33,代碼來源:environment.py

示例11: detach

def detach(ctx, name):
    try:
        restore_session(ctx)
        platform = Platform(ctx.obj['client'])
        stdout(platform.detach_vcenter(vc_name=name), ctx)
    except Exception as e:
        stderr(e, ctx)
開發者ID:vmware,項目名稱:vca-cli,代碼行數:7,代碼來源:vc.py

示例12: test_0020_get_vc

 def test_0020_get_vc(self):
     """Platform.get_vcenter finds a known vcenter."""
     logger = Environment.get_default_logger()
     platform = Platform(TestVC._client)
     vcenter = platform.get_vcenter(TestVC._vcenter_host_name)
     logger.debug('vCenter: name=%s, url=%s' %
                  (vcenter.get('name'), vcenter.Url.text))
     self.assertIsNotNone(vcenter)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:8,代碼來源:vc_tests.py

示例13: test_0010_list_vc

 def test_0010_list_vc(self):
     """Platform.list_vcenters prints a list of virtual center servers."""
     logger = Environment.get_default_logger()
     platform = Platform(TestVC._client)
     vcenters = platform.list_vcenters()
     for vcenter in vcenters:
         logger.debug('vCenter found: %s' % vcenter.get('name'))
     self.assertTrue(len(vcenters) > 0)
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:8,代碼來源:vc_tests.py

示例14: disable

def disable(ctx, name):
    try:
        restore_session(ctx)
        platform = Platform(ctx.obj['client'])
        stdout(platform.enable_disable_vcenter(
            vc_name=name, enable_flag=False), ctx)
    except Exception as e:
        stderr(e, ctx)
開發者ID:vmware,項目名稱:vca-cli,代碼行數:8,代碼來源:vc.py

示例15: test_0030_get_vc_negative

 def test_0030_get_vc_negative(self):
     """Platform.get_vcenter does not find a non-existent vcenter."""
     try:
         platform = Platform(TestVC._client)
         platform.get_vcenter(TestVC._vcenter_invalid)
         self.fail('Should not be able to find VC that does not exist ' +
                   TestVC._vcenter_invalid)
     except EntityNotFoundException as e:
         return
開發者ID:vmware,項目名稱:pyvcloud,代碼行數:9,代碼來源:vc_tests.py


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