예제 #1
0
func getServer(t *testing.T, client *gophercloud.ServiceClient, server *os.Server) {
	t.Logf("> servers.Get")

	details, err := servers.Get(client, server.ID).Extract()
	th.AssertNoErr(t, err)
	logServer(t, details, -1)
}
예제 #2
0
파일: get.go 프로젝트: flazz/rack
func (command *commandGet) Execute(resource *handler.Resource) {
	serverID := resource.Params.(*paramsGet).server
	server, err := servers.Get(command.Context().ServiceClient, serverID).Extract()
	if err != nil {
		resource.Err = err
		return
	}
	resource.Result = serverSingle(server)
}
예제 #3
0
func (sdk *RackspaceSDK) getInstance(id string) (s *OpenStackServers.Server) {
	for i := 0; i < 12; i++ {
		var err error
		s, err = servers.Get(sdk.p, id).Extract()
		if err != nil {
			fmt.Println("RackspaceSDK getInstance", err)
			time.Sleep(time.Second)
			continue
		}
	}
	return s
}
예제 #4
0
파일: details.go 프로젝트: rackeric/erack
// print details of cloud servers instance to stdout
func Details(c *cli.Context) {
	// assign vars from cli args
	user := c.String("user")
	key := c.String("key")
	region := c.String("region")
	// server create specific options
	// check both options and arguments for server uuid
	serverid := c.Args().First()
	if c.String("uuid") != "" {
		serverid = 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.NewComputeV2(provider, gophercloud.EndpointOpts{
		Region: region,
	})
	if err2 != nil {
		fmt.Println(err2)
	}

	// get cloud server
	s, id := servers.Get(serviceClient, serverid).Extract()
	fmt.Println("Name: ", s.Name)
	fmt.Println("UUID: ", s.ID)
	fmt.Println("Created: ", s.Created)
	fmt.Println("Updated: ", s.Updated)
	fmt.Println("Progress: ", s.Progress)
	fmt.Println("HostID: ", s.HostID)
	fmt.Println("Image: ", s.Image["id"])
	fmt.Println("Flavor ID: ", s.Flavor["id"])
	fmt.Println("Status: ", s.Status)
	fmt.Println("Access: ", s.AccessIPv4)
	fmt.Println("Public: ", s.Addresses["public"])
	fmt.Println("Addresses: ", s.Addresses)
	if id != nil {
		fmt.Println(id)
	}
}
예제 #5
0
func probeNodeAddress(compute *gophercloud.ServiceClient, name string) (string, error) {
	id, err := readInstanceID()
	if err == nil {
		srv, err := servers.Get(compute, id).Extract()
		if err != nil {
			return "", err
		}
		return getAddressByServer(srv)
	}

	ip, err := getAddressByName(compute, name)
	if err != nil {
		return "", err
	}

	return ip, nil
}