Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(83)

Delta Between Two Patch Sets: nova/nova.go

Issue 6875052: Add filtering to ListServers APIs (Closed)
Left Patch Set: Created 12 years, 3 months ago
Right Patch Set: Add filtering to ListServers APIs Created 12 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « http/client.go ('k') | nova/nova_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // The nova package provides a way to access the OpenStack Compute APIs. 1 // The nova package provides a way to access the OpenStack Compute APIs.
2 // See http://docs.openstack.org/api/openstack-compute/2/content/. 2 // See http://docs.openstack.org/api/openstack-compute/2/content/.
3 package nova 3 package nova
4 4
5 import ( 5 import (
6 "encoding/base64" 6 "encoding/base64"
7 "fmt" 7 "fmt"
8 "launchpad.net/goose/client" 8 "launchpad.net/goose/client"
9 goosehttp "launchpad.net/goose/http" 9 goosehttp "launchpad.net/goose/http"
10 "net/http" 10 "net/http"
11 "net/url" 11 "net/url"
12 ) 12 )
13 13
14 const ( 14 const (
15 apiFlavors = "/flavors" 15 apiFlavors = "/flavors"
16 apiFlavorsDetail = "/flavors/detail" 16 apiFlavorsDetail = "/flavors/detail"
17 apiServers = "/servers" 17 apiServers = "/servers"
18 apiServersDetail = "/servers/detail" 18 apiServersDetail = "/servers/detail"
19 apiSecurityGroups = "/os-security-groups" 19 apiSecurityGroups = "/os-security-groups"
20 apiSecurityGroupRules = "/os-security-group-rules" 20 apiSecurityGroupRules = "/os-security-group-rules"
21 apiFloatingIPs = "/os-floating-ips" 21 apiFloatingIPs = "/os-floating-ips"
22 ) 22 )
23 23
24 const ( 24 const (
jameinel 2012/12/04 13:01:45 I wonder if these should be typed as well as group
wallyworld 2012/12/05 00:46:41 I considered it but then filter.Add(key, value) wo
25 // Server status values. 25 // Server status values.
26 StatusActive = "ACTIVE" // The server is active. 26 StatusActive = "ACTIVE" // The server is active.
27 StatusBuild = "BUILD" // The server has not finished the original build process. 27 StatusBuild = "BUILD" // The server has not finished the original build process.
28 StatusDeleted = "DELETED" // The server is deleted. 28 StatusDeleted = "DELETED" // The server is deleted.
29 StatusError = "ERROR" // The server is in error. 29 StatusError = "ERROR" // The server is in error.
30 StatusHardReboot = "HARD_REBOOT" // The server is hard rebooting. 30 StatusHardReboot = "HARD_REBOOT" // The server is hard rebooting.
31 StatusPassword = "PASSWORD" // The password is being reset on t he server. 31 StatusPassword = "PASSWORD" // The password is being reset on t he server.
32 StatusReboot = "REBOOT" // The server is in a soft reboot s tate. 32 StatusReboot = "REBOOT" // The server is in a soft reboot s tate.
33 StatusRebuild = "REBUILD" // The server is currently being re built from an image. 33 StatusRebuild = "REBUILD" // The server is currently being re built from an image.
34 StatusRescue = "RESCUE" // The server is in rescue mode. 34 StatusRescue = "RESCUE" // The server is in rescue mode.
(...skipping 24 matching lines...) Expand all
59 return &Client{client} 59 return &Client{client}
60 } 60 }
61 61
62 // ---------------------------------------------------------------------------- 62 // ----------------------------------------------------------------------------
63 // Filtering helper. 63 // Filtering helper.
64 64
65 // Filter builds filtering parameters to be used in an OpenStack query which sup ports 65 // Filter builds filtering parameters to be used in an OpenStack query which sup ports
66 // filtering. For example: 66 // filtering. For example:
67 // 67 //
68 // filter := NewFilter() 68 // filter := NewFilter()
69 // filter.Add("name", "server_name") 69 // filter.Add(nova.FilterServer, "server_name")
70 // filter.Add("status", "ACTIVE") 70 // filter.Add(nova.FilterStatus, nova.StatusBuild)
71 // resp, err := nova.ListServers(filter) 71 // resp, err := nova.ListServers(filter)
jameinel 2012/12/04 13:01:45 Maybe it wouldn't help, as we don't have "filter.A
wallyworld 2012/12/05 00:46:41 Add is used for all sorts of filter keys: status,
72 // 72 //
73 type Filter struct { 73 type Filter struct {
74 url.Values 74 url.Values
75 } 75 }
76 76
77 // NewFilter creates a new Filter. 77 // NewFilter creates a new Filter.
78 func NewFilter() *Filter { 78 func NewFilter() *Filter {
79 return &Filter{make(url.Values)} 79 return &Filter{make(url.Values)}
80 } 80 }
81 81
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } `json:"removeFloatingIp"` 468 } `json:"removeFloatingIp"`
469 } 469 }
470 req.RemoveFloatingIP.Address = address 470 req.RemoveFloatingIP.Address = address
471 471
472 url := fmt.Sprintf("%s/%s/action", apiServers, serverId) 472 url := fmt.Sprintf("%s/%s/action", apiServers, serverId)
473 requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []in t{http.StatusAccepted}} 473 requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []in t{http.StatusAccepted}}
474 err := c.client.SendRequest(client.POST, "compute", url, &requestData, 474 err := c.client.SendRequest(client.POST, "compute", url, &requestData,
475 "failed to remove floating ip %s to server %s", address, serverI d) 475 "failed to remove floating ip %s to server %s", address, serverI d)
476 return err 476 return err
477 } 477 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b