client/lxd_images.go
func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (RemoteOperation, error) {
	// Sanity checks
	if r == source {
		return nil, fmt.Errorf("The source and target servers must be different")
	}

	// Get source server connection information
	info, err := source.GetConnectionInfo()
	if err != nil {
		return nil, err
	}

	// Prepare the copy request
	req := api.ImagesPost{
		Source: &api.ImagesPostSource{
			ImageSource: api.ImageSource{
				Certificate: info.Certificate,
				Protocol:    info.Protocol,
			},
			Fingerprint: image.Fingerprint,
			Mode:        "pull",
			Type:        "image",
		},
	}

	// Generate secret token if needed
	if !image.Public {
		secret, err := source.GetImageSecret(image.Fingerprint)
		if err != nil {
			return nil, err
		}

		req.Source.Secret = secret
	}

	// Process the arguments
	if args != nil {
		req.Aliases = args.Aliases
		req.AutoUpdate = args.AutoUpdate
		req.Public = args.Public

		if args.CopyAliases {
			req.Aliases = image.Aliases
			if args.Aliases != nil {
				req.Aliases = append(req.Aliases, args.Aliases...)
			}
		}
	}

	return r.tryCopyImage(req, info.Addresses)
}
func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (RemoteOperation, error) {
	// Sanity checks
	if r == source {
		return nil, fmt.Errorf("The source and target servers must be different")
	}

	// Get source server connection information
	info, err := source.GetConnectionInfo()
	if err != nil {
		return nil, err
	}

	// Prepare the copy request
	req := api.ImagesPost{
		Source: &api.ImagesPostSource{
			ImageSource: api.ImageSource{
				Certificate: info.Certificate,
				Protocol:    info.Protocol,
			},
			Fingerprint: image.Fingerprint,
			Mode:        "pull",
			Type:        "image",
		},
	}

	// Generate secret token if needed
	if !image.Public {
		secret, err := source.GetImageSecret(image.Fingerprint)
		if err != nil {
			return nil, err
		}

		req.Source.Secret = secret
	}

	// Process the arguments
	if args != nil {
		req.Aliases = args.Aliases
		req.AutoUpdate = args.AutoUpdate
		req.Public = args.Public

		if args.CopyAliases {
			req.Aliases = image.Aliases
			if args.Aliases != nil {
				req.Aliases = append(req.Aliases, args.Aliases...)
			}
		}
	}

	return r.tryCopyImage(req, info.Addresses)
}
func ( r * ProtocolLXD ) CopyImage ( source ImageServer , image api . Image , args * ImageCopyArgs ) ( RemoteOperation , error ) { // Sanity checks if r == source { return nil , fmt . Errorf ( " " ) } // Get source server connection information info , err := source . GetConnectionInfo ( ) if err != nil { return nil , err } // Prepare the copy request req := api . ImagesPost { Source : & api . ImagesPostSource { ImageSource : api . ImageSource { Certificate : info . Certificate , Protocol : info . Protocol , } , Fingerprint : image . Fingerprint , Mode : " " , Type : " " , } , } // Generate secret token if needed if ! image . Public { secret , err := source . GetImageSecret ( image . Fingerprint ) if err != nil { return nil , err } req . Source . Secret = secret } // Process the arguments if args != nil { req . Aliases = args . Aliases req . AutoUpdate = args . AutoUpdate req . Public = args . Public if args . CopyAliases { req . Aliases = image . Aliases if args . Aliases != nil { req . Aliases = append ( req . Aliases , args . Aliases ... ) } } } return r . tryCopyImage ( req , info . Addresses ) }
// CopyImage copies an image from a remote server. Additional options can be passed using ImageCopyArgs
CopyImage copies an image from a remote server . Additional options can be passed using ImageCopyArgs