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