Configure NAT with baremetal when necessary
[apex.git] / apex / undercloud / undercloud.py
index 3cd1e70..d2de2de 100644 (file)
@@ -124,6 +124,16 @@ class Undercloud:
                 "Unable to find IP for undercloud.  Check if VM booted "
                 "correctly")
 
+    def detect_nat(self, net_settings):
+        if self.external_net:
+            net = net_settings['networks'][constants.EXTERNAL_NETWORK][0]
+        else:
+            net = net_settings['networks'][constants.ADMIN_NETWORK]
+        if net['gateway'] == net['installer_vm']['ip']:
+            return True
+        else:
+            return False
+
     def configure(self, net_settings, deploy_settings,
                   playbook, apex_temp_dir, virtual_oc=False):
         """
@@ -141,7 +151,8 @@ class Undercloud:
         ansible_vars = Undercloud.generate_config(net_settings,
                                                   deploy_settings)
         ansible_vars['apex_temp_dir'] = apex_temp_dir
-        ansible_vars['virtual_overcloud'] = virtual_oc
+
+        ansible_vars['nat'] = self.detect_nat(net_settings)
         try:
             utils.run_ansible(ansible_vars, playbook, host=self.ip,
                               user='stack')