Skip to content

Commit f9a9109

Browse files
committed
wire up cloud network public add,remove the rest of the way to plans
1 parent 8e2fd1f commit f9a9109

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
cloud:
3+
network:
4+
public:
5+
add:
6+
- uniq-id: "{{- .Var.uniq_id -}}"
7+
configure-ips: true
8+
new-ips: 2
9+
- uniq-id: "{{- .Var.uniq_id -}}"
10+
configure-ips: true
11+
pool-ips:
12+
- "{{- .Var.poolip1 -}}"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
cloud:
3+
network:
4+
public:
5+
remove:
6+
- uniq-id: "{{- .Var.uniq_id -}}"
7+
configure-ips: true
8+
ips:
9+
- "{{- .Var.rmip1 -}}"

instance/plan.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Plan struct {
2727
type PlanCloud struct {
2828
Server *PlanCloudServer
2929
Template *PlanCloudTemplate
30+
Network *PlanCloudNetwork
3031
}
3132

3233
type PlanCloudServer struct {
@@ -38,6 +39,15 @@ type PlanCloudTemplate struct {
3839
Restore []CloudTemplateRestoreParams
3940
}
4041

42+
type PlanCloudNetwork struct {
43+
Public *PlanCloudNetworkPublic
44+
}
45+
46+
type PlanCloudNetworkPublic struct {
47+
Add []CloudNetworkPublicAddParams
48+
Remove []CloudNetworkPublicRemoveParams
49+
}
50+
4151
func (ci *Client) ProcessPlan(plan *Plan) error {
4252

4353
if plan.Cloud != nil {
@@ -69,6 +79,12 @@ func (ci *Client) processPlanCloud(cloud *PlanCloud) error {
6979
}
7080
}
7181

82+
if cloud.Network != nil {
83+
if err := ci.processPlanCloudNetwork(cloud.Network); err != nil {
84+
return err
85+
}
86+
}
87+
7288
return nil
7389
}
7490

@@ -136,6 +152,60 @@ func (ci *Client) processPlanCloudTemplate(template *PlanCloudTemplate) error {
136152
return nil
137153
}
138154

155+
func (ci *Client) processPlanCloudNetwork(network *PlanCloudNetwork) error {
156+
157+
if network.Public != nil {
158+
if err := ci.processPlanCloudNetworkPublic(network.Public); err != nil {
159+
return err
160+
}
161+
}
162+
163+
return nil
164+
}
165+
166+
func (ci *Client) processPlanCloudNetworkPublic(public *PlanCloudNetworkPublic) error {
167+
168+
if public.Add != nil {
169+
for _, c := range public.Add {
170+
if err := ci.processPlanCloudNetworkPublicAdd(&c); err != nil {
171+
return err
172+
}
173+
}
174+
}
175+
176+
if public.Remove != nil {
177+
for _, c := range public.Remove {
178+
if err := ci.processPlanCloudNetworkPublicRemove(&c); err != nil {
179+
return err
180+
}
181+
}
182+
}
183+
184+
return nil
185+
}
186+
187+
func (ci *Client) processPlanCloudNetworkPublicAdd(params *CloudNetworkPublicAddParams) error {
188+
result, err := ci.CloudNetworkPublicAdd(params)
189+
if err != nil {
190+
ci.Die(err)
191+
}
192+
193+
fmt.Print(result)
194+
195+
return nil
196+
}
197+
198+
func (ci *Client) processPlanCloudNetworkPublicRemove(params *CloudNetworkPublicRemoveParams) error {
199+
result, err := ci.CloudNetworkPublicRemove(params)
200+
if err != nil {
201+
ci.Die(err)
202+
}
203+
204+
fmt.Print(result)
205+
206+
return nil
207+
}
208+
139209
func (ci *Client) processPlanCloudTemplateRestore(params *CloudTemplateRestoreParams) error {
140210

141211
result, err := ci.CloudTemplateRestore(params)

0 commit comments

Comments
 (0)