def test_build_composed_system(self): spt_uuid = "61c3a463-1355-4c68-a4e3-4f08c322af1b" computer_system = ComputerSystem.build_composed_system( self.server_hardware, self.server_hardware_types, self.server_profile, [self.drives[4]], spt_uuid, self.manager_uuid) result = json.loads(computer_system.serialize()) self.assertEqualMockup(self.computer_system_mockup, result)
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_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 test_build_composed_system_with_external_storage(self): volume_resource_block = { "@odata.id": "/redfish/v1/CompositionService/ResourceBlocks/" "volume_uuid" } computer_system_mockup = deepcopy(self.computer_system_mockup) computer_system_mockup["Links"]["ResourceBlocks"].append( volume_resource_block) spt_uuid = "61c3a463-1355-4c68-a4e3-4f08c322af1b" volume_uri = ["/rest/storage-volumes/volume_uuid"] computer_system = ComputerSystem.build_composed_system( self.server_hardware, self.server_hardware_types, self.server_profile, [self.drives[4]], spt_uuid, self.manager_uuid, volume_uri) result = json.loads(computer_system.serialize()) self.assertEqualMockup(computer_system_mockup, result)