本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/compute/v2/servers.ConfirmResize函数的典型用法代码示例。如果您正苦于以下问题:Golang ConfirmResize函数的具体用法?Golang ConfirmResize怎么用?Golang ConfirmResize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConfirmResize函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestActionResizeConfirm
func TestActionResizeConfirm(t *testing.T) {
t.Parallel()
choices, err := ComputeChoicesFromEnv()
if err != nil {
t.Fatal(err)
}
client, err := newClient()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
server, err := createServer(t, client, choices)
if err != nil {
t.Fatal(err)
}
defer servers.Delete(client, server.ID)
resizeServer(t, client, server, choices)
t.Logf("Attempting to confirm resize for server %s", server.ID)
if res := servers.ConfirmResize(client, server.ID); res.Err != nil {
t.Fatal(err)
}
if err = waitForStatus(client, server, "ACTIVE"); err != nil {
t.Fatal(err)
}
}
示例2: resourceComputeInstanceV2Update
//.........这里部分代码省略.........
log.Printf("[DEBUG] Attempting to disassociate %s from %s", oldFIP, d.Id())
if err := disassociateFloatingIPFromInstance(computeClient, oldFIP, d.Id(), oldFixedIP); err != nil {
return fmt.Errorf("Error disassociating Floating IP during update: %s", err)
}
log.Printf("[DEBUG] Attempting to associate %s to %s", newFIP, d.Id())
if err := associateFloatingIPToInstance(computeClient, newFIP, d.Id(), newFixedIP); err != nil {
return fmt.Errorf("Error associating Floating IP during update: %s", err)
}
}
}
}
if d.HasChange("volume") {
// ensure the volume configuration is correct
if err := checkVolumeConfig(d); err != nil {
return err
}
// old attachments and new attachments
oldAttachments, newAttachments := d.GetChange("volume")
// for each old attachment, detach the volume
oldAttachmentSet := oldAttachments.(*schema.Set).List()
if blockClient, err := config.blockStorageV1Client(d.Get("region").(string)); err != nil {
return err
} else {
if err := detachVolumesFromInstance(computeClient, blockClient, d.Id(), oldAttachmentSet); err != nil {
return err
}
}
// for each new attachment, attach the volume
newAttachmentSet := newAttachments.(*schema.Set).List()
if blockClient, err := config.blockStorageV1Client(d.Get("region").(string)); err != nil {
return err
} else {
if err := attachVolumesToInstance(computeClient, blockClient, d.Id(), newAttachmentSet); err != nil {
return err
}
}
d.SetPartial("volume")
}
if d.HasChange("flavor_id") || d.HasChange("flavor_name") {
flavorId, err := getFlavorID(computeClient, d)
if err != nil {
return err
}
resizeOpts := &servers.ResizeOpts{
FlavorRef: flavorId,
}
log.Printf("[DEBUG] Resize configuration: %#v", resizeOpts)
err = servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr()
if err != nil {
return fmt.Errorf("Error resizing OpenStack server: %s", err)
}
// Wait for the instance to finish resizing.
log.Printf("[DEBUG] Waiting for instance (%s) to finish resizing", d.Id())
stateConf := &resource.StateChangeConf{
Pending: []string{"RESIZE"},
Target: []string{"VERIFY_RESIZE"},
Refresh: ServerV2StateRefreshFunc(computeClient, d.Id()),
Timeout: 3 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
_, err = stateConf.WaitForState()
if err != nil {
return fmt.Errorf("Error waiting for instance (%s) to resize: %s", d.Id(), err)
}
// Confirm resize.
log.Printf("[DEBUG] Confirming resize")
err = servers.ConfirmResize(computeClient, d.Id()).ExtractErr()
if err != nil {
return fmt.Errorf("Error confirming resize of OpenStack server: %s", err)
}
stateConf = &resource.StateChangeConf{
Pending: []string{"VERIFY_RESIZE"},
Target: []string{"ACTIVE"},
Refresh: ServerV2StateRefreshFunc(computeClient, d.Id()),
Timeout: 3 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
_, err = stateConf.WaitForState()
if err != nil {
return fmt.Errorf("Error waiting for instance (%s) to confirm resize: %s", d.Id(), err)
}
}
return resourceComputeInstanceV2Read(d, meta)
}
示例3: ConfirmResize
// ConfirmResize confirms a previous resize operation on a server.
// See Resize() for more details.
func ConfirmResize(client *gophercloud.ServiceClient, id string) os.ActionResult {
return os.ConfirmResize(client, id)
}