- time.sleep(1)
- continue
-
- if task[0] == 'instance':
- print self.name, ": processing task instance", task[1]['action']
- retry=0
- while retry <2:
- retry += 1
- r=self.action_on_server(task[1], retry==2)
- if r>=0:
- break
- elif task[0] == 'image':
- pass
- elif task[0] == 'exit':
- print self.name, ": processing task exit"
- self.terminate()
- return 0
- elif task[0] == 'reload':
- print self.name, ": processing task reload terminating and relaunching"
- self.terminate()
- break
- elif task[0] == 'edit-iface':
- print self.name, ": processing task edit-iface port=%s, old_net=%s, new_net=%s" % (task[1], task[2], task[3])
- self.edit_iface(task[1], task[2], task[3])
- elif task[0] == 'restore-iface':
- print self.name, ": processing task restore-iface %s mac=%s" % (task[1], task[2])
- self.restore_iface(task[1], task[2])
- elif task[0] == 'new-ovsbridge':
- print self.name, ": Creating compute OVS bridge"
- self.create_ovs_bridge()
- elif task[0] == 'new-vxlan':
- print self.name, ": Creating vxlan tunnel=" + task[1] + ", remote ip=" + task[2]
- self.create_ovs_vxlan_tunnel(task[1], task[2])
- elif task[0] == 'del-ovsbridge':
- print self.name, ": Deleting OVS bridge"
- self.delete_ovs_bridge()
- elif task[0] == 'del-vxlan':
- print self.name, ": Deleting vxlan " + task[1] + " tunnel"
- self.delete_ovs_vxlan_tunnel(task[1])
- elif task[0] == 'create-ovs-bridge-port':
- print self.name, ": Adding port ovim-" + task[1] + " to OVS bridge"
- self.create_ovs_bridge_port(task[1])
- elif task[0] == 'del-ovs-port':
- print self.name, ": Delete bridge attached to ovs port vlan {} net {}".format(task[1], task[2])
- self.delete_bridge_port_attached_to_ovs(task[1], task[2])
- else:
- print self.name, ": unknown task", task
-
+ task = None
+ self.queueLock.release()
+
+ if task is None:
+ now=time.time()
+ if self.localinfo_dirty:
+ self.save_localinfo()
+ elif self.next_update_server_status < now:
+ self.update_servers_status()
+ self.next_update_server_status = now + 5
+ elif len(self.pending_terminate_server)>0 and self.pending_terminate_server[0][0]<now:
+ self.server_forceoff()
+ else:
+ time.sleep(1)
+ continue
+
+ if task[0] == 'instance':
+ self.logger.debug("processing task instance " + str(task[1]['action']))
+ retry = 0
+ while retry < 2:
+ retry += 1
+ r = self.action_on_server(task[1], retry==2)
+ if r >= 0:
+ break
+ elif task[0] == 'image':
+ pass
+ elif task[0] == 'exit':
+ self.logger.debug("processing task exit")
+ self.terminate()
+ return 0
+ elif task[0] == 'reload':
+ self.logger.debug("processing task reload terminating and relaunching")
+ self.terminate()
+ break
+ elif task[0] == 'edit-iface':
+ self.logger.debug("processing task edit-iface port={}, old_net={}, new_net={}".format(
+ task[1], task[2], task[3]))
+ self.edit_iface(task[1], task[2], task[3])
+ elif task[0] == 'restore-iface':
+ self.logger.debug("processing task restore-iface={} mac={}".format(task[1], task[2]))
+ self.restore_iface(task[1], task[2])
+ elif task[0] == 'new-ovsbridge':
+ self.logger.debug("Creating compute OVS bridge")
+ self.create_ovs_bridge()
+ elif task[0] == 'new-vxlan':
+ self.logger.debug("Creating vxlan tunnel='{}', remote ip='{}'".format(task[1], task[2]))
+ self.create_ovs_vxlan_tunnel(task[1], task[2])
+ elif task[0] == 'del-ovsbridge':
+ self.logger.debug("Deleting OVS bridge")
+ self.delete_ovs_bridge()
+ elif task[0] == 'del-vxlan':
+ self.logger.debug("Deleting vxlan {} tunnel".format(task[1]))
+ self.delete_ovs_vxlan_tunnel(task[1])
+ elif task[0] == 'create-ovs-bridge-port':
+ self.logger.debug("Adding port ovim-{} to OVS bridge".format(task[1]))
+ self.create_ovs_bridge_port(task[1])
+ elif task[0] == 'del-ovs-port':
+ self.logger.debug("Delete bridge attached to ovs port vlan {} net {}".format(task[1], task[2]))
+ self.delete_bridge_port_attached_to_ovs(task[1], task[2])
+ else:
+ self.logger.debug("unknown task " + str(task))
+
+ except Exception as e:
+ self.logger.critical("Unexpected exception at run: " + str(e), exc_info=True)
+