Exemplo n.º 1
0
func (lobster *Lobster) mapImage(apiImage *api.Image, details *api.ImageDetails) *compute.Image {
	image := &compute.Image{
		ID:      strconv.Itoa(apiImage.Id),
		Name:    apiImage.Name,
		Regions: []string{apiImage.Region},
	}

	if apiImage.Status == "active" {
		image.Status = compute.ImageAvailable
	} else if apiImage.Status == "pending" {
		image.Status = compute.ImagePending
	} else {
		if details != nil {
			image.Status = compute.ImageStatus(details.Status)
		} else {
			image.Status = compute.ImageStatus(apiImage.Status)
		}
	}

	if details != nil {
		image.Size = details.Size
	}

	return image
}
Exemplo n.º 2
0
func (gc *GoogleCompute) mapImage(apiImage *gcompute.Image, region string) *compute.Image {
	image := &compute.Image{
		ID:   apiImage.SelfLink,
		Name: apiImage.Name,
		Size: apiImage.DiskSizeGb * 1024 * 1024 * 1024,
	}

	if apiImage.Status == "READY" {
		image.Status = compute.ImageAvailable
	} else if apiImage.Status == "PENDING" {
		image.Status = compute.ImagePending
	} else {
		image.Status = compute.ImageStatus(strings.ToLower(apiImage.Status))
	}

	return image
}