//--------------------------------------------------------------------- // Loading. //--------------------------------------------------------------------- public async static Task <InstanceDetailsModel> LoadAsync( InstanceLocator instanceLocator, IComputeEngineAdapter computeEngineAdapter, IInventoryService inventoryService, CancellationToken token) { var instance = await computeEngineAdapter .GetInstanceAsync( instanceLocator, token) .ConfigureAwait(false); var project = await computeEngineAdapter .GetProjectAsync( instanceLocator.ProjectId, token) .ConfigureAwait(false); var osInfo = await inventoryService.GetInstanceInventoryAsync( instanceLocator, token) .ConfigureAwait(false); return(new InstanceDetailsModel( project, instance, osInfo)); }
public async static Task <InstancePropertiesInspectorModel> LoadAsync( InstanceLocator instanceLocator, IComputeEngineAdapter computeEngineAdapter, IInventoryService inventoryService, CancellationToken token) { var instance = await computeEngineAdapter .GetInstanceAsync( instanceLocator, token) .ConfigureAwait(false); var project = await computeEngineAdapter .GetProjectAsync( instanceLocator.ProjectId, token) .ConfigureAwait(false); // // Reading OS inventory data can fail because of a // `compute.disableGuestAttributesAccess` constraint. // GuestOsInfo osInfo; try { osInfo = await inventoryService.GetInstanceInventoryAsync( instanceLocator, token) .ConfigureAwait(false); } catch (Exception e) when(e.Unwrap() is GoogleApiException apiEx && apiEx.IsConstraintViolation()) { TraceSources.IapDesktop.TraceWarning( "Failed to load OS inventory data: {0}", e); // Proceed with empty data. osInfo = null; } return(new InstancePropertiesInspectorModel( project, instance, osInfo)); } }