Coverage for manila/tests/conf_fixture.py: 100%

54 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2010 United States Government as represented by the 

2# Administrator of the National Aeronautics and Space Administration. 

3# All Rights Reserved. 

4# 

5# Licensed under the Apache License, Version 2.0 (the "License"); you may 

6# not use this file except in compliance with the License. You may obtain 

7# a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, software 

12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

14# License for the specific language governing permissions and limitations 

15# under the License. 

16 

17import os 

18 

19from oslo_policy import opts 

20from oslo_service import wsgi 

21 

22# some of these are imported for their side-effects 

23from manila.api import openstack # noqa 

24from manila.common import config 

25 

26CONF = config.CONF 

27 

28 

29def set_defaults(conf): 

30 _safe_set_of_opts(conf, 'verbose', True) 

31 _safe_set_of_opts(conf, 'state_path', os.path.abspath( 

32 os.path.join(os.path.dirname(__file__), 

33 '..', 

34 '..'))) 

35 _safe_set_of_opts(conf, 'connection', "sqlite://", group='database') 

36 _safe_set_of_opts(conf, 'sqlite_synchronous', False) 

37 _POLICY_PATH = os.path.abspath(os.path.join(CONF.state_path, 

38 'manila/tests/policy.yaml')) 

39 opts.set_defaults(conf, policy_file=_POLICY_PATH) 

40 _safe_set_of_opts(conf, 'share_export_ip', '0.0.0.0') 

41 _safe_set_of_opts(conf, 'service_instance_user', 'fake_user') 

42 _API_PASTE_PATH = os.path.abspath(os.path.join(CONF.state_path, 

43 'etc/manila/api-paste.ini')) 

44 wsgi.register_opts(conf) 

45 _safe_set_of_opts(conf, 'api_paste_config', _API_PASTE_PATH) 

46 # we use "fake" and "openstack" as project ID in a number of tests 

47 _safe_set_of_opts(conf, 'project_id_regex', r"[0-9a-fopnstk\-]+") 

48 _safe_set_of_opts(conf, 'share_driver', 

49 'manila.tests.fake_driver.FakeShareDriver') 

50 _safe_set_of_opts(conf, 'auth_strategy', 'noauth') 

51 

52 _safe_set_of_opts(conf, 'zfs_share_export_ip', '1.1.1.1') 

53 _safe_set_of_opts(conf, 'zfs_service_ip', '2.2.2.2') 

54 _safe_set_of_opts(conf, 'zfs_zpool_list', ['foo', 'bar']) 

55 _safe_set_of_opts(conf, 'zfs_share_helpers', 'NFS=foo.bar.Helper') 

56 _safe_set_of_opts(conf, 'zfs_replica_snapshot_prefix', 'foo_prefix_') 

57 

58 _safe_set_of_opts(conf, 'hitachi_hsp_host', '172.24.47.190') 

59 _safe_set_of_opts(conf, 'hitachi_hsp_username', 'hsp_user') 

60 _safe_set_of_opts(conf, 'hitachi_hsp_password', 'hsp_password') 

61 

62 _safe_set_of_opts(conf, 'as13000_nas_ip', '1.1.1.1') 

63 _safe_set_of_opts(conf, 'as13000_nas_login', 'admin') 

64 _safe_set_of_opts(conf, 'as13000_nas_password', 'password') 

65 _safe_set_of_opts(conf, 'as13000_share_pools', 'pool0') 

66 

67 _safe_set_of_opts(conf, 'instorage_nas_ip', '1.1.1.1') 

68 _safe_set_of_opts(conf, 'instorage_nas_login', 'admin') 

69 _safe_set_of_opts(conf, 'instorage_nas_password', 'password') 

70 _safe_set_of_opts(conf, 'instorage_nas_pools', 'pool0') 

71 

72 _safe_set_of_opts(conf, 'infortrend_nas_ip', '172.27.1.1') 

73 _safe_set_of_opts(conf, 'infortrend_share_pools', 'share-pool-01') 

74 _safe_set_of_opts(conf, 'infortrend_share_channels', '0,1') 

75 

76 _safe_set_of_opts(conf, 'macrosan_nas_ip', '1.1.1.1') 

77 _safe_set_of_opts(conf, 'macrosan_share_pools', 'pool0') 

78 

79 _safe_set_of_opts(conf, 'qnap_management_url', 'http://1.2.3.4:8080') 

80 _safe_set_of_opts(conf, 'qnap_share_ip', '1.2.3.4') 

81 _safe_set_of_opts(conf, 'qnap_nas_login', 'admin') 

82 _safe_set_of_opts(conf, 'qnap_nas_password', 'qnapadmin') 

83 _safe_set_of_opts(conf, 'qnap_poolname', 'Storage Pool 1') 

84 

85 _safe_set_of_opts(conf, 'unity_server_meta_pool', 'nas_server_pool') 

86 

87 conf.set_default('response_validation', 'error', group='api') 

88 

89 

90def _safe_set_of_opts(conf, *args, **kwargs): 

91 try: 

92 conf.set_default(*args, **kwargs) 

93 except config.cfg.NoSuchOptError: 

94 # Assumed that opt is not imported and not used 

95 pass