Correct bug from previous commit in pvcvd as well
This commit is contained in:
		| @@ -58,15 +58,25 @@ class NodeInstance(): | |||||||
|         self.inflush = False |         self.inflush = False | ||||||
|  |  | ||||||
|         # Zookeeper handlers for changed states |         # Zookeeper handlers for changed states | ||||||
|         @zk_conn.DataWatch('/nodes/{}/daemonstate'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/daemonstate'.format(self.name)) | ||||||
|         def watch_hypervisor_daemonstate(data, stat, event=""): |         def watch_hypervisor_daemonstate(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.daemon_state = data.decode('ascii') |                 self.daemon_state = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.daemon_state = 'stop' |                 self.daemon_state = 'stop' | ||||||
|  |  | ||||||
|         @zk_conn.DataWatch('/nodes/{}/domainstate'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/domainstate'.format(self.name)) | ||||||
|         def watch_hypervisor_domainstate(data, stat, event=""): |         def watch_hypervisor_domainstate(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.domain_state = data.decode('ascii') |                 self.domain_state = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
| @@ -81,43 +91,73 @@ class NodeInstance(): | |||||||
|                 if self.domain_state == 'unflush' and self.inflush == False: |                 if self.domain_state == 'unflush' and self.inflush == False: | ||||||
|                     self.unflush() |                     self.unflush() | ||||||
|  |  | ||||||
|         @zk_conn.DataWatch('/nodes/{}/memfree'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/memfree'.format(self.name)) | ||||||
|         def watch_hypervisor_memfree(data, stat, event=""): |         def watch_hypervisor_memfree(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.memfree = data.decode('ascii') |                 self.memfree = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.memfree = 0 |                 self.memfree = 0 | ||||||
|      |      | ||||||
|         @zk_conn.DataWatch('/nodes/{}/memused'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/memused'.format(self.name)) | ||||||
|         def watch_hypervisor_memused(data, stat, event=""): |         def watch_hypervisor_memused(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.memused = data.decode('ascii') |                 self.memused = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.memused = 0 |                 self.memused = 0 | ||||||
|      |      | ||||||
|         @zk_conn.DataWatch('/nodes/{}/memalloc'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/memalloc'.format(self.name)) | ||||||
|         def watch_hypervisor_memalloc(data, stat, event=""): |         def watch_hypervisor_memalloc(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.memalloc = data.decode('ascii') |                 self.memalloc = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.memalloc = 0 |                 self.memalloc = 0 | ||||||
|      |      | ||||||
|         @zk_conn.DataWatch('/nodes/{}/vcpualloc'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/vcpualloc'.format(self.name)) | ||||||
|         def watch_hypervisor_vcpualloc(data, stat, event=""): |         def watch_hypervisor_vcpualloc(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.vcpualloc = data.decode('ascii') |                 self.vcpualloc = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.vcpualloc = 0 |                 self.vcpualloc = 0 | ||||||
|      |      | ||||||
|         @zk_conn.DataWatch('/nodes/{}/runningdomains'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/runningdomains'.format(self.name)) | ||||||
|         def watch_hypervisor_runningdomains(data, stat, event=""): |         def watch_hypervisor_runningdomains(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.domain_list = data.decode('ascii').split() |                 self.domain_list = data.decode('ascii').split() | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|                 self.domain_list = [] |                 self.domain_list = [] | ||||||
|  |  | ||||||
|         @zk_conn.DataWatch('/nodes/{}/domainscount'.format(self.name)) |         @self.zk_conn.DataWatch('/nodes/{}/domainscount'.format(self.name)) | ||||||
|         def watch_hypervisor_domainscount(data, stat, event=""): |         def watch_hypervisor_domainscount(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|                 self.domains_count = data.decode('ascii') |                 self.domains_count = data.decode('ascii') | ||||||
|             except AttributeError: |             except AttributeError: | ||||||
|   | |||||||
| @@ -54,8 +54,13 @@ class VMInstance: | |||||||
|         self.dom = self.lookupByUUID(self.domuuid) |         self.dom = self.lookupByUUID(self.domuuid) | ||||||
|  |  | ||||||
|         # Watch for changes to the state field in Zookeeper |         # Watch for changes to the state field in Zookeeper | ||||||
|         @zk_conn.DataWatch('/domains/{}/state'.format(self.domuuid)) |         @self.zk_conn.DataWatch('/domains/{}/state'.format(self.domuuid)) | ||||||
|         def watch_state(data, stat, event=""): |         def watch_state(data, stat, event=""): | ||||||
|  |             if event and event.type == 'DELETED': | ||||||
|  |                 # The key has been deleted after existing before; terminate this watcher | ||||||
|  |                 # because this class instance is about to be reaped in Daemon.py | ||||||
|  |                 return False | ||||||
|  |  | ||||||
|             # If we get a delete state, just terminate outselves |             # If we get a delete state, just terminate outselves | ||||||
|             if data == None: |             if data == None: | ||||||
|                 return |                 return | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user