@@ -650,24 +650,24 @@ func resourceLibvirtNetworkDelete(d *schema.ResourceData, meta interface{}) erro
650
650
if err != nil {
651
651
return fmt .Errorf ("Couldn't determine if network is active: %s" , err )
652
652
}
653
+
653
654
// network can be in 2 states, handles this case by case
654
- active := activeInt == 1
655
- // in case network is inactive just undefine it
656
- if ! active {
657
- if err := virConn .NetworkUndefine (network ); err != nil {
658
- return fmt .Errorf ("Couldn't undefine libvirt network: %s" , err )
659
- }
660
- }
661
- // network is active, so we need to destroy it and undefine it
662
- if active {
655
+ if active := int2bool (int (activeInt )); active {
656
+ // network is active, so we need to destroy it and undefine it
663
657
if err := virConn .NetworkDestroy (network ); err != nil {
664
658
return fmt .Errorf ("When destroying libvirt network: %s" , err )
665
659
}
666
660
661
+ if err := virConn .NetworkUndefine (network ); err != nil {
662
+ return fmt .Errorf ("Couldn't undefine libvirt network: %s" , err )
663
+ }
664
+ } else {
665
+ // in case network is inactive just undefine it
667
666
if err := virConn .NetworkUndefine (network ); err != nil {
668
667
return fmt .Errorf ("Couldn't undefine libvirt network: %s" , err )
669
668
}
670
669
}
670
+
671
671
stateConf := & resource.StateChangeConf {
672
672
Pending : []string {"ACTIVE" },
673
673
Target : []string {"NOT-EXISTS" },
0 commit comments