diff options
author | Ravi Shekhar Jethani <rsjethani@gmail.com> | 2017-09-20 19:20:18 +0530 |
---|---|---|
committer | Ravi Shekhar Jethani <rsjethani@gmail.com> | 2017-09-20 19:20:18 +0530 |
commit | 3d156aa7710f2d5bcc94e4283bfabd15db53c7b6 (patch) | |
tree | bdf33399607b264c76331501d3dfa24a3dc7dddc /libvirt/resource_libvirt_domain.go | |
parent | 3fd193d2f81e36405cb65352f9cd134c9b9050b8 (diff) | |
download | terraform-provider-libvirt-3d156aa7710f2d5bcc94e4283bfabd15db53c7b6.tar terraform-provider-libvirt-3d156aa7710f2d5bcc94e4283bfabd15db53c7b6.tar.gz |
Remove redundant hostname check
Currently while creating domain we are checking whether hostname
has been set or not. But from the code it's clear that hostname
will _always_ be set. Hostname will be set to domain name by default
which maybe overridden via the optional hostname attribute of the
network interface definition.
Hence removing the unnecessary check.
Diffstat (limited to 'libvirt/resource_libvirt_domain.go')
-rw-r--r-- | libvirt/resource_libvirt_domain.go | 31 |
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" |