@@ -35,8 +35,7 @@ import (
35
35
func (c * Client ) Convert () * cobra.Command {
36
36
var portID string
37
37
var bonded , layer2 , bulk , force , ipv4 , ipv6 bool
38
- // retrievePortCmd represents the retrievePort command
39
- retrievePortCmd := & cobra.Command {
38
+ convertPortCmd := & cobra.Command {
40
39
Use : `convert -i <port_UUID> [--bonded] [--bulk] --layer2 [--force] [--public-ipv4] [--public-ipv6]` ,
41
40
Aliases : []string {},
42
41
Short : "Converts a list of ports or the details of the specified port." ,
@@ -87,7 +86,10 @@ func (c *Client) Convert() *cobra.Command {
87
86
return nil , nil , nil
88
87
}
89
88
}
90
- return c .PortService .ConvertLayer2 (context .Background (), portID ).Execute ()
89
+
90
+ return c .PortService .ConvertLayer2 (context .Background (), portID ).
91
+ PortAssignInput (* metal .NewPortAssignInput ()).
92
+ Execute ()
91
93
}
92
94
convToL3 := func (portID string ) (* metal.Port , * http.Response , error ) {
93
95
log .Printf ("Converting port %s to layer-3 with addresses %v" , portID , addrs )
@@ -105,8 +107,6 @@ func (c *Client) Convert() *cobra.Command {
105
107
106
108
port , _ , err := c .PortService .FindPortById (context .Background (), portID ).
107
109
Include (c .Servicer .Includes (nil )).
108
- // TODO: uncomment this when metal api supports it
109
- // Exclude(c.Servicer.Excludes(nil)).
110
110
Execute ()
111
111
if err != nil {
112
112
return fmt .Errorf ("Could not get Port: %w" , err )
@@ -121,31 +121,27 @@ func (c *Client) Convert() *cobra.Command {
121
121
},
122
122
}
123
123
124
- retrievePortCmd .Flags ().StringVarP (& portID , "port-id" , "i" , "" , "The UUID of a port." )
125
- retrievePortCmd .Flags ().BoolVarP (& bonded , "bonded" , "b" , false , "Convert to layer-2 bonded." )
126
- retrievePortCmd .Flags ().BoolVarP (& bulk , "bulk" , "" , false , "Affect both ports in a bond." )
127
- retrievePortCmd .Flags ().BoolVarP (& layer2 , "layer2" , "2" , false , "Convert to layer-2 unbonded." )
128
- retrievePortCmd .Flags ().BoolVarP (& force , "force" , "f" , false , "Force conversion to layer-2 bonded." )
129
- retrievePortCmd .Flags ().BoolVarP (& ipv4 , "public-ipv4" , "4" , false , "Convert to layer-2 bonded with public IPv4." )
130
- retrievePortCmd .Flags ().BoolVarP (& ipv6 , "public-ipv6" , "6" , false , "Convert to layer-2 bonded with public IPv6." )
124
+ convertPortCmd .Flags ().StringVarP (& portID , "port-id" , "i" , "" , "The UUID of a port." )
125
+ convertPortCmd .Flags ().BoolVarP (& bonded , "bonded" , "b" , false , "Convert to layer-2 bonded." )
126
+ convertPortCmd .Flags ().BoolVarP (& bulk , "bulk" , "" , false , "Affect both ports in a bond." )
127
+ convertPortCmd .Flags ().BoolVarP (& layer2 , "layer2" , "2" , false , "Convert to layer-2 unbonded." )
128
+ convertPortCmd .Flags ().BoolVarP (& force , "force" , "f" , false , "Force conversion to layer-2 bonded." )
129
+ convertPortCmd .Flags ().BoolVarP (& ipv4 , "public-ipv4" , "4" , false , "Convert to layer-2 bonded with public IPv4." )
130
+ convertPortCmd .Flags ().BoolVarP (& ipv6 , "public-ipv6" , "6" , false , "Convert to layer-2 bonded with public IPv6." )
131
131
132
- return retrievePortCmd
132
+ return convertPortCmd
133
133
}
134
134
135
135
func portBondingHandler (cmd * cobra.Command , c * Client , portId string ) error {
136
136
if cmd .Flag ("bonded" ).Changed {
137
137
_ , _ , err := c .PortService .BondPort (context .Background (), portId ).
138
138
Include (c .Servicer .Includes (nil )).
139
- // TODO: uncomment this when metal api supports it
140
- // Exclude(c.Servicer.Excludes(nil)).
141
139
Execute ()
142
140
return err
143
141
}
144
142
145
143
_ , _ , err := c .PortService .DisbondPort (context .Background (), portId ).
146
144
Include (c .Servicer .Includes (nil )).
147
- // TODO: uncomment this when metal api supports it
148
- // Exclude(c.Servicer.Excludes(nil)).
149
145
Execute ()
150
146
return err
151
147
}
0 commit comments