Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/configurations/acord/Makefile b/xos/configurations/acord/Makefile
index 5b03692..6d5a04f 100644
--- a/xos/configurations/acord/Makefile
+++ b/xos/configurations/acord/Makefile
@@ -1,11 +1,11 @@
 SETUPDIR:=../setup
 MYIP:=$(shell hostname -i)
 
-cloudlab: common_cloudlab cloudlab_ceilometer_custom_images acord
+cloudlab: common_cloudlab cloudlab_ceilometer_custom_images ceilometer_cloudlab_cord_plugins acord
 
-devstack: upgrade_pkgs common_devstack devstack_net_fix devstack_images acord
+devstack: upgrade_pkgs common_devstack devstack_net_fix devstack_images ceilometer_devstack_cord_plugins acord
 
-cord: ceilometer_dashboard
+cord: 
 	sudo MYIP=$(MYIP) docker-compose up -d
 	bash ../common/wait_for_xos.sh
 	sudo MYIP=$(MYIP) docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/fixtures.yaml
@@ -25,11 +25,33 @@
 common_devstack:
 	make -C ../common -f Makefile.devstack
 
-ceilometer_dashboard:
-	#NOTE: The below dashboard install scripts assume
-	#clouldlab openstack environment created using "OpenStack" profile
-	#bash install_xos_ceilometer_dashboard.sh
-	#bash install_ceilometer_patch.sh
+ceilometer_cloudlab_cord_plugins:
+	if [ -d ./ceilometer-plugins ]; then rm -fr ./ceilometer-plugins; fi
+	git clone https://github.com/srikanthvavila/ceilometer-plugins.git
+	sudo cp -r ceilometer-plugins/network/ext_services /usr/lib/python2.7/dist-packages/ceilometer/network/
+	sudo cp -r ceilometer-plugins/network/statistics/onos /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/
+	sudo cp ceilometer-plugins/network/statistics/__init__.py /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/ 
+	sudo cp ceilometer-plugins/entry_points.txt /usr/lib/python2.7/dist-packages/ceilometer-*egg-info/
+	sudo cp ceilometer-plugins/pipeline.yaml /etc/ceilometer/
+	echo "Restarting ceilometer-agent-notification"
+	sudo service ceilometer-agent-notification restart
+	echo "Restarting ceilometer-agent-central"
+	sudo service ceilometer-agent-central restart
+
+ceilometer_devstack_cord_plugins:
+	if [ -d ./ceilometer-plugins ]; then rm -fr ./ceilometer-plugins; fi
+	git clone https://github.com/srikanthvavila/ceilometer-plugins.git
+	sudo cp -r ceilometer-plugins/network/ext_services /opt/stack/ceilometer/ceilometer/network/
+	sudo cp ceilometer-plugins/entry_points.txt /opt/stack/ceilometer/ceilometer*egg-info/
+	sudo cp ceilometer-plugins/pipeline.yaml /etc/ceilometer/
+	echo "Remember to restart ceilometer-anotification ceilometer-acentral screens"
+
+ceilometer_pub_sub:
+	if [ -d ./pub-sub ]; then rm -fr ./pub-sub; fi
+	git clone https://github.com/srikanthvavila/pub-sub.git
+	echo "Starting Ceilometer PUB/SUB service...Ensure zookeeper and kafka services are launched (if required)"
+	cd pub-sub/ceilometer_pub_sub/ ; python sub_main.py & 
+	cd ../..
 
 stop:
 	sudo MYIP=$(MYIP) docker-compose stop
diff --git a/xos/configurations/cord-pod/cord-vtn-vsg.yaml b/xos/configurations/cord-pod/cord-vtn-vsg.yaml
index c06e237..f29e257 100644
--- a/xos/configurations/cord-pod/cord-vtn-vsg.yaml
+++ b/xos/configurations/cord-pod/cord-vtn-vsg.yaml
@@ -8,6 +8,12 @@
 topology_template:
   node_templates:
     # CORD Services
+    service_vtr:
+      type: tosca.nodes.Service
+      properties:
+          view_url: /admin/vtr/vtrservice/$id$/
+          kind: vTR
+
     service_volt:
       type: tosca.nodes.Service
       requirements:
diff --git a/xos/configurations/cord-pod/docker-compose.yml b/xos/configurations/cord-pod/docker-compose.yml
index a0fec91..cb7194f 100644
--- a/xos/configurations/cord-pod/docker-compose.yml
+++ b/xos/configurations/cord-pod/docker-compose.yml
@@ -74,6 +74,18 @@
         - .:/root/setup:ro
         - ./id_rsa:/opt/xos/synchronizers/monitoring_channel/monitoring_channel_private_key:ro  # private key
 
+xos_synchronizer_vtr:
+    image: xosproject/xos-synchronizer-openstack
+    command: bash -c "sleep 120; cp /root/setup/node_key /opt/xos/synchronizers/vtr/; chmod 0600 /opt/xos/synchronizers/vtr/node_key; python /opt/xos/synchronizers/vtr/vtr-synchronizer.py -C /root/setup/files/vtr_synchronizer_config"
+    labels:
+        org.xosproject.kind: synchronizer
+        org.xosproject.target: vtr
+    links:
+        - xos_db
+    volumes:
+        - .:/root/setup:ro
+        - ./id_rsa:/opt/xos/synchronizers/vtr/vcpe_private_key:ro  # private key
+
 xos:
     command: python /opt/xos/manage.py runserver 0.0.0.0:80 --insecure --makemigrations
     image: xosproject/xos
diff --git a/xos/configurations/cord-pod/files/vtr_synchronizer_config b/xos/configurations/cord-pod/files/vtr_synchronizer_config
new file mode 100644
index 0000000..2c9140a
--- /dev/null
+++ b/xos/configurations/cord-pod/files/vtr_synchronizer_config
@@ -0,0 +1,47 @@
+
+[plc]
+name=plc
+deployment=VICCI
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=128.112.171.237
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+
+[observer]
+name=vtr
+dependency_graph=/opt/xos/synchronizers/vtr/model-deps
+steps_dir=/opt/xos/synchronizers/vtr/steps
+sys_dir=/opt/xos/synchronizers/vtr/sys
+deleters_dir=/opt/xos/synchronizers/vtr/deleters
+log_file=console
+#/var/log/hpc.log
+driver=None
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+# set proxy_ssh to false on cloudlab
+full_setup=True
+proxy_ssh=True
+proxy_ssh_key=/opt/xos/synchronizers/vtr/node_key
+proxy_ssh_user=root
+
+[networking]
+use_vtn=True
+
+[feefie]
+client_id='vicci_dev_central'
+user_id='pl'
diff --git a/xos/configurations/cord/Makefile b/xos/configurations/cord/Makefile
index 56990a2..9fee5f8 100644
--- a/xos/configurations/cord/Makefile
+++ b/xos/configurations/cord/Makefile
@@ -5,7 +5,7 @@
 
 devstack: upgrade_pkgs common_devstack devstack_net_fix cord
 
-cord: ceilometer_dashboard virtualbng_json vtn_network_cfg_json
+cord: virtualbng_json vtn_network_cfg_json
 	sudo MYIP=$(MYIP) docker-compose up -d
 	bash ../common/wait_for_xos.sh
 	sudo MYIP=$(MYIP) docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/fixtures.yaml
@@ -23,14 +23,28 @@
 common_devstack:
 	make -C ../common -f Makefile.devstack
 
-acord: cloudlab_ceilometer_custom_images ceilometer_dashboard
+acord: cloudlab_ceilometer_custom_images ceilometer_cloudlab_cord_plugins
 	sudo MYIP=$(MYIP) docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord/ceilometer.yaml
 
-ceilometer_dashboard:
-	#NOTE: The below dashboard install scripts assume
-	#clouldlab openstack environment created using "OpenStack" profile
-	#bash install_xos_ceilometer_dashboard.sh
-	bash install_ceilometer_patch.sh
+ceilometer_cloudlab_cord_plugins:
+	if [ -d ./ceilometer-plugins ]; then rm -fr ./ceilometer-plugins; fi
+	git clone https://github.com/srikanthvavila/ceilometer-plugins.git
+	sudo cp -r ceilometer-plugins/network/ext_services /usr/lib/python2.7/dist-packages/ceilometer/network/
+	sudo cp -r ceilometer-plugins/network/statistics/onos /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/
+	sudo cp ceilometer-plugins/network/statistics/__init__.py /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/ 
+	sudo cp ceilometer-plugins/entry_points.txt /usr/lib/python2.7/dist-packages/ceilometer-*egg-info/
+	sudo cp ceilometer-plugins/pipeline.yaml /etc/ceilometer/
+	echo "Restarting ceilometer-agent-notification"
+	sudo service ceilometer-agent-notification restart
+	echo "Restarting ceilometer-agent-central"
+	sudo service ceilometer-agent-central restart
+
+ceilometer_pub_sub:
+	if [ -d ./pub-sub ]; then rm -fr ./pub-sub; fi
+	git clone https://github.com/srikanthvavila/pub-sub.git
+	echo "Starting Ceilometer PUB/SUB service...Ensure zookeeper and kafka services are launched (if required)"
+	cd pub-sub/ceilometer_pub_sub/ ; python sub_main.py & 
+	cd ../..
 
 virtualbng_json:
 	export SETUPDIR=$(SETUPDIR); bash make-virtualbng-json.sh
diff --git a/xos/configurations/cord/ceilometer_pub_sub.tar.gz b/xos/configurations/cord/ceilometer_pub_sub.tar.gz
deleted file mode 100644
index eb88a2b..0000000
--- a/xos/configurations/cord/ceilometer_pub_sub.tar.gz
+++ /dev/null
Binary files differ
diff --git a/xos/configurations/cord/install_ceilometer_patch.sh b/xos/configurations/cord/install_ceilometer_patch.sh
deleted file mode 100755
index 77aa05b..0000000
--- a/xos/configurations/cord/install_ceilometer_patch.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-if [ -d /usr/lib/python2.7/dist-packages/ceilometer/network/ext_services ]; then
-    echo "Seems VCPE notification listeners are already enabled in ceilometer... so exiting gracefully..."
-    exit 0
-fi
-echo "Verifying if all the required files are present"
-if [ ! -f openstack_ceilometer_patch.tar.gz ] || [ ! -f ceilometer_pub_sub.tar.gz ];
-then
-    echo "File openstack_ceilometer_patch.tar.gz or ceilometer_pub_sub.tar.gz not found"
-    exit 1
-fi
-echo "Copying the ceilometer patch files to /usr/lib/python2.7/dist-packages/ceilometer"
-tar -xzf openstack_ceilometer_patch.tar.gz
-sudo mv ceilometer/network/ext_services /usr/lib/python2.7/dist-packages/ceilometer/network/
-sudo mv ceilometer/network/statistics/onos /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/
-sudo mv /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/__init__.py /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/orig_init.orig_py
-sudo mv ceilometer/network/statistics/__init__.py /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/
-sudo mv ceilometer-2015.1.1.egg-info/entry_points.txt /usr/lib/python2.7/dist-packages/ceilometer-*egg-info/
-sudo mv pipeline.yaml /etc/ceilometer/
-echo "Restarting ceilometer-agent-notification"
-sudo service ceilometer-agent-notification restart
-echo "Restarting ceilometer-agent-central"
-sudo service ceilometer-agent-central restart
-tar -xzf ceilometer_pub_sub.tar.gz
-echo "Starting Ceilometer PUB/SUB service"
-cd ceilometer_pub_sub
-python sub_main.py &
diff --git a/xos/configurations/cord/openstack_ceilometer_patch.tar.gz b/xos/configurations/cord/openstack_ceilometer_patch.tar.gz
deleted file mode 100644
index 2c4f02c..0000000
--- a/xos/configurations/cord/openstack_ceilometer_patch.tar.gz
+++ /dev/null
Binary files differ
diff --git a/xos/configurations/frontend/mocks/cord.yaml b/xos/configurations/frontend/mocks/cord.yaml
index ce1af09..c448da5 100644
--- a/xos/configurations/frontend/mocks/cord.yaml
+++ b/xos/configurations/frontend/mocks/cord.yaml
@@ -8,6 +8,12 @@
 topology_template:
   node_templates:
     # CORD Services
+    service_vtr:
+      type: tosca.nodes.Service
+      properties:
+          view_url: /admin/vtr/vtrservice/$id$/
+          kind: vTR
+
     service_volt:
       type: tosca.nodes.Service
       requirements:
diff --git a/xos/core/xoslib/methods/ceilometerview.py b/xos/core/xoslib/methods/ceilometerview.py
index 9e46aa7..0fb94c4 100644
--- a/xos/core/xoslib/methods/ceilometerview.py
+++ b/xos/core/xoslib/methods/ceilometerview.py
@@ -919,43 +919,43 @@
         # to info that I am able to obtain from Ceilometer meters, hopefully
         # some day it will be supported all.
         return datastructures.SortedDict([
-            ('vcpe', {
-                'type': _("VCPE"),
+            ('vsg', {
+                'type': _("VSG"),
                 'label': '',
-                'description': _("Existence of vcpe instance"),
+                'description': _("Existence of vsg instance"),
             }),
-            ('vcpe.dns.cache.size', {
-                'type': _("VCPE"),
+            ('vsg.dns.cache.size', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("Number of entries in DNS cache"),
             }),
-            ('vcpe.dns.total_instered_entries', {
-                'type': _("VCPE"),
+            ('vsg.dns.total_instered_entries', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("Total number of inserted entries into the cache"),
             }),
-            ('vcpe.dns.replaced_unexpired_entries', {
-                'type': _("VCPE"),
+            ('vsg.dns.replaced_unexpired_entries', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("Unexpired entries that were thrown out of cache"),
             }),
-            ('vcpe.dns.queries_answered_locally', {
-                'type': _("VCPE"),
+            ('vsg.dns.queries_answered_locally', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("Number of cache hits"),
             }),
-            ('vcpe.dns.queries_forwarded', {
-                'type': _("VCPE"),
+            ('vsg.dns.queries_forwarded', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("Number of cache misses"),
             }),
-            ('vcpe.dns.server.queries_sent', {
-                'type': _("VCPE"),
+            ('vsg.dns.server.queries_sent', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("For each upstream server, the number of queries sent"),
             }),
-            ('vcpe.dns.server.queries_failed', {
-                'type': _("VCPE"),
+            ('vsg.dns.server.queries_failed', {
+                'type': _("VSG"),
                 'label': '',
                 'description': _("For each upstream server, the number of queries failed"),
             }),
@@ -1165,7 +1165,7 @@
         services = {
             _('Nova'): meters.list_nova(),
             _('Neutron'): meters.list_neutron(),
-            _('VCPE'): meters.list_vcpe(),
+            _('VSG'): meters.list_vcpe(),
             _('VOLT'): meters.list_volt(),
             _('SDN'): meters.list_sdn(),
         }
@@ -1236,7 +1236,7 @@
         services = {
             _('Nova'): meters.list_nova(),
             _('Neutron'): meters.list_neutron(),
-            _('VCPE'): meters.list_vcpe(),
+            _('VSG'): meters.list_vcpe(),
             _('VOLT'): meters.list_volt(),
             _('SDN'): meters.list_sdn(),
         }
@@ -1394,7 +1394,7 @@
             services = {
                 _('Nova'): meters.list_nova(except_meters=exclude_nova_meters_info),
                 _('Neutron'): meters.list_neutron(except_meters=exclude_neutron_meters_info),
-                _('VCPE'): meters.list_vcpe(),
+                _('VSG'): meters.list_vcpe(),
                 _('VOLT'): meters.list_volt(),
                 _('SDN'): meters.list_sdn(),
             }
diff --git a/xos/services/vtr/admin.py b/xos/services/vtr/admin.py
index d00e1a3..0bdd475 100644
--- a/xos/services/vtr/admin.py
+++ b/xos/services/vtr/admin.py
@@ -64,7 +64,10 @@
             self.fields['argument'].initial = self.instance.argument
             self.fields['target'].initial = self.instance.target
             self.fields['scope'].initial = self.instance.scope
-            self.fields['result'].initial = self.instance.result
+            if (self.instance.enacted is not None) and (self.instance.enacted >= self.instance.updated):
+                self.fields['result'].initial = self.instance.result
+            else:
+                self.fields['result'].initial = ""
         if (not self.instance) or (not self.instance.pk):
             # default fields for an 'add' form
             self.fields['kind'].initial = VTR_KIND
@@ -87,13 +90,16 @@
     list_display = ('backend_status_icon', 'id', 'target', 'test', 'argument' )
     list_display_links = ('backend_status_icon', 'id')
     fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', # 'subscriber_root', 'service_specific_id', 'service_specific_attribute',
-                                     'target', 'scope', 'test', 'argument', 'result'],
+                                     'target', 'scope', 'test', 'argument', 'is_synced', 'result'],
                           'classes':['suit-tab suit-tab-general']})]
-    readonly_fields = ('backend_status_text', 'service_specific_attribute')
+    readonly_fields = ('backend_status_text', 'service_specific_attribute', 'is_synced')
     form = VTRTenantForm
 
     suit_form_tabs = (('general','Details'),)
 
+    def is_synced(self, obj):
+        return (obj.enacted is not None) and (obj.enacted >= obj.updated)
+
     def queryset(self, request):
         return VTRTenant.get_tenant_objects_by_user(request.user)
 
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
index 3fb7fa7..66deed5 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
@@ -84,8 +84,9 @@
   - name: Add eth0.500
     shell: "{{ '{{' }} item {{ '}}' }}"
     with_items:
-      - ip link del link eth0 eth0.500 || true
+      - ifconfig br-wan down || true
       - brctl delbr br-wan || true
+      - ip link del link eth0 eth0.500 || true
       - ip link add link eth0 eth0.500 type vlan id 500
       - ifconfig eth0.500 up
       - ifconfig eth0.500 0.0.0.0
@@ -105,6 +106,7 @@
        - ip link del link eth0 eth0.500
        - ip link add link eth0 eth0.500 type vlan id 500
        - ip link set eth0.500 up
+       - ifconfig br-wan down || true
        - brctl delbr br-wan || true
        - brctl addbr br-wan
        - brctl addif br-wan eth0.500