Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // goose/nova - Go package to interact with OpenStack Compute (Nova) API. | 1 // goose/nova - Go package to interact with OpenStack Compute (Nova) API. |
2 // See http://docs.openstack.org/api/openstack-compute/2/content/. | 2 // See http://docs.openstack.org/api/openstack-compute/2/content/. |
3 | 3 |
4 package nova | 4 package nova |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "launchpad.net/goose/client" | 8 "launchpad.net/goose/client" |
9 "launchpad.net/goose/errors" | 9 "launchpad.net/goose/errors" |
10 goosehttp "launchpad.net/goose/http" | 10 goosehttp "launchpad.net/goose/http" |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 Name string `json:"zoneName"` | 676 Name string `json:"zoneName"` |
677 State AvailabilityZoneState `json:"zoneState"` | 677 State AvailabilityZoneState `json:"zoneState"` |
678 } | 678 } |
679 | 679 |
680 // AvailabilityZoneState describes an availability zone's state. | 680 // AvailabilityZoneState describes an availability zone's state. |
681 type AvailabilityZoneState struct { | 681 type AvailabilityZoneState struct { |
682 Available bool | 682 Available bool |
683 } | 683 } |
684 | 684 |
685 // ListAvailabilityZones lists all availability zones. | 685 // ListAvailabilityZones lists all availability zones. |
686 // | |
687 // Availability zones are an OpenStack extension; if the server does not | |
688 // support them, then an error satisfying errors.IsNotImplemented will be | |
689 // returned. | |
686 func (c *Client) ListAvailabilityZones() ([]AvailabilityZone, error) { | 690 func (c *Client) ListAvailabilityZones() ([]AvailabilityZone, error) { |
687 var resp struct { | 691 var resp struct { |
688 AvailabilityZoneInfo []AvailabilityZone | 692 AvailabilityZoneInfo []AvailabilityZone |
689 } | 693 } |
690 requestData := goosehttp.RequestData{RespValue: &resp} | 694 requestData := goosehttp.RequestData{RespValue: &resp} |
691 err := c.client.SendRequest(client.GET, "compute", apiAvailabilityZone, &requestData) | 695 err := c.client.SendRequest(client.GET, "compute", apiAvailabilityZone, &requestData) |
692 if errors.IsNotFound(err) { | 696 if errors.IsNotFound(err) { |
693 // Availability zones are an extension, so don't | 697 // Availability zones are an extension, so don't |
694 // return an error if the API does not exist. | 698 // return an error if the API does not exist. |
695 » » return nil, nil | 699 » » return nil, errors.NewNotImplementedf( |
gz
2014/06/07 17:13:03
I'd prefer we return a specific error that can be
axw
2014/06/09 01:37:27
I think you're right, and I'd prefer to get the AP
| |
700 » » » err, nil, "the server does not support availability zone s", | |
701 » » ) | |
696 } | 702 } |
697 if err != nil { | 703 if err != nil { |
698 return nil, errors.Newf(err, "failed to get list of availability zones") | 704 return nil, errors.Newf(err, "failed to get list of availability zones") |
699 } | 705 } |
700 return resp.AvailabilityZoneInfo, nil | 706 return resp.AvailabilityZoneInfo, nil |
701 } | 707 } |
LEFT | RIGHT |