Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1203,11 +1203,12 @@ $ scw inspect myserver | jq '.[0].public_ip.address'

### master (unreleased)

* API: Add ZoneID field in server location
* `scw image -a -f type=volume` fix unmarshal error on size field
* `scw ps` do not display empty server with --filter

### v1.10.1 (2016-10-24)

* `scw image -a -f type=volume` fix unmarshal error on size field
* `scw login` fix CheckCredentials ([418](https://github.com/scaleway/scaleway-cli/issues/418))

View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v1.10...v1.10.1)
Expand Down
39 changes: 20 additions & 19 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ type ScalewayServer struct {
Hypervisor string `json:"hypervisor_id,omitempty"`
Blade string `json:"blade_id,omitempty"`
Node string `json:"node_id,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
} `json:"location,omitempty"`

IPV6 *ScalewayIPV6Definition `json:"ipv6,omitempty"`
Expand Down Expand Up @@ -1128,10 +1129,10 @@ func (s *ScalewayAPI) GetServers(all bool, limit int) (*[]ScalewayServer, error)
return nil, err
}
for i, server := range servers.Servers {
// FIXME region, arch, owner, title
// FIXME arch, owner, title
servers.Servers[i].DNSPublic = server.Identifier + URLPublicDNS
servers.Servers[i].DNSPrivate = server.Identifier + URLPrivateDNS
s.Cache.InsertServer(server.Identifier, "fr-1", server.Arch, server.Organization, server.Name)
s.Cache.InsertServer(server.Identifier, server.Location.ZoneID, server.Arch, server.Organization, server.Name)
}
// FIXME: when API limit is ready, remove the following code
if limit > 0 && limit < len(servers.Servers) {
Expand Down Expand Up @@ -1177,10 +1178,10 @@ func (s *ScalewayAPI) GetServer(serverID string) (*ScalewayServer, error) {
if err = json.Unmarshal(body, &oneServer); err != nil {
return nil, err
}
// FIXME region, arch, owner, title
// FIXME arch, owner, title
oneServer.Server.DNSPublic = oneServer.Server.Identifier + URLPublicDNS
oneServer.Server.DNSPrivate = oneServer.Server.Identifier + URLPrivateDNS
s.Cache.InsertServer(oneServer.Server.Identifier, "fr-1", oneServer.Server.Arch, oneServer.Server.Organization, oneServer.Server.Name)
s.Cache.InsertServer(oneServer.Server.Identifier, oneServer.Server.Location.ZoneID, oneServer.Server.Arch, oneServer.Server.Organization, oneServer.Server.Name)
return &oneServer.Server, nil
}

Expand Down Expand Up @@ -1239,8 +1240,8 @@ func (s *ScalewayAPI) PostServer(definition ScalewayServerDefinition) (string, e
if err = json.Unmarshal(body, &server); err != nil {
return "", err
}
// FIXME region, arch, owner, title
s.Cache.InsertServer(server.Server.Identifier, "fr-1", server.Server.Arch, server.Server.Organization, server.Server.Name)
// FIXME arch, owner, title
s.Cache.InsertServer(server.Server.Identifier, server.Server.Location.ZoneID, server.Server.Arch, server.Server.Organization, server.Server.Name)
return server.Server.Identifier, nil
}

Expand Down Expand Up @@ -1299,8 +1300,8 @@ func (s *ScalewayAPI) PostSnapshot(volumeID string, name string) (string, error)
if err = json.Unmarshal(body, &snapshot); err != nil {
return "", err
}
// FIXME region, arch, owner, title
s.Cache.InsertSnapshot(snapshot.Snapshot.Identifier, "fr-1", "", snapshot.Snapshot.Organization, snapshot.Snapshot.Name)
// FIXME arch, owner, title
s.Cache.InsertSnapshot(snapshot.Snapshot.Identifier, "", "", snapshot.Snapshot.Organization, snapshot.Snapshot.Name)
return snapshot.Snapshot.Identifier, nil
}

Expand Down Expand Up @@ -1334,7 +1335,7 @@ func (s *ScalewayAPI) PostImage(volumeID string, name string, bootscript string,
return "", err
}
// FIXME region, arch, owner, title
s.Cache.InsertImage(image.Image.Identifier, "fr-1", image.Image.Arch, image.Image.Organization, image.Image.Name, "")
s.Cache.InsertImage(image.Image.Identifier, "", image.Image.Arch, image.Image.Organization, image.Image.Name, "")
return image.Image.Identifier, nil
}

Expand Down Expand Up @@ -1491,7 +1492,7 @@ func (s *ScalewayAPI) GetImages() (*[]MarketImage, error) {
return nil, err
}
for _, orgaImage := range OrgaImages.Images {
s.Cache.InsertImage(orgaImage.Identifier, "fr-1", orgaImage.Arch, orgaImage.Organization, orgaImage.Name, "")
s.Cache.InsertImage(orgaImage.Identifier, "", orgaImage.Arch, orgaImage.Organization, orgaImage.Name, "")
images.Images = append(images.Images, MarketImage{
Categories: []string{"MyImages"},
CreationDate: orgaImage.CreationDate,
Expand All @@ -1510,7 +1511,7 @@ func (s *ScalewayAPI) GetImages() (*[]MarketImage, error) {
{
Arch: orgaImage.Arch,
ID: orgaImage.Identifier,
Zone: "fr-1",
Zone: "",
},
},
},
Expand Down Expand Up @@ -1542,7 +1543,7 @@ func (s *ScalewayAPI) GetImage(imageID string) (*ScalewayImage, error) {
return nil, err
}
// FIXME region, arch, owner, title
s.Cache.InsertImage(oneImage.Image.Identifier, "fr-1", oneImage.Image.Arch, oneImage.Image.Organization, oneImage.Image.Name, "")
s.Cache.InsertImage(oneImage.Image.Identifier, "", oneImage.Image.Arch, oneImage.Image.Organization, oneImage.Image.Name, "")
return &oneImage.Image, nil
}

Expand Down Expand Up @@ -1621,7 +1622,7 @@ func (s *ScalewayAPI) GetSnapshots() (*[]ScalewaySnapshot, error) {
}
for _, snapshot := range snapshots.Snapshots {
// FIXME region, arch, owner, title
s.Cache.InsertSnapshot(snapshot.Identifier, "fr-1", "", snapshot.Organization, snapshot.Name)
s.Cache.InsertSnapshot(snapshot.Identifier, "", "", snapshot.Organization, snapshot.Name)
}
return &snapshots.Snapshots, nil
}
Expand All @@ -1646,7 +1647,7 @@ func (s *ScalewayAPI) GetSnapshot(snapshotID string) (*ScalewaySnapshot, error)
return nil, err
}
// FIXME region, arch, owner, title
s.Cache.InsertSnapshot(oneSnapshot.Snapshot.Identifier, "fr-1", "", oneSnapshot.Snapshot.Organization, oneSnapshot.Snapshot.Name)
s.Cache.InsertSnapshot(oneSnapshot.Snapshot.Identifier, "", "", oneSnapshot.Snapshot.Organization, oneSnapshot.Snapshot.Name)
return &oneSnapshot.Snapshot, nil
}

Expand Down Expand Up @@ -1675,7 +1676,7 @@ func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error) {
}
for _, volume := range volumes.Volumes {
// FIXME region, arch, owner, title
s.Cache.InsertVolume(volume.Identifier, "fr-1", "", volume.Organization, volume.Name)
s.Cache.InsertVolume(volume.Identifier, "", "", volume.Organization, volume.Name)
}
return &volumes.Volumes, nil
}
Expand All @@ -1700,7 +1701,7 @@ func (s *ScalewayAPI) GetVolume(volumeID string) (*ScalewayVolume, error) {
return nil, err
}
// FIXME region, arch, owner, title
s.Cache.InsertVolume(oneVolume.Volume.Identifier, "fr-1", "", oneVolume.Volume.Organization, oneVolume.Volume.Name)
s.Cache.InsertVolume(oneVolume.Volume.Identifier, "", "", oneVolume.Volume.Organization, oneVolume.Volume.Name)
return &oneVolume.Volume, nil
}

Expand Down Expand Up @@ -1728,7 +1729,7 @@ func (s *ScalewayAPI) GetBootscripts() (*[]ScalewayBootscript, error) {
}
for _, bootscript := range bootscripts.Bootscripts {
// FIXME region, arch, owner, title
s.Cache.InsertBootscript(bootscript.Identifier, "fr-1", bootscript.Arch, bootscript.Organization, bootscript.Title)
s.Cache.InsertBootscript(bootscript.Identifier, "", bootscript.Arch, bootscript.Organization, bootscript.Title)
}
return &bootscripts.Bootscripts, nil
}
Expand All @@ -1753,7 +1754,7 @@ func (s *ScalewayAPI) GetBootscript(bootscriptID string) (*ScalewayBootscript, e
return nil, err
}
// FIXME region, arch, owner, title
s.Cache.InsertBootscript(oneBootscript.Bootscript.Identifier, "fr-1", oneBootscript.Bootscript.Arch, oneBootscript.Bootscript.Organization, oneBootscript.Bootscript.Title)
s.Cache.InsertBootscript(oneBootscript.Bootscript.Identifier, "", oneBootscript.Bootscript.Arch, oneBootscript.Bootscript.Organization, oneBootscript.Bootscript.Title)
return &oneBootscript.Bootscript, nil
}

Expand Down Expand Up @@ -2153,7 +2154,7 @@ func (s *ScalewayAPI) GetImageID(needle, arch string) (*ScalewayImageIdentifier,
Identifier: images[0].Identifier,
Arch: images[0].Arch,
// FIXME region, owner hardcoded
Region: "fr-1",
Region: "",
Owner: "",
}, nil
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func RunPs(ctx CommandContext, args PsArgs) error {

for key, value := range args.Filters {
switch key {
case "state", "name", "tags", "image", "ip", "arch", "server-type":
case "state", "name", "tags", "image", "ip", "arch", "server-type", "zone":
continue
default:
logrus.Warnf("Unknown filter: '%s=%s'", key, value)
Expand Down Expand Up @@ -97,6 +97,10 @@ func RunPs(ctx CommandContext, args PsArgs) error {
if value != server.CommercialType {
goto skipServer
}
case "zone":
if value != server.Location.ZoneID {
goto skipServer
}
}
}
filtered = append(filtered, server)
Expand All @@ -106,7 +110,7 @@ func RunPs(ctx CommandContext, args PsArgs) error {
w := tabwriter.NewWriter(ctx.Stdout, 20, 1, 3, ' ', 0)
defer w.Flush()
if !args.Quiet {
fmt.Fprintf(w, "SERVER ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tPORTS\tNAME\tCOMMERCIAL TYPE\n")
fmt.Fprintf(w, "SERVER ID\tIMAGE\tZONE\tCREATED\tSTATUS\tPORTS\tNAME\tCOMMERCIAL TYPE\n")
}
sort.Sort(api.ScalewaySortServers(filtered))
for i, server := range filtered {
Expand All @@ -122,7 +126,7 @@ func RunPs(ctx CommandContext, args PsArgs) error {
creationTime, _ := time.Parse("2006-01-02T15:04:05.000000+00:00", server.CreationDate)
shortCreationDate := units.HumanDuration(time.Now().UTC().Sub(creationTime))
port := server.PublicAddress.IP
fmt.Fprintf(w, "%s\t%s\t\t%s\t%s\t%s\t%s\t%s\n", shortID, shortImage, shortCreationDate, server.State, port, shortName, server.CommercialType)
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", shortID, shortImage, server.Location.ZoneID, shortCreationDate, server.State, port, shortName, server.CommercialType)
}
}
return nil
Expand Down