blob: 4ee21090f2c3e79f8d33878c1401899f0ad56d6a [file] [log] [blame]
Yulia Portnova21289b22015-03-18 15:21:43 +02001class 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)