| from runtest import conditions |
| import base_section |
| |
| |
| MICROVERSION_RELEASE_MAPPING = { |
| 'pike': |
| { |
| 'min_api_microversion': '2.0', |
| 'max_api_microversion': '2.40' |
| }, |
| 'queens': |
| { |
| 'min_api_microversion': '2.0', |
| 'max_api_microversion': '2.42' |
| } |
| } |
| |
| FEATURE_SUPPORT = { |
| 'lvm': |
| { |
| 'create_delete_share': 'mitaka', |
| 'manage_unmanage_share': '~', |
| 'extend_share': 'mitaka', |
| 'shrink_share': '~', |
| 'create_delete_snapshot': 'mitaka', |
| 'create_share_from_snapshot': 'mitaka', |
| 'manage_unmanage_snapshot': '~', |
| 'revert_to_snapshot': 'ocata', |
| 'mountable_snapshot': 'ocata' |
| }, |
| 'glusterfs': |
| { |
| 'create_delete_share': 'juno', |
| 'manage_unmanage_share': '~', |
| 'extend_share': '~', |
| 'shrink_share': '~', |
| 'create_delete_snapshot': 'liberty', |
| 'create_share_from_snapshot': 'liberty', |
| 'manage_unmanage_snapshot': '~', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~' |
| }, |
| 'nexentastor4': |
| { |
| 'create_delete_share': 'newton', |
| 'manage_unmanage_share': '~', |
| 'extend_share': 'newton', |
| 'shrink_share': '~', |
| 'create_delete_snapshot': 'newton', |
| 'create_share_from_snapshot': 'newton', |
| 'manage_unmanage_snapshot': '~', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~' |
| }, |
| 'nexentastor5': |
| { |
| 'create_delete_share': 'newton', |
| 'manage_unmanage_share': '~', |
| 'extend_share': 'newton', |
| 'shrink_share': 'newton', |
| 'create_delete_snapshot': 'newton', |
| 'create_share_from_snapshot': 'newton', |
| 'manage_unmanage_snapshot': '~', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~' |
| } |
| } |
| |
| ACCESS_RULES = { |
| 'lvm': |
| { |
| 'ipv4': |
| { |
| 'release': 'mitaka', |
| 'protocols': 'nfs' |
| }, |
| 'ipv6': |
| { |
| 'release': 'pike', |
| 'protocols': 'nfs' |
| }, |
| 'user': |
| { |
| 'release': 'mitaka', |
| 'protocols': 'cifs' |
| } |
| }, |
| 'glusterfs': |
| { |
| 'ipv4': |
| { |
| 'release': 'juno', |
| 'protocols': 'nfs' |
| }, |
| 'ipv6': |
| { |
| 'release': '~', |
| 'protocols': '' |
| }, |
| 'user': |
| { |
| 'release': '~', |
| 'protocols': '' |
| } |
| }, |
| 'nexentastor4': |
| { |
| 'ipv4': |
| { |
| 'release': 'newton', |
| 'protocols': 'nfs' |
| }, |
| 'ipv6': |
| { |
| 'release': '~', |
| 'protocols': '' |
| }, |
| 'user': |
| { |
| 'release': '~', |
| 'protocols': '' |
| } |
| }, |
| 'nexentastor5': |
| { |
| 'ipv4': |
| { |
| 'release': 'newton', |
| 'protocols': 'nfs' |
| }, |
| 'ipv6': |
| { |
| 'release': '~', |
| 'protocols': '' |
| }, |
| 'user': |
| { |
| 'release': '~', |
| 'protocols': '' |
| } |
| } |
| } |
| |
| COMMON_CAPABILITIES = { |
| 'lvm': |
| { |
| 'dedupe': '~', |
| 'compression': '~', |
| 'thin_provisioning': '~', |
| 'thick_provisioning': 'mitaka', |
| 'qos': '~', |
| 'create_share_from_snapshot': 'kilo', |
| 'revert_to_snapshot': 'ocata', |
| 'mountable_snapshot': 'ocata', |
| 'ipv4_support': 'pike', |
| 'ipv6_support': 'pike' |
| }, |
| 'glusterfs': |
| { |
| 'dedupe': '~', |
| 'compression': '~', |
| 'thin_provisioning': '~', |
| 'thick_provisioning': 'liberty', |
| 'qos': '~', |
| 'create_share_from snapshot': 'liberty', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~', |
| 'ipv4_support': 'pike', |
| 'ipv6_support': '~' |
| }, |
| 'nexentastor4': |
| { |
| 'dedupe': 'newton', |
| 'compression': 'newton', |
| 'thin_provisioning': 'newton', |
| 'thick_provisioning': 'newton', |
| 'qos': '~', |
| 'create_share_from_snapshot': 'newton', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~', |
| 'ipv4_support': 'pike', |
| 'ipv6_support': '~' |
| }, |
| 'nexentastor5': |
| { |
| 'dedupe': 'newton', |
| 'compression': 'newton', |
| 'thin_provisioning': 'newton', |
| 'thick_provisioning': 'newton', |
| 'qos': '~', |
| 'create_share_from_snapshot': 'newton', |
| 'revert_to_snapshot': '~', |
| 'mountable_snapshot': '~', |
| 'ipv4_support': 'newton', |
| 'ipv6_support': '~' |
| } |
| } |
| |
| |
| class Share(base_section.BaseSection): |
| name = "share" |
| options = [ |
| 'backend_names', |
| 'capability_create_share_from_snapshot_support', |
| 'capability_storage_protocol', |
| 'default_share_type_name', |
| 'enable_ip_rules_for_protocols', |
| 'enable_user_rules_for_protocols', |
| 'enable_protocols', |
| 'max_api_microversion', |
| 'min_api_microversion', |
| 'multitenancy_enabled', |
| 'multi_backend', |
| 'run_ipv6_tests', |
| 'run_mount_snapshot_tests', |
| 'run_migration_with_preserve_snapshots_tests', |
| 'run_driver_assisted_migration_tests', |
| 'run_host_assisted_migration_tests', |
| 'run_replication_tests', |
| 'run_manage_unmanage_snapshot_tests', |
| 'run_manage_unmanage_tests', |
| 'run_share_group_tests', |
| 'run_revert_to_snapshot_tests', |
| 'run_snapshot_tests', |
| 'run_shrink_tests', |
| 'run_quota_tests', |
| 'suppress_errors_in_cleanup', |
| 'share_creation_retry_number', |
| 'client_vm_flavor_ref', |
| 'image_with_share_tools', |
| 'image_password', |
| ] |
| |
| @property |
| def backend_names(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| backend_names = [] |
| if backends: |
| for item, value in backends.items(): |
| if value.get('enabled', True): |
| backend_names.append(value['name']) |
| return ', '.join(backend_names) |
| |
| @property |
| def capability_create_share_from_snapshot_support(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= COMMON_CAPABILITIES[driver][ |
| 'create_share_from_snapshot']: |
| return True |
| return False |
| |
| @property |
| def capability_storage_protocol(self): |
| pass |
| |
| @property |
| def default_share_type_name(self): |
| c = conditions.BaseRule('manila.api.enabled', 'eq', True) |
| return self.get_item_when_condition_match( |
| 'manila.common.default_share_type', c) |
| |
| @property |
| def enable_ip_rules_for_protocols(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= ACCESS_RULES[driver]['ipv4']['release']: |
| return ACCESS_RULES[driver]['ipv4']['protocols'] |
| |
| @property |
| def enable_user_rules_for_protocols(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= ACCESS_RULES[driver]['user']['release']: |
| return ACCESS_RULES[driver]['user']['protocols'] |
| |
| @property |
| def enable_protocols(self): |
| pass |
| |
| @property |
| def multitenancy_enabled(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| if value.get('dhss', True): |
| return True |
| return False |
| |
| @property |
| def multi_backend(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| backend_names = [] |
| if backends: |
| for item, value in backends.items(): |
| if value.get('enabled', True): |
| backend_names.append(value['name']) |
| return True if len(backend_names) > 1 else False |
| |
| @property |
| def max_api_microversion(self): |
| c = conditions.BaseRule('manila.api.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.api.version', c) |
| if manila_version and manila_version in MICROVERSION_RELEASE_MAPPING: |
| return MICROVERSION_RELEASE_MAPPING[manila_version][ |
| 'max_api_microversion'] |
| |
| @property |
| def min_api_microversion(self): |
| c = conditions.BaseRule('manila.api.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.api.version', c) |
| if manila_version and manila_version in MICROVERSION_RELEASE_MAPPING: |
| return MICROVERSION_RELEASE_MAPPING[manila_version][ |
| 'min_api_microversion'] |
| |
| @property |
| def run_ipv6_tests(self): |
| pass |
| |
| @property |
| def run_mount_snapshot_tests(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= COMMON_CAPABILITIES[driver][ |
| 'mountable_snapshot']: |
| return True |
| return False |
| |
| @property |
| def run_migration_with_preserve_snapshots_tests(self): |
| pass |
| |
| @property |
| def run_driver_assisted_migration_tests(self): |
| pass |
| |
| # Defines whether to run host-assisted migration tests or not |
| @property |
| def run_host_assisted_migration_tests(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| return False |
| |
| @property |
| def run_replication_tests(self): |
| pass |
| |
| @property |
| def run_manage_unmanage_snapshot_tests(self): |
| pass |
| |
| @property |
| def run_manage_unmanage_tests(self): |
| pass |
| |
| # Defines whether to run share group tests or not |
| @property |
| def run_share_group_tests(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| backend_names = [] |
| if backends: |
| for item, value in backends.items(): |
| if value.get('enabled', True): |
| backend_names.append(value['name']) |
| return True if len(backend_names) > 1 else False |
| |
| @property |
| def run_revert_to_snapshot_tests(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= COMMON_CAPABILITIES[driver][ |
| 'revert_to_snapshot']: |
| return True |
| return False |
| |
| @property |
| def run_snapshot_tests(self): |
| pass |
| |
| @property |
| def run_shrink_tests(self): |
| c = conditions.BaseRule('manila.share.enabled', 'eq', True) |
| manila_version = self.get_item_when_condition_match( |
| 'manila.share.version', c) |
| backends = self.get_item_when_condition_match( |
| 'manila.share.enabled_share_backends', c) |
| if backends: |
| for item, value in backends.items(): |
| driver = value.get('type') |
| if manila_version >= FEATURE_SUPPORT[driver]['shrink_share']: |
| return True |
| return False |
| |
| @property |
| def run_quota_tests(self): |
| pass |
| |
| # Defines number of retries for share creation. |
| @property |
| def share_creation_retry_number(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| return 2 |
| |
| # Whether to suppress errors with clean up operation or not. |
| @property |
| def suppress_errors_in_cleanup(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| return False |
| |
| # Defines client vm flavor reference. |
| @property |
| def client_vm_flavor_ref(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| c = conditions.BaseRule('keystone.client.enabled', 'eq', True) |
| nodes = self.get_nodes_where_condition_match(c) |
| flavor_name = self.runtest_opts.get('convert_to_uuid', {}).get( |
| 'compute', {}).get('flavor_ref_alt') |
| if not flavor_name: |
| return |
| |
| keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {}) |
| res = self.authenticated_openstack_module_call( |
| nodes[0], 'novang.flavor_list', profile=keystone_profile_admin)[nodes[0]] |
| |
| if flavor_name in res: |
| return res[flavor_name]['id'] |
| |
| # Defines name of image with share tools. |
| @property |
| def image_with_share_tools(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| c = conditions.BaseRule('keystone.client.enabled', 'eq', True) |
| nodes = self.get_nodes_where_condition_match(c) |
| image_name = self.runtest_opts.get('convert_to_uuid', {}).get( |
| 'compute', {}).get('image_ref_nfs') |
| if not image_name: |
| return |
| |
| keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {}) |
| res = self.authenticated_openstack_module_call( |
| nodes[0], 'glanceng.image_list', profile=keystone_profile_admin)[nodes[0]] |
| |
| for item in res: |
| if item['name'] == image_name: |
| return item['name'] |
| |
| # Defines password for image with share tools. |
| @property |
| def image_password(self): |
| if conditions.BaseRule('manila.api.enabled', 'eq', True): |
| image_name = self.runtest_opts.get('convert_to_uuid', {}).get( |
| 'compute', {}).get('image_ref_nfs') |
| if not image_name: |
| return |
| |
| image_map = {'manila-service-image-master': 'manila'} |
| |
| return image_map.get(image_name) |