Browse Source

Refresh data before display

master
Doug Le Tough 4 years ago
parent
commit
3d7bf73dab
2 changed files with 22 additions and 17 deletions
  1. +14
    -15
      data_manager/__init__.py
  2. +8
    -2
      ui/display_manager.py

+ 14
- 15
data_manager/__init__.py View File

@ -27,13 +27,13 @@ class DataManager(object):
self.protocol = protocol
self.host = host
self.connection = None
self.domains = self.get_domains()
self.storage_pools = self.get_storage_pools()
self.networks = self.get_networks()
self.network_filters = self.get_network_filters()
self.interfaces = self.get_interfaces()
self.secrets = self.get_secrets()
self.devices = self.get_devices()
self.get_domains()
self.get_networks()
self.get_network_filters()
self.get_interfaces()
self.get_secrets()
self.get_storage_pools()
self.get_devices()
def connect(self):
""" Connect to hypervisor via libvirt """
@ -84,7 +84,7 @@ class DataManager(object):
}
domains.append(domain)
self.disconnect()
return domains
self.domains = domains
def get_networks(self):
""" Get networks infos and status from hypervisor """
@ -103,7 +103,7 @@ class DataManager(object):
}
networks.append(network)
self.disconnect()
return networks
self.networks = networks
def get_network_filters(self):
""" Get networks_filters infos from hypervisor """
@ -118,7 +118,7 @@ class DataManager(object):
}
nw_filters.append(nw_filter)
self.disconnect()
return nw_filters
self.network_filters = nw_filters
def get_interfaces(self):
""" Get interfaces infos and status from hypervisor """
@ -134,7 +134,7 @@ class DataManager(object):
}
interfaces.append(interface)
self.disconnect()
return interfaces
self.interfaces = interfaces
def get_secrets(self):
""" Get secrets infos from hypervisor """
@ -152,7 +152,7 @@ class DataManager(object):
}
secrets.append(secret)
self.disconnect()
return secrets
self.secrets = secrets
def get_storage_pools(self):
""" Get storage_pools infos and status from hypervisor """
@ -171,9 +171,8 @@ class DataManager(object):
'is_persistent': sto.isPersistent(),
}
pools.append(pool)
self.disconnect()
return pools
self.storage_pools = pools
def get_storage_volumes(self, volumes):
""" Get storage_volumes infos from storage_pool """
@ -224,7 +223,7 @@ class DataManager(object):
device['model'] = cap.text
if device['name'] and device['type']:
devices.append(device)
return devices
self.devices = devices
def debug(self):
""" Log all information gathered for debugging purpose """


+ 8
- 2
ui/display_manager.py View File

@ -206,7 +206,7 @@ class DisplayManager(object):
('No image', curses.color_pair(22) + curses.A_BOLD),
('Image ', curses.color_pair(36) + curses.A_BOLD)
]
self.dataManager.get_domains()
for domain in sorted(self.dataManager.domains, key=itemgetter('name')):
domain_active, domain_active_color = self.active_colors[domain['is_active']]
domain_persistence, domain_persistence_color = self.persistence_colors[domain['is_persistent']]
@ -249,7 +249,7 @@ class DisplayManager(object):
'storage': curses.color_pair(43) + curses.A_BOLD,
'system': curses.color_pair(50) + curses.A_BOLD,
}
self.dataManager.get_devices()
for device in sorted(self.dataManager.devices, key=itemgetter('type'), reverse=False):
device_type_color = device_type_colors[device['type']]
data_line = [
@ -279,6 +279,7 @@ class DisplayManager(object):
""" Getting networks data from dataManager and put it in shape for display purpose """
self.logger.log('* DisplayManager: Getting networks' , 'info')
self.init_general_data()
self.dataManager.get_networks()
for network in sorted(self.dataManager.networks, key=itemgetter('name'), reverse=False):
net_autostart, net_autostart_color = self.autostart_colors[network['autostart']]
net_active, net_active_color = self.active_colors[network['is_active']]
@ -310,6 +311,7 @@ class DisplayManager(object):
""" Getting networks filters data from dataManager and put it in shape for display purpose """
self.logger.log('* DisplayManager: Getting network filters' , 'info')
self.init_general_data()
self.dataManager.get_network_filters()
for nw_filter in sorted(self.dataManager.nw_filters, key=itemgetter('name'), reverse=False):
data_line = [
(str(nw_filter['uuid']), curses.A_BOLD),
@ -329,6 +331,7 @@ class DisplayManager(object):
""" Getting interfaces data from dataManager and put it in shape for display purpose """
self.logger.log('* DisplayManager: Getting interfaces' , 'info')
self.init_general_data()
self.dataManager.get_interfaces()
for interface in sorted(self.dataManager.interfaces, key=itemgetter('name'), reverse=False):
if_active, if_active_color = self.active_colors[interface['is_active']]
data_line = [
@ -350,6 +353,7 @@ class DisplayManager(object):
""" Getting secrets data from dataManager and put it in shape for display purpose """
self.logger.log('* DisplayManager: Getting secrets' , 'info')
self.init_general_data()
self.dataManager.get_secrets()
for secret in sorted(self.dataManager.secrets, key=itemgetter('name'), reverse=False):
data_line = [
(str(secret['uuid']), curses.A_BOLD),
@ -371,6 +375,7 @@ class DisplayManager(object):
""" Getting storage pools data from dataManager and put it in shape for display purpose """
self.logger.log('* DisplayManager: Getting storage pools' , 'info')
self.init_general_data()
self.dataManager.get_storage_pools()
for pool in sorted(self.dataManager.storage_pools, key=itemgetter('name'), reverse=False):
pool_autostart, pool_autostart_color = self.autostart_colors[pool['autostart']]
pool_active, pool_active_color = self.active_colors[pool['is_active']]
@ -404,6 +409,7 @@ class DisplayManager(object):
# Volumes data don't need to be selected
# so we don't need to have a persitent reference
data = []
# FIXME : Refresh data before parsing ?
for volume in sorted(pool, key=itemgetter('name'), reverse=False):
data_line = [
(str(vol['key']), curses.A_BOLD),


Loading…
Cancel
Save