Skip to content

Commit 7aa2dd9

Browse files
allmightyspiffGitHub Enterprise
authored andcommitted
Merge pull request #810 from SoftLayer/vlanTag
Vlan tag features
2 parents c4906a4 + 2c5fc8d commit 7aa2dd9

60 files changed

Lines changed: 2627 additions & 463 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group: bluezone
22
language: go
33
go:
4-
- 1.19.3
4+
- 1.21.3
55
addons:
66
apt:
77
packages:

bin/buildAndDeploy.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,19 @@ def runTests() -> None:
6363

6464
go_vet = ['go', 'vet'] + clean_mods
6565
# Not using the 'real' command here because this looks neater.
66+
6667
print(f'[turquoise2]Running: go vet $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
67-
subprocess.run(go_vet, check=True)
68+
try:
69+
subprocess.run(go_vet, check=True)
70+
except subprocess.CalledProcessError as e:
71+
print(f"[red]>>> Go Vet failed <<<")
72+
sys.exit(e.returncode)
6873
go_test = ['go', 'test'] + clean_mods
6974
print(f'[turquoise2]Running: go test $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
7075
try:
7176
subprocess.run(go_test, check=True)
7277
except subprocess.CalledProcessError as e:
73-
print(f"[red]Unit tests failed")
78+
print(f"[red]>>> Go Test failed <<<")
7479
sys.exit(e.returncode)
7580
go_sec = ['gosec', '-exclude-dir=fixture', '-exclude-dir=plugin/resources', '-quiet', './...']
7681
# Not using the 'real' command because this is more copy/pasteable.

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/miekg/dns v1.1.50
1111
github.com/nicksnyder/go-i18n v1.10.1
1212
github.com/onsi/ginkgo v1.16.2
13-
github.com/onsi/gomega v1.27.10
13+
github.com/onsi/gomega v1.29.0
1414
github.com/softlayer/softlayer-go v1.1.2
1515
github.com/spf13/cobra v1.5.0
1616
github.com/spf13/pflag v1.0.5
@@ -24,7 +24,8 @@ require (
2424
github.com/fatih/structs v1.1.0 // indirect
2525
github.com/fsnotify/fsnotify v1.4.9 // indirect
2626
github.com/gofrs/flock v0.8.1 // indirect
27-
github.com/google/go-cmp v0.5.9 // indirect
27+
github.com/golang/protobuf v1.5.3 // indirect
28+
github.com/google/go-cmp v0.6.0 // indirect
2829
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2930
github.com/mattn/go-colorable v0.1.8 // indirect
3031
github.com/mattn/go-isatty v0.0.12 // indirect
@@ -41,6 +42,7 @@ require (
4142
golang.org/x/sys v0.13.0 // indirect
4243
golang.org/x/term v0.13.0 // indirect
4344
golang.org/x/tools v0.12.0 // indirect
45+
google.golang.org/protobuf v1.28.0 // indirect
4446
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
4547
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
4648
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
3030
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
3131
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
3232
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
33+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
3334
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
3435
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
3536
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
3637
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
3738
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
39+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3840
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
3941
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
42+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
43+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
4044
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
4145
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
4246
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
@@ -74,10 +78,13 @@ github.com/onsi/ginkgo v1.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134=
7478
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
7579
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
7680
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
81+
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
7782
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
7883
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
7984
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
8085
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
86+
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
87+
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
8188
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
8289
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
8390
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -168,6 +175,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
168175
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
169176
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
170177
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
178+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
179+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
171180
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
172181
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
173182
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

plugin/commands/hardware/authorize-storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func NewAuthorizeStorageCommand(sl *metadata.SoftlayerCommand) (cmd *AuthorizeSt
2525
HardwareManager: managers.NewHardwareServerManager(sl.Session),
2626
}
2727

28-
2928
cobraCmd := &cobra.Command{
3029
Use: "authorize-storage " + T("IDENTIFIER"),
3130
Short: T("Authorize File and Block Storage to a Hardware Server"),

plugin/commands/hardware/billing.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func NewBillingCommand(sl *metadata.SoftlayerCommand) (cmd *BillingCommand) {
2727
HardwareManager: managers.NewHardwareServerManager(sl.Session),
2828
}
2929

30-
3130
cobraCmd := &cobra.Command{
3231
Use: "billing " + T("IDENTIFIER"),
3332
Short: T("Get billing for a hardware device."),

plugin/commands/hardware/cancel.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func NewCancelCommand(sl *metadata.SoftlayerCommand) (cmd *CancelCommand) {
3030
HardwareManager: managers.NewHardwareServerManager(sl.Session),
3131
}
3232

33-
3433
cobraCmd := &cobra.Command{
3534
Use: "cancel " + T("IDENTIFIER"),
3635
Short: T("Cancel a hardware server"),

plugin/commands/hardware/create_options_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ var _ = Describe("hardware create options", func() {
3333
Context("hardware create options", func() {
3434
BeforeEach(func() {
3535
fakeHardwareManager.GetCreateOptionsReturns(map[string]map[string]string{
36-
managers.KEY_LOCATIONS: map[string]string{"dal10": "Dallas 10"},
37-
managers.KEY_SIZES: map[string]string{"D2620_128GB_2X1T_SATA_RAID_1xM60_GPU": "Dual Xeon 2620v4, 128GB Ram, 2x800GB SSD disks, RAID1"},
38-
managers.KEY_OS: map[string]string{"CENTOS_6_32": "CentOS 6.5-32"},
39-
managers.KEY_NAME_OS: map[string]string{"CENTOS_6_32": "OS_CENTOS_6_X_32_BIT"},
40-
managers.KEY_PORT_SPEED: map[string]string{"100_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS": "10000"},
36+
managers.KEY_LOCATIONS: map[string]string{"dal10": "Dallas 10"},
37+
managers.KEY_SIZES: map[string]string{"D2620_128GB_2X1T_SATA_RAID_1xM60_GPU": "Dual Xeon 2620v4, 128GB Ram, 2x800GB SSD disks, RAID1"},
38+
managers.KEY_OS: map[string]string{"CENTOS_6_32": "CentOS 6.5-32"},
39+
managers.KEY_NAME_OS: map[string]string{"CENTOS_6_32": "OS_CENTOS_6_X_32_BIT"},
40+
managers.KEY_PORT_SPEED: map[string]string{"100_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS": "10000"},
4141
managers.KEY_PORT_SPEED_DESCRIPTION: map[string]string{"100_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS": "10 Gbps Redundant Public & Private Network Uplinks"},
42-
managers.KEY_EXTRAS: map[string]string{"8_PUBLIC_IP_ADDRESSES": "8 Public IP Addresses"},
42+
managers.KEY_EXTRAS: map[string]string{"8_PUBLIC_IP_ADDRESSES": "8 Public IP Addresses"},
4343
})
4444
})
4545
It("return error", func() {

plugin/commands/hardware/detail.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ func (cmd *DetailCommand) Run(args []string) error {
6262

6363
hardDrives, err := cmd.HardwareManager.GetHardDrives(hardwareId)
6464
if err != nil {
65-
return errors.NewAPIError(T("Failed to get the hard drives detail for the hardware server {{.ID}}.\n", map[string]interface{}{"ID": hardwareId}), err.Error(), 2)
65+
return err
6666
}
6767

6868
bandwidthAllotmentDetail, err := cmd.HardwareManager.GetBandwidthAllotmentDetail(hardwareId, "")
6969
if err != nil {
70-
return errors.NewAPIError(T("Failed to get bandwidth allotment detail for the hardware server {{.ID}}.\n", map[string]interface{}{"ID": hardwareId}), err.Error(), 2)
70+
return err
7171
}
7272

7373
billingCycleBandwidthUsage, err := cmd.HardwareManager.GetBillingCycleBandwidthUsage(hardwareId, "")
7474
if err != nil {
75-
return errors.NewAPIError(T("Failed to get billing cycle bandwidth usage for the hardware server {{.ID}}.\n", map[string]interface{}{"ID": hardwareId}), err.Error(), 2)
75+
return err
7676
}
7777

7878
if outputFormat == "JSON" {
@@ -157,11 +157,33 @@ func (cmd *DetailCommand) Run(args []string) error {
157157

158158
if vlans := hardware.NetworkVlans; len(vlans) > 0 {
159159
buf := new(bytes.Buffer)
160-
vlanTable := terminal.NewTable(buf, []string{T("Type"), T("Number"), T("ID")})
160+
vlanTable := terminal.NewTable(buf, []string{T("Network"), T("Number"), T("ID"), T("Name"), T("Type")})
161161
for _, vlan := range vlans {
162-
vlanTable.Add(utils.FormatStringPointer(vlan.NetworkSpace),
162+
vlanTable.Add(
163+
utils.FormatStringPointer(vlan.NetworkSpace),
163164
utils.FormatIntPointer(vlan.VlanNumber),
164-
utils.FormatIntPointer(vlan.Id))
165+
utils.FormatIntPointer(vlan.Id),
166+
utils.FormatStringPointer(vlan.FullyQualifiedName),
167+
T("Primary"),
168+
)
169+
}
170+
for _, component := range hardware.NetworkComponents {
171+
if component.PrimaryIpAddress != nil {
172+
uplink := component.UplinkComponent
173+
if uplink == nil {
174+
continue
175+
}
176+
for _, trunk := range uplink.NetworkVlanTrunks {
177+
t_vlan := trunk.NetworkVlan
178+
vlanTable.Add(
179+
utils.FormatStringPointer(t_vlan.NetworkSpace),
180+
utils.FormatIntPointer(t_vlan.VlanNumber),
181+
utils.FormatIntPointer(t_vlan.Id),
182+
utils.FormatStringPointer(t_vlan.FullyQualifiedName),
183+
T("Trunked"),
184+
)
185+
}
186+
}
165187
}
166188
vlanTable.Print()
167189
table.Add("Vlans", buf.String())

0 commit comments

Comments
 (0)