Yulia Portnova | 21289b2 | 2015-03-18 15:21:43 +0200 | [diff] [blame] | 1 | class Node(object): |
| 2 | |
| 3 | def __init__(self, ip, roles, username=None, |
| 4 | password=None, key_path=None, port=None): |
| 5 | self.roles = roles |
| 6 | self.ip = ip |
| 7 | self.username = username |
| 8 | self.password = password |
| 9 | self.port = port |
| 10 | self.key_path = key_path |
| 11 | |
| 12 | def set_conn_attr(self, name, value): |
| 13 | setattr(self, name, value) |
| 14 | |
| 15 | @property |
| 16 | def connection(self): |
| 17 | connection = [] |
| 18 | |
| 19 | if self.username: |
| 20 | connection.append(self.username) |
| 21 | if self.password: |
| 22 | connection.extend([":", self.password, "@"]) |
| 23 | connection.append("@") |
| 24 | |
| 25 | connection.append(self.ip) |
| 26 | if self.port: |
| 27 | connection.extend([":", self.port]) |
| 28 | if self.key_path: |
| 29 | connection.extend([":", self.key_path]) |
| 30 | else: |
| 31 | if self.key_path: |
| 32 | connection.extend([":", ":", self.key_path]) |
| 33 | return "".join(connection) |