@@ -355,6 +355,116 @@ def test_generate_public_vlan(self):
355355
356356 self .assertEqual (data , assert_data )
357357
358+ def test_generate_public_vlan_with_public_subnet (self ):
359+ data = self .vs ._generate_create_dict (
360+ cpus = 1 ,
361+ memory = 1 ,
362+ hostname = 'test' ,
363+ domain = 'example.com' ,
364+ os_code = "STRING" ,
365+ public_vlan = 1 ,
366+ public_subnet = 1
367+ )
368+
369+ assert_data = {
370+ 'startCpus' : 1 ,
371+ 'maxMemory' : 1 ,
372+ 'hostname' : 'test' ,
373+ 'domain' : 'example.com' ,
374+ 'localDiskFlag' : True ,
375+ 'operatingSystemReferenceCode' : "STRING" ,
376+ 'hourlyBillingFlag' : True ,
377+ 'primaryNetworkComponent' : {'networkVlan' : {'id' : 1 ,
378+ 'primarySubnet' : {'id' : 1 }}},
379+ 'supplementalCreateObjectOptions' : {'bootMode' : None },
380+ }
381+
382+ self .assertEqual (data , assert_data )
383+
384+ def test_generate_private_vlan_with_private_subnet (self ):
385+ data = self .vs ._generate_create_dict (
386+ cpus = 1 ,
387+ memory = 1 ,
388+ hostname = 'test' ,
389+ domain = 'example.com' ,
390+ os_code = "STRING" ,
391+ private_vlan = 1 ,
392+ private_subnet = 1
393+ )
394+
395+ assert_data = {
396+ 'startCpus' : 1 ,
397+ 'maxMemory' : 1 ,
398+ 'hostname' : 'test' ,
399+ 'domain' : 'example.com' ,
400+ 'localDiskFlag' : True ,
401+ 'operatingSystemReferenceCode' : "STRING" ,
402+ 'hourlyBillingFlag' : True ,
403+ 'primaryBackendNetworkComponent' : {'networkVlan' : {'id' : 1 ,
404+ 'primarySubnet' : {'id' : 1 }}},
405+ 'supplementalCreateObjectOptions' : {'bootMode' : None },
406+ }
407+
408+ self .assertEqual (data , assert_data )
409+
410+ def test_generate_private_vlan_subnet_public_vlan_subnet (self ):
411+ data = self .vs ._generate_create_dict (
412+ cpus = 1 ,
413+ memory = 1 ,
414+ hostname = 'test' ,
415+ domain = 'example.com' ,
416+ os_code = "STRING" ,
417+ private_vlan = 1 ,
418+ private_subnet = 1 ,
419+ public_vlan = 1 ,
420+ public_subnet = 1 ,
421+ )
422+
423+ assert_data = {
424+ 'startCpus' : 1 ,
425+ 'maxMemory' : 1 ,
426+ 'hostname' : 'test' ,
427+ 'domain' : 'example.com' ,
428+ 'localDiskFlag' : True ,
429+ 'operatingSystemReferenceCode' : "STRING" ,
430+ 'hourlyBillingFlag' : True ,
431+ 'primaryBackendNetworkComponent' : {'networkVlan' : {'id' : 1 ,
432+ 'primarySubnet' : {'id' : 1 }}},
433+ 'primaryNetworkComponent' : {'networkVlan' : {'id' : 1 ,
434+ 'primarySubnet' : {'id' : 1 }}},
435+ 'supplementalCreateObjectOptions' : {'bootMode' : None },
436+ }
437+
438+ self .assertEqual (data , assert_data )
439+
440+ def test_generate_private_subnet (self ):
441+ actual = self .assertRaises (
442+ exceptions .SoftLayerError ,
443+ self .vs ._generate_create_dict ,
444+ cpus = 1 ,
445+ memory = 1 ,
446+ hostname = 'test' ,
447+ domain = 'example.com' ,
448+ os_code = "STRING" ,
449+ private_subnet = 1 ,
450+ )
451+
452+ self .assertEqual (str (actual ), "You need to specify a private_vlan with private_subnet" )
453+
454+ def test_generate_public_subnet (self ):
455+ actual = self .assertRaises (
456+ exceptions .SoftLayerError ,
457+ self .vs ._generate_create_dict ,
458+ cpus = 1 ,
459+ memory = 1 ,
460+ hostname = 'test' ,
461+ domain = 'example.com' ,
462+ os_code = "STRING" ,
463+ public_subnet = 1 ,
464+ )
465+
466+ self .assertEqual (str (actual ), "You need to specify a public_vlan with public_subnet" )
467+
358468 def test_generate_private_vlan (self ):
359469 data = self .vs ._generate_create_dict (
360470 cpus = 1 ,
@@ -373,12 +483,73 @@ def test_generate_private_vlan(self):
373483 'localDiskFlag' : True ,
374484 'operatingSystemReferenceCode' : "STRING" ,
375485 'hourlyBillingFlag' : True ,
376- 'primaryBackendNetworkComponent' : {" networkVlan" : {"id" : 1 }},
486+ 'primaryBackendNetworkComponent' : {' networkVlan' : {'id' : 1 }},
377487 'supplementalCreateObjectOptions' : {'bootMode' : None },
378488 }
379489
380490 self .assertEqual (data , assert_data )
381491
492+ def test_create_network_components_vlan_subnet_private_vlan_subnet_public (self ):
493+ data = self .vs ._create_network_components (
494+ private_vlan = 1 ,
495+ private_subnet = 1 ,
496+ public_vlan = 1 ,
497+ public_subnet = 1 ,
498+ )
499+
500+ assert_data = {
501+ 'primaryBackendNetworkComponent' : {'networkVlan' : {'id' : 1 ,
502+ 'primarySubnet' : {'id' : 1 }}},
503+ 'primaryNetworkComponent' : {'networkVlan' : {'id' : 1 ,
504+ 'primarySubnet' : {'id' : 1 }}},
505+ }
506+
507+ self .assertEqual (data , assert_data )
508+
509+ def test_create_network_components_vlan_subnet_private (self ):
510+ data = self .vs ._create_network_components (
511+ private_vlan = 1 ,
512+ private_subnet = 1 ,
513+ )
514+
515+ assert_data = {
516+ 'primaryBackendNetworkComponent' : {'networkVlan' : {'id' : 1 ,
517+ 'primarySubnet' : {'id' : 1 }}},
518+ }
519+
520+ self .assertEqual (data , assert_data )
521+
522+ def test_create_network_components_vlan_subnet_public (self ):
523+ data = self .vs ._create_network_components (
524+ public_vlan = 1 ,
525+ public_subnet = 1 ,
526+ )
527+
528+ assert_data = {
529+ 'primaryNetworkComponent' : {'networkVlan' : {'id' : 1 ,
530+ 'primarySubnet' : {'id' : 1 }}},
531+ }
532+
533+ self .assertEqual (data , assert_data )
534+
535+ def test_create_network_components_private_subnet (self ):
536+ actual = self .assertRaises (
537+ exceptions .SoftLayerError ,
538+ self .vs ._create_network_components ,
539+ private_subnet = 1 ,
540+ )
541+
542+ self .assertEqual (str (actual ), "You need to specify a private_vlan with private_subnet" )
543+
544+ def test_create_network_components_public_subnet (self ):
545+ actual = self .assertRaises (
546+ exceptions .SoftLayerError ,
547+ self .vs ._create_network_components ,
548+ public_subnet = 1 ,
549+ )
550+
551+ self .assertEqual (str (actual ), "You need to specify a public_vlan with public_subnet" )
552+
382553 def test_generate_userdata (self ):
383554 data = self .vs ._generate_create_dict (
384555 cpus = 1 ,
@@ -621,10 +792,10 @@ def test_edit_full(self):
621792
622793 self .assertEqual (result , True )
623794 args = ({
624- 'hostname' : 'new-host' ,
625- 'domain' : 'new.sftlyr.ws' ,
626- 'notes' : 'random notes' ,
627- },)
795+ 'hostname' : 'new-host' ,
796+ 'domain' : 'new.sftlyr.ws' ,
797+ 'notes' : 'random notes' ,
798+ },)
628799 self .assert_called_with ('SoftLayer_Virtual_Guest' , 'editObject' ,
629800 identifier = 100 ,
630801 args = args )
0 commit comments