def add_generic_nfs_storage_domain(prefix, sd_nfs_name, nfs_host_name, mount_path, sd_format='v4', sd_type='data', nfs_version='v4_2'): if sd_type == 'data': dom_type = sdk4.types.StorageDomainType.DATA elif sd_type == 'iso': dom_type = sdk4.types.StorageDomainType.ISO elif sd_type == 'export': dom_type = sdk4.types.StorageDomainType.EXPORT if nfs_version == 'v3': nfs_vers = sdk4.types.NfsVersion.V3 elif nfs_version == 'v4': nfs_vers = sdk4.types.NfsVersion.V4 elif nfs_version == 'v4_1': nfs_vers = sdk4.types.NfsVersion.V4_1 elif nfs_version == 'v4_2': nfs_vers = sdk4.types.NfsVersion.V4_2 else: nfs_vers = sdk4.types.NfsVersion.AUTO api = prefix.virt_env.engine_vm().get_api_v4() ips = _get_host_ips_in_net(prefix, nfs_host_name, testlib.get_prefixed_name('net-management')) kwargs = {} if sd_format >= 'v4': if not versioning.cluster_version_ok(4, 1): kwargs['storage_format'] = sdk4.types.StorageFormat.V3 elif not versioning.cluster_version_ok(4, 3): kwargs['storage_format'] = sdk4.types.StorageFormat.V4 random_host = _random_host_from_dc_4(api, DC_NAME) LOGGER.debug('random host: {}'.format(random_host.name)) p = sdk4.types.StorageDomain(name=sd_nfs_name, description='APIv4 NFS storage domain', type=dom_type, host=random_host, storage=sdk4.types.HostStorage( type=sdk4.types.StorageType.NFS, address=ips[0], path=mount_path, nfs_version=nfs_vers, ), **kwargs) _add_storage_domain(api, p)
def add_iscsi_storage_domain(prefix): luns = test_utils.get_luns(prefix, SD_ISCSI_HOST_NAME, SD_ISCSI_PORT, SD_ISCSI_TARGET, from_lun=0, to_lun=SD_ISCSI_NR_LUNS) v4_domain = versioning.cluster_version_ok(DC_VER_MAJ, DC_VER_MIN) api = prefix.virt_env.engine_vm().get_api_v4() p = sdk4.types.StorageDomain( name=SD_ISCSI_NAME, description='iSCSI Storage Domain', type=sdk4.types.StorageDomainType.DATA, discard_after_delete=v4_domain, data_center=sdk4.types.DataCenter(name=DC_NAME, ), host=_random_host_from_dc(api, DC_NAME), storage_format=(sdk4.types.StorageFormat.V4 if v4_domain else sdk4.types.StorageFormat.V3), storage=sdk4.types.HostStorage( type=sdk4.types.StorageType.ISCSI, override_luns=True, volume_group=sdk4.types.VolumeGroup(logical_units=luns), ), ) _add_storage_domain(api, p)
def add_iscsi_storage_domain(prefix): luns = test_utils.get_luns( prefix, SD_ISCSI_HOST_NAME, SD_ISCSI_PORT, SD_ISCSI_TARGET, from_lun=0, to_lun=SD_ISCSI_NR_LUNS) v4_domain = versioning.cluster_version_ok(DC_VER_MAJ, DC_VER_MIN) api = prefix.virt_env.engine_vm().get_api_v4() p = sdk4.types.StorageDomain( name=SD_ISCSI_NAME, description='iSCSI Storage Domain', type=sdk4.types.StorageDomainType.DATA, discard_after_delete=v4_domain, data_center=sdk4.types.DataCenter( name=DC_NAME, ), host=_random_host_from_dc(api, DC_NAME), storage_format=(sdk4.types.StorageFormat.V4 if v4_domain else sdk4.types.StorageFormat.V3), storage=sdk4.types.HostStorage( type=sdk4.types.StorageType.ISCSI, override_luns=True, volume_group=sdk4.types.VolumeGroup( logical_units=luns ), ), ) _add_storage_domain(api, p)
def add_generic_nfs_storage_domain_4(prefix, sd_nfs_name, nfs_host_name, mount_path, sd_format=SD_FORMAT, sd_type='data', nfs_version='v4_1'): if sd_type == 'data': dom_type = sdk4.types.StorageDomainType.DATA elif sd_type == 'iso': dom_type = sdk4.types.StorageDomainType.ISO elif sd_type == 'export': dom_type = sdk4.types.StorageDomainType.EXPORT if nfs_version == 'v3': nfs_vers = sdk4.types.NfsVersion.V3 elif nfs_version == 'v4': nfs_vers = sdk4.types.NfsVersion.V4 elif nfs_version == 'v4_1': nfs_vers = sdk4.types.NfsVersion.V4_1 elif nfs_version == 'v4_2': nfs_vers = sdk4.types.NfsVersion.V4_2 else: nfs_vers = sdk4.types.NfsVersion.AUTO api = prefix.virt_env.engine_vm().get_api(api_ver=4) kwargs = {} if sd_format >= 'v4': if not versioning.cluster_version_ok(4, 1): kwargs['storage_format'] = sdk4.types.StorageFormat.V3 elif not versioning.cluster_version_ok(4, 3): kwargs['storage_format'] = sdk4.types.StorageFormat.V4 p = sdk4.types.StorageDomain(name=sd_nfs_name, description='APIv4 NFS storage domain', type=dom_type, host=_random_host_from_dc_4(api, DC_NAME), storage=sdk4.types.HostStorage( type=sdk4.types.StorageType.NFS, address=_get_host_ip( prefix, nfs_host_name), path=mount_path, nfs_version=nfs_vers, ), **kwargs) _add_storage_domain_4(api, p)
def verify_suspend_resume_vm0(prefix): api = prefix.virt_env.engine_vm().get_api_v4() _verify_vm_state(api.system_service(), VM0_NAME, types.VmStatus.UP) vm_host = _vm_host(prefix, VM0_NAME) def log_line_count(regexp): awk = ('BEGIN {{ n = 0; }} ' '$1 " " $2 > "{}" && $0 ~ /{}/ {{ n = n + 1; }} ' 'END {{ print n; }}').format(_log_time_before_suspend, regexp) ret = vm_host.ssh(['awk', "'" + awk + "'", VDSM_LOG]) nt.assert_equals(ret.code, EX_OK) return int(ret.out) if versioning.cluster_version_ok(4, 2): identifier = 'memoryDumpVolume' else: identifier = 'hiberVolHandle' nt.assert_equals(log_line_count('START create\(.*' + identifier), 1) nt.ok_(log_line_count('CPU running: onResume') >= 1)
def verify_suspend_resume_vm0(prefix): api = prefix.virt_env.engine_vm().get_api_v4() _verify_vm_state(api.system_service(), VM0_NAME, types.VmStatus.UP) vm_host = _vm_host(prefix, VM0_NAME) def log_line_count(regexp): awk = ('BEGIN {{ n = 0; }} ' '$1 " " $2 > "{}" && $0 ~ /{}/ {{ n = n + 1; }} ' 'END {{ print n; }}').format( _log_time_before_suspend, regexp ) ret = vm_host.ssh(['awk', "'" + awk + "'", VDSM_LOG]) nt.assert_equals(ret.code, EX_OK) return int(ret.out) if versioning.cluster_version_ok(4, 2): identifier = 'memoryDumpVolume' else: identifier = 'hiberVolHandle' nt.assert_equals(log_line_count('START create\(.*' + identifier), 1) nt.ok_(log_line_count('CPU running: onResume') >= 1)
def add_generic_nfs_storage_domain(prefix, sd_nfs_name, nfs_host_name, mount_path, sd_format='v4', sd_type='data', nfs_version='v4_2'): if sd_type == 'data': dom_type = sdk4.types.StorageDomainType.DATA elif sd_type == 'iso': dom_type = sdk4.types.StorageDomainType.ISO elif sd_type == 'export': dom_type = sdk4.types.StorageDomainType.EXPORT if nfs_version == 'v3': nfs_vers = sdk4.types.NfsVersion.V3 elif nfs_version == 'v4': nfs_vers = sdk4.types.NfsVersion.V4 elif nfs_version == 'v4_1': nfs_vers = sdk4.types.NfsVersion.V4_1 elif nfs_version == 'v4_2': nfs_vers = sdk4.types.NfsVersion.V4_2 else: nfs_vers = sdk4.types.NfsVersion.AUTO api = prefix.virt_env.engine_vm().get_api(api_ver=4) ips = _get_host_ips_in_net(prefix, nfs_host_name, testlib.get_prefixed_name('net-storage')) kwargs = {} if sd_format >= 'v4' and \ not versioning.cluster_version_ok(4, 1): kwargs['storage_format'] = sdk4.types.StorageFormat.V3 p = sdk4.types.StorageDomain( name=sd_nfs_name, description='APIv4 NFS storage domain', type=dom_type, host=_random_host_from_dc(api, DC_NAME), storage=sdk4.types.HostStorage( type=sdk4.types.StorageType.NFS, address=ips[0], path=mount_path, nfs_version=nfs_vers, ), **kwargs ) _add_storage_domain(api, p)
# DC/Cluster DC_NAME = 'test-dc' CLUSTER_NAME = 'test-cluster' # Networks VM_NETWORK = u'VM Network with a very long name and עברית' VM_NETWORK_IPv4_ADDR = '192.0.2.{}' VM_NETWORK_IPv4_MASK = '255.255.255.0' VM_NETWORK_IPv6_ADDR = '2001:0db8:85a3:0000:0000:8a2e:0370:733{}' VM_NETWORK_IPv6_MASK = '64' VM_NETWORK_VLAN_ID = 100 MIGRATION_NETWORK = 'Migration_Net' # MTU 9000 if versioning.cluster_version_ok(4, 3): BOND_NAME = 'bond_fancy0' else: BOND_NAME = 'bond0' MIGRATION_NETWORK_IPv4_ADDR = '192.0.3.{}' MIGRATION_NETWORK_IPv4_MASK = '255.255.255.0' MIGRATION_NETWORK_IPv6_ADDR = '1001:0db8:85a3:0000:0000:574c:14ea:0a0{}' MIGRATION_NETWORK_IPv6_MASK = '64' def _host_vm_nics(prefix, host_name, network_name): """ Return names of host VM NICs attached by Lago to a given libvirt network, just like do_status in site-packages/lago/cmd.py:446