MCPcopy
hub / github.com/retspen/webvirtcloud / connect

Method connect

vrtManager/connection.py:68–99  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

66 self.connect()
67
68 def connect(self):
69 self.connection_state_lock.acquire()
70 try:
71 # recheck if we have a connection (it may have been
72 if not self.connected:
73 if self.type == CONN_TCP:
74 self.__connect_tcp()
75 elif self.type == CONN_SSH:
76 self.__connect_ssh()
77 elif self.type == CONN_TLS:
78 self.__connect_tls()
79 elif self.type == CONN_SOCKET:
80 self.__connect_socket()
81 else:
82 raise ValueError('"{type}" is not a valid connection type'.format(type=self.type))
83
84 if self.connected:
85 # do some preprocessing of the connection:
86 # * set keep alive interval
87 # * set connection close/fail handler
88 try:
89 self.connection.setKeepAlive(connection_manager.keepalive_interval, connection_manager.keepalive_count)
90 try:
91 self.connection.registerCloseCallback(self.__connection_close_callback, None)
92 except:
93 # Temporary fix for libvirt > libvirt-0.10.2-41
94 pass
95 except libvirtError as e:
96 # hypervisor driver does not seem to support persistent connections
97 self.last_error = str(e)
98 finally:
99 self.connection_state_lock.release()
100
101 @property
102 def connected(self):

Callers 7

__init__Method · 0.95
ui.jsFile · 0.80
playback.jsFile · 0.80
tcp-client.jsFile · 0.80
get_connectionMethod · 0.80
host_is_upMethod · 0.80
instanceFunction · 0.80

Calls 5

__connect_tcpMethod · 0.95
__connect_sshMethod · 0.95
__connect_tlsMethod · 0.95
__connect_socketMethod · 0.95
releaseMethod · 0.80

Tested by

no test coverage detected