Skip to content

Commit 58b7014

Browse files
authored
Add VPC2 deprecation to bare metal and instance (#366)
1 parent f1cfb73 commit 58b7014

4 files changed

+87
-184
lines changed

bare_metal_server.go

+35-23
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ type BareMetalServerService interface {
4141
AttachVPC(ctx context.Context, serverID, vpcID string) error
4242
DetachVPC(ctx context.Context, serverID, vpcID string) error
4343

44+
// Deprecated: VPC2 is no longer supported
4445
ListVPC2Info(ctx context.Context, serverID string) ([]VPC2Info, *http.Response, error)
46+
// Deprecated: VPC2 is no longer supported
4547
AttachVPC2(ctx context.Context, serverID string, vpc2Req *AttachVPC2Req) error
48+
// Deprecated: VPC2 is no longer supported
4649
DetachVPC2(ctx context.Context, serverID, vpcID string) error
4750
}
4851

@@ -81,28 +84,31 @@ type BareMetalServer struct {
8184

8285
// BareMetalCreate represents the optional parameters that can be set when creating a Bare Metal server
8386
type BareMetalCreate struct {
84-
Region string `json:"region"`
85-
Plan string `json:"plan"`
86-
OsID int `json:"os_id,omitempty"`
87-
StartupScriptID string `json:"script_id,omitempty"`
88-
SnapshotID string `json:"snapshot_id,omitempty"`
89-
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
90-
Label string `json:"label,omitempty"`
91-
SSHKeyIDs []string `json:"sshkey_id,omitempty"`
92-
AppID int `json:"app_id,omitempty"`
93-
ImageID string `json:"image_id,omitempty"`
94-
UserData string `json:"user_data,omitempty"`
95-
ActivationEmail *bool `json:"activation_email,omitempty"`
96-
Hostname string `json:"hostname,omitempty"`
97-
MdiskMode string `json:"mdisk_mode,omitempty"`
98-
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
99-
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
100-
Tags []string `json:"tags,omitempty"`
101-
UserScheme string `json:"user_scheme,omitempty"`
102-
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
103-
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
104-
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
105-
AppVariables map[string]string `json:"app_variables,omitempty"`
87+
Region string `json:"region"`
88+
Plan string `json:"plan"`
89+
OsID int `json:"os_id,omitempty"`
90+
StartupScriptID string `json:"script_id,omitempty"`
91+
SnapshotID string `json:"snapshot_id,omitempty"`
92+
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
93+
Label string `json:"label,omitempty"`
94+
SSHKeyIDs []string `json:"sshkey_id,omitempty"`
95+
AppID int `json:"app_id,omitempty"`
96+
ImageID string `json:"image_id,omitempty"`
97+
UserData string `json:"user_data,omitempty"`
98+
ActivationEmail *bool `json:"activation_email,omitempty"`
99+
Hostname string `json:"hostname,omitempty"`
100+
MdiskMode string `json:"mdisk_mode,omitempty"`
101+
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
102+
PersistentPxe *bool `json:"persistent_pxe,omitempty"`
103+
Tags []string `json:"tags,omitempty"`
104+
UserScheme string `json:"user_scheme,omitempty"`
105+
// Deprecated: VPC2 is no longer supported
106+
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
107+
// Deprecated: VPC2 is no longer supported
108+
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
109+
// Deprecated: VPC2 is no longer supported
110+
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
111+
AppVariables map[string]string `json:"app_variables,omitempty"`
106112
}
107113

108114
// BareMetalUpdate represents the optional parameters that can be set when updating a Bare Metal server
@@ -116,9 +122,12 @@ type BareMetalUpdate struct {
116122
MdiskMode string `json:"mdisk_mode,omitempty"`
117123
Tags []string `json:"tags,omitempty"`
118124
UserScheme string `json:"user_scheme,omitempty"`
125+
// Deprecated: VPC2 is no longer supported
119126
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
127+
// Deprecated: VPC2 is no longer supported
120128
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
121-
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
129+
// Deprecated: VPC2 is no longer supported
130+
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
122131
}
123132

124133
// BareMetalServerBandwidth represents bandwidth information for a Bare Metal server
@@ -496,6 +505,7 @@ func (b *BareMetalServerServiceHandler) DetachVPC(ctx context.Context, serverID,
496505
}
497506

498507
// ListVPC2Info currently attached to a Bare Metal server.
508+
// Deprecated: VPC2 is no longer supported
499509
func (b *BareMetalServerServiceHandler) ListVPC2Info(ctx context.Context, serverID string) ([]VPC2Info, *http.Response, error) {
500510
uri := fmt.Sprintf("%s/%s/vpc2", bmPath, serverID)
501511
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
@@ -513,6 +523,7 @@ func (b *BareMetalServerServiceHandler) ListVPC2Info(ctx context.Context, server
513523
}
514524

515525
// AttachVPC2 to a Bare Metal server.
526+
// Deprecated: VPC2 is no longer supported
516527
func (b *BareMetalServerServiceHandler) AttachVPC2(ctx context.Context, serverID string, vpc2Req *AttachVPC2Req) error {
517528
uri := fmt.Sprintf("%s/%s/vpc2/attach", bmPath, serverID)
518529

@@ -526,6 +537,7 @@ func (b *BareMetalServerServiceHandler) AttachVPC2(ctx context.Context, serverID
526537
}
527538

528539
// DetachVPC2 from a Bare Metal server.
540+
// Deprecated: VPC2 is no longer supported
529541
func (b *BareMetalServerServiceHandler) DetachVPC2(ctx context.Context, serverID, vpcID string) error {
530542
uri := fmt.Sprintf("%s/%s/vpc2/detach", bmPath, serverID)
531543
body := RequestBody{"vpc_id": vpcID}

bare_metal_server_test.go

-53
Original file line numberDiff line numberDiff line change
@@ -799,56 +799,3 @@ func TestBareMetalServerServiceHandler_CreateMarketplaceImage(t *testing.T) {
799799
t.Errorf("BareMetalServer.Create returned %+v, expected %+v", bm, expected)
800800
}
801801
}
802-
803-
func TestBareMetalServerServiceHandler_ListVPC2Info(t *testing.T) {
804-
setup()
805-
defer teardown()
806-
807-
mux.HandleFunc("/v2/bare-metals/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2", func(writer http.ResponseWriter, request *http.Request) {
808-
response := `{"vpcs": [{"id": "v1-net539626f0798d7","mac_address": "5a:02:00:00:24:e9","ip_address": "10.99.0.3"}]}`
809-
fmt.Fprint(writer, response)
810-
})
811-
812-
vpc, _, err := client.BareMetalServer.ListVPC2Info(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33")
813-
if err != nil {
814-
t.Errorf("BareMetalServer.ListVPC2Info returned %+v, ", err)
815-
}
816-
817-
expected := []VPC2Info{
818-
{
819-
ID: "v1-net539626f0798d7",
820-
MacAddress: "5a:02:00:00:24:e9",
821-
IPAddress: "10.99.0.3",
822-
},
823-
}
824-
825-
if !reflect.DeepEqual(vpc, expected) {
826-
t.Errorf("BareMetalServer.ListVPC2Info returned %+v, expected %+v", vpc, expected)
827-
}
828-
}
829-
830-
func TestBareMetalServerServiceHandler_AttachVPC2(t *testing.T) {
831-
setup()
832-
defer teardown()
833-
834-
mux.HandleFunc("/v2/bare-metals/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2/attach", func(writer http.ResponseWriter, request *http.Request) {
835-
fmt.Fprint(writer)
836-
})
837-
838-
if err := client.BareMetalServer.AttachVPC2(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33", &AttachVPC2Req{VPCID: "14b3e7d6-ffb5-4994-8502-57fcd9db3b33"}); err != nil {
839-
t.Errorf("BareMetalServer.AttachVPC2 returned %+v", err)
840-
}
841-
}
842-
843-
func TestBareMetalServerServiceHandler_DetachVPC2(t *testing.T) {
844-
setup()
845-
defer teardown()
846-
847-
mux.HandleFunc("/v2/bare-metals/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2/detach", func(writer http.ResponseWriter, request *http.Request) {
848-
fmt.Fprint(writer)
849-
})
850-
851-
if err := client.BareMetalServer.DetachVPC2(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33", "14b3e7d6-ffb5-4994-8502-57fcd9db3b33"); err != nil {
852-
t.Errorf("BareMetalServer.DetachVPC2 returned %+v", err)
853-
}
854-
}

instance.go

+52-39
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ type InstanceService interface {
3737
AttachVPC(ctx context.Context, instanceID, vpcID string) error
3838
DetachVPC(ctx context.Context, instanceID, vpcID string) error
3939

40+
// Deprecated: VPC2 is no longer supported
4041
ListVPC2Info(ctx context.Context, instanceID string, options *ListOptions) ([]VPC2Info, *Meta, *http.Response, error)
42+
// Deprecated: VPC2 is no longer supported
4143
AttachVPC2(ctx context.Context, instanceID string, vpc2Req *AttachVPC2Req) error
44+
// Deprecated: VPC2 is no longer supported
4245
DetachVPC2(ctx context.Context, instanceID, vpcID string) error
4346

4447
ISOStatus(ctx context.Context, instanceID string) (*Iso, *http.Response, error)
@@ -148,13 +151,15 @@ type vpc2InfoBase struct {
148151
}
149152

150153
// VPC2Info information for a given instance.
154+
// Deprecated: VPC2 is no longer supported
151155
type VPC2Info struct {
152156
ID string `json:"id"`
153157
MacAddress string `json:"mac_address"`
154158
IPAddress string `json:"ip_address"`
155159
}
156160

157161
// AttachVPC2Req parameters for attaching a VPC 2.0 network
162+
// Deprecated: VPC2 is no longer supported
158163
type AttachVPC2Req struct {
159164
VPCID string `json:"vpc_id,omitempty"`
160165
IPAddress *string `json:"ip_address,omitempty"`
@@ -232,49 +237,54 @@ type Upgrades struct {
232237

233238
// InstanceCreateReq struct used to create an instance.
234239
type InstanceCreateReq struct {
235-
Region string `json:"region,omitempty"`
236-
Plan string `json:"plan,omitempty"`
237-
Label string `json:"label,omitempty"`
238-
Tags []string `json:"tags"`
239-
OsID int `json:"os_id,omitempty"`
240-
ISOID string `json:"iso_id,omitempty"`
241-
AppID int `json:"app_id,omitempty"`
242-
ImageID string `json:"image_id,omitempty"`
243-
FirewallGroupID string `json:"firewall_group_id,omitempty"`
244-
Hostname string `json:"hostname,omitempty"`
245-
IPXEChainURL string `json:"ipxe_chain_url,omitempty"`
246-
ScriptID string `json:"script_id,omitempty"`
247-
SnapshotID string `json:"snapshot_id,omitempty"`
248-
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
249-
DisablePublicIPv4 *bool `json:"disable_public_ipv4,omitempty"`
250-
EnableVPC *bool `json:"enable_vpc,omitempty"`
251-
AttachVPC []string `json:"attach_vpc,omitempty"`
252-
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
253-
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
254-
SSHKeys []string `json:"sshkey_id,omitempty"`
255-
Backups string `json:"backups,omitempty"`
256-
DDOSProtection *bool `json:"ddos_protection,omitempty"`
257-
UserData string `json:"user_data,omitempty"`
258-
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
259-
ActivationEmail *bool `json:"activation_email,omitempty"`
260-
UserScheme string `json:"user_scheme,omitempty"`
261-
AppVariables map[string]string `json:"app_variables,omitempty"`
240+
Region string `json:"region,omitempty"`
241+
Plan string `json:"plan,omitempty"`
242+
Label string `json:"label,omitempty"`
243+
Tags []string `json:"tags"`
244+
OsID int `json:"os_id,omitempty"`
245+
ISOID string `json:"iso_id,omitempty"`
246+
AppID int `json:"app_id,omitempty"`
247+
ImageID string `json:"image_id,omitempty"`
248+
FirewallGroupID string `json:"firewall_group_id,omitempty"`
249+
Hostname string `json:"hostname,omitempty"`
250+
IPXEChainURL string `json:"ipxe_chain_url,omitempty"`
251+
ScriptID string `json:"script_id,omitempty"`
252+
SnapshotID string `json:"snapshot_id,omitempty"`
253+
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
254+
DisablePublicIPv4 *bool `json:"disable_public_ipv4,omitempty"`
255+
EnableVPC *bool `json:"enable_vpc,omitempty"`
256+
AttachVPC []string `json:"attach_vpc,omitempty"`
257+
// Deprecated: VPC2 is no longer supported
258+
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
259+
// Deprecated: VPC2 is no longer supported
260+
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
261+
SSHKeys []string `json:"sshkey_id,omitempty"`
262+
Backups string `json:"backups,omitempty"`
263+
DDOSProtection *bool `json:"ddos_protection,omitempty"`
264+
UserData string `json:"user_data,omitempty"`
265+
ReservedIPv4 string `json:"reserved_ipv4,omitempty"`
266+
ActivationEmail *bool `json:"activation_email,omitempty"`
267+
UserScheme string `json:"user_scheme,omitempty"`
268+
AppVariables map[string]string `json:"app_variables,omitempty"`
262269
}
263270

264271
// InstanceUpdateReq struct used to update an instance.
265272
type InstanceUpdateReq struct {
266-
Plan string `json:"plan,omitempty"`
267-
Label string `json:"label,omitempty"`
268-
Tags []string `json:"tags"`
269-
OsID int `json:"os_id,omitempty"`
270-
AppID int `json:"app_id,omitempty"`
271-
ImageID string `json:"image_id,omitempty"`
272-
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
273-
EnableVPC *bool `json:"enable_vpc,omitempty"`
274-
AttachVPC []string `json:"attach_vpc,omitempty"`
275-
DetachVPC []string `json:"detach_vpc,omitempty"`
276-
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
277-
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
273+
Plan string `json:"plan,omitempty"`
274+
Label string `json:"label,omitempty"`
275+
Tags []string `json:"tags"`
276+
OsID int `json:"os_id,omitempty"`
277+
AppID int `json:"app_id,omitempty"`
278+
ImageID string `json:"image_id,omitempty"`
279+
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
280+
EnableVPC *bool `json:"enable_vpc,omitempty"`
281+
AttachVPC []string `json:"attach_vpc,omitempty"`
282+
DetachVPC []string `json:"detach_vpc,omitempty"`
283+
// Deprecated: VPC2 is no longer supported
284+
EnableVPC2 *bool `json:"enable_vpc2,omitempty"`
285+
// Deprecated: VPC2 is no longer supported
286+
AttachVPC2 []string `json:"attach_vpc2,omitempty"`
287+
// Deprecated: VPC2 is no longer supported
278288
DetachVPC2 []string `json:"detach_vpc2,omitempty"`
279289
Backups string `json:"backups,omitempty"`
280290
DDOSProtection *bool `json:"ddos_protection"`
@@ -566,6 +576,7 @@ func (i *InstanceServiceHandler) DetachVPC(ctx context.Context, instanceID, vpcI
566576
}
567577

568578
// ListVPC2Info currently attached to an instance.
579+
// Deprecated: VPC2 is no longer supported
569580
func (i *InstanceServiceHandler) ListVPC2Info(ctx context.Context, instanceID string, options *ListOptions) ([]VPC2Info, *Meta, *http.Response, error) { //nolint:lll,dupl
570581
uri := fmt.Sprintf("%s/%s/vpc2", instancePath, instanceID)
571582
req, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)
@@ -590,6 +601,7 @@ func (i *InstanceServiceHandler) ListVPC2Info(ctx context.Context, instanceID st
590601
}
591602

592603
// AttachVPC2 to an instance
604+
// Deprecated: VPC2 is no longer supported
593605
func (i *InstanceServiceHandler) AttachVPC2(ctx context.Context, instanceID string, vpc2Req *AttachVPC2Req) error {
594606
uri := fmt.Sprintf("%s/%s/vpc2/attach", instancePath, instanceID)
595607

@@ -603,6 +615,7 @@ func (i *InstanceServiceHandler) AttachVPC2(ctx context.Context, instanceID stri
603615
}
604616

605617
// DetachVPC2 from an instance.
618+
// Deprecated: VPC2 is no longer supported
606619
func (i *InstanceServiceHandler) DetachVPC2(ctx context.Context, instanceID, vpcID string) error {
607620
uri := fmt.Sprintf("%s/%s/vpc2/detach", instancePath, instanceID)
608621
body := RequestBody{"vpc_id": vpcID}

instance_test.go

-69
Original file line numberDiff line numberDiff line change
@@ -198,49 +198,6 @@ func TestServerServiceHandler_ListVPCInfo(t *testing.T) {
198198
}
199199
}
200200

201-
func TestServerServiceHandler_ListVPC2Info(t *testing.T) {
202-
setup()
203-
defer teardown()
204-
205-
mux.HandleFunc("/v2/instances/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2", func(writer http.ResponseWriter, request *http.Request) {
206-
response := `{"vpcs": [{"id": "v1-net539626f0798d7","mac_address": "5a:02:00:00:24:e9","ip_address": "10.99.0.3"}],"meta":{"total":1,"links":{"next":"thisismycusror","prev":""}}}`
207-
fmt.Fprint(writer, response)
208-
})
209-
210-
options := &ListOptions{
211-
PerPage: 1,
212-
Cursor: "",
213-
}
214-
vpc, meta, _, err := client.Instance.ListVPC2Info(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33", options)
215-
if err != nil {
216-
t.Errorf("Instance.ListVPC2Info returned %+v, ", err)
217-
}
218-
219-
expected := []VPC2Info{
220-
{
221-
ID: "v1-net539626f0798d7",
222-
MacAddress: "5a:02:00:00:24:e9",
223-
IPAddress: "10.99.0.3",
224-
},
225-
}
226-
227-
if !reflect.DeepEqual(vpc, expected) {
228-
t.Errorf("Instance.ListVPC2Info returned %+v, expected %+v", vpc, expected)
229-
}
230-
231-
expectedMeta := &Meta{
232-
Total: 1,
233-
Links: &Links{
234-
Next: "thisismycusror",
235-
Prev: "",
236-
},
237-
}
238-
239-
if !reflect.DeepEqual(meta, expectedMeta) {
240-
t.Errorf("Instance.ListVPC2Info meta returned %+v, expected %+v", meta, expectedMeta)
241-
}
242-
}
243-
244201
func TestServerServiceHandler_GetUserData(t *testing.T) {
245202
setup()
246203
defer teardown()
@@ -963,32 +920,6 @@ func TestServerServiceHandler_DetachVPC(t *testing.T) {
963920
}
964921
}
965922

966-
func TestServerServiceHandler_AttachVPC2(t *testing.T) {
967-
setup()
968-
defer teardown()
969-
970-
mux.HandleFunc("/v2/instances/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2/attach", func(writer http.ResponseWriter, request *http.Request) {
971-
fmt.Fprint(writer)
972-
})
973-
974-
if err := client.Instance.AttachVPC2(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33", &AttachVPC2Req{VPCID: "14b3e7d6-ffb5-4994-8502-57fcd9db3b33"}); err != nil {
975-
t.Errorf("Instance.AttachVPC2 returned %+v", err)
976-
}
977-
}
978-
979-
func TestServerServiceHandler_DetachVPC2(t *testing.T) {
980-
setup()
981-
defer teardown()
982-
983-
mux.HandleFunc("/v2/instances/14b3e7d6-ffb5-4994-8502-57fcd9db3b33/vpc2/detach", func(writer http.ResponseWriter, request *http.Request) {
984-
fmt.Fprint(writer)
985-
})
986-
987-
if err := client.Instance.DetachVPC2(ctx, "14b3e7d6-ffb5-4994-8502-57fcd9db3b33", "14b3e7d6-ffb5-4994-8502-57fcd9db3b33"); err != nil {
988-
t.Errorf("Instance.DetachVPC2 returned %+v", err)
989-
}
990-
}
991-
992923
func TestServerServiceHandler_ISOAttach(t *testing.T) {
993924
setup()
994925
defer teardown()

0 commit comments

Comments
 (0)