Update Lego (Gandi API v5, cloudxns, ...)
This commit is contained in:
parent
dd873fbeee
commit
7d3dd5a0e4
43 changed files with 4112 additions and 1238 deletions
176
vendor/github.com/exoscale/egoscale/topology.go
generated
vendored
176
vendor/github.com/exoscale/egoscale/topology.go
generated
vendored
|
@ -1,186 +1,163 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetSecurityGroups returns all security groups
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetSecurityGroups() (map[string]SecurityGroup, error) {
|
||||
var sgs map[string]SecurityGroup
|
||||
params := url.Values{}
|
||||
resp, err := exo.Request("listSecurityGroups", params)
|
||||
|
||||
resp, err := exo.Request(&ListSecurityGroups{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r ListSecurityGroupsResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sgs = make(map[string]SecurityGroup)
|
||||
for _, sg := range r.SecurityGroups {
|
||||
sgs[sg.Name] = *sg
|
||||
for _, sg := range resp.(*ListSecurityGroupsResponse).SecurityGroup {
|
||||
sgs[sg.Name] = sg
|
||||
}
|
||||
return sgs, nil
|
||||
}
|
||||
|
||||
func (exo *Client) GetSecurityGroupId(name string) (string, error) {
|
||||
params := url.Values{}
|
||||
resp, err := exo.Request("listSecurityGroups", params)
|
||||
// GetSecurityGroupID returns security group by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetSecurityGroupID(name string) (string, error) {
|
||||
resp, err := exo.Request(&ListSecurityGroups{SecurityGroupName: name})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var r ListSecurityGroupsResponse
|
||||
err = json.Unmarshal(resp, &r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, sg := range r.SecurityGroups {
|
||||
for _, sg := range resp.(*ListSecurityGroupsResponse).SecurityGroup {
|
||||
if sg.Name == name {
|
||||
return sg.Id, nil
|
||||
return sg.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (exo *Client) GetZones() (map[string]string, error) {
|
||||
// GetAllZones returns all the zone id by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetAllZones() (map[string]string, error) {
|
||||
var zones map[string]string
|
||||
params := url.Values{}
|
||||
resp, err := exo.Request("listZones", params)
|
||||
|
||||
resp, err := exo.Request(&ListZones{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r ListZonesResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
return zones, err
|
||||
}
|
||||
|
||||
zones = make(map[string]string)
|
||||
for _, zone := range r.Zones {
|
||||
zones[zone.Name] = zone.Id
|
||||
for _, zone := range resp.(*ListZonesResponse).Zone {
|
||||
zones[strings.ToLower(zone.Name)] = zone.ID
|
||||
}
|
||||
return zones, nil
|
||||
}
|
||||
|
||||
// GetProfiles returns a mapping of the service offerings by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetProfiles() (map[string]string, error) {
|
||||
|
||||
var profiles map[string]string
|
||||
params := url.Values{}
|
||||
resp, err := exo.Request("listServiceOfferings", params)
|
||||
|
||||
profiles := make(map[string]string)
|
||||
resp, err := exo.Request(&ListServiceOfferings{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
var r ListServiceOfferingsResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
profiles = make(map[string]string)
|
||||
for _, offering := range r.ServiceOfferings {
|
||||
profiles[strings.ToLower(offering.Name)] = offering.Id
|
||||
for _, offering := range resp.(*ListServiceOfferingsResponse).ServiceOffering {
|
||||
profiles[strings.ToLower(offering.Name)] = offering.ID
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
// GetKeypairs returns the list of SSH keyPairs
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetKeypairs() ([]SSHKeyPair, error) {
|
||||
params := url.Values{}
|
||||
|
||||
resp, err := exo.Request("listSSHKeyPairs", params)
|
||||
var keypairs []SSHKeyPair
|
||||
|
||||
resp, err := exo.Request(&ListSSHKeyPairs{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return keypairs, err
|
||||
}
|
||||
|
||||
var r ListSSHKeyPairsResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var keypairs = make([]SSHKeyPair, r.Count, r.Count)
|
||||
for i, keypair := range r.SSHKeyPairs {
|
||||
keypairs[i] = *keypair
|
||||
r := resp.(*ListSSHKeyPairsResponse)
|
||||
keypairs = make([]SSHKeyPair, r.Count)
|
||||
for i, keypair := range r.SSHKeyPair {
|
||||
keypairs[i] = keypair
|
||||
}
|
||||
return keypairs, nil
|
||||
}
|
||||
|
||||
// GetAffinityGroups returns a mapping of the (anti-)affinity groups
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetAffinityGroups() (map[string]string, error) {
|
||||
var affinitygroups map[string]string
|
||||
params := url.Values{}
|
||||
|
||||
resp, err := exo.Request("listAffinityGroups", params)
|
||||
|
||||
resp, err := exo.Request(&ListAffinityGroups{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r ListAffinityGroupsResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
return affinitygroups, err
|
||||
}
|
||||
|
||||
affinitygroups = make(map[string]string)
|
||||
for _, affinitygroup := range r.AffinityGroups {
|
||||
affinitygroups[affinitygroup.Name] = affinitygroup.Id
|
||||
for _, affinitygroup := range resp.(*ListAffinityGroupsResponse).AffinityGroup {
|
||||
affinitygroups[affinitygroup.Name] = affinitygroup.ID
|
||||
}
|
||||
return affinitygroups, nil
|
||||
|
||||
}
|
||||
|
||||
func (exo *Client) GetImages() (map[string]map[int]string, error) {
|
||||
var images map[string]map[int]string
|
||||
images = make(map[string]map[int]string)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("templatefilter", "featured")
|
||||
|
||||
resp, err := exo.Request("listTemplates", params)
|
||||
// GetImages list the available featured images and group them by name, then size.
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetImages() (map[string]map[int64]string, error) {
|
||||
var images map[string]map[int64]string
|
||||
images = make(map[string]map[int64]string)
|
||||
re := regexp.MustCompile(`^Linux (?P<name>.+?) (?P<version>[0-9.]+)\b`)
|
||||
|
||||
resp, err := exo.Request(&ListTemplates{
|
||||
TemplateFilter: "featured",
|
||||
ZoneID: "1", // XXX: Hack to list only CH-GVA
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return images, err
|
||||
}
|
||||
|
||||
var r ListTemplatesResponse
|
||||
if err := json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, template := range resp.(*ListTemplatesResponse).Template {
|
||||
size := int64(template.Size >> 30) // B to GiB
|
||||
|
||||
fullname := strings.ToLower(template.Name)
|
||||
|
||||
if _, present := images[fullname]; !present {
|
||||
images[fullname] = make(map[int64]string)
|
||||
}
|
||||
images[fullname][size] = template.ID
|
||||
|
||||
re := regexp.MustCompile(`^Linux (?P<name>.+?) (?P<version>[0-9.]+).*$`)
|
||||
for _, template := range r.Templates {
|
||||
size := int(template.Size / (1024 * 1024 * 1024))
|
||||
submatch := re.FindStringSubmatch(template.Name)
|
||||
if len(submatch) > 0 {
|
||||
name := strings.Replace(strings.ToLower(submatch[1]), " ", "-", -1)
|
||||
version := submatch[2]
|
||||
image := fmt.Sprintf("%s-%s", name, version)
|
||||
|
||||
_, present := images[image]
|
||||
if !present {
|
||||
images[image] = make(map[int]string)
|
||||
if _, present := images[image]; !present {
|
||||
images[image] = make(map[int64]string)
|
||||
}
|
||||
images[image][size] = template.Id
|
||||
|
||||
images[fmt.Sprintf("%s-%s", name, version)][size] = template.Id
|
||||
images[image][size] = template.ID
|
||||
}
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
// GetTopology returns an big, yet incomplete view of the world
|
||||
//
|
||||
// Deprecated: will go away in the future
|
||||
func (exo *Client) GetTopology() (*Topology, error) {
|
||||
|
||||
zones, err := exo.GetZones()
|
||||
zones, err := exo.GetAllZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -194,7 +171,7 @@ func (exo *Client) GetTopology() (*Topology, error) {
|
|||
}
|
||||
groups := make(map[string]string)
|
||||
for k, v := range securityGroups {
|
||||
groups[k] = v.Id
|
||||
groups[k] = v.ID
|
||||
}
|
||||
|
||||
keypairs, err := exo.GetKeypairs()
|
||||
|
@ -212,6 +189,7 @@ func (exo *Client) GetTopology() (*Topology, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
profiles, err := exo.GetProfiles()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -219,9 +197,9 @@ func (exo *Client) GetTopology() (*Topology, error) {
|
|||
|
||||
topo := &Topology{
|
||||
Zones: zones,
|
||||
Profiles: profiles,
|
||||
Images: images,
|
||||
Keypairs: keynames,
|
||||
Profiles: profiles,
|
||||
AffinityGroups: affinitygroups,
|
||||
SecurityGroups: groups,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue