@@ -48,7 +48,6 @@ var _ = Describe("Instance", func() {
4848 var (
4949 mockCtrl * gomock.Controller
5050 mockClient * cloudstack.CloudStackClient
51- as * cloudstack.MockAddressServiceIface
5251 vms * cloudstack.MockVirtualMachineServiceIface
5352 sos * cloudstack.MockServiceOfferingServiceIface
5453 dos * cloudstack.MockDiskOfferingServiceIface
@@ -65,7 +64,6 @@ var _ = Describe("Instance", func() {
6564 dos = mockClient .DiskOffering .(* cloudstack.MockDiskOfferingServiceIface )
6665 ts = mockClient .Template .(* cloudstack.MockTemplateServiceIface )
6766 vs = mockClient .Volume .(* cloudstack.MockVolumeServiceIface )
68- as = mockClient .Address .(* cloudstack.MockAddressServiceIface )
6967 client = cloud .NewClientFromCSAPIClient (mockClient , nil )
7068
7169 dummies .SetDummyVars ()
@@ -129,13 +127,6 @@ var _ = Describe("Instance", func() {
129127 vms .EXPECT ().GetVirtualMachinesMetricByID (* dummies .CSMachine1 .Spec .InstanceID ).Return (nil , - 1 , notFoundError )
130128 vms .EXPECT ().GetVirtualMachinesMetricByName (dummies .CSMachine1 .Name ).Return (nil , - 1 , notFoundError )
131129 }
132- expectPublicIPAddress := func () {
133- aslp := & cloudstack.ListPublicIpAddressesParams {}
134- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
135- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
136- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
137- }, nil )
138- }
139130
140131 It ("doesn't re-create if one already exists." , func () {
141132 vms .EXPECT ().GetVirtualMachinesMetricByID (* dummies .CSMachine1 .Spec .InstanceID ).Return (vmMetricResp , - 1 , nil )
@@ -153,29 +144,14 @@ var _ = Describe("Instance", func() {
153144
154145 It ("returns errors occurring while fetching service offering information" , func () {
155146 expectVMNotFound ()
156- expectPublicIPAddress ()
157147 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).Return (& cloudstack.ServiceOffering {}, - 1 , unknownError )
158148 Ω (client .GetOrCreateVMInstance (
159149 dummies .CSMachine1 , dummies .CAPIMachine , dummies .CSCluster , dummies .CSFailureDomain1 , dummies .CSAffinityGroup , "" )).
160150 ShouldNot (Succeed ())
161151 })
162152
163- It ("returns errors occurring if not enough public IPs available" , func () {
164- expectVMNotFound ()
165-
166- aslp := & cloudstack.ListPublicIpAddressesParams {}
167- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
168- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
169- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Allocated" }},
170- }, nil )
171- Ω (client .GetOrCreateVMInstance (
172- dummies .CSMachine1 , dummies .CAPIMachine , dummies .CSCluster , dummies .CSFailureDomain1 , dummies .CSAffinityGroup , "" )).
173- ShouldNot (Succeed ())
174- })
175-
176153 It ("returns errors if more than one service offering found" , func () {
177154 expectVMNotFound ()
178- expectPublicIPAddress ()
179155 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).Return (& cloudstack.ServiceOffering {
180156 Id : dummies .CSMachine1 .Spec .Offering .ID ,
181157 Name : dummies .CSMachine1 .Spec .Offering .Name ,
@@ -187,7 +163,7 @@ var _ = Describe("Instance", func() {
187163
188164 It ("returns errors while fetching template" , func () {
189165 expectVMNotFound ()
190- expectPublicIPAddress ()
166+
191167 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
192168 Return (& cloudstack.ServiceOffering {
193169 Id : dummies .CSMachine1 .Spec .Offering .ID ,
@@ -202,7 +178,7 @@ var _ = Describe("Instance", func() {
202178
203179 It ("returns errors when more than one template found" , func () {
204180 expectVMNotFound ()
205- expectPublicIPAddress ()
181+
206182 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
207183 Return (& cloudstack.ServiceOffering {
208184 Id : dummies .CSMachine1 .Spec .Offering .ID ,
@@ -216,7 +192,7 @@ var _ = Describe("Instance", func() {
216192
217193 It ("returns errors when more than one diskoffering found" , func () {
218194 expectVMNotFound ()
219- expectPublicIPAddress ()
195+
220196 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
221197 Return (& cloudstack.ServiceOffering {
222198 Id : dummies .CSMachine1 .Spec .Offering .ID ,
@@ -231,7 +207,6 @@ var _ = Describe("Instance", func() {
231207
232208 It ("returns errors when fetching diskoffering" , func () {
233209 expectVMNotFound ()
234- expectPublicIPAddress ()
235210 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
236211 Return (& cloudstack.ServiceOffering {
237212 Id : dummies .CSMachine1 .Spec .Offering .ID ,
@@ -247,7 +222,6 @@ var _ = Describe("Instance", func() {
247222
248223 It ("returns errors when disk size not zero for non-customized disk offering" , func () {
249224 expectVMNotFound ()
250- expectPublicIPAddress ()
251225 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 1
252226 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
253227 Return (& cloudstack.ServiceOffering {
@@ -264,7 +238,6 @@ var _ = Describe("Instance", func() {
264238
265239 It ("returns errors when disk size zero for customized disk offering" , func () {
266240 expectVMNotFound ()
267- expectPublicIPAddress ()
268241 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
269242 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
270243 Return (& cloudstack.ServiceOffering {
@@ -284,7 +257,6 @@ var _ = Describe("Instance", func() {
284257 Context ("when account & domains have limits" , func () {
285258 It ("returns errors when there are not enough available CPU in account" , func () {
286259 expectVMNotFound ()
287- expectPublicIPAddress ()
288260 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
289261 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
290262 Return (& cloudstack.ServiceOffering {
@@ -313,7 +285,6 @@ var _ = Describe("Instance", func() {
313285
314286 It ("returns errors when there are not enough available CPU in domain" , func () {
315287 expectVMNotFound ()
316- expectPublicIPAddress ()
317288 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
318289 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
319290 Return (& cloudstack.ServiceOffering {
@@ -342,7 +313,6 @@ var _ = Describe("Instance", func() {
342313
343314 It ("returns errors when there is not enough available memory in account" , func () {
344315 expectVMNotFound ()
345- expectPublicIPAddress ()
346316 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
347317 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
348318 Return (& cloudstack.ServiceOffering {
@@ -371,7 +341,6 @@ var _ = Describe("Instance", func() {
371341
372342 It ("returns errors when there is not enough available memory in domain" , func () {
373343 expectVMNotFound ()
374- expectPublicIPAddress ()
375344 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
376345 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
377346 Return (& cloudstack.ServiceOffering {
@@ -400,7 +369,6 @@ var _ = Describe("Instance", func() {
400369
401370 It ("returns errors when there is not enough available VM limit in account" , func () {
402371 expectVMNotFound ()
403- expectPublicIPAddress ()
404372 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
405373 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
406374 Return (& cloudstack.ServiceOffering {
@@ -429,7 +397,6 @@ var _ = Describe("Instance", func() {
429397
430398 It ("returns errors when there is not enough available VM limit in domain" , func () {
431399 expectVMNotFound ()
432- expectPublicIPAddress ()
433400 dummies .CSMachine1 .Spec .DiskOffering .CustomSize = 0
434401 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
435402 Return (& cloudstack.ServiceOffering {
@@ -459,7 +426,6 @@ var _ = Describe("Instance", func() {
459426
460427 It ("handles deployment errors" , func () {
461428 expectVMNotFound ()
462- expectPublicIPAddress ()
463429 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
464430 Return (& cloudstack.ServiceOffering {
465431 Id : offeringFakeID ,
@@ -531,11 +497,6 @@ var _ = Describe("Instance", func() {
531497 dummies .CSMachine1 .Spec .Offering .Name = "offering"
532498 dummies .CSMachine1 .Spec .Template .Name = "template"
533499
534- aslp := & cloudstack.ListPublicIpAddressesParams {}
535- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
536- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
537- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
538- }, nil )
539500 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).Return (& cloudstack.ServiceOffering {
540501 Id : offeringFakeID ,
541502 Cpunumber : 1 ,
@@ -556,11 +517,6 @@ var _ = Describe("Instance", func() {
556517 dummies .CSMachine1 .Spec .Template .Name = "template"
557518 dummies .CSMachine1 .Spec .DiskOffering = infrav1.CloudStackResourceDiskOffering {}
558519
559- aslp := & cloudstack.ListPublicIpAddressesParams {}
560- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
561- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
562- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
563- }, nil )
564520 sos .EXPECT ().GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).Return (& cloudstack.ServiceOffering {
565521 Id : offeringFakeID ,
566522 Cpunumber : 1 ,
@@ -579,11 +535,6 @@ var _ = Describe("Instance", func() {
579535 dummies .CSMachine1 .Spec .Offering .Name = ""
580536 dummies .CSMachine1 .Spec .Template .Name = "template"
581537
582- aslp := & cloudstack.ListPublicIpAddressesParams {}
583- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
584- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
585- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
586- }, nil )
587538 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).Return (& cloudstack.ServiceOffering {
588539 Id : offeringFakeID ,
589540 Cpunumber : 1 ,
@@ -609,11 +560,7 @@ var _ = Describe("Instance", func() {
609560 Cpunumber : 1 ,
610561 Memory : 1024 ,
611562 }, 1 , nil )
612- aslp := & cloudstack.ListPublicIpAddressesParams {}
613- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
614- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
615- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
616- }, nil )
563+
617564 ts .EXPECT ().GetTemplateByID (dummies .CSMachine1 .Spec .Template .ID , executableFilter ).Return (& cloudstack.Template {Name : "" }, 1 , nil )
618565 dos .EXPECT ().GetDiskOfferingID (dummies .CSMachine1 .Spec .DiskOffering .Name , gomock .Any ()).Return (diskOfferingFakeID , 1 , nil )
619566 dos .EXPECT ().GetDiskOfferingByID (dummies .CSMachine1 .Spec .DiskOffering .ID ).Return (& cloudstack.DiskOffering {Iscustomized : false }, 1 , nil )
@@ -628,11 +575,6 @@ var _ = Describe("Instance", func() {
628575 dummies .CSMachine1 .Spec .Offering .Name = ""
629576 dummies .CSMachine1 .Spec .Template .Name = ""
630577
631- aslp := & cloudstack.ListPublicIpAddressesParams {}
632- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
633- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
634- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
635- }, nil )
636578 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).
637579 Return (& cloudstack.ServiceOffering {
638580 Id : offeringFakeID ,
@@ -656,11 +598,6 @@ var _ = Describe("Instance", func() {
656598 dummies .CSMachine1 .Spec .Offering .Name = "offering"
657599 dummies .CSMachine1 .Spec .Template .Name = "template"
658600
659- aslp := & cloudstack.ListPublicIpAddressesParams {}
660- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
661- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
662- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
663- }, nil )
664601 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).Return (& cloudstack.ServiceOffering {
665602 Id : dummies .CSMachine1 .Spec .Offering .ID ,
666603 Name : dummies .CSMachine1 .Spec .Offering .Name ,
@@ -688,11 +625,6 @@ var _ = Describe("Instance", func() {
688625 dummies .CSMachine1 .Spec .Offering .Name = "offering"
689626 dummies .CSMachine1 .Spec .Template .Name = "template"
690627
691- aslp := & cloudstack.ListPublicIpAddressesParams {}
692- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
693- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
694- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
695- }, nil )
696628 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).Return (& cloudstack.ServiceOffering {Name : "offering-not-match" }, 1 , nil )
697629 requiredRegexp := "offering name %s does not match name %s returned using UUID %s"
698630 Ω (client .GetOrCreateVMInstance (
@@ -706,18 +638,12 @@ var _ = Describe("Instance", func() {
706638 dummies .CSMachine1 .Spec .Offering .Name = "offering"
707639 dummies .CSMachine1 .Spec .Template .Name = "template"
708640
709- aslp := & cloudstack.ListPublicIpAddressesParams {}
710- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
711- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
712- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
713- }, nil )
714641 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).Return (& cloudstack.ServiceOffering {Name : "offering" }, 1 , nil )
715642 ts .EXPECT ().GetTemplateByID (dummies .CSMachine1 .Spec .Template .ID , executableFilter ).Return (& cloudstack.Template {Name : "template-not-match" }, 1 , nil )
716643 requiredRegexp := "template name %s does not match name %s returned using UUID %s"
717644 Ω (client .GetOrCreateVMInstance (
718645 dummies .CSMachine1 , dummies .CAPIMachine , dummies .CSCluster , dummies .CSFailureDomain1 , dummies .CSAffinityGroup , "" )).
719646 Should (MatchError (MatchRegexp (requiredRegexp , dummies .CSMachine1 .Spec .Template .Name , "template-not-match" , templateFakeID )))
720-
721647 })
722648
723649 It ("works with Id and name both provided, disk offering id/name mismatch" , func () {
@@ -728,19 +654,13 @@ var _ = Describe("Instance", func() {
728654 dummies .CSMachine1 .Spec .Template .Name = "template"
729655 dummies .CSMachine1 .Spec .DiskOffering .Name = "diskoffering"
730656
731- aslp := & cloudstack.ListPublicIpAddressesParams {}
732- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
733- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
734- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
735- }, nil )
736657 sos .EXPECT ().GetServiceOfferingByID (dummies .CSMachine1 .Spec .Offering .ID ).Return (& cloudstack.ServiceOffering {Name : "offering" }, 1 , nil )
737658 ts .EXPECT ().GetTemplateByID (dummies .CSMachine1 .Spec .Template .ID , executableFilter ).Return (& cloudstack.Template {Name : "template" }, 1 , nil )
738659 dos .EXPECT ().GetDiskOfferingID (dummies .CSMachine1 .Spec .DiskOffering .Name , gomock .Any ()).Return (diskOfferingFakeID + "-not-match" , 1 , nil )
739660 requiredRegexp := "diskOffering ID %s does not match ID %s returned using name %s"
740661 Ω (client .GetOrCreateVMInstance (
741662 dummies .CSMachine1 , dummies .CAPIMachine , dummies .CSCluster , dummies .CSFailureDomain1 , dummies .CSAffinityGroup , "" )).
742663 Should (MatchError (MatchRegexp (requiredRegexp , dummies .CSMachine1 .Spec .DiskOffering .ID , diskOfferingFakeID + "-not-match" , dummies .CSMachine1 .Spec .DiskOffering .Name )))
743-
744664 })
745665 })
746666
@@ -762,11 +682,6 @@ var _ = Describe("Instance", func() {
762682 GetVirtualMachinesMetricByName (dummies .CSMachine1 .Name ).
763683 Return (nil , - 1 , notFoundError )
764684
765- aslp := & cloudstack.ListPublicIpAddressesParams {}
766- as .EXPECT ().NewListPublicIpAddressesParams ().Return (aslp )
767- as .EXPECT ().ListPublicIpAddresses (aslp ).Return (& cloudstack.ListPublicIpAddressesResponse {
768- Count : 2 , PublicIpAddresses : []* cloudstack.PublicIpAddress {{State : "Allocated" }, {State : "Free" }},
769- }, nil )
770685 sos .EXPECT ().
771686 GetServiceOfferingByName (dummies .CSMachine1 .Spec .Offering .Name , gomock .Any ()).
772687 Return (& cloudstack.ServiceOffering {
0 commit comments