mirror of https://github.com/docker/docs.git
godep/exoscale: update egoscale
Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
This commit is contained in:
parent
1f4502e3e0
commit
b35ad0d322
|
@ -132,7 +132,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/pyr/egoscale/src/egoscale",
|
"ImportPath": "github.com/pyr/egoscale/src/egoscale",
|
||||||
"Rev": "8bdfe1d0420634bdd37d73d00d51f86f8d08e481"
|
"Rev": "5759f42eb6041d8dbf837a642e6c061c2bb62f47"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/tent/http-link-go",
|
"ImportPath": "github.com/tent/http-link-go",
|
||||||
|
|
|
@ -2,8 +2,8 @@ package egoscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (exo *Client) CreateEgressRule(rule SecurityGroupRule) (*AuthorizeSecurityGroupEgressResponse, error) {
|
func (exo *Client) CreateEgressRule(rule SecurityGroupRule) (*AuthorizeSecurityGroupEgressResponse, error) {
|
||||||
|
@ -16,7 +16,7 @@ func (exo *Client) CreateEgressRule(rule SecurityGroupRule) (*AuthorizeSecurityG
|
||||||
if rule.Protocol == "ICMP" {
|
if rule.Protocol == "ICMP" {
|
||||||
params.Set("icmpcode", fmt.Sprintf("%d", rule.IcmpCode))
|
params.Set("icmpcode", fmt.Sprintf("%d", rule.IcmpCode))
|
||||||
params.Set("icmptype", fmt.Sprintf("%d", rule.IcmpType))
|
params.Set("icmptype", fmt.Sprintf("%d", rule.IcmpType))
|
||||||
} else if (rule.Protocol == "TCP" || rule.Protocol == "UDP") {
|
} else if rule.Protocol == "TCP" || rule.Protocol == "UDP" {
|
||||||
params.Set("startport", fmt.Sprintf("%d", rule.Port))
|
params.Set("startport", fmt.Sprintf("%d", rule.Port))
|
||||||
params.Set("endport", fmt.Sprintf("%d", rule.Port))
|
params.Set("endport", fmt.Sprintf("%d", rule.Port))
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,7 +46,7 @@ func (exo *Client) CreateIngressRule(rule SecurityGroupRule) (*AuthorizeSecurity
|
||||||
if rule.Protocol == "ICMP" {
|
if rule.Protocol == "ICMP" {
|
||||||
params.Set("icmpcode", fmt.Sprintf("%d", rule.IcmpCode))
|
params.Set("icmpcode", fmt.Sprintf("%d", rule.IcmpCode))
|
||||||
params.Set("icmptype", fmt.Sprintf("%d", rule.IcmpType))
|
params.Set("icmptype", fmt.Sprintf("%d", rule.IcmpType))
|
||||||
} else if (rule.Protocol == "TCP" || rule.Protocol == "UDP") {
|
} else if rule.Protocol == "TCP" || rule.Protocol == "UDP" {
|
||||||
params.Set("startport", fmt.Sprintf("%d", rule.Port))
|
params.Set("startport", fmt.Sprintf("%d", rule.Port))
|
||||||
params.Set("endport", fmt.Sprintf("%d", rule.Port))
|
params.Set("endport", fmt.Sprintf("%d", rule.Port))
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,18 +85,18 @@ func (exo *Client) CreateSecurityGroupWithRules(name string, ingress []SecurityG
|
||||||
|
|
||||||
sgid := r.Wrapped.Id
|
sgid := r.Wrapped.Id
|
||||||
|
|
||||||
for _, erule := range(egress) {
|
for _, erule := range egress {
|
||||||
erule.SecurityGroupId = sgid
|
erule.SecurityGroupId = sgid
|
||||||
_, err = exo.CreateEgressRule(erule)
|
_, err = exo.CreateEgressRule(erule)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, inrule := range(ingress) {
|
for _, inrule := range ingress {
|
||||||
inrule.SecurityGroupId = sgid
|
inrule.SecurityGroupId = sgid
|
||||||
_, err = exo.CreateIngressRule(inrule)
|
_, err = exo.CreateIngressRule(inrule)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package egoscale
|
package egoscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClient(endpoint string, apiKey string, apiSecret string) *Client {
|
func NewClient(endpoint string, apiKey string, apiSecret string) *Client {
|
||||||
|
|
|
@ -21,3 +21,21 @@ func (exo *Client) CreateKeypair(name string) (*CreateSSHKeyPairResponse, error)
|
||||||
|
|
||||||
return &r.Wrapped, nil
|
return &r.Wrapped, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (exo *Client) DeleteKeypair(name string) (*StandardResponse, error) {
|
||||||
|
params := url.Values{}
|
||||||
|
params.Set("name", name)
|
||||||
|
|
||||||
|
resp, err := exo.Request("deleteSSHKeyPair", params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r StandardResponse
|
||||||
|
if err := json.Unmarshal(resp, &r); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &r, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package egoscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (exo *Client) GetSecurityGroups() (map[string]string, error) {
|
func (exo *Client) GetSecurityGroups() (map[string]string, error) {
|
||||||
|
@ -23,7 +23,7 @@ func (exo *Client) GetSecurityGroups() (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sgs = make(map[string]string)
|
sgs = make(map[string]string)
|
||||||
for _, sg := range(r.SecurityGroups) {
|
for _, sg := range r.SecurityGroups {
|
||||||
sgs[sg.Name] = sg.Id
|
sgs[sg.Name] = sg.Id
|
||||||
}
|
}
|
||||||
return sgs, nil
|
return sgs, nil
|
||||||
|
@ -44,7 +44,7 @@ func (exo *Client) GetZones() (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
zones = make(map[string]string)
|
zones = make(map[string]string)
|
||||||
for _, zone := range(r.Zones) {
|
for _, zone := range r.Zones {
|
||||||
zones[zone.Name] = zone.Id
|
zones[zone.Name] = zone.Id
|
||||||
}
|
}
|
||||||
return zones, nil
|
return zones, nil
|
||||||
|
@ -66,7 +66,7 @@ func (exo *Client) GetProfiles() (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
profiles = make(map[string]string)
|
profiles = make(map[string]string)
|
||||||
for _, offering := range(r.ServiceOfferings) {
|
for _, offering := range r.ServiceOfferings {
|
||||||
profiles[strings.ToLower(offering.Name)] = offering.Id
|
profiles[strings.ToLower(offering.Name)] = offering.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func (exo *Client) GetKeypairs() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
keypairs = make([]string, r.Count, r.Count)
|
keypairs = make([]string, r.Count, r.Count)
|
||||||
for i, keypair := range(r.SSHKeyPairs) {
|
for i, keypair := range r.SSHKeyPairs {
|
||||||
keypairs[i] = keypair.Name
|
keypairs[i] = keypair.Name
|
||||||
}
|
}
|
||||||
return keypairs, nil
|
return keypairs, nil
|
||||||
|
@ -115,7 +115,7 @@ func (exo *Client) GetImages() (map[string]map[int]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
re := regexp.MustCompile(`^Linux (?P<name>Ubuntu|Debian) (?P<version>[0-9.]+).*$`)
|
re := regexp.MustCompile(`^Linux (?P<name>Ubuntu|Debian) (?P<version>[0-9.]+).*$`)
|
||||||
for _, template := range(r.Templates) {
|
for _, template := range r.Templates {
|
||||||
size := template.Size / (1024 * 1024 * 1024)
|
size := template.Size / (1024 * 1024 * 1024)
|
||||||
submatch := re.FindStringSubmatch(template.Name)
|
submatch := re.FindStringSubmatch(template.Name)
|
||||||
if len(submatch) > 0 {
|
if len(submatch) > 0 {
|
||||||
|
@ -124,7 +124,7 @@ func (exo *Client) GetImages() (map[string]map[int]string, error) {
|
||||||
image := fmt.Sprintf("%s-%s", name, version)
|
image := fmt.Sprintf("%s-%s", name, version)
|
||||||
|
|
||||||
_, present := images[image]
|
_, present := images[image]
|
||||||
if (!present) {
|
if !present {
|
||||||
images[image] = make(map[int]string)
|
images[image] = make(map[int]string)
|
||||||
}
|
}
|
||||||
images[image][size] = template.Id
|
images[image][size] = template.Id
|
||||||
|
@ -138,23 +138,23 @@ func (exo *Client) GetImages() (map[string]map[int]string, error) {
|
||||||
func (exo *Client) GetTopology() (*Topology, error) {
|
func (exo *Client) GetTopology() (*Topology, error) {
|
||||||
|
|
||||||
zones, err := exo.GetZones()
|
zones, err := exo.GetZones()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
images, err := exo.GetImages()
|
images, err := exo.GetImages()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groups, err := exo.GetSecurityGroups()
|
groups, err := exo.GetSecurityGroups()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
keypairs, err := exo.GetKeypairs()
|
keypairs, err := exo.GetKeypairs()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
profiles, err := exo.GetProfiles()
|
profiles, err := exo.GetProfiles()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package egoscale
|
package egoscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -12,13 +12,17 @@ type Client struct {
|
||||||
apiSecret string
|
apiSecret string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
ErrorCode int `json:"errorcode"`
|
ErrorCode int `json:"errorcode"`
|
||||||
CSErrorCode int `json:"cserrorcode"`
|
CSErrorCode int `json:"cserrorcode"`
|
||||||
ErrorText string `json:"errortext"`
|
ErrorText string `json:"errortext"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StandardResponse struct {
|
||||||
|
Success string `json:"success"`
|
||||||
|
DisplayText string `json:"displaytext"`
|
||||||
|
}
|
||||||
|
|
||||||
type Topology struct {
|
type Topology struct {
|
||||||
Zones map[string]string
|
Zones map[string]string
|
||||||
Images map[string]map[int]string
|
Images map[string]map[int]string
|
||||||
|
@ -145,7 +149,6 @@ type SSHKeyPair struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type ListSecurityGroupsResponse struct {
|
type ListSecurityGroupsResponse struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
SecurityGroups []*SecurityGroup `json:"securitygroup"`
|
SecurityGroups []*SecurityGroup `json:"securitygroup"`
|
||||||
|
@ -218,7 +221,6 @@ type DeployVirtualMachineResponse struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
VirtualmachineIds []string `json:"virtualmachineIds,omitempty"`
|
VirtualmachineIds []string `json:"virtualmachineIds,omitempty"`
|
||||||
|
|
||||||
} `json:"affinitygroup,omitempty"`
|
} `json:"affinitygroup,omitempty"`
|
||||||
Cpunumber int `json:"cpunumber,omitempty"`
|
Cpunumber int `json:"cpunumber,omitempty"`
|
||||||
Cpuspeed int `json:"cpuspeed,omitempty"`
|
Cpuspeed int `json:"cpuspeed,omitempty"`
|
||||||
|
@ -356,7 +358,6 @@ type VirtualMachine struct {
|
||||||
Secondaryip []string `json:"secondaryip,omitempty"`
|
Secondaryip []string `json:"secondaryip,omitempty"`
|
||||||
Traffictype string `json:"traffictype,omitempty"`
|
Traffictype string `json:"traffictype,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
|
|
||||||
} `json:"nic,omitempty"`
|
} `json:"nic,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Passwordenabled bool `json:"passwordenabled,omitempty"`
|
Passwordenabled bool `json:"passwordenabled,omitempty"`
|
||||||
|
@ -377,7 +378,6 @@ type VirtualMachine struct {
|
||||||
Zonename string `json:"zonename,omitempty"`
|
Zonename string `json:"zonename,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type StartVirtualMachineResponse struct {
|
type StartVirtualMachineResponse struct {
|
||||||
JobID string `json:"jobid,omitempty"`
|
JobID string `json:"jobid,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,6 @@ type DestroyVirtualMachineResponse struct {
|
||||||
JobID string `json:"jobid,omitempty"`
|
JobID string `json:"jobid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type RebootVirtualMachineResponse struct {
|
type RebootVirtualMachineResponse struct {
|
||||||
JobID string `json:"jobid,omitempty"`
|
JobID string `json:"jobid,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -402,3 +401,7 @@ type CreateSSHKeyPairWrappedResponse struct {
|
||||||
type CreateSSHKeyPairResponse struct {
|
type CreateSSHKeyPairResponse struct {
|
||||||
Privatekey string `json:"privatekey,omitempty"`
|
Privatekey string `json:"privatekey,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteSSHKeyPairResponse struct {
|
||||||
|
Privatekey string `json:"privatekey,omitempty"`
|
||||||
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package egoscale
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (exo *Client) CreateVirtualMachine(p MachineProfile) (string, error) {
|
func (exo *Client) CreateVirtualMachine(p MachineProfile) (string, error) {
|
||||||
|
@ -140,3 +140,23 @@ func (exo *Client) GetVirtualMachine(id string) (*VirtualMachine, error) {
|
||||||
return nil, fmt.Errorf("cannot retrieve virtualmachine with id %s", id)
|
return nil, fmt.Errorf("cannot retrieve virtualmachine with id %s", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (exo *Client) ListVirtualMachines(id string) ([]*VirtualMachine, error) {
|
||||||
|
|
||||||
|
params := url.Values{}
|
||||||
|
params.Set("id", id)
|
||||||
|
|
||||||
|
resp, err := exo.Request("listVirtualMachines", params)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r ListVirtualMachinesResponse
|
||||||
|
|
||||||
|
if err := json.Unmarshal(resp, &r); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.VirtualMachines, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue