adminpw handling modification
[ta/config-manager.git] / cmdatahandlers / src / cmdatahandlers / users / config.py
1 # Copyright 2019 Nokia
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from cmdatahandlers.api import configerror
16 from cmdatahandlers.api import config
17
18 class Config(config.Config):
19     def __init__(self, confman):
20         super(Config, self).__init__(confman)
21         self.ROOT = 'cloud.users'
22         self.DOMAIN = 'users'
23
24     def init(self):
25         pass
26
27     def validate(self):
28         self.validate_root()
29
30     def get_users(self):
31         """ get the users list
32
33             Return:
34
35             A list of users
36
37             Raise:
38
39             ConfigError in-case of an error
40         """
41         self.validate_root()
42         return []
43
44     def get_user_password(self, user):
45         """ get the password for a user
46
47             Return:
48
49             A string representing the password
50
51             Raise:
52
53             ConfigError in-case of an error
54         """
55         raise configerror.ConfigError('Invalid user %s' % user)
56
57     def get_admin_user_password(self):
58         """ get the admin user password
59
60             Return:
61
62             A string representing the admin user password
63
64             Raise:
65
66             ConfigError in-case of an error
67         """
68         return self.config[self.ROOT]['admin_user_password']
69
70     def get_admin_user(self):
71         """ get the admin user
72
73             Return:
74
75             A string representing the admin user
76
77             Raise:
78
79             ConfigError in-case of an error
80         """
81         return self.config[self.ROOT]['admin_user_name']
82
83     def get_initial_user_name(self):
84         """ get the initial user name
85
86             Return:
87
88             A string representing the initial user name
89
90             Raise:
91
92             ConfigError in-case of an error
93         """
94         return self.config[self.ROOT]['initial_user_name']
95
96     def get_initial_user_password(self):
97         """ get the initial user password
98
99             Return:
100
101             A string representing the initial user password
102
103             Raise:
104
105             ConfigError in-case of an error
106         """
107         return self.config[self.ROOT]['initial_user_password']
108
109     def mask_sensitive_data(self):
110         self.config[self.ROOT]['admin_user_password'] = self.MASK
111         self.config[self.ROOT]['initial_user_password'] = self.MASK
112