def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI VIF ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'vms/{}'.format(id_from_ref(properties['parent'])), 'relname': 'vifs', 'id': id_from_ref(ref), } title = properties.get('device') or properties['uuid'] return { 'compname': 'vms/{}'.format(id_from_ref(properties.get('VM'))), 'relname': 'vifs', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_metrics_ref': properties.get('metrics'), 'xenapi_uuid': properties.get('uuid'), 'macaddress': properties.get('MAC'), 'mac_autogenerated': properties.get('MAC_autogenerated'), 'mtu': properties.get('MTU'), 'allowed_operations': properties.get('allowed_operations'), 'currently_attached': properties.get('currently_attached'), 'vif_device': properties.get('device'), 'ipv4_allowed': properties.get('ipv4_allowed'), 'ipv6_allowed': properties.get('ipv6_allowed'), 'locking_mode': properties.get('locking_mode'), 'setNetwork': id_from_ref(properties.get('network')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI SR ref and properties. ''' if 'uuid' not in properties: return { 'relname': 'srs', 'id': id_from_ref(ref), } title = properties.get('name_label') or properties['uuid'] sm_config = properties.get('sm_config', {}) return { 'relname': 'srs', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'allowed_operations': properties.get('allowed_operations'), 'content_type': properties.get('content_type'), 'local_cache_enabled': properties.get('local_cache_enabled'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'physical_size': properties.get('physical_size'), 'shared': properties.get('shared'), 'sm_type': sm_config.get('type'), 'sr_type': properties.get('type'), 'setPBDs': ids_from_refs(properties.get('PBDs', [])) }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI PBD ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'hosts/{}'.format(id_from_ref(properties['parent'])), 'relname': 'pbds', 'id': id_from_ref(ref), } device_config = properties.get('device_config', {}) title = device_config.get('location') or \ device_config.get('device') or \ properties['uuid'] return { 'compname': 'hosts/{}'.format(id_from_ref(properties.get('host'))), 'relname': 'pbds', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'currently_attached': properties.get('currently_attached'), 'dc_device': device_config.get('device'), 'dc_legacy_mode': to_boolean(device_config.get('legacy_mode')), 'dc_location': device_config.get('location'), 'setSR': id_from_ref(properties.get('SR')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI network ref and properties. ''' if 'uuid' not in properties: return { 'relname': 'networks', 'id': id_from_ref(ref), } title = properties.get('name_label') or properties['uuid'] other_config = properties.get('other_config', {}) return { 'relname': 'networks', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'mtu': properties.get('MTU'), 'allowed_operations': properties.get('allowed_operations'), 'bridge': properties.get('bridge'), 'default_locking_mode': properties.get('default_locking_mode'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'ipv4_begin': other_config.get('ip_begin'), 'ipv4_end': other_config.get('ip_end'), 'is_guest_installer_network': to_boolean(other_config.get('is_guest_installer_network')), 'is_host_internal_management_network': to_boolean(other_config.get('is_host_internal_management_network')), 'ipv4_netmask': other_config.get('ipv4_netmask'), 'setPIFs': ids_from_refs(properties.get('PIFs', [])), 'setVIFs': ids_from_refs(properties.get('VIFs', [])), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI VBD ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'vms/{}'.format(id_from_ref(properties['parent'])), 'relname': 'vbds', 'id': id_from_ref(ref), } title = properties.get('device') or \ properties.get('userdevice') or \ properties['uuid'] return { 'compname': 'vms/{}'.format(id_from_ref(properties.get('VM'))), 'relname': 'vbds', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_metrics_ref': properties.get('metrics'), 'xenapi_uuid': properties.get('uuid'), 'allowed_operations': properties.get('allowed_operations'), 'bootable': properties.get('bootable'), 'currently_attached': properties.get('currently_attached'), 'vbd_device': properties.get('device'), 'empty': properties.get('empty'), 'mode': properties.get('mode'), 'storage_lock': properties.get('storage_lock'), 'vbd_type': properties.get('type'), 'unpluggable': properties.get('unpluggable'), 'userdevice': properties.get('userdevice'), 'setVDI': id_from_ref(properties.get('VDI')), }
def objectmap(self, ref, properties): ''' Return an ObjectMap given XenAPI host_cpu ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'hosts/{}'.format(id_from_ref(properties['parent'])), 'relname': 'hostcpus', 'id': id_from_ref(ref), } title = properties.get('number') or properties['uuid'] cpu_speed = int_or_none(properties.get('speed')) if cpu_speed: cpu_speed = cpu_speed * 1048576 # Convert from MHz to Hz. return { 'compname': 'hosts/{}'.format(id_from_ref(properties.get('host'))), 'relname': 'hostcpus', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'family': int_or_none(properties.get('family')), 'features': properties.get('features'), 'flags': properties.get('flags'), 'model': int_or_none(properties.get('model')), 'modelname': properties.get('modelname'), 'number': int_or_none(properties.get('number')), 'speed': cpu_speed, 'stepping': int_or_none(properties.get('stepping')), 'vendor': properties.get('vendor'), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI VM ref and properties. ''' if not properties: return { 'relname': 'vms', 'id': id_from_ref(ref), } if properties.get('is_a_snapshot') or \ properties.get('is_snapshot_from_vmpp') or \ properties.get('is_a_template'): return title = properties.get('name_label') or properties['uuid'] guest_metrics_ref = properties.get('guest_metrics') if guest_metrics_ref == 'OpaqueRef:NULL': guest_metrics_ref = None return { 'relname': 'vms', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_metrics_ref': properties.get('metrics'), 'xenapi_guest_metrics_ref': guest_metrics_ref, 'xenapi_uuid': properties.get('uuid'), 'hvm_shadow_multiplier': properties.get('HVM_shadow_multiplier'), 'vcpus_at_startup': int_or_none(properties.get('VCPUs_at_startup')), 'vcpus_max': int_or_none(properties.get('VCPUs_max')), 'actions_after_crash': properties.get('actions_after_crash'), 'actions_after_reboot': properties.get('actions_after_reboot'), 'actions_after_shutdown': properties.get('actions_after_shutdown'), 'allowed_operations': properties.get('allowed_operations'), 'domarch': properties.get('domarch'), 'domid': int_or_none(properties.get('domid')), 'ha_always_run': properties.get('ha_always_run'), 'ha_restart_priority': properties.get('ha_restart_priority'), 'is_a_snapshot': properties.get('is_a_snapshot'), 'is_a_template': properties.get('is_a_template'), 'is_control_domain': properties.get('is_control_domain'), 'is_snapshot_from_vmpp': properties.get('is_snapshot_from_vmpp'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'power_state': properties.get('power_state'), 'shutdown_delay': int_or_none(properties.get('shutdown_delay')), 'start_delay': int_or_none(properties.get('start_delay')), 'user_version': int_or_none(properties.get('user_version')), 'version': int_or_none(properties.get('version')), 'setHost': id_from_ref(properties.get('resident_on')), 'setVMAppliance': id_from_ref(properties.get('appliance')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI PIF ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'hosts/{}'.format(id_from_ref(properties['parent'])), 'relname': 'pifs', 'id': id_from_ref(ref), } title = properties.get('device') or properties['uuid'] # IP is a single string whereas IPv6 is a list. ipv4_addresses = [x for x in [properties.get('IP')] if x] ipv6_addresses = [x for x in properties.get('IPv6', []) if x] vlan = properties.get('VLAN') if vlan == '-1': vlan = None return { 'compname': 'hosts/{}'.format(id_from_ref(properties.get('host'))), 'relname': 'pifs', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_metrics_ref': properties.get('metrics'), 'xenapi_uuid': properties.get('uuid'), 'dns': properties.get('dns'), 'ipv4_addresses': ipv4_addresses, 'ipv6_addresses': ipv6_addresses, 'macaddress': properties.get('MAC'), 'mtu': properties.get('MTU'), 'vlan': vlan, 'currently_attached': properties.get('currently_attached'), 'pif_device': properties.get('device'), 'disallow_unplug': properties.get('disallow_unplug'), 'ipv4_gateway': properties.get('gateway'), 'ipv4_configuration_mode': properties.get('ip_configuration_mode'), 'ipv6_configuration_mode': properties.get('ipv6_configuration_mode'), 'ipv6_gateway': properties.get('ipv6_gateway'), 'management': properties.get('management'), 'ipv4_netmask': properties.get('netmask'), 'physical': properties.get('physical'), 'primary_address_type': properties.get('primary_address_type'), 'setNetwork': id_from_ref(properties.get('network')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI host ref and properties. ''' if 'uuid' not in properties: return { 'relname': 'hosts', 'id': id_from_ref, } title = properties.get('name_label') or properties.get('hostname') cpu_info = properties.get('cpu_info', {}) cpu_speed = float_or_none(cpu_info.get('speed')) if cpu_speed: cpu_speed = cpu_speed * 1048576 # Convert from MHz to Hz. return { 'relname': 'hosts', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'xenapi_metrics_ref': properties.get('metrics'), 'api_version_major': properties.get('API_version_major'), 'api_version_minor': properties.get('API_version_minor'), 'api_version_vendor': properties.get('API_version_vendor'), 'address': properties.get('address'), 'allowed_operations': properties.get('allowed_operations'), 'capabilities': properties.get('capabilities'), 'cpu_count': int_or_none(cpu_info.get('cpu_count')), 'cpu_speed': cpu_speed, 'edition': properties.get('edition'), 'enabled': properties.get('enabled'), 'hostname': properties.get('hostname'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'sched_policy': properties.get('sched_policy'), 'setVMs': ids_from_refs(properties.get('resident_VMs', [])), 'setSuspendImageSR': id_from_ref(properties.get('suspend_image_sr')), 'setCrashDumpSR': id_from_ref(properties.get('crash_dump_sr')), 'setLocalCacheSR': id_from_ref(properties.get('local_cache_sr')), }
def objectmap_metrics(cls, ref, properties): ''' Return an ObjectMap given XenAPI host ref and host_metrics properties. ''' return { 'relname': 'vms', 'id': id_from_ref(ref), 'memory_actual': int_or_none(properties.get('memory_actual')), }
def objectmap_metrics(cls, ref, properties): ''' Return an ObjectMap given XenAPI host ref and host_metrics properties. ''' return { 'relname': 'hosts', 'id': id_from_ref(ref), 'memory_total': int_or_none(properties.get('memory_total')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI pool ref and properties. ''' if 'uuid' not in properties: return { 'relname': 'pools', 'id': id_from_ref(ref), } pool_title = properties.get('name_label') or 'default' other_config = properties.get('other_config', {}) return { 'relname': 'pools', 'id': id_from_ref(ref), 'title': pool_title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'ha_allow_overcommit': properties.get('ha_allow_overcommit'), 'ha_enabled': properties.get('ha_enabled'), 'ha_host_failures_to_tolerate': int_or_none(properties.get('ha_host_failures_to_tolerate')), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'oc_cpuid_feature_mask': other_config.get('cpuid_feature_mask'), 'oc_memory_ratio_hvm': other_config.get('memory-ratio-hvm'), 'oc_memory_ratio_pv': other_config.get('memory-ratio-pv'), 'vswitch_controller': properties.get('vswitch_controller'), 'setMaster': id_from_ref(properties.get('master')), 'setDefaultSR': id_from_ref(properties.get('default_SR')), 'setSuspendImageSR': id_from_ref(properties.get('suspend_image_SR')), 'setCrashDumpSR': id_from_ref(properties.get('crash_dump_SR')), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI VDI ref and properties. ''' if 'uuid' not in properties: return { 'compname': 'srs/{}'.format(id_from_ref(properties['parent'])), 'relname': 'vdis', 'id': id_from_ref(ref), } title = properties.get('name_label') or \ properties.get('location') or \ properties['uuid'] return { 'compname': 'srs/{}'.format(id_from_ref(properties.get('SR'))), 'relname': 'vdis', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'allow_caching': properties.get('allow_caching'), 'allowed_operations': properties.get('allowed_operations'), 'is_a_snapshot': properties.get('is_a_snapshot'), 'location': properties.get('location'), 'managed': properties.get('managed'), 'missing': properties.get('missing'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'on_boot': properties.get('on_boot'), 'read_only': properties.get('read_only'), 'sharable': properties.get('sharable'), 'storage_lock': properties.get('storage_lock'), 'vdi_type': properties.get('type'), 'virtual_size': properties.get('virtual_size'), 'setVBDs': ids_from_refs(properties.get('VBDs', [])), }
def objectmap_metrics(cls, ref, properties): ''' Return an ObjectMap given XenAPI host ref and host_metrics properties. ''' # Extract nested refs. ref, host_ref = ref speed = int_or_none(properties.get('speed')) if speed: speed = speed * 1e6 # Convert from Mbps to bps. return { 'compname': 'hosts/{}'.format(id_from_ref(host_ref)), 'relname': 'pifs', 'id': id_from_ref(ref), 'carrier': properties.get('carrier'), 'pif_device_id': properties.get('device_id'), 'pif_device_name': properties.get('device_name'), 'speed': speed, 'vendor_name': properties.get('vendor_name'), }
def objectmap(cls, ref, properties): ''' Return an ObjectMap given XenAPI vm_appliance ref and properties. ''' if not properties: return { 'relname': 'vmappliances', 'id': id_from_ref(ref), } title = properties.get('name_label') or properties['uuid'] return { 'relname': 'vmappliances', 'id': id_from_ref(ref), 'title': title, 'xenapi_ref': ref, 'xenapi_uuid': properties.get('uuid'), 'allowed_operations': properties.get('allowed_operations'), 'name_description': properties.get('name_description'), 'name_label': properties.get('name_label'), 'setVMs': ids_from_refs(properties.get('VMs', [])), }
def full_datamaps(self, events): ''' Return a list of datamaps representing a full model. ''' sr_oms = [] vdi_oms = defaultdict(list) host_oms = [] host_cpu_oms = defaultdict(list) pbd_oms = defaultdict(list) pif_oms = defaultdict(list) network_oms = [] vm_oms = [] vbd_oms = defaultdict(list) vif_oms = defaultdict(list) vm_appliance_oms = [] pool_oms = [] # Used to prevent yielding multiple endpoint.os ObjectMaps. os_om_flag = False for event in events: if event['operation'] == 'del': # There should be no delete events in a full model. continue om = self.get_objectmap(event) if not om: continue if event['class'] == 'sr': sr_oms.append(om) # Initialize contained objmap lists. vdi_oms.setdefault(event['ref'], []) elif event['class'] == 'vdi': sr_ref = event['snapshot']['SR'] vdi_oms[sr_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = sr_ref elif event['class'] == 'host': host_oms.append(om) # Initialize contained objmap lists. host_cpu_oms.setdefault(event['ref'], []) pbd_oms.setdefault(event['ref'], []) pif_oms.setdefault(event['ref'], []) # Save metric -> host mapping for host_metrics events. host_metrics_ref = event['snapshot']['metrics'] self.backrefs[host_metrics_ref] = event['ref'] # Build the endpoint's os ObjectMap from the first host # data we see. if not os_om_flag: os_om_flag = True yield self.objectmap_endpoint_os(event['snapshot']) elif event['class'] == 'host_metrics': host_oms.append(om) elif event['class'] == 'host_cpu': host_ref = event['snapshot']['host'] host_cpu_oms[host_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pbd': host_ref = event['snapshot']['host'] pbd_oms[host_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pif': host_ref = event['snapshot']['host'] pif_oms[host_ref].append(om) # Save metric -> pif mapping for pif_metrics events. pif_metrics_ref = event['snapshot']['metrics'] self.backrefs[pif_metrics_ref] = ( event['ref'], event['snapshot']['host']) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pif_metrics': host_ref = self.backrefs[event['ref']][1] pif_oms[host_ref].append(om) elif event['class'] == 'network': network_oms.append(om) elif event['class'] == 'vm': vm_oms.append(om) # Initialize contained objmap lists. vbd_oms.setdefault(event['ref'], []) vif_oms.setdefault(event['ref'], []) # Save metric -> vm mapping for vm_metrics events. vm_metrics_ref = event['snapshot']['metrics'] self.backrefs[vm_metrics_ref] = event['ref'] elif event['class'] == 'vm_metrics': vm_oms.append(om) elif event['class'] == 'vbd': vm_ref = event['snapshot']['VM'] vbd_oms[vm_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = vm_ref elif event['class'] == 'vif': vm_ref = event['snapshot']['VM'] vif_oms[vm_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = vm_ref elif event['class'] == 'vm_appliance': vm_appliance_oms.append(om) elif event['class'] == 'pool': pool_oms.append(om) yield RelationshipMap( relname='srs', modname=MODULE_NAME['SR'], objmaps=sr_oms) for parent_ref, objmaps in vdi_oms.iteritems(): yield RelationshipMap( compname='srs/{}'.format(id_from_ref(parent_ref)), relname='vdis', modname=MODULE_NAME['VDI'], objmaps=objmaps) yield RelationshipMap( relname='hosts', modname=MODULE_NAME['Host'], objmaps=merge_objectmaps(host_oms)) for parent_ref, objmaps in host_cpu_oms.iteritems(): yield RelationshipMap( compname='hosts/{}'.format(id_from_ref(parent_ref)), relname='hostcpus', modname=MODULE_NAME['HostCPU'], objmaps=objmaps) for parent_ref, objmaps in pbd_oms.iteritems(): yield RelationshipMap( compname='hosts/{}'.format(id_from_ref(parent_ref)), relname='pbds', modname=MODULE_NAME['PBD'], objmaps=objmaps) for parent_ref, objmaps in pif_oms.iteritems(): yield RelationshipMap( compname='hosts/{}'.format(id_from_ref(parent_ref)), relname='pifs', modname=MODULE_NAME['PIF'], objmaps=merge_objectmaps(objmaps)) yield RelationshipMap( relname='networks', modname=MODULE_NAME['Network'], objmaps=network_oms) yield RelationshipMap( relname='vms', modname=MODULE_NAME['VM'], objmaps=merge_objectmaps(vm_oms)) for parent_ref, objmaps in vbd_oms.iteritems(): yield RelationshipMap( compname='vms/{}'.format(id_from_ref(parent_ref)), relname='vbds', modname=MODULE_NAME['VBD'], objmaps=objmaps) for parent_ref, objmaps in vif_oms.iteritems(): yield RelationshipMap( compname='vms/{}'.format(id_from_ref(parent_ref)), relname='vifs', modname=MODULE_NAME['VIF'], objmaps=objmaps) yield RelationshipMap( relname='vmappliances', modname=MODULE_NAME['VMAppliance'], objmaps=vm_appliance_oms) yield RelationshipMap( relname='pools', modname=MODULE_NAME['Pool'], objmaps=pool_oms)
def full_datamaps(self, events): ''' Return a list of datamaps representing a full model. ''' sr_oms = [] vdi_oms = defaultdict(list) host_oms = [] host_cpu_oms = defaultdict(list) pbd_oms = defaultdict(list) pif_oms = defaultdict(list) network_oms = [] vm_oms = [] vbd_oms = defaultdict(list) vif_oms = defaultdict(list) vm_appliance_oms = [] pool_oms = [] # Used to prevent yielding multiple endpoint.os ObjectMaps. os_om_flag = False for event in events: if event['operation'] == 'del': # There should be no delete events in a full model. continue om = self.get_objectmap(event) if not om: continue if event['class'] == 'sr': sr_oms.append(om) # Initialize contained objmap lists. vdi_oms.setdefault(event['ref'], []) elif event['class'] == 'vdi': sr_ref = event['snapshot']['SR'] vdi_oms[sr_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = sr_ref elif event['class'] == 'host': host_oms.append(om) # Initialize contained objmap lists. host_cpu_oms.setdefault(event['ref'], []) pbd_oms.setdefault(event['ref'], []) pif_oms.setdefault(event['ref'], []) # Save metric -> host mapping for host_metrics events. host_metrics_ref = event['snapshot']['metrics'] self.backrefs[host_metrics_ref] = event['ref'] # Build the endpoint's os ObjectMap from the first host # data we see. if not os_om_flag: os_om_flag = True yield self.objectmap_endpoint_os(event['snapshot']) elif event['class'] == 'host_metrics': host_oms.append(om) elif event['class'] == 'host_cpu': host_ref = event['snapshot']['host'] host_cpu_oms[host_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pbd': host_ref = event['snapshot']['host'] pbd_oms[host_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pif': host_ref = event['snapshot']['host'] pif_oms[host_ref].append(om) # Save metric -> pif mapping for pif_metrics events. pif_metrics_ref = event['snapshot']['metrics'] self.backrefs[pif_metrics_ref] = (event['ref'], event['snapshot']['host']) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = host_ref elif event['class'] == 'pif_metrics': host_ref = self.backrefs[event['ref']][1] pif_oms[host_ref].append(om) elif event['class'] == 'network': network_oms.append(om) elif event['class'] == 'vm': vm_oms.append(om) # Initialize contained objmap lists. vbd_oms.setdefault(event['ref'], []) vif_oms.setdefault(event['ref'], []) # Save metric -> vm mapping for vm_metrics events. vm_metrics_ref = event['snapshot']['metrics'] self.backrefs[vm_metrics_ref] = event['ref'] elif event['class'] == 'vm_metrics': vm_oms.append(om) elif event['class'] == 'vbd': vm_ref = event['snapshot']['VM'] vbd_oms[vm_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = vm_ref elif event['class'] == 'vif': vm_ref = event['snapshot']['VM'] vif_oms[vm_ref].append(om) # Need to track this to handle subcomponent deletion. self.parentrefs[event['ref']] = vm_ref elif event['class'] == 'vm_appliance': vm_appliance_oms.append(om) elif event['class'] == 'pool': pool_oms.append(om) yield RelationshipMap(relname='srs', modname=MODULE_NAME['SR'], objmaps=sr_oms) for parent_ref, objmaps in vdi_oms.iteritems(): yield RelationshipMap(compname='srs/{}'.format( id_from_ref(parent_ref)), relname='vdis', modname=MODULE_NAME['VDI'], objmaps=objmaps) yield RelationshipMap(relname='hosts', modname=MODULE_NAME['Host'], objmaps=merge_objectmaps(host_oms)) for parent_ref, objmaps in host_cpu_oms.iteritems(): yield RelationshipMap(compname='hosts/{}'.format( id_from_ref(parent_ref)), relname='hostcpus', modname=MODULE_NAME['HostCPU'], objmaps=objmaps) for parent_ref, objmaps in pbd_oms.iteritems(): yield RelationshipMap(compname='hosts/{}'.format( id_from_ref(parent_ref)), relname='pbds', modname=MODULE_NAME['PBD'], objmaps=objmaps) for parent_ref, objmaps in pif_oms.iteritems(): yield RelationshipMap(compname='hosts/{}'.format( id_from_ref(parent_ref)), relname='pifs', modname=MODULE_NAME['PIF'], objmaps=merge_objectmaps(objmaps)) yield RelationshipMap(relname='networks', modname=MODULE_NAME['Network'], objmaps=network_oms) yield RelationshipMap(relname='vms', modname=MODULE_NAME['VM'], objmaps=merge_objectmaps(vm_oms)) for parent_ref, objmaps in vbd_oms.iteritems(): yield RelationshipMap(compname='vms/{}'.format( id_from_ref(parent_ref)), relname='vbds', modname=MODULE_NAME['VBD'], objmaps=objmaps) for parent_ref, objmaps in vif_oms.iteritems(): yield RelationshipMap(compname='vms/{}'.format( id_from_ref(parent_ref)), relname='vifs', modname=MODULE_NAME['VIF'], objmaps=objmaps) yield RelationshipMap(relname='vmappliances', modname=MODULE_NAME['VMAppliance'], objmaps=vm_appliance_oms) yield RelationshipMap(relname='pools', modname=MODULE_NAME['Pool'], objmaps=pool_oms)