self.queueLock = threading.Lock()
self.taskQueue = Queue.Queue(2000)
self.ssh_conn = None
+ self.connectivity = True
self.lvirt_conn_uri = "qemu+ssh://{user}@{host}/system?no_tty=1&no_verify=1".format(
user=self.user, host=self.host)
if keyfile:
text = e.args[0]
self.logger.error("ssh_connect ssh Exception: " + text)
+ def check_connectivity(self):
+ if not self.test:
+
+ try:
+ if not self.ssh_conn:
+ self.ssh_connect()
+
+ command = 'sudo brctl show'
+ (_, stdout, stderr) = self.ssh_conn.exec_command(command, timeout=10)
+ content = stderr.read()
+ if len(content) > 0:
+ self.connectivity = False
+ self.logger.error("ssh conection error")
+ except paramiko.ssh_exception.SSHException as e:
+ text = e.args[0]
+ self.connectivity = False
+ self.logger.error("ssh_connect ssh Exception: " + text)
+ raise paramiko.ssh_exception.SSHException("ssh error conection")
+ except Exception as e:
+ self.connectivity = False
+ raise paramiko.ssh_exception.SSHException("ssh error conection")
+
def load_localinfo(self):
if not self.test:
try:
Create a bridge in compute OVS to allocate VMs
:return: True if success
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
+
+
try:
command = 'sudo ovs-vsctl --may-exist add-br br-int -- set Bridge br-int stp_enable=true'
self.logger.debug("command: " + command)
:return:
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
try:
port_name = 'ovim-' + str(vlan)
:param dhcp_path: conf fiel path that live in namespace side
:return:
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
if not self.is_dhcp_port_free(vlan, net_uuid):
return True
:param remote_ip: tunnel endpoint remote compute ip.
:return:
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
try:
command = 'sudo ovs-vsctl add-port br-int ' + vxlan_interface + \
:param vxlan_interface: vlxan name to be delete it.
:return: True if success.
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
try:
command = 'sudo ovs-vsctl del-port br-int ' + vxlan_interface
Delete a OVS bridge from a compute.
:return: True if success
"""
- if self.test:
+ if self.test or not self.connectivity:
return True
try:
command = 'sudo ovs-vsctl del-br br-int'
self.config["db_lock"] = threading.Lock()
self.of_test_mode = False if self.config['mode'] == 'normal' or self.config['mode'] == "OF only" else True
+
+ # Create one thread for each host
+ host_test_mode = True if self.config['mode'] == 'test' or self.config['mode'] == "OF only" else False
+ host_develop_mode = True if self.config['mode'] == 'development' else False
+ host_develop_bridge_iface = self.config.get('development_bridge', None)
+
+ # get host list from data base before starting threads
+ r, hosts = self.db.get_table(SELECT=('name', 'ip_name', 'user', 'uuid', 'password', 'keyfile'),
+ FROM='hosts', WHERE={'status': 'ok'})
+ if r < 0:
+ raise ovimException("Cannot get hosts from database {}".format(hosts))
+
+ self.config['host_threads'] = {}
+
+ for host in hosts:
+ thread = ht.host_thread(name=host['name'], user=host['user'], host=host['ip_name'], db=self.config["db"],
+ password=host['password'],
+ keyfile=host.get('keyfile', self.config["host_ssh_keyfile"]),
+ db_lock=self.config["db_lock"], test=host_test_mode,
+ image_path=self.config['host_image_path'],
+ version=self.config['version'], host_id=host['uuid'],
+ develop_mode=host_develop_mode,
+ develop_bridge_iface=host_develop_bridge_iface,
+ logger_name=self.logger_name + ".host." + host['name'],
+ debug=self.config.get('log_level_host'))
+
+ try:
+ thread.check_connectivity()
+ except Exception as e:
+ self.logger.critical('Error detected for compute = {} with ip = {}'
+ .format(host['name'], host['ip_name']))
+
+ self.config['host_threads'][host['uuid']] = thread
+
# precreate interfaces; [bridge:<host_bridge_name>, VLAN used at Host, uuid of network camping in this bridge,
# speed in Gbit/s
thread.start()
self.config['dhcp_thread'] = thread
- # Create one thread for each host
- host_test_mode = True if self.config['mode'] == 'test' or self.config['mode'] == "OF only" else False
- host_develop_mode = True if self.config['mode'] == 'development' else False
- host_develop_bridge_iface = self.config.get('development_bridge', None)
- # get host list from data base before starting threads
- r, hosts = self.db.get_table(SELECT=('name', 'ip_name', 'user', 'uuid', 'password', 'keyfile'),
- FROM='hosts', WHERE={'status': 'ok'})
- if r < 0:
- raise ovimException("Cannot get hosts from database {}".format(hosts))
-
- self.config['host_threads'] = {}
- for host in hosts:
- thread = ht.host_thread(name=host['name'], user=host['user'], host=host['ip_name'], db=self.config["db"],
- password=host['password'],
- keyfile=host.get('keyfile', self.config["host_ssh_keyfile"]),
- db_lock=self.config["db_lock"], test=host_test_mode,
- image_path=self.config['host_image_path'],
- version=self.config['version'], host_id=host['uuid'],
- develop_mode=host_develop_mode,
- develop_bridge_iface=host_develop_bridge_iface,
- logger_name=self.logger_name + ".host." + host['name'],
- debug=self.config.get('log_level_host'))
- thread.start()
- self.config['host_threads'][host['uuid']] = thread
# create ovs dhcp thread
result, content = self.db.get_table(FROM='nets')
debug=self.config.get('log_level_host'))
# dhcp_host.start()
self.config['host_threads']['openvim_controller'] = dhcp_host
- if not host_test_mode:
- dhcp_host.ssh_connect()
+ try:
+ dhcp_host.check_connectivity()
+ except Exception as e:
+ pass
+
return dhcp_host
def launch_dhcp_server(self, vlan, first_ip, last_ip, cidr, gateway):