func (this *OpenStack) ImageInfo(imageIdentification string) (*lobster.ImageInfo, error) { osImage, err := image.Get(this.ImageClient, imageIdentification).Extract() if err != nil { return nil, err } image := new(lobster.ImageInfo) image.Size, _ = strconv.ParseInt(osImage.Size, 10, 64) if osImage.Status == "active" { image.Status = lobster.ImageActive } else if osImage.Status == "error" || osImage.Status == "killed" { image.Status = lobster.ImageError } else { image.Status = lobster.ImagePending } return image, nil }
func (cloug *Cloug) ImageInfo(imageIdentification string) (*lobster.ImageInfo, error) { if cloug.imageService == nil { return nil, fmt.Errorf("operation not supported") } image, err := cloug.imageService.GetImage(imageIdentification) if err != nil { return nil, err } info := lobster.ImageInfo{ Size: image.Size, Details: image.Details, } if image.Status == compute.ImageAvailable { info.Status = lobster.ImageActive } else if image.Status == compute.ImagePending { info.Status = lobster.ImagePending } return &info, nil }
func (this *Lobster) ImageInfo(imageIdentification string) (*lobster.ImageInfo, error) { imageIdentificationInt, _ := strconv.Atoi(imageIdentification) apiInfoResponse, err := this.client.ImageInfo(imageIdentificationInt) if err != nil { return nil, err } apiInfo := apiInfoResponse.Details info := lobster.ImageInfo{ Size: apiInfo.Size, Details: apiInfo.Details, } if apiInfo.Status == "pending" { info.Status = lobster.ImagePending } else if apiInfo.Status == "active" { info.Status = lobster.ImageActive } else if apiInfo.Status == "error" { info.Status = lobster.ImageError } return &info, nil }