Ejemplo n.º 1
0
// print list of cloud block storage volumes to stdout
func Show(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) }

    v, err3 := volumes.Get(serviceClient, volumeId).Extract()
    if err3 != nil { fmt.Println(err3) }
    fmt.Println("Name: ", v.Name)
    fmt.Println("ID: ", v.ID)
    fmt.Println("Size: ", v.Size)
    fmt.Println("Status: ", v.Status)
    fmt.Println("Type: ", v.VolumeType)
    fmt.Println("Created: ", v.CreatedAt)
}
Ejemplo n.º 2
0
func testVolumeGet(t *testing.T, client *gophercloud.ServiceClient, id string) {
	vol, err := volumes.Get(client, id).Extract()
	th.AssertNoErr(t, err)
	t.Logf("Created volume: ID [%s] Size [%s]", vol.ID, vol.Size)
}