Beispiel #1
0
// delete a cloud block storage snapshots from volume uuid
func Delete(c *cli.Context) {
	// assign vars from cli args
	user := c.String("user")
	key := c.String("key")
	region := c.String("region")
	volumeId := c.Args().First()
	if c.String("uuid") != "" {
		volumeId = c.String("uuid")
	}

	// step 1, set up auth options
	ao := gophercloud.AuthOptions{
		Username: user,
		APIKey:   key,
	}
	// step 2, rax auth to get back provider instance
	provider, err := rackspace.AuthenticatedClient(ao)
	if err != nil {
		fmt.Println(err)
	}

	// set rax region
	serviceClient, err2 := rackspace.NewBlockStorageV1(provider, gophercloud.EndpointOpts{
		Region: region,
	})
	if err2 != nil {
		fmt.Println(err2)
	}

	// delete snapshot from uuid
	err3 := snapshots.Delete(serviceClient, volumeId).ExtractErr()
	if err3 != nil {
		fmt.Println(err3)
	}
}
Beispiel #2
0
func testSnapshotDelete(t *testing.T, client *gophercloud.ServiceClient, id string) {
	res := snapshots.Delete(client, id)
	th.AssertNoErr(t, res.Err)
	t.Logf("Deleted snapshot %s", id)
}