From bdc4aea18e62765cb0ea3b84dd7f25878ebd45f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 16:41:54 +0200 Subject: [PATCH 1/6] feat(vpc): add support to visualize private nic from instance get server --- internal/namespaces/instance/v1/custom_server.go | 3 +++ .../instance/v1/testdata/test-get-server-simple.golden | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index fb028fe9f1..a795c8cb99 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -131,6 +131,9 @@ func getServerResponseMarshalerFunc(i interface{}, opt *human.MarshalOpt) (strin }, { FieldName: "Volumes", Title: "Volumes", + }, { + FieldName: "Server.PrivateNics", + Title: "Private NICs", }, } diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index bb53ca3c1f..af261aa329 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -63,6 +63,9 @@ Allowed Actions: Volumes: ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION PROJECT STATE ZONE 57f887b2-f3c4-4ca3-b42e-92b797f11b61 snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 - 20 GB l_ssd few seconds ago few seconds ago 951df375-e094-4d26-97c1-ba548eeb9c42 951df375-e094-4d26-97c1-ba548eeb9c42 available fr-par-1 + +Private NICs: +ID SERVER ID PRIVATE NETWORK ID MAC ADDRESS 🟩🟩🟩 JSON STDOUT 🟩🟩🟩 { "server": { From f59cc49d2ffd27b683ddfbe2f751bd8b9b1ef1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 17:33:08 +0200 Subject: [PATCH 2/6] Fix --- .../namespaces/instance/v1/custom_server.go | 51 +++++ .../v1/testdata/test-get-server-simple.golden | 199 ++++++++---------- 2 files changed, 138 insertions(+), 112 deletions(-) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index a795c8cb99..7786f77afb 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -16,6 +16,7 @@ import ( "github.com/scaleway/scaleway-cli/internal/human" "github.com/scaleway/scaleway-cli/internal/interactive" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" + "github.com/scaleway/scaleway-sdk-go/api/vpc/v1" "github.com/scaleway/scaleway-sdk-go/logger" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -370,6 +371,56 @@ func serverGetBuilder(c *core.Command) *core.Command { } return suggestion } + + c.Interceptor = func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) { + rawResp, err := runner(ctx, argsI) + if err != nil { + return rawResp, err + } + getServerResp := rawResp.(*instance.GetServerResponse) + + client := core.ExtractClient(ctx) + vpcAPI := vpc.NewAPI(client) + + type customNICs struct { + ID string + MacAddress string + PrivateNetworkName string + PrivateNetworkID string + } + + nics := []customNICs{} + + for _, nic := range getServerResp.Server.PrivateNics { + pn, err := vpcAPI.GetPrivateNetwork(&vpc.GetPrivateNetworkRequest{ + PrivateNetworkID: nic.PrivateNetworkID, + }) + if err != nil { + return rawResp, nil + } + nics = append(nics, customNICs{ + ID: nic.ID, + PrivateNetworkID: pn.ID, + PrivateNetworkName: pn.Name, + MacAddress: nic.MacAddress, + }) + } + + return &struct { + *instance.Server + NICs []customNICs `json:"nics"` + }{ + getServerResp.Server, + nics, + }, nil + } + + c.View = &core.View{ + Sections: []*core.ViewSection{ + {FieldName: "NICs", Title: "Private NICs"}, + }, + } + return c } diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index af261aa329..4b9e6adcc9 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -1,6 +1,5 @@ 🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 🟩🟩🟩 STDOUT️ 🟩🟩🟩️ -Server: ID 441a810a-8635-4e66-9e41-32bce3aa5988 Name cli-srv-exciting-mayer Organization 951df375-e094-4d26-97c1-ba548eeb9c42 @@ -41,94 +40,31 @@ StateDetail - Arch x86_64 Zone fr-par-1 -Server Image: -ID f974feac-abae-4365-b988-8ec7d1cec10d -Name Ubuntu Bionic Beaver -Arch x86_64 -CreationDate few seconds ago -ModificationDate few seconds ago -DefaultBootscript x86_64 mainline 4.9.93 rev1 -ExtraVolumes 0 -FromServer - -Organization 51b656e3-4865-41e8-adbc-0c45bdd780db -Public true -RootVolume dd5f5c10-23b1-4c9c-8445-eb6740957c84 -State available -Project 51b656e3-4865-41e8-adbc-0c45bdd780db -Zone fr-par-1 - -Allowed Actions: -[poweron backup] - -Volumes: -ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION PROJECT STATE ZONE -57f887b2-f3c4-4ca3-b42e-92b797f11b61 snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 - 20 GB l_ssd few seconds ago few seconds ago 951df375-e094-4d26-97c1-ba548eeb9c42 951df375-e094-4d26-97c1-ba548eeb9c42 available fr-par-1 - Private NICs: -ID SERVER ID PRIVATE NETWORK ID MAC ADDRESS +ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID 🟩🟩🟩 JSON STDOUT 🟩🟩🟩 { - "server": { - "id": "441a810a-8635-4e66-9e41-32bce3aa5988", - "name": "cli-srv-exciting-mayer", - "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", - "project": "951df375-e094-4d26-97c1-ba548eeb9c42", - "allowed_actions": [ - "poweron", - "backup" - ], - "tags": [], - "commercial_type": "DEV1-S", + "id": "441a810a-8635-4e66-9e41-32bce3aa5988", + "name": "cli-srv-exciting-mayer", + "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", + "project": "951df375-e094-4d26-97c1-ba548eeb9c42", + "allowed_actions": [ + "poweron", + "backup" + ], + "tags": [], + "commercial_type": "DEV1-S", + "creation_date": "1970-01-01T00:00:00.0Z", + "dynamic_ip_required": false, + "enable_ipv6": false, + "hostname": "cli-srv-exciting-mayer", + "image": { + "id": "f974feac-abae-4365-b988-8ec7d1cec10d", + "name": "Ubuntu Bionic Beaver", + "arch": "x86_64", "creation_date": "1970-01-01T00:00:00.0Z", - "dynamic_ip_required": false, - "enable_ipv6": false, - "hostname": "cli-srv-exciting-mayer", - "image": { - "id": "f974feac-abae-4365-b988-8ec7d1cec10d", - "name": "Ubuntu Bionic Beaver", - "arch": "x86_64", - "creation_date": "1970-01-01T00:00:00.0Z", - "modification_date": "1970-01-01T00:00:00.0Z", - "default_bootscript": { - "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", - "default": false, - "dtb": "", - "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", - "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "organization": "11111111-1111-4111-8111-111111111111", - "project": "11111111-1111-4111-8111-111111111111", - "public": false, - "title": "x86_64 mainline 4.9.93 rev1", - "arch": "x86_64", - "zone": "fr-par-1" - }, - "extra_volumes": {}, - "from_server": "", - "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", - "public": true, - "root_volume": { - "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", - "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", - "size": 10000000000, - "volume_type": "l_ssd" - }, - "state": "available", - "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", - "zone": "fr-par-1" - }, - "protected": false, - "private_ip": null, - "public_ip": { - "id": "3006a180-67e0-433c-8b6a-142e202bd931", - "address": "51.158.70.223", - "dynamic": false - }, "modification_date": "1970-01-01T00:00:00.0Z", - "state": "stopped", - "location": null, - "ipv6": null, - "bootscript": { + "default_bootscript": { "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "dtb": "", @@ -142,35 +78,74 @@ ID SERVER ID PRIVATE NETWORK ID MAC ADDRESS "arch": "x86_64", "zone": "fr-par-1" }, - "boot_type": "local", - "volumes": { - "0": { - "id": "57f887b2-f3c4-4ca3-b42e-92b797f11b61", - "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", - "export_uri": "", - "size": 20000000000, - "volume_type": "l_ssd", - "creation_date": "1970-01-01T00:00:00.0Z", - "modification_date": "1970-01-01T00:00:00.0Z", - "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", - "project": "951df375-e094-4d26-97c1-ba548eeb9c42", - "server": { - "id": "441a810a-8635-4e66-9e41-32bce3aa5988", - "name": "cli-srv-exciting-mayer" - }, - "state": "available", - "zone": "fr-par-1" - } + "extra_volumes": {}, + "from_server": "", + "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "public": true, + "root_volume": { + "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", + "size": 10000000000, + "volume_type": "l_ssd" }, - "security_group": { - "id": "54e2d5f6-d79c-44cc-b19f-613699b9cc7e", - "name": "Default security group" - }, - "maintenances": [], - "state_detail": "", + "state": "available", + "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "zone": "fr-par-1" + }, + "protected": false, + "private_ip": null, + "public_ip": { + "id": "3006a180-67e0-433c-8b6a-142e202bd931", + "address": "51.158.70.223", + "dynamic": false + }, + "modification_date": "1970-01-01T00:00:00.0Z", + "state": "stopped", + "location": null, + "ipv6": null, + "bootscript": { + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", + "default": false, + "dtb": "", + "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", + "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "organization": "11111111-1111-4111-8111-111111111111", + "project": "11111111-1111-4111-8111-111111111111", + "public": false, + "title": "x86_64 mainline 4.9.93 rev1", "arch": "x86_64", - "placement_group": null, - "private_nics": [], "zone": "fr-par-1" - } + }, + "boot_type": "local", + "volumes": { + "0": { + "id": "57f887b2-f3c4-4ca3-b42e-92b797f11b61", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", + "export_uri": "", + "size": 20000000000, + "volume_type": "l_ssd", + "creation_date": "1970-01-01T00:00:00.0Z", + "modification_date": "1970-01-01T00:00:00.0Z", + "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", + "project": "951df375-e094-4d26-97c1-ba548eeb9c42", + "server": { + "id": "441a810a-8635-4e66-9e41-32bce3aa5988", + "name": "cli-srv-exciting-mayer" + }, + "state": "available", + "zone": "fr-par-1" + } + }, + "security_group": { + "id": "54e2d5f6-d79c-44cc-b19f-613699b9cc7e", + "name": "Default security group" + }, + "maintenances": [], + "state_detail": "", + "arch": "x86_64", + "placement_group": null, + "private_nics": [], + "zone": "fr-par-1", + "nics": [] } From 48eed45f68999cc4498356932cfe84ccff5dc4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 19:38:01 +0200 Subject: [PATCH 3/6] Fix --- internal/namespaces/instance/v1/custom.go | 1 - .../namespaces/instance/v1/custom_server.go | 58 +++------- .../v1/testdata/test-get-server-simple.golden | 103 +++++++++++------- 3 files changed, 80 insertions(+), 82 deletions(-) diff --git a/internal/namespaces/instance/v1/custom.go b/internal/namespaces/instance/v1/custom.go index dddd69119e..dc3e62f7cf 100644 --- a/internal/namespaces/instance/v1/custom.go +++ b/internal/namespaces/instance/v1/custom.go @@ -42,7 +42,6 @@ func GetCommands() *core.Commands { human.RegisterMarshalerFunc(instance.ServerState(""), human.EnumMarshalFunc(serverStateMarshalSpecs)) human.RegisterMarshalerFunc(instance.ServerLocation{}, serverLocationMarshalerFunc) human.RegisterMarshalerFunc([]*instance.Server{}, serversMarshalerFunc) - human.RegisterMarshalerFunc(instance.GetServerResponse{}, getServerResponseMarshalerFunc) human.RegisterMarshalerFunc(instance.Bootscript{}, bootscriptMarshalerFunc) cmds.MustFind("instance", "server", "list").Override(serverListBuilder) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 7786f77afb..8dae9fc812 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -114,46 +114,6 @@ func serversMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) return human.Marshal(humanServers, opt) } -func getServerResponseMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) { - serverResponse := i.(instance.GetServerResponse) - - // Sections - opt.Sections = []*human.MarshalSection{ - { - FieldName: "Server", - Title: "Server", - }, - { - FieldName: "Server.Image", - Title: "Server Image", - }, { - FieldName: "Server.AllowedActions", - Title: "Allowed Actions", - }, { - FieldName: "Volumes", - Title: "Volumes", - }, { - FieldName: "Server.PrivateNics", - Title: "Private NICs", - }, - } - - customServer := &struct { - Server *instance.Server - Volumes []*instance.Volume - }{ - serverResponse.Server, - orderVolumes(serverResponse.Server.Volumes), - } - - str, err := human.Marshal(customServer, opt) - if err != nil { - return "", err - } - - return str, nil -} - // orderVolumes return an ordered slice based on the volume map key "0", "1", "2",... func orderVolumes(v map[string]*instance.Volume) []*instance.Volume { indexes := []string(nil) @@ -408,16 +368,30 @@ func serverGetBuilder(c *core.Command) *core.Command { return &struct { *instance.Server - NICs []customNICs `json:"nics"` + Volumes []*instance.Volume + PrivateNics []customNICs `json:"nics"` }{ getServerResp.Server, + orderVolumes(getServerResp.Server.Volumes), nics, }, nil } c.View = &core.View{ Sections: []*core.ViewSection{ - {FieldName: "NICs", Title: "Private NICs"}, + { + FieldName: "Image", + Title: "Server Image", + }, { + FieldName: "AllowedActions", + Title: "Allowed Actions", + }, { + FieldName: "Volumes", + Title: "Volumes", + }, { + FieldName: "PrivateNics", + Title: "Private NICs", + }, }, } diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index 4b9e6adcc9..b23ed83648 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -1,44 +1,50 @@ 🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 🟩🟩🟩 STDOUT️ 🟩🟩🟩️ -ID 441a810a-8635-4e66-9e41-32bce3aa5988 -Name cli-srv-exciting-mayer -Organization 951df375-e094-4d26-97c1-ba548eeb9c42 -Project 951df375-e094-4d26-97c1-ba548eeb9c42 -AllowedActions.0 poweron -AllowedActions.1 backup -CommercialType DEV1-S -CreationDate few seconds ago -DynamicIPRequired false -EnableIPv6 false -Hostname cli-srv-exciting-mayer -Image.ID f974feac-abae-4365-b988-8ec7d1cec10d -Image.Name Ubuntu Bionic Beaver -Image.Arch x86_64 -Image.CreationDate few seconds ago -Image.ModificationDate few seconds ago -Image.DefaultBootscript x86_64 mainline 4.9.93 rev1 -Image.ExtraVolumes 0 -Image.FromServer - -Image.Organization 51b656e3-4865-41e8-adbc-0c45bdd780db -Image.Public true -Image.RootVolume dd5f5c10-23b1-4c9c-8445-eb6740957c84 -Image.State available -Image.Project 51b656e3-4865-41e8-adbc-0c45bdd780db -Image.Zone fr-par-1 -Protected false -PublicIP.ID 3006a180-67e0-433c-8b6a-142e202bd931 -PublicIP.Address 51.158.70.223 -PublicIP.Dynamic false -ModificationDate few seconds ago -State archived -Bootscript x86_64 mainline 4.9.93 rev1 -BootType local -Volumes 1 -SecurityGroup.ID 54e2d5f6-d79c-44cc-b19f-613699b9cc7e -SecurityGroup.Name Default security group -StateDetail - -Arch x86_64 -Zone fr-par-1 +ID 441a810a-8635-4e66-9e41-32bce3aa5988 +Name cli-srv-exciting-mayer +Organization 951df375-e094-4d26-97c1-ba548eeb9c42 +Project 951df375-e094-4d26-97c1-ba548eeb9c42 +CommercialType DEV1-S +CreationDate few seconds ago +DynamicIPRequired false +EnableIPv6 false +Hostname cli-srv-exciting-mayer +Protected false +PublicIP.ID 3006a180-67e0-433c-8b6a-142e202bd931 +PublicIP.Address 51.158.70.223 +PublicIP.Dynamic false +ModificationDate few seconds ago +State archived +Bootscript x86_64 mainline 4.9.93 rev1 +BootType local +SecurityGroup.ID 54e2d5f6-d79c-44cc-b19f-613699b9cc7e +SecurityGroup.Name Default security group +StateDetail - +Arch x86_64 +Zone fr-par-1 + +Server Image: +ID f974feac-abae-4365-b988-8ec7d1cec10d +Name Ubuntu Bionic Beaver +Arch x86_64 +CreationDate few seconds ago +ModificationDate few seconds ago +DefaultBootscript x86_64 mainline 4.9.93 rev1 +ExtraVolumes 0 +FromServer - +Organization 51b656e3-4865-41e8-adbc-0c45bdd780db +Public true +RootVolume dd5f5c10-23b1-4c9c-8445-eb6740957c84 +State available +Project 51b656e3-4865-41e8-adbc-0c45bdd780db +Zone fr-par-1 + +Allowed Actions: +[poweron backup] + +Volumes: +ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION PROJECT STATE ZONE +57f887b2-f3c4-4ca3-b42e-92b797f11b61 snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 - 20 GB l_ssd few seconds ago few seconds ago 951df375-e094-4d26-97c1-ba548eeb9c42 951df375-e094-4d26-97c1-ba548eeb9c42 available fr-par-1 Private NICs: ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID @@ -147,5 +153,24 @@ ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID "placement_group": null, "private_nics": [], "zone": "fr-par-1", + "Volumes": [ + { + "id": "57f887b2-f3c4-4ca3-b42e-92b797f11b61", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", + "export_uri": "", + "size": 20000000000, + "volume_type": "l_ssd", + "creation_date": "1970-01-01T00:00:00.0Z", + "modification_date": "1970-01-01T00:00:00.0Z", + "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", + "project": "951df375-e094-4d26-97c1-ba548eeb9c42", + "server": { + "id": "441a810a-8635-4e66-9e41-32bce3aa5988", + "name": "cli-srv-exciting-mayer" + }, + "state": "available", + "zone": "fr-par-1" + } + ], "nics": [] } From 0df68e673a95a80cd08e6a8331152ce55f9c9629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 19:40:28 +0200 Subject: [PATCH 4/6] Fix --- internal/namespaces/instance/v1/custom_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 8dae9fc812..4fe0c1725e 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -356,7 +356,7 @@ func serverGetBuilder(c *core.Command) *core.Command { PrivateNetworkID: nic.PrivateNetworkID, }) if err != nil { - return rawResp, nil + return nil, err } nics = append(nics, customNICs{ ID: nic.ID, From 357fe57320e06664b0020b4437e9b633050c7363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 19:41:57 +0200 Subject: [PATCH 5/6] Fix --- internal/namespaces/instance/v1/custom_server.go | 2 +- .../instance/v1/testdata/test-get-server-simple.golden | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 4fe0c1725e..7c05ed739e 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -369,7 +369,7 @@ func serverGetBuilder(c *core.Command) *core.Command { return &struct { *instance.Server Volumes []*instance.Volume - PrivateNics []customNICs `json:"nics"` + PrivateNics []customNICs `json:"private_nics"` }{ getServerResp.Server, orderVolumes(getServerResp.Server.Volumes), diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index b23ed83648..cafc4810c2 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -151,7 +151,6 @@ ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID "state_detail": "", "arch": "x86_64", "placement_group": null, - "private_nics": [], "zone": "fr-par-1", "Volumes": [ { @@ -172,5 +171,5 @@ ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID "zone": "fr-par-1" } ], - "nics": [] + "private_nics": [] } From ce5a4be87b49040a6365083072d430c642e8b2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 14 Sep 2020 19:47:05 +0200 Subject: [PATCH 6/6] Fix --- internal/namespaces/instance/v1/custom_server.go | 11 ++++++++++- .../v1/testdata/test-get-server-simple.golden | 11 ++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 7c05ed739e..a18c5042c7 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -388,7 +388,16 @@ func serverGetBuilder(c *core.Command) *core.Command { }, { FieldName: "Volumes", Title: "Volumes", - }, { + }, + { + Title: "Public IP", + FieldName: "PublicIP", + }, + { + Title: "IPv6", + FieldName: "IPv6", + }, + { FieldName: "PrivateNics", Title: "Private NICs", }, diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index cafc4810c2..93a070db7f 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -10,9 +10,6 @@ DynamicIPRequired false EnableIPv6 false Hostname cli-srv-exciting-mayer Protected false -PublicIP.ID 3006a180-67e0-433c-8b6a-142e202bd931 -PublicIP.Address 51.158.70.223 -PublicIP.Dynamic false ModificationDate few seconds ago State archived Bootscript x86_64 mainline 4.9.93 rev1 @@ -46,6 +43,14 @@ Volumes: ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION PROJECT STATE ZONE 57f887b2-f3c4-4ca3-b42e-92b797f11b61 snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 - 20 GB l_ssd few seconds ago few seconds ago 951df375-e094-4d26-97c1-ba548eeb9c42 951df375-e094-4d26-97c1-ba548eeb9c42 available fr-par-1 +Public IP: +ID 3006a180-67e0-433c-8b6a-142e202bd931 +Address 51.158.70.223 +Dynamic false + +IPv6: +- + Private NICs: ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID 🟩🟩🟩 JSON STDOUT 🟩🟩🟩