summaryrefslogtreecommitdiff
path: root/libvirt/resource_libvirt_domain.go
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt/resource_libvirt_domain.go')
-rw-r--r--libvirt/resource_libvirt_domain.go31
1 files changed, 13 insertions, 18 deletions
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go
index 40a62687..64f1b914 100644
--- a/libvirt/resource_libvirt_domain.go
+++ b/libvirt/resource_libvirt_domain.go
@@ -529,25 +529,20 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
}
}
} else {
- // no IPs provided: if the hostname has been provided, wait until we get an IP
- if len(hostname) > 0 {
- if waitForLeaseI, ok := d.GetOk(prefix + ".wait_for_lease"); ok {
- waitForLease := waitForLeaseI.(bool)
- if !waitForLease {
- return fmt.Errorf("Cannot map '%s': we are not waiting for lease and no IP has been provided", hostname)
- }
- }
- // the resource specifies a hostname but not an IP, so we must wait until we
- // have a valid lease and then read the IP we have been assigned, so we can
- // do the mapping
- log.Printf("[DEBUG] Will wait for an IP for hostname '%s'...", hostname)
- partialNetIfaces[strings.ToUpper(mac)] = pendingMapping{
- mac: strings.ToUpper(mac),
- hostname: hostname,
- network: network,
+ // no IPs provided so check whether we are waiting for a lease
+ if waitForLeaseI, ok := d.GetOk(prefix + ".wait_for_lease"); ok {
+ waitForLease := waitForLeaseI.(bool)
+ if !waitForLease {
+ return fmt.Errorf("Cannot map '%s': we are not waiting for lease and no IP has been provided", hostname)
}
- } else {
- // neither an IP or a hostname has been provided: so nothing must be forced
+ }
+ // we must wait until we have a valid lease and then read the IP we
+ // have been assigned, so we can do the mapping
+ log.Printf("[DEBUG] Will wait for an IP for hostname '%s'...", hostname)
+ partialNetIfaces[strings.ToUpper(mac)] = pendingMapping{
+ mac: strings.ToUpper(mac),
+ hostname: hostname,
+ network: network,
}
}
netIface.Type = "network"