Ejemplo n.º 1
0
        public async Task <ImageInfo> RegisterAsync(RegisterImageRequest request)
        {
            Ensure.NotNull(request, nameof(request));

            var image = new ImageInfo(
                id: await db.Images.Sequence.NextAsync(),
                type: request.Type,
                name: request.Name,
                ownerId: request.OwnerId,
                size: request.Size,
                resource: request.Resource,
                properties: request.Properties
                );

            await db.Images.InsertAsync(image);

            return(image);
        }
Ejemplo n.º 2
0
        public async Task <ImageInfo> GetAsync(ResourceProvider provider, string resourceId)
        {
            var image = await FindAsync(provider, resourceId);

            if (image == null)
            {
                // Automatically register machine images until we can depend on the manager to register them for us before use

                var registerRequest = new RegisterImageRequest(
                    name: Guid.NewGuid().ToString("N"),
                    ownerId: ResourceProvider.Aws.Id,   // assume to be AWS for now
                    resource: new ManagedResource(provider, ResourceTypes.Image, resourceId),
                    type: ImageType.Machine
                    );

                image = await RegisterAsync(registerRequest);
            }

            return(image);
        }