本文整理汇总了Python中devops.models.Node类的典型用法代码示例。如果您正苦于以下问题:Python Node类的具体用法?Python Node怎么用?Python Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_snapshot_with_existing_name_force_delete
def test_snapshot_with_existing_name_force_delete(self, mock_has_snapshot,
mock_delete_snapshot,
mock_create_snapshot):
mock_has_snapshot.return_value = True
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
snap_name = factories.fuzzy_string('snap_')
snap_description = factories.fuzzy_string('description_')
node.snapshot(
name=snap_name,
force=True,
description=snap_description,
disk_only=True)
self.assertEqual(mock_delete_snapshot.called, True)
mock_delete_snapshot.assert_called_with(node=node, name=snap_name)
mock_create_snapshot.assert_called_with(
node=node,
name=snap_name,
description=snap_description,
disk_only=True,
external=False)
示例2: test_external_snapshot
def test_external_snapshot(
self, mock_has_snapshot, mock_create_volume,
mock_libvirt_version, mock_create_snapshot):
mock_has_snapshot.return_value = False
mock_libvirt_version.return_value = 1002012
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
vol_volume_name = factories.fuzzy_string()
vol = Volume.volume_create(vol_volume_name,
capacity=1000000000,
format='qcow2',
environment=environment)
DiskDevice.node_attach_volume(node=node, volume=vol)
environment.define()
snap_name = factories.fuzzy_string('snap_')
snap_description = factories.fuzzy_string('description_')
node.snapshot(name=snap_name, description=snap_description,
external=True)
mock_create_volume.assert_called_with(snap_name)
mock_create_snapshot.assert_called_with(
node=node, name=snap_name, description=snap_description,
disk_only=False, external=True)
示例3: test_node_creation
def test_node_creation(self):
environment = Environment.create('test_env3')
internal = Network.network_create(
environment=environment, name='internal', pool=None)
node = Node.node_create(name='test_node', environment=environment)
Interface.interface_create(node=node, network=internal)
environment.define()
示例4: test_external_snapshot_revert_with_children_revert_present
def test_external_snapshot_revert_with_children_revert_present(
self, mock_revert_snapshot_recreate_disks,
mock_revert_snapshot, mock_get_snapshot, mock_has_snapshot,
mock_destroy, mock_update_disks_from_snapshot):
revert_postfix = '-revert3'
def get_snapshot(node, snapname):
if snapname.endswith(revert_postfix):
return mock.Mock(get_type='external', children_num=0)
else:
return mock.Mock(get_type='external', children_num=1)
mock_has_snapshot.return_value = True
mock_get_snapshot.side_effect = get_snapshot
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
snapshot_name = factories.fuzzy_string('snap_')
node.revert(name=snapshot_name, destroy=False)
revert_snapshot_name = '{0}{1}'.format(snapshot_name, revert_postfix)
mock_update_disks_from_snapshot.assert_called_with(
revert_snapshot_name)
mock_revert_snapshot_recreate_disks.assert_called_with(
node, revert_snapshot_name)
mock_revert_snapshot.assert_called_with(node=node,
name=revert_snapshot_name)
示例5: test_external_snapshot_volume_creation
def test_external_snapshot_volume_creation(self, mock_volume_define):
mock_volume_define.return_value = None
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
vol_volume_name = factories.fuzzy_string()
vol = Volume.volume_create(vol_volume_name,
capacity=1000000000,
format='qcow2',
environment=environment)
DiskDevice.node_attach_volume(node=node, volume=vol)
environment.define()
snapshot_name = factories.fuzzy_string('snap_')
snapshot_volume_name = '{0}.{1}'.format(vol_volume_name,
snapshot_name)
node.snapshot_create_volume(snapshot_name)
vol1 = environment.get_volume(name=snapshot_volume_name)
self.assertEqual(len(node.disk_devices), 1)
self.assertEqual(vol1.name, snapshot_volume_name)
self.assertEqual(vol1.format, 'qcow2')
self.assertEqual(vol1.environment, environment)
self.assertEqual(vol1.backing_store, vol)
self.assertEqual(vol1, node.disk_devices[0].volume)
mock_volume_define.assert_called_with(vol1)
示例6: test_update_disks_from_snapshot_with_children
def test_update_disks_from_snapshot_with_children(
self, mock_has_snapshot, mock_volume_define,
mock_libvirt_version,
mock_get_snapshot, mock_create_snapshot):
mock_has_snapshot.return_value = False
mock_libvirt_version.return_value = 1002012
volume_path_template = '/var/lib/libvirt/images/{0}'
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
vol_volume_name = factories.fuzzy_string()
vol = Volume.volume_create(vol_volume_name,
capacity=1000000000,
format='qcow2',
environment=environment)
vol.uuid = volume_path_template.format(vol_volume_name)
DiskDevice.node_attach_volume(node=node, volume=vol)
environment.define()
snap_name = factories.fuzzy_string('snap_')
snap_description = factories.fuzzy_string('description_')
snapshot_volume_name = '{0}.{1}'.format(vol_volume_name,
snap_name)
mock_get_snapshot.return_value = mock.Mock(
get_type='external', children_num=1,
disks={'sda': volume_path_template.format(snap_name)})
node.snapshot(name=snap_name, description=snap_description,
external=True)
vol1 = environment.get_volume(name=snapshot_volume_name)
vol1.uuid = volume_path_template.format(snap_name)
vol1.save()
node._update_disks_from_snapshot(snap_name)
self.assertEqual(node.disk_devices[0].volume, vol)
示例7: test_external_snapshot_erase
def test_external_snapshot_erase(
self, mock_has_snapshot, mock_volume_define,
mock_libvirt_version, mock_delete_snapshot,
mock_get_snapshot, mock_create_snapshot):
mock_has_snapshot.return_value = False
mock_libvirt_version.return_value = 1002012
mock_get_snapshot.return_value = mock.Mock(get_type='external',
children_num=0)
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
vol_volume_name = factories.fuzzy_string()
vol = Volume.volume_create(vol_volume_name,
capacity=1000000000,
format='qcow2',
environment=environment)
DiskDevice.node_attach_volume(node=node, volume=vol)
environment.define()
snap_name = factories.fuzzy_string('snap_')
snap_description = factories.fuzzy_string('description_')
node.snapshot(name=snap_name, description=snap_description,
external=True)
mock_has_snapshot.return_value = True
node.erase_snapshot(snap_name)
mock_delete_snapshot.assert_called_with(node=node, name=snap_name)
self.assertEqual(node.disk_devices[0].volume, vol)
示例8: add_nessus_node
def add_nessus_node(self):
node = Node.node_create(
name='slave-nessus',
environment=self.devops_env,
boot=['hd'])
node.attach_to_networks()
volume = Volume.volume_get_predefined(NESSUS_IMAGE_PATH)
DiskDevice.node_attach_volume(node=node, volume=volume)
node.define()
node.start()
示例9: test_network_model
def test_network_model(self):
environment = Environment.create('test_env')
node = Node.node_create('test_node', environment)
network = Network.network_create(
environment=environment, name='internal', ip_network='10.1.0.0/24')
interface1 = Interface.interface_create(network=network, node=node)
self.assertEquals('virtio', interface1.model)
interface2 = Interface.interface_create(
network=network, node=node, model='e1000')
self.assertEquals('e1000', interface2.model)
示例10: test_snapshot_with_existing_name
def test_snapshot_with_existing_name(self, mock_has_snapshot,
mock_node_create_snapshot):
mock_has_snapshot.return_value = True
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
node.snapshot(name='test_name')
self.assertEqual(mock_node_create_snapshot.called, False)
示例11: test_network_iterator
def test_network_iterator(self):
environment = Environment.create('test_env')
node = Node.node_create('test_node', environment)
network = Network.network_create(
environment=environment, name='internal', ip_network='10.1.0.0/24')
interface = Interface.interface_create(network=network, node=node)
Address.objects.create(str('10.1.0.1'), interface=interface)
network.next_ip()
Address.objects.create(str('10.1.0.3'), interface=interface)
ip = network.next_ip()
self.assertEquals('10.1.0.4', str(ip))
示例12: test_external_snapshot_incorrect_libvirt_version
def test_external_snapshot_incorrect_libvirt_version(
self, mock_has_snapshot, mock_libvirt_version,
mock_create_snapshot):
mock_has_snapshot.return_value = False
mock_libvirt_version.return_value = 1002009
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
node.snapshot(name='test_name', external=True)
self.assertEqual(mock_create_snapshot.called, False)
示例13: test_external_snapshot_with_children_erase
def test_external_snapshot_with_children_erase(
self, mock_has_snapshot, mock_get_snapshot, mock_delete_snapshot):
mock_has_snapshot.return_value = True
mock_get_snapshot.return_value = mock.Mock(
get_type='external', children_num=1)
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
snap_name = factories.fuzzy_string('snap_')
node.erase_snapshot(snap_name)
self.assertEqual(mock_delete_snapshot.called, False)
mock_get_snapshot.assert_called_with(node, snap_name)
示例14: one
def one():
environment = Environment.create('cdrom')
internal_pool = Network.create_network_pool(
networks=[IPNetwork('10.108.0.0/16')], prefix=24
)
private_pool = Network.create_network_pool(
networks=[IPNetwork('10.108.0.0/16')], prefix=24
)
external_pool = Network.create_network_pool(
networks=[IPNetwork('172.18.95.0/24')], prefix=27
)
internal = Network.network_create(
environment=environment, name='internal', pool=internal_pool)
external = Network.network_create(
environment=environment, name='external', pool=external_pool,
forward='nat')
private = Network.network_create(
environment=environment, name='private', pool=private_pool)
for i in range(1, 2):
node = Node.node_create(
name='test_node' + str(i), environment=environment)
Interface.interface_create(node=node, network=internal)
Interface.interface_create(node=node, network=external)
Interface.interface_create(node=node, network=private)
volume = Volume.volume_get_predefined(
'/var/lib/libvirt/images/centos63-cobbler-base.qcow2')
v3 = Volume.volume_create_child(
'test_vp895' + str(i), backing_store=volume,
environment=environment)
v4 = Volume.volume_create_child(
'test_vp896' + str(i), backing_store=volume,
environment=environment)
DiskDevice.node_attach_volume(node=node, volume=v3)
DiskDevice.node_attach_volume(node, v4)
DiskDevice.node_attach_volume(
node,
Volume.volume_get_predefined(
'/var/lib/libvirt/images/fuel-centos-6.3-x86_64.iso'),
device='cdrom', bus='sata')
environment.define()
environment.start()
remotes = []
for node in environment.get_nodes():
node.await('internal')
node.remote('internal', 'root', 'r00tme').check_stderr(
'ls -la', verbose=True)
remotes.append(node.remote('internal', 'root', 'r00tme'))
SSHClient.execute_together(remotes, 'ls -la')
示例15: test_external_snapshot_revert_no_children
def test_external_snapshot_revert_no_children(
self, mock_revert_snapshot_recreate_disks,
mock_revert_snapshot, mock_get_snapshot, mock_has_snapshot,
mock_destroy, mock_update_disks_from_snapshot):
mock_has_snapshot.return_value = True
mock_get_snapshot.return_value = mock.Mock(get_type='external',
children_num=0)
environment = Environment.create('test_env_extsnap')
node = Node.node_create(name='test_node', environment=environment)
environment.define()
snapshot_name = factories.fuzzy_string('snap_')
node.revert(name=snapshot_name, destroy=False)
mock_update_disks_from_snapshot.assert_called_with(snapshot_name)
mock_revert_snapshot_recreate_disks.assert_called_with(
node, snapshot_name)
mock_revert_snapshot.assert_called_with(node=node, name=snapshot_name)