def get_computer_system(uuid): """Get the Redfish Computer System for a given UUID. Return ComputerSystem redfish JSON for a given server profile or server profile template UUID. Returns: JSON: Redfish json with ComputerSystem When Server hardware or Server profilte templates is not found calls abort(404) """ resource = _get_oneview_resource(uuid) category = resource["category"] if category == 'server-profile-templates': computer_system_resource = CapabilitiesObject(resource) elif category == 'server-profiles': server_hardware = g.oneview_client.server_hardware\ .get_by_uri(resource["serverHardwareUri"]).data server_hardware_type = g.oneview_client.server_hardware_types\ .get_by_uri(resource['serverHardwareTypeUri']).data computer_system_service = ComputerSystemService(g.oneview_client) drives = _get_drives_from_sp(resource) spt_uuid = computer_system_service.\ get_server_profile_template_from_sp(resource["uri"]) # Get external storage volumes from server profile volumes_uris = [ volume["volumeUri"] for volume in resource["sanStorage"]["volumeAttachments"] ] # Emptying volume list to suppress external storage changes for # current release. # In future, remove this line to enable external storage support volumes_uris = [] manager_uuid = get_manager_uuid(resource['serverHardwareTypeUri']) # Build Computer System object and validates it computer_system_resource = ComputerSystem.build_composed_system( server_hardware, server_hardware_type, resource, drives, spt_uuid, manager_uuid, volumes_uris) else: abort(status.HTTP_404_NOT_FOUND, 'Computer System UUID {} not found'.format(uuid)) return ResponseBuilder.success(computer_system_resource, {"ETag": "W/" + resource["eTag"]})
def get_chassis(uuid): """Get the Redfish Chassis. Get method to return Chassis JSON when /redfish/v1/Chassis/id is requested. Returns: JSON: JSON with Chassis. """ category = '' cached_category = category_resource.get_category_by_resource_id(uuid) if cached_category: category = cached_category.resource.replace('_', '-') else: resource_index = g.oneview_client.index_resources.get_all( filter='uuid=' + uuid ) if not resource_index: abort(status.HTTP_404_NOT_FOUND, "Chassis {} not found".format(uuid)) category = resource_index[0]["category"] manager_uuid = get_manager_uuid(uuid) if category == 'server-hardware': server_hardware = g.oneview_client.server_hardware.get(uuid) etag = server_hardware['eTag'] ch = BladeChassis(server_hardware, manager_uuid) elif category == 'enclosures': enclosure = g.oneview_client.enclosures.get(uuid) etag = enclosure['eTag'] enclosure_environment_config = g.oneview_client.enclosures. \ get_environmental_configuration(uuid) ch = EnclosureChassis( enclosure, enclosure_environment_config, manager_uuid ) elif category == 'racks': racks = g.oneview_client.racks.get(uuid) etag = racks['eTag'] ch = RackChassis(racks) return ResponseBuilder.success(ch, {"ETag": "W/" + etag})
def get_computer_system(uuid): """Get the Redfish Computer System for a given UUID. Return ComputerSystem redfish JSON for a given server profile or server profile template UUID. Returns: JSON: Redfish json with ComputerSystem When Server hardware or Server profilte templates is not found calls abort(404) """ resource = _get_oneview_resource(uuid) category = resource["category"] if category == 'server-profile-templates': computer_system_resource = CapabilitiesObject(resource) elif category == 'server-profiles': server_hardware = g.oneview_client.server_hardware\ .get(resource["serverHardwareUri"]) server_hardware_type = g.oneview_client.server_hardware_types\ .get(resource['serverHardwareTypeUri']) computer_system_service = ComputerSystemService(g.oneview_client) drives = _get_drives_from_sp(resource) spt_uuid = computer_system_service.\ get_server_profile_template_from_sp(resource["uri"]) manager_uuid = get_manager_uuid(resource['serverHardwareTypeUri']) # Build Computer System object and validates it computer_system_resource = ComputerSystem.build_composed_system( server_hardware, server_hardware_type, resource, drives, spt_uuid, manager_uuid) else: abort(status.HTTP_404_NOT_FOUND, 'Computer System UUID {} not found'.format(uuid)) return ResponseBuilder.success( computer_system_resource, {"ETag": "W/" + resource["eTag"]})
def get_resource_block_computer_system(uuid): """Get Computer System of a Resource Block Return ResourceBlock Computer System redfish JSON for a given UUID. Logs exception of any error and return Internal Server Error or Not Found. Returns: JSON: Redfish json with ResourceBlock Computer System. """ server_hardware = g.oneview_client.server_hardware.get_by_id(uuid).data manager_uuid = get_manager_uuid(uuid) computer_system = ComputerSystem.build_physical_system( server_hardware, manager_uuid) return ResponseBuilder.success(computer_system, {"ETag": "W/" + server_hardware["eTag"]})