當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。