本文整理汇总了Python中cloudinit.sources.DataSourceOpenNebula类的典型用法代码示例。如果您正苦于以下问题:Python DataSourceOpenNebula类的具体用法?Python DataSourceOpenNebula怎么用?Python DataSourceOpenNebula使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataSourceOpenNebula类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: in
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"])
示例2: test_user_data_plain
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"])
示例3: test_user_data
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'])
示例4: test_user_data_encoding_required_for_decode
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"])
示例5: test_user_data_encoding_required_for_decode
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'])
示例6: in
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'])
示例7: test_hostname
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"])
示例8: test_find_candidates
def test_find_candidates(self):
def my_devs_with(criteria):
return {"LABEL=CONTEXT": ["/dev/sdb"], "LABEL=CDROM": ["/dev/sr0"], "TYPE=iso9660": ["/dev/vdb"]}.get(
criteria, []
)
orig_find_devs_with = util.find_devs_with
try:
util.find_devs_with = my_devs_with
self.assertEqual(["/dev/sdb", "/dev/sr0", "/dev/vdb"], ds.find_candidate_devs())
finally:
util.find_devs_with = orig_find_devs_with
示例9: test_hostname
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'])
示例10: test_ssh_key
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,))
示例11: test_ssh_key
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,))
示例12: test_network_interfaces
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)
示例13: test_network_interfaces
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)
#.........这里部分代码省略.........
示例14:
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"], {})
示例15: test_context_parser
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'])