Rev 24: goose: use lowercase constants in http://bazaar.launchpad.net/+branch/goose
John Arbash Meinel
john at arbash-meinel.com
Wed Nov 28 15:47:20 UTC 2012
At http://bazaar.launchpad.net/+branch/goose
------------------------------------------------------------
revno: 24 [merge]
revision-id: john at arbash-meinel.com-20121128154707-bke77gqkmrzesh11
parent: john at arbash-meinel.com-20121126111139-42s7ravmctpscybu
parent: john at arbash-meinel.com-20121128085657-fwulxyl5p2pkzecd
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: goose
timestamp: Wed 2012-11-28 15:47:07 +0000
message:
goose: use lowercase constants
[r=dimitern] Switch from OS_API_* constants to api* constants for go consistency.
modified:
client/client.go client.go-20121113091937-s07to3f8enhoq025-2
nova/nova.go nova.go-20121123004313-uzljzxlhw5mgo47l-1
-------------- next part --------------
=== modified file 'client/client.go'
--- a/client/client.go 2012-11-23 03:05:16 +0000
+++ b/client/client.go 2012-11-28 08:56:57 +0000
@@ -10,7 +10,7 @@
)
const (
- OS_API_TOKENS = "/tokens"
+ apiTokens = "/tokens"
GET = "GET"
POST = "POST"
@@ -41,7 +41,7 @@
func NewOpenStackClient(creds *identity.Credentials, auth_method identity.AuthMethod) *OpenStackClient {
client := OpenStackClient{creds: creds}
- client.creds.URL = client.creds.URL + OS_API_TOKENS
+ client.creds.URL = client.creds.URL + apiTokens
switch auth_method {
default:
panic(fmt.Errorf("Invalid identity authorisation method: %d", auth_method))
=== modified file 'nova/nova.go'
--- a/nova/nova.go 2012-11-23 03:05:16 +0000
+++ b/nova/nova.go 2012-11-28 08:56:57 +0000
@@ -9,13 +9,13 @@
)
const (
- OS_API_FLAVORS = "/flavors"
- OS_API_FLAVORS_DETAIL = "/flavors/detail"
- OS_API_SERVERS = "/servers"
- OS_API_SERVERS_DETAIL = "/servers/detail"
- OS_API_SECURITY_GROUPS = "/os-security-groups"
- OS_API_SECURITY_GROUP_RULES = "/os-security-group-rules"
- OS_API_FLOATING_IPS = "/os-floating-ips"
+ apiFlavors = "/flavors"
+ apiFlavorsDetail = "/flavors/detail"
+ apiServers = "/servers"
+ apiServersDetail = "/servers/detail"
+ apiSecurityGroups = "/os-security-groups"
+ apiSecurityGroupRules = "/os-security-group-rules"
+ apiFloatingIPs = "/os-floating-ips"
)
// Provide access to the OpenStack Compute service.
@@ -92,7 +92,7 @@
Flavors []Entity
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.GET, "compute", OS_API_FLAVORS, &requestData, "failed to get list of flavors")
+ err = n.client.SendRequest(client.GET, "compute", apiFlavors, &requestData, "failed to get list of flavors")
return resp.Flavors, err
}
@@ -111,7 +111,7 @@
Flavors []FlavorDetail
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.GET, "compute", OS_API_FLAVORS_DETAIL, &requestData,
+ err = n.client.SendRequest(client.GET, "compute", apiFlavorsDetail, &requestData,
"failed to get list of flavors details")
return resp.Flavors, err
}
@@ -122,7 +122,7 @@
Servers []Entity
}
requestData := goosehttp.RequestData{RespValue: &resp, ExpectedStatus: []int{http.StatusOK}}
- err = n.client.SendRequest(client.GET, "compute", OS_API_SERVERS, &requestData,
+ err = n.client.SendRequest(client.GET, "compute", apiServers, &requestData,
"failed to get list of servers")
return resp.Servers, err
}
@@ -150,7 +150,7 @@
Servers []ServerDetail
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.GET, "compute", OS_API_SERVERS_DETAIL, &requestData,
+ err = n.client.SendRequest(client.GET, "compute", apiServersDetail, &requestData,
"failed to get list of servers details")
return resp.Servers, err
}
@@ -160,7 +160,7 @@
var resp struct {
Server ServerDetail
}
- url := fmt.Sprintf("%s/%s", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s", apiServers, serverId)
requestData := goosehttp.RequestData{RespValue: &resp}
err := n.client.SendRequest(client.GET, "compute", url, &requestData,
"failed to get details for serverId=%s", serverId)
@@ -172,7 +172,7 @@
var resp struct {
Server ServerDetail
}
- url := fmt.Sprintf("%s/%s", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s", apiServers, serverId)
requestData := goosehttp.RequestData{RespValue: &resp, ExpectedStatus: []int{http.StatusNoContent}}
err = n.client.SendRequest(client.DELETE, "compute", url, &requestData,
"failed to delete server with serverId=%s", serverId)
@@ -201,7 +201,7 @@
req.Server.UserData = &encoded
}
requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
- err = n.client.SendRequest(client.POST, "compute", OS_API_SERVERS, &requestData,
+ err = n.client.SendRequest(client.POST, "compute", apiServers, &requestData,
"failed to run a server with %#v", opts)
return
}
@@ -230,7 +230,7 @@
Groups []SecurityGroup `json:"security_groups"`
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.GET, "compute", OS_API_SECURITY_GROUPS, &requestData,
+ err = n.client.SendRequest(client.GET, "compute", apiSecurityGroups, &requestData,
"failed to list security groups")
return resp.Groups, err
}
@@ -240,7 +240,7 @@
var resp struct {
Groups []SecurityGroup `json:"security_groups"`
}
- url := fmt.Sprintf("%s/%s/%s", OS_API_SERVERS, serverId, OS_API_SECURITY_GROUPS)
+ url := fmt.Sprintf("%s/%s/%s", apiServers, serverId, apiSecurityGroups)
requestData := goosehttp.RequestData{RespValue: &resp}
err = n.client.SendRequest(client.GET, "compute", url, &requestData,
"failed to list server (%s) security groups", serverId)
@@ -262,14 +262,14 @@
SecurityGroup SecurityGroup `json:"security_group"`
}
requestData := goosehttp.RequestData{ReqValue: req, RespValue: &resp, ExpectedStatus: []int{http.StatusOK}}
- err = n.client.SendRequest(client.POST, "compute", OS_API_SECURITY_GROUPS, &requestData,
+ err = n.client.SendRequest(client.POST, "compute", apiSecurityGroups, &requestData,
"failed to create a security group with name=%s", name)
return resp.SecurityGroup, err
}
func (n *OpenStackNovaProvider) DeleteSecurityGroup(groupId int) (err error) {
- url := fmt.Sprintf("%s/%d", OS_API_SECURITY_GROUPS, groupId)
+ url := fmt.Sprintf("%s/%d", apiSecurityGroups, groupId)
requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.DELETE, "compute", url, &requestData,
"failed to delete a security group with id=%d", groupId)
@@ -297,14 +297,14 @@
}
requestData := goosehttp.RequestData{ReqValue: req, RespValue: &resp}
- err = n.client.SendRequest(client.POST, "compute", OS_API_SECURITY_GROUP_RULES, &requestData,
+ err = n.client.SendRequest(client.POST, "compute", apiSecurityGroupRules, &requestData,
"failed to create a rule for the security group with id=%s", ruleInfo.GroupId)
return resp.SecurityGroupRule, err
}
func (n *OpenStackNovaProvider) DeleteSecurityGroupRule(ruleId int) (err error) {
- url := fmt.Sprintf("%s/%d", OS_API_SECURITY_GROUP_RULES, ruleId)
+ url := fmt.Sprintf("%s/%d", apiSecurityGroupRules, ruleId)
requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.DELETE, "compute", url, &requestData,
"failed to delete a security group rule with id=%d", ruleId)
@@ -320,7 +320,7 @@
}
req.AddSecurityGroup.Name = groupName
- url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s/action", apiServers, serverId)
requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.POST, "compute", url, &requestData,
"failed to add security group '%s' from server with id=%s", groupName, serverId)
@@ -336,7 +336,7 @@
}
req.RemoveSecurityGroup.Name = groupName
- url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s/action", apiServers, serverId)
requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.POST, "compute", url, &requestData,
"failed to remove security group '%s' from server with id=%s", groupName, serverId)
@@ -358,7 +358,7 @@
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.GET, "compute", OS_API_FLOATING_IPS, &requestData,
+ err = n.client.SendRequest(client.GET, "compute", apiFloatingIPs, &requestData,
"failed to list floating ips")
return resp.FloatingIPs, err
}
@@ -369,7 +369,7 @@
FloatingIP FloatingIP `json:"floating_ip"`
}
- url := fmt.Sprintf("%s/%d", OS_API_FLOATING_IPS, ipId)
+ url := fmt.Sprintf("%s/%d", apiFloatingIPs, ipId)
requestData := goosehttp.RequestData{RespValue: &resp}
err = n.client.SendRequest(client.GET, "compute", url, &requestData,
"failed to get floating ip %d details", ipId)
@@ -383,14 +383,14 @@
}
requestData := goosehttp.RequestData{RespValue: &resp}
- err = n.client.SendRequest(client.POST, "compute", OS_API_FLOATING_IPS, &requestData,
+ err = n.client.SendRequest(client.POST, "compute", apiFloatingIPs, &requestData,
"failed to allocate a floating ip")
return resp.FloatingIP, err
}
func (n *OpenStackNovaProvider) DeleteFloatingIP(ipId int) (err error) {
- url := fmt.Sprintf("%s/%d", OS_API_FLOATING_IPS, ipId)
+ url := fmt.Sprintf("%s/%d", apiFloatingIPs, ipId)
requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.DELETE, "compute", url, &requestData,
"failed to delete floating ip %d details", ipId)
@@ -406,7 +406,7 @@
}
req.AddFloatingIP.Address = address
- url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s/action", apiServers, serverId)
requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.POST, "compute", url, &requestData,
"failed to add floating ip %s to server %s", address, serverId)
@@ -422,7 +422,7 @@
}
req.RemoveFloatingIP.Address = address
- url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
+ url := fmt.Sprintf("%s/%s/action", apiServers, serverId)
requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
err = n.client.SendRequest(client.POST, "compute", url, &requestData,
"failed to remove floating ip %s to server %s", address, serverId)
More information about the bazaar-commits
mailing list