lib/rubber/cloud/vsphere.rb in rubber-2.12.2 vs lib/rubber/cloud/vsphere.rb in rubber-2.13.0
- old
+ new
@@ -100,10 +100,28 @@
def destroy_instance(instance_id)
compute_provider.servers.get(instance_id).destroy(:force => true)
end
+ def after_refresh_instance(instance)
+ rubber_cfg = Rubber::Configuration.get_configuration(Rubber.env)
+ host_env = rubber_cfg.environment.bind(nil, instance.name)
+
+ dns_servers = [host_env.public_nic, env.public_nic, host_env.private_nic, env.private_nic].collect { |nic| nic.dns_servers if nic }.compact.first
+
+ # VMware Tools currently (as of Aug. 25, 2014) has a bug with Ubuntu 14.04 whereby it fails to properly configure
+ # DNS when static IP configurations are used in a customization spec. This works around the problem by setting
+ # up the resolvconf configuration directly.
+ if dns_servers && ! dns_servers.empty?
+ contents = dns_servers.map { |server| "nameserver #{server}" }.join("\n")
+ contents << "\n"
+
+ capistrano.put(contents, '/etc/resolvconf/resolv.conf.d/base', :mode => '0644', :hosts => instance.external_ip)
+ capistrano.run('resolvconf -u', :hosts => instance.external_ip)
+ end
+ end
+
def describe_instances(instance_id=nil)
instances = []
opts = {}
if instance_id
@@ -116,10 +134,14 @@
rubber_cfg = Rubber::Configuration.get_configuration(Rubber.env)
host_env = rubber_cfg.environment.bind(nil, item.name)
instance = {}
instance[:id] = item.id
- instance[:state] = item.tools_state
+
+ # If the VM is up, but the VMware Tools installation is out-of-date, just treat it as if the tools installation
+ # is okay. Otherwise, the rubber:refresh process won't detect that the VM has booted properly, even though
+ # it's running just fine. In all other cases, use the state reported by the vSphere API call.
+ instance[:state] = item.tools_state == 'toolsOld' ? active_state : item.tools_state
# We can't trust the describe operation when the instance is newly created because the VM customization
# step likely hasn't completed yet. This means we'll get back the IP address for the VM template, rather
# than the one we just configured.
if host_env.public_nic
\ No newline at end of file