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


Python Environment.create方法代码示例

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


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

示例1: test_network_pool

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
 def test_network_pool(self):
     environment = Environment.create('test_env2')
     self.assertEqual('10.0.0.0/24', str(Network.network_create(
         environment=environment, name='internal', pool=None).ip_network))
     self.assertEqual('10.0.1.0/24', str(Network.network_create(
         environment=environment, name='external', pool=None).ip_network))
     self.assertEqual('10.0.2.0/24', str(Network.network_create(
         environment=environment, name='private', pool=None).ip_network))
     environment = Environment.create('test_env2')
     self.assertEqual('10.0.3.0/24', str(Network.network_create(
         environment=environment, name='internal', pool=None).ip_network))
     self.assertEqual('10.0.4.0/24', str(Network.network_create(
         environment=environment, name='external', pool=None).ip_network))
     self.assertEqual('10.0.5.0/24', str(Network.network_create(
         environment=environment, name='private', pool=None).ip_network))
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:17,代码来源:test_manager.py

示例2: setUp

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    def setUp(self):
        super(TestLibvirtVolume, self).setUp()

        self.sleep_mock = self.patch('devops.helpers.retry.sleep')

        self.open_mock = mock.mock_open(read_data='image_data')
        self.patch('devops.driver.libvirt.libvirt_driver.open',
                   self.open_mock, create=True)

        self.os_mock = self.patch('devops.helpers.helpers.os')
        Size = collections.namedtuple('Size', ['st_size'])
        self.file_sizes = {
            '/tmp/admin.iso': Size(st_size=500),
        }
        self.os_mock.stat.side_effect = self.file_sizes.get

        self.env = Environment.create('test_env')
        self.group = self.env.add_group(
            group_name='test_group',
            driver_name='devops.driver.libvirt.libvirt_driver',
            connection_string='test:///default',
            storage_pool_name='default-pool')

        self.node = self.group.add_node(
            name='test_node',
            role='default',
            architecture='i686',
            hypervisor='test',
        )

        self.d = self.group.driver
开发者ID:jvalinas,项目名称:fuel-devops,代码行数:33,代码来源:test_volume.py

示例3: test_external_snapshot

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:28,代码来源:test_manager.py

示例4: setUp

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    def setUp(self):
        super(TestCloudImage, self).setUp()

        self.open_mock = mock.mock_open(read_data='image_data')
        self.patch('devops.driver.libvirt.libvirt_driver.open',
                   self.open_mock, create=True)

        self.os_mock = self.patch('devops.helpers.helpers.os')
        # noinspection PyPep8Naming
        Size = collections.namedtuple('Size', ['st_size'])
        self.file_sizes = {
            '/tmp/test/cloud_settings.iso': Size(st_size=1 * 1024 ** 3),
        }
        self.os_mock.stat.side_effect = self.file_sizes.get

        self.generate_cloud_image_settings_mock = self.patch(
            'devops.helpers.cloud_image_settings'
            '.generate_cloud_image_settings')

        self.volume_upload_mock = self.patch(
            'devops.driver.libvirt.Volume.upload')

        # Environment with a 'public' network

        self.env = Environment.create('test')
        self.group = self.env.add_group(
            group_name='test_group',
            driver_name='devops.driver.libvirt',
            connection_string='test:///default',
            storage_pool_name='default-pool')

        self.pub_ap = self.env.add_address_pool(
            name='public-pool01', net='10.109.0.0/16:24', tag=0,
            ip_reserved=dict(gateway=1, l2_network_device=1),
            ip_ranges=dict(default=[2, -2]))
        self.group.add_l2_network_device(
            name='public', address_pool='public-pool01')

        # Node connected to the 'public' network

        self.node = self.group.add_node(
            name='test-node',
            role='cloud-node',
            architecture='x86_64',
            hypervisor='test',
            cloud_init_volume_name='iso',
            cloud_init_iface_up='enp0s3')

        self.system_volume = self.node.add_volume(name='system', capacity=10)
        self.iso_volume = self.node.add_volume(name='iso', capacity=5)

        self.adm_iface = self.node.add_interface(
            label='enp0s3',
            l2_network_device_name='public',
            mac_address='64:b6:87:44:14:17',
            interface_model='e1000')

        self.node.add_network_config(
            label='enp0s3',
            networks=['public'])
开发者ID:openstack,项目名称:fuel-devops,代码行数:62,代码来源:test_node_cloudimage.py

示例5: test_external_snapshot_erase

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:33,代码来源:test_manager.py

示例6: test_update_disks_from_snapshot_with_children

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:37,代码来源:test_manager.py

示例7: test_external_snapshot_revert_with_children_revert_present

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:29,代码来源:test_manager.py

示例8: test_snapshot_with_existing_name_force_delete

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:28,代码来源:test_manager.py

示例9: test_external_snapshot_volume_creation

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:30,代码来源:test_manager.py

示例10: test_node_creation

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
 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()
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:9,代码来源:test_manager.py

示例11: test_create_volume

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
 def test_create_volume(self):
     environment = Environment.create('test_env3')
     volume = Volume.volume_get_predefined(
         '/var/lib/libvirt/images/disk-135824657433.qcow2')
     v3 = Volume.volume_create_child(
         'test_vp89', backing_store=volume, environment=environment)
     v3.define()
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:9,代码来源:test_manager.py

示例12: setUp

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    def setUp(self):
        super(TestLibvirtL2NetworkDevice, self).setUp()

        self.env = Environment.create('test_env')
        self.group = self.env.add_group(
            group_name='test_group',
            driver_name='devops.driver.libvirt',
            connection_string='test:///default')

        self.ap = self.env.add_address_pool(
            name='test_ap',
            net='172.0.0.0/16:24',
            tag=0,
            ip_reserved=dict(l2_network_device='172.0.0.1'),
        )

        self.net_pool = self.group.add_network_pool(
            name='fuelweb_admin',
            address_pool_name='test_ap',
        )

        self.l2_net_dev = self.group.add_l2_network_device(
            name='test_l2_net_dev',
            forward=dict(mode='nat'),
            address_pool='test_ap',
        )

        self.d = self.group.driver
开发者ID:openstack,项目名称:fuel-devops,代码行数:30,代码来源:test_l2_network_device.py

示例13: setUp

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    def setUp(self):
        super(TestLibvirtNodeMultipath, self).setUp()

        self.sleep_mock = self.patch('devops.helpers.retry.sleep')
        self.libvirt_sleep_mock = self.patch(
            'devops.driver.libvirt.libvirt_driver.sleep')

        self.env = Environment.create('test_env')
        self.group = self.env.add_group(
            group_name='test_group',
            driver_name='devops.driver.libvirt',
            connection_string='test:///default',
            storage_pool_name='default-pool',
            vnc_password='123456',
        )

        self.ap = self.env.add_address_pool(
            name='test_ap',
            net='172.0.0.0/16:24',
            tag=0,
            ip_reserved=dict(l2_network_device=1),
        )

        self.net_pool = self.group.add_network_pool(
            name='fuelweb_admin',
            address_pool_name='test_ap',
        )

        self.l2_net_dev = self.group.add_l2_network_device(
            name='test_l2_net_dev',
            address_pool='test_ap',
            forward=dict(mode='nat'),
        )

        self.node = self.group.add_node(
            name='test_node',
            role='default',
            architecture='i686',
            hypervisor='test',
        )

        self.interface = self.node.add_interface(
            label='eth0',
            l2_network_device_name='test_l2_net_dev',
            interface_model='virtio',
        )
        self.interface.mac_address = '64:b6:87:44:14:17'
        self.interface.save()

        self.volume = self.node.add_volume(
            name='test_volume',
            capacity=5,
            multipath_count=2,
            serial='3b16d312420d4adbb2d5b04fcbd5221c',
        )

        self.d = self.group.driver

        self.l2_net_dev.define()
开发者ID:TregubovYury,项目名称:fuel-devops,代码行数:61,代码来源:test_node_multipath.py

示例14: test_network_model

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
 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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:12,代码来源:test_manager.py

示例15: test_snapshot_with_existing_name

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create [as 别名]
    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)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:12,代码来源:test_manager.py


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