Пример #1
0
func (command *commandCreate) Execute(resource *handler.Resource) {
	opts := resource.Params.(*paramsCreate).opts
	snapshot, err := osSnapshots.Create(command.Ctx.ServiceClient, opts).Extract()
	if err != nil {
		resource.Err = err
		return
	}
	resource.Result = snapshotSingle(snapshot)
}
Пример #2
0
func (command *commandCreate) Execute(resource *handler.Resource) {
	opts := resource.Params.(*paramsCreate).opts
	snapshot, err := osSnapshots.Create(command.Ctx.ServiceClient, opts).Extract()
	if err != nil {
		resource.Err = err
		return
	}

	if resource.Params.(*paramsCreate).wait {
		err = osSnapshots.WaitForStatus(command.Ctx.ServiceClient, snapshot.ID, "available", 600)
		if err != nil {
			resource.Err = err
			return
		}

		snapshot, err = osSnapshots.Get(command.Ctx.ServiceClient, snapshot.ID).Extract()
		if err != nil {
			resource.Err = err
			return
		}
	}

	resource.Result = snapshotSingle(snapshot)
}
Пример #3
0
// Create will create a new Snapshot based on the values in CreateOpts. To
// extract the Snapshot object from the response, call the Extract method on the
// CreateResult.
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
	return CreateResult{os.Create(client, opts)}
}