Merge branch 'master' of github.com:open-cloud/xos
diff --git a/Dockerfile.cord b/Dockerfile.cord
index 2261628..bc72016 100644
--- a/Dockerfile.cord
+++ b/Dockerfile.cord
@@ -3,3 +3,4 @@
 
 ADD xos/observers/vcpe/supervisor/vcpe-observer.conf /etc/supervisor/conf.d/
 RUN sed -i 's/ubuntu-vcpe4/trusty-server-multi-nic/' /opt/xos/cord/models.py
+RUN sed -i 's/proxy_ssh=True/proxy_ssh=False/' /opt/xos/observers/vcpe/vcpe_observer_config
diff --git a/xos/cord/models.py b/xos/cord/models.py
index 7cf58e7..37b29a5 100644
--- a/xos/cord/models.py
+++ b/xos/cord/models.py
@@ -633,15 +633,7 @@
 
     @property
     def wan_mac(self):
-        ip = self.wan_ip
-        if not ip:
-           return None
-        try:
-           (a,b,c,d) = ip.split('.')
-           wan_mac = "02:42:%02x:%02x:%02x:%02x" % (int(a), int(b), int(c), int(d))
-        except:
-           wan_mac = "Exception"
-        return wan_mac
+        return self.addresses.get("wan", (None, None) )[1]
 
     @property
     def private_ip(self):
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.py b/xos/observers/vcpe/steps/sync_vcpetenant.py
index 53d0c54..ecc7b7c 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.py
@@ -116,10 +116,16 @@
         if o.volt:
             vlan_ids.append(o.volt.vlan_id)
 
+        try:
+            full_setup = Config().observer_full_setup
+        except:
+            full_setup = True
+
         fields = {"vlan_ids": vlan_ids,
                 "dnsdemux_ip": dnsdemux_ip,
                 "cdn_prefixes": cdn_prefixes,
-                "bbs_addrs": bbs_addrs}
+                "bbs_addrs": bbs_addrs,
+                "full_setup": full_setup}
 
         # add in the sync_attributes that come from the SubscriberRoot object
 
@@ -203,4 +209,3 @@
 
     def delete_record(self, m):
         pass
-
diff --git a/xos/observers/vcpe/templates/start-vcpe.sh.j2 b/xos/observers/vcpe/templates/start-vcpe.sh.j2
index 565adaf..7e714de 100755
--- a/xos/observers/vcpe/templates/start-vcpe.sh.j2
+++ b/xos/observers/vcpe/templates/start-vcpe.sh.j2
@@ -1,5 +1,15 @@
 #!/bin/bash
 
+function mac_to_iface {
+    MAC=$1
+    ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
+}
+
+function generate_mac_from_ip {
+    IP=$1
+    printf "02:42:%02x:%02x:%02x:%02x\n" `echo $IP|awk -F '.' '{print $1, $2, $3, $4}'`
+}
+
 iptables -L > /dev/null
 ip6tables -L > /dev/null
 
@@ -15,12 +25,18 @@
 fi
 
 # Set up networking via pipework
-docker exec $VCPE ifconfig eth0 >> /dev/null || pipework eth4 -i eth0 $VCPE {{ wan_ip }}/17@192.168.128.1 {{ wan_mac }}
-docker exec $VCPE ifconfig eth1 >> /dev/null || pipework eth3 -i eth1 $VCPE 192.168.0.1/24 @{{ vlan_ids[0] }}
-docker exec $VCPE ifconfig eth2 >> /dev/null || pipework eth0 -i eth2 $VCPE {{ hpc_client_ip }}/24
+WAN_CONTAINER_MAC=$( generate_mac_from_ip {{ wan_ip }} )
+WAN_IFACE=$( mac_to_iface {{ wan_mac }} )
+docker exec $VCPE ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VCPE {{ wan_ip }}/17@192.168.128.1 $WAN_CONTAINER_MAC
+
+LAN_IFACE=$( mac_to_iface {{ lan_mac }} )
+docker exec $VCPE ifconfig eth1 >> /dev/null || pipework $LAN_IFACE -i eth1 $VCPE 192.168.0.1/24 @{{ vlan_ids[0] }}
+
+HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
+docker exec $VCPE ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VCPE {{ hpc_client_ip }}/24
 
 # Make sure VM's eth0 (hpc_client) has no IP address
-ifconfig eth0 0.0.0.0
+ifconfig $HPC_IFACE 0.0.0.0
 
 # Now can start up dnsmasq
 docker exec $VCPE service dnsmasq start
diff --git a/xos/observers/vcpe/vcpe_observer_config b/xos/observers/vcpe/vcpe_observer_config
index 6d58340..afd1501 100644
--- a/xos/observers/vcpe/vcpe_observer_config
+++ b/xos/observers/vcpe/vcpe_observer_config
@@ -33,6 +33,8 @@
 pretend=False
 backoff_disabled=True
 save_ansible_output=True
+proxy_ssh=True
+full_setup=True
 
 [feefie]
 client_id='vicci_dev_central'
diff --git a/xos/openstack_observer/ansible.py b/xos/openstack_observer/ansible.py
index b53dd98..0e006ae 100755
--- a/xos/openstack_observer/ansible.py
+++ b/xos/openstack_observer/ansible.py
@@ -109,7 +109,7 @@
             except:
                 # fail silently
                 pass
-        
+
     else:
         msg = open(fqp+'.out').read()
 
@@ -139,28 +139,40 @@
     sliver_name = opts["sliver_name"]
     hostname = opts["hostname"]
     private_key = opts["private_key"]
+    nat_ip = opts["nat_ip"]
+
+    try:
+        proxy_ssh = Config().observer_proxy_ssh
+    except:
+        proxy_ssh = True
 
     (opts, fqp) = get_playbook_fn(opts, path)
     private_key_pathname = fqp + ".key"
     config_pathname = fqp + ".config"
     hosts_pathname = fqp + ".hosts"
 
-    proxy_command = "ProxyCommand ssh -q -i %s -o StrictHostKeyChecking=no %s@%s" % (private_key_pathname, instance_id, hostname)
-
     f = open(private_key_pathname, "w")
     f.write(private_key)
     f.close()
 
     f = open(config_pathname, "w")
     f.write("[ssh_connection]\n")
-    f.write('ssh_args = -o "%s" -o StrictHostKeyChecking=no\n' % proxy_command)
+    if proxy_ssh:
+        proxy_command = "ProxyCommand ssh -q -i %s -o StrictHostKeyChecking=no %s@%s" % (private_key_pathname, instance_id, hostname)
+        f.write('ssh_args = -o "%s"\n' % proxy_command)
     f.write('scp_if_ssh = True\n')
     f.write('pipelining = True\n')
+    f.write('\n[defaults]\n')
+    f.write('host_key_checking = False\n')
     f.close()
 
     f = open(hosts_pathname, "w")
     f.write("[%s]\n" % sliver_name)
-    f.write("%s ansible_ssh_private_key_file=%s\n" % (hostname, private_key_pathname))
+    if proxy_ssh:
+        f.write("%s ansible_ssh_private_key_file=%s\n" % (hostname, private_key_pathname))
+    else:
+        # acb: Login user is hardcoded, this is not great
+        f.write("%s ansible_ssh_private_key_file=%s ansible_ssh_user=ubuntu\n" % (nat_ip, private_key_pathname))
     f.close()
 
     # SSH will complain if private key is world or group readable