Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
1 | import base64 |
||
10 | class DatabaseRdsSpec(Action): |
||
11 | def run(self, payload): |
||
12 | # For dbidentifier |
||
13 | db_name = re.sub('[^0-9a-zA-Z]+', '-', payload['name']) + "-" + payload['namespace'] |
||
14 | |||
15 | #Lets get a username generated |
||
16 | user_name = self._user_name(uid=payload['uid']) |
||
17 | # Lets get a password randomly generated |
||
18 | pw = self._id_generator() |
||
19 | instance_class = 'db.m3.xlarge' |
||
20 | port = '3306' |
||
21 | rds_engine = 'mysql' |
||
22 | allocated_storage = '50' |
||
23 | |||
24 | payload = { |
||
25 | 'db_name': db_name, |
||
26 | 'user_name': user_name, |
||
27 | 'pw': pw, |
||
28 | 'instance_class': instance_class, |
||
29 | 'port': port, |
||
30 | 'rds_engine': rds_engine, |
||
31 | 'allocated_storage': allocated_storage, |
||
32 | } |
||
33 | |||
34 | return payload |
||
35 | |||
36 | def _user_name(self, uid): |
||
37 | short_uid = uid[0:7] |
||
38 | return "db_" + short_uid |
||
39 | pass |
||
40 | |||
41 | def _id_generator(self): |
||
42 | return uuid.uuid4().hex |
||
43 | pass |
||
44 |