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


Python DataSourceOpenNebula.read_context_disk_dir方法代码示例

本文整理汇总了Python中cloudinit.sources.DataSourceOpenNebula.read_context_disk_dir方法的典型用法代码示例。如果您正苦于以下问题:Python DataSourceOpenNebula.read_context_disk_dir方法的具体用法?Python DataSourceOpenNebula.read_context_disk_dir怎么用?Python DataSourceOpenNebula.read_context_disk_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudinit.sources.DataSourceOpenNebula的用法示例。


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

示例1: test_user_data_base64_encoding

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data_base64_encoding(self):
        for k in ("USER_DATA", "USERDATA"):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: util.b64e(USER_DATA), "USERDATA_ENCODING": "base64"})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue("userdata" in results)
            self.assertEqual(USER_DATA, results["userdata"])
开发者ID:number5,项目名称:cloud-init,代码行数:10,代码来源:test_opennebula.py

示例2: test_user_data

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data(self):
        for k in ('USER_DATA', 'USERDATA'):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: USER_DATA})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue('userdata' in results)
            self.assertEqual(USER_DATA, results['userdata'])
开发者ID:cloudsigma,项目名称:cloud-init,代码行数:10,代码来源:test_opennebula.py

示例3: test_user_data_plain

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data_plain(self):
        for k in ("USER_DATA", "USERDATA"):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: USER_DATA, "USERDATA_ENCODING": ""})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue("userdata" in results)
            self.assertEqual(USER_DATA, results["userdata"])
开发者ID:number5,项目名称:cloud-init,代码行数:10,代码来源:test_opennebula.py

示例4: test_user_data_base64_encoding

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data_base64_encoding(self):
        for k in ('USER_DATA', 'USERDATA'):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: b64encode(USER_DATA),
                                        'USERDATA_ENCODING': 'base64'})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue('userdata' in results)
            self.assertEqual(USER_DATA, results['userdata'])
开发者ID:Esysc,项目名称:cloud-init-0.7.5,代码行数:11,代码来源:test_opennebula.py

示例5: test_user_data_encoding_required_for_decode

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data_encoding_required_for_decode(self):
        b64userdata = b64encode(USER_DATA)
        for k in ('USER_DATA', 'USERDATA'):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: b64userdata})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue('userdata' in results)
            self.assertEqual(b64userdata, results['userdata'])
开发者ID:Esysc,项目名称:cloud-init-0.7.5,代码行数:11,代码来源:test_opennebula.py

示例6: test_hostname

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_hostname(self):
        for k in ("HOSTNAME", "PUBLIC_IP", "IP_PUBLIC", "ETH0_IP"):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: PUBLIC_IP})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue("metadata" in results)
            self.assertTrue("local-hostname" in results["metadata"])
            self.assertEqual(PUBLIC_IP, results["metadata"]["local-hostname"])
开发者ID:number5,项目名称:cloud-init,代码行数:11,代码来源:test_opennebula.py

示例7: test_user_data_encoding_required_for_decode

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_user_data_encoding_required_for_decode(self):
        b64userdata = util.b64e(USER_DATA)
        for k in ("USER_DATA", "USERDATA"):
            my_d = os.path.join(self.tmp, k)
            populate_context_dir(my_d, {k: b64userdata})
            results = ds.read_context_disk_dir(my_d)

            self.assertTrue("userdata" in results)
            self.assertEqual(b64userdata, results["userdata"])
开发者ID:number5,项目名称:cloud-init,代码行数:11,代码来源:test_opennebula.py

示例8: test_hostname

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_hostname(self, m_get_phys_by_mac):
        for dev in ('eth0', 'ens3'):
            m_get_phys_by_mac.return_value = {MACADDR: dev}
            for k in ('HOSTNAME', 'PUBLIC_IP', 'IP_PUBLIC', 'ETH0_IP'):
                my_d = os.path.join(self.tmp, k)
                populate_context_dir(my_d, {k: PUBLIC_IP})
                results = ds.read_context_disk_dir(my_d)

                self.assertTrue('metadata' in results)
                self.assertTrue('local-hostname' in results['metadata'])
                self.assertEqual(
                    PUBLIC_IP, results['metadata']['local-hostname'])
开发者ID:cloud-init,项目名称:cloud-init,代码行数:14,代码来源:test_opennebula.py

示例9: test_ssh_key

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_ssh_key(self):
        public_keys = ["first key", "second key"]
        for c in range(4):
            for k in ("SSH_KEY", "SSH_PUBLIC_KEY"):
                my_d = os.path.join(self.tmp, "%s-%i" % (k, c))
                populate_context_dir(my_d, {k: "\n".join(public_keys)})
                results = ds.read_context_disk_dir(my_d)

                self.assertTrue("metadata" in results)
                self.assertTrue("public-keys" in results["metadata"])
                self.assertEqual(public_keys, results["metadata"]["public-keys"])

            public_keys.append(SSH_KEY % (c + 1,))
开发者ID:number5,项目名称:cloud-init,代码行数:15,代码来源:test_opennebula.py

示例10: test_ssh_key

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_ssh_key(self):
        public_keys = ['first key', 'second key']
        for c in range(4):
            for k in ('SSH_KEY', 'SSH_PUBLIC_KEY'):
                my_d = os.path.join(self.tmp, "%s-%i" % (k, c))
                populate_context_dir(my_d, {k: '\n'.join(public_keys)})
                results = ds.read_context_disk_dir(my_d)

                self.assertTrue('metadata' in results)
                self.assertTrue('public-keys' in results['metadata'])
                self.assertEqual(public_keys,
                                 results['metadata']['public-keys'])

            public_keys.append(SSH_KEY % (c + 1,))
开发者ID:Esysc,项目名称:cloud-init-0.7.5,代码行数:16,代码来源:test_opennebula.py

示例11: test_context_parser

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_context_parser(self):
        populate_context_dir(self.seed_dir, TEST_VARS)
        results = ds.read_context_disk_dir(self.seed_dir)

        self.assertTrue('metadata' in results)
        self.assertEqual(TEST_VARS, results['metadata'])
开发者ID:Esysc,项目名称:cloud-init-0.7.5,代码行数:8,代码来源:test_opennebula.py

示例12: test_seed_dir_empty2_context

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_seed_dir_empty2_context(self):
        populate_context_dir(self.seed_dir, {})
        results = ds.read_context_disk_dir(self.seed_dir)

        self.assertEqual(results['userdata'], None)
        self.assertEqual(results['metadata'], {})
开发者ID:Esysc,项目名称:cloud-init-0.7.5,代码行数:8,代码来源:test_opennebula.py

示例13: test_seed_dir_empty1_context

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_seed_dir_empty1_context(self):
        populate_dir(self.seed_dir, {"context.sh": ""})
        results = ds.read_context_disk_dir(self.seed_dir)

        self.assertEqual(results["userdata"], None)
        self.assertEqual(results["metadata"], {})
开发者ID:number5,项目名称:cloud-init,代码行数:8,代码来源:test_opennebula.py

示例14: test_network_interfaces

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_network_interfaces(self, m_get_phys_by_mac):
        for dev in ('eth0', 'ens3'):
            m_get_phys_by_mac.return_value = {MACADDR: dev}

            # without ETH0_MAC
            # for Older OpenNebula?
            populate_context_dir(self.seed_dir, {'ETH0_IP': IP_BY_MACADDR})
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP_BY_MACADDR + '/' + IP4_PREFIX in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_IP and ETH0_MAC
            populate_context_dir(
                self.seed_dir, {'ETH0_IP': IP_BY_MACADDR, 'ETH0_MAC': MACADDR})
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP_BY_MACADDR + '/' + IP4_PREFIX in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_IP with empty string and ETH0_MAC
            # in the case of using Virtual Network contains
            # "AR = [ TYPE = ETHER ]"
            populate_context_dir(
                self.seed_dir, {'ETH0_IP': '', 'ETH0_MAC': MACADDR})
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP_BY_MACADDR + '/' + IP4_PREFIX in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_MASK
            populate_context_dir(
                self.seed_dir, {
                    'ETH0_IP': IP_BY_MACADDR,
                    'ETH0_MAC': MACADDR,
                    'ETH0_MASK': '255.255.0.0'
                })
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP_BY_MACADDR + '/16' in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_MASK with empty string
            populate_context_dir(
                self.seed_dir, {
                    'ETH0_IP': IP_BY_MACADDR,
                    'ETH0_MAC': MACADDR,
                    'ETH0_MASK': ''
                })
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP_BY_MACADDR + '/' + IP4_PREFIX in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_IP6
            populate_context_dir(
                self.seed_dir, {
                    'ETH0_IP6': IP6_GLOBAL,
                    'ETH0_MAC': MACADDR,
                })
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP6_GLOBAL + '/64' in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_IP6_ULA
            populate_context_dir(
                self.seed_dir, {
                    'ETH0_IP6_ULA': IP6_ULA,
                    'ETH0_MAC': MACADDR,
                })
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
            self.assertTrue(
                IP6_ULA + '/64' in
                results['network-interfaces']['ethernets'][dev]['addresses'])

            # ETH0_IP6 and ETH0_IP6_PREFIX_LENGTH
            populate_context_dir(
                self.seed_dir, {
                    'ETH0_IP6': IP6_GLOBAL,
                    'ETH0_IP6_PREFIX_LENGTH': IP6_PREFIX,
                    'ETH0_MAC': MACADDR,
                })
            results = ds.read_context_disk_dir(self.seed_dir)

            self.assertTrue('network-interfaces' in results)
#.........这里部分代码省略.........
开发者ID:cloud-init,项目名称:cloud-init,代码行数:103,代码来源:test_opennebula.py

示例15: test_network_interfaces

# 需要导入模块: from cloudinit.sources import DataSourceOpenNebula [as 别名]
# 或者: from cloudinit.sources.DataSourceOpenNebula import read_context_disk_dir [as 别名]
    def test_network_interfaces(self):
        populate_context_dir(self.seed_dir, {"ETH0_IP": "1.2.3.4"})
        results = ds.read_context_disk_dir(self.seed_dir)

        self.assertTrue("network-interfaces" in results)
开发者ID:number5,项目名称:cloud-init,代码行数:7,代码来源:test_opennebula.py


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