Ejemplo n.º 1
0
func deleteServer(t *testing.T, client *gophercloud.ServiceClient, server *os.Server) {
	t.Logf("> servers.Delete")

	res := servers.Delete(client, server.ID)
	th.AssertNoErr(t, res.Err)

	t.Logf("Server deleted successfully.")
}
Ejemplo n.º 2
0
Archivo: delete.go Proyecto: flazz/rack
func (command *commandDelete) Execute(resource *handler.Resource) {
	serverID := resource.Params.(*paramsDelete).server
	err := servers.Delete(command.Ctx.ServiceClient, serverID).ExtractErr()
	if err != nil {
		resource.Err = err
		return
	}
	resource.Result = fmt.Sprintf("Deleting instance [%s]\n", serverID)
}
Ejemplo n.º 3
0
func (sdk *RackspaceSDK) DeleteInstanceById(id string) {
	instance, exist := sdk.ListAllInstance()[id]
	if exist {
		servers.Delete(sdk.p, instance.Id)
	}
	for {
		_, exist := sdk.ListAllInstance()[id]
		if !exist {
			break
		}
		time.Sleep(time.Second)
	}
}
Ejemplo n.º 4
0
func TestAttachVolume(t *testing.T) {
	choices, err := optionsFromEnv()
	if err != nil {
		t.Fatal(err)
	}

	computeClient, err := newClient()
	if err != nil {
		t.Fatalf("Unable to create a compute client: %v", err)
	}

	blockClient, err := newBlockClient(t)
	if err != nil {
		t.Fatalf("Unable to create a blockstorage client: %v", err)
	}

	server, err := createVAServer(t, computeClient, choices)
	if err != nil {
		t.Fatalf("Unable to create server: %v", err)
	}
	defer func() {
		servers.Delete(computeClient, server.ID)
		t.Logf("Server deleted.")
	}()

	if err = osServers.WaitForStatus(computeClient, server.ID, "ACTIVE", 300); err != nil {
		t.Fatalf("Unable to wait for server: %v", err)
	}

	volume, err := createVAVolume(t, blockClient)
	if err != nil {
		t.Fatalf("Unable to create volume: %v", err)
	}
	defer func() {
		err = volumes.Delete(blockClient, volume.ID).ExtractErr()
		th.AssertNoErr(t, err)
		t.Logf("Volume deleted.")
	}()

	createVolumeAttachment(t, computeClient, blockClient, server.ID, volume.ID)

}