CORD-1908: cleanup VSG service

Change-Id: Ib7fa0a68dbba185b30d7cd1ea1b425ad3d33a8d3
diff --git a/xos/synchronizer/steps/sync_monitoring_agent.yaml b/xos/synchronizer/steps/sync_monitoring_agent.yaml
index e617504..677c4c7 100644
--- a/xos/synchronizer/steps/sync_monitoring_agent.yaml
+++ b/xos/synchronizer/steps/sync_monitoring_agent.yaml
@@ -27,8 +27,8 @@
       rabbit_host: {{ rabbit_host }}
 
   tasks:
-  - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
-    shell: pgrep -f [v]cpe_stats_notifier | wc -l
+  - name: Verify if vsg_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
+    shell: pgrep -f [v]sg_stats_notifier | wc -l
     register: cron_job_pids_count
 
   - name: DEBUG
@@ -40,8 +40,8 @@
     when: cron_job_pids_count.stdout == "0"
 
   - name: Copy cron job to destination
-    copy: src=/opt/xos/synchronizers/vsg/vcpe_stats_notifier.py
-      dest=/usr/local/share/vsg_monitoring_agent/vcpe_stats_notifier.py
+    copy: src=/opt/xos/synchronizers/vsg/vsg_stats_notifier.py
+      dest=/usr/local/share/vsg_monitoring_agent/vsg_stats_notifier.py
     become: yes
     when: cron_job_pids_count.stdout == "0"
 
@@ -50,8 +50,8 @@
     become: yes
     when: cron_job_pids_count.stdout == "0"
 
-  - name: Initiate vcpe_stats_notifier cron job
-    command: sudo python /usr/local/share/vsg_monitoring_agent/vcpe_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
+  - name: Initiate vsg_stats_notifier cron job
+    command: sudo python /usr/local/share/vsg_monitoring_agent/vsg_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
     async: 9999999999999999
     poll: 0
     become: yes
diff --git a/xos/synchronizer/steps/sync_vcpetenant.yaml b/xos/synchronizer/steps/sync_vcpetenant.yaml
deleted file mode 100644
index d3109e2..0000000
--- a/xos/synchronizer/steps/sync_vcpetenant.yaml
+++ /dev/null
@@ -1,195 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
----
-- hosts: {{ instance_name }}
-  gather_facts: False
-  connection: ssh
-  become_user: ubuntu
-
-  vars:
-      cdn_enable: {{ cdn_enable }}
-      dnsdemux_ip: {{ dnsdemux_ip }}
-      firewall_enable: {{ firewall_enable }}
-      url_filter_enable: {{ url_filter_enable }}
-      c_tags:
-        {% for c_tag in c_tags %}
-        - {{ c_tag }}
-        {% endfor %}
-      s_tags:
-        {% for s_tag in s_tags %}
-        - {{ s_tag }}
-        {% endfor %}
-      firewall_rules:
-        {% for firewall_rule in firewall_rules.split("\n") %}
-        - {{ firewall_rule }}
-        {% endfor %}
-      cdn_prefixes:
-        {% for prefix in cdn_prefixes %}
-        - {{ prefix }}
-        {% endfor %}
-      bbs_addrs:
-        {% for bbs_addr in bbs_addrs %}
-        - {{ bbs_addr }}
-        {% endfor %}
-      dns_servers:
-        {% for dns_server in dns_servers %}
-        - {{ dns_server }}
-        {% endfor %}
-      nat_ip: {{ nat_ip }}
-      nat_mac: {{ nat_mac }}
-      lan_ip: {{ lan_ip }}
-      lan_mac: {{ lan_mac }}
-      wan_ip: {{ wan_ip }}
-      wan_mac: {{ wan_mac }}
-      wan_container_mac: {{ wan_container_mac }}
-      wan_next_hop: 10.0.1.253   # FIX ME
-      private_ip: {{ private_ip }}
-      private_mac: {{ private_mac }}
-      hpc_client_ip: {{ hpc_client_ip }}
-      hpc_client_mac: {{ hpc_client_mac }}
-      keystone_tenant_id: {{ keystone_tenant_id }}
-      keystone_user_id: {{ keystone_user_id }}
-      rabbit_user: {{ rabbit_user }}
-      rabbit_password: {{ rabbit_password }}
-      rabbit_host: {{ rabbit_host }}
-      safe_browsing:
-        {% for mac in safe_browsing_macs %}
-        - {{ mac }}
-        {% endfor %}
-      uplink_speed: {{ uplink_speed }}
-      downlink_speed: {{ downlink_speed }}
-      status: {{ status }}
-      enable_uverse: {{ enable_uverse }}
-      url_filter_kind: {{ url_filter_kind }}
-
-  tasks:
-{% if full_setup %}
-  - name: Docker repository
-    copy: src=/opt/xos/synchronizers/vsg/files/docker.list
-      dest=/etc/apt/sources.list.d/docker.list
-
-  - name: Import the repository key
-    apt_key: keyserver=keyserver.ubuntu.com id=36A1D7869245C8950F966E92D8576A8BA88D21E9
-
-  - name: install Docker
-    apt: name=lxc-docker state=present update_cache=yes
-
-  - name: install python-setuptools
-    apt: name=python-setuptools state=present
-
-  - name: install pip
-    easy_install: name=pip
-
-  - name: install docker-py
-    pip: name=docker-py version=0.5.3
-
-  - name: install Pipework
-    get_url: url=https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework
-       dest=/usr/local/bin/pipework
-       mode=0755
-
-  - name: make sure /etc/dnsmasq.d exists
-    file: path=/etc/dnsmasq.d state=directory owner=root group=root
-
-  - name: Disable resolvconf service
-    shell: service resolvconf stop
-    shell: echo manual > /etc/init/resolvconf.override
-    shell: rm -f /etc/resolv.conf
-
-  - name: Install resolv.conf
-    copy: src=/opt/xos/synchronizers/vsg/files/vm-resolv.conf
-      dest=/etc/resolv.conf
-
-  - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
-    shell: pgrep -f [v]cpe_stats_notifier | wc -l
-    register: cron_job_pids_count
-
-#  - name: DEBUG
-#    debug: var=cron_job_pids_count.stdout
-
-#  - name: make sure ~/bin exists
-#    file: path=~/bin state=directory owner=root group=root
-#    when: cron_job_pids_count.stdout == "0"
-
-  - name: Copy cron job to destination
-    copy: src=/opt/xos/synchronizers/vsg/vcpe_stats_notifier.py
-      dest=/usr/local/sbin/vcpe_stats_notifier.py
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: install python-kombu
-    apt: name=python-kombu state=present
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: Initiate vcpe_stats_notifier cron job
-    command: sudo python /usr/local/sbin/vcpe_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
-    async: 9999999999999999
-    poll: 0
-    when: cron_job_pids_count.stdout == "0"
-{% endif %}
-
-  - name: vCPE upstart
-    template: src=/opt/xos/synchronizers/vsg/templates/vcpe.conf.j2 dest=/etc/init/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}.conf
-
-  - name: vCPE startup script
-    template: src=/opt/xos/synchronizers/vsg/templates/start-vcpe.sh.j2 dest=/usr/local/sbin/start-vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}.sh mode=0755
-    notify:
-#    - restart vcpe
-     - stop vcpe
-     - remove container
-     - start vcpe
-
-  - name: create /etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d
-    file: path=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d state=directory owner=root group=root
-
-  - name: vCPE basic dnsmasq config
-    copy: src=/opt/xos/synchronizers/vsg/files/vcpe.dnsmasq dest=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/vcpe.conf owner=root group=root
-    notify:
-    - restart dnsmasq
-
-  - name: dnsmasq config
-    template: src=/opt/xos/synchronizers/vsg/templates/dnsmasq_servers.j2 dest=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/servers.conf owner=root group=root
-    notify:
-    - restart dnsmasq
-
-# These are samples, not necessary for correct function of demo
-
-#  - name: networking info
-#    template: src=/opt/xos/synchronizers/vsg/templates/vlan_sample.j2 dest=/etc/vlan_sample owner=root group=root
-
-#  - name: firewall info
-#    template: src=/opt/xos/synchronizers/vsg/templates/firewall_sample.j2 dest=/etc/firewall_sample owner=root group=root
-
-  - name: Make sure vCPE service is running
-    service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=started
-
-  handlers:
-  # Dnsmasq is automatically restarted in the container
-  - name: restart dnsmasq
-    shell: docker exec vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} killall dnsmasq
-
-  - name: restart vcpe
-    shell: service vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} stop; sleep 1; service vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} start
-
-  - name: stop vcpe
-    service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=stopped
-
-  - name: remove container
-    docker: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=absent image=docker-vcpe
-
-  - name: start vcpe
-    service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=started
-
diff --git a/xos/synchronizer/steps/sync_vcpetenant_new.yaml b/xos/synchronizer/steps/sync_vcpetenant_new.yaml
deleted file mode 100644
index 723c1d9..0000000
--- a/xos/synchronizer/steps/sync_vcpetenant_new.yaml
+++ /dev/null
@@ -1,152 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
----
-- hosts: {{ instance_name }}
-  gather_facts: False
-  connection: ssh
-  become_user: {{ username }}
-
-  vars:
-      container_name: {{ container_name }}
-      cdn_enable: {{ cdn_enable }}
-      dnsdemux_ip: {{ dnsdemux_ip }}
-      firewall_enable: {{ firewall_enable }}
-      url_filter_enable: {{ url_filter_enable }}
-      c_tags:
-        {% for c_tag in c_tags %}
-        - {{ c_tag }}
-        {% endfor %}
-      s_tags:
-        {% for s_tag in s_tags %}
-        - {{ s_tag }}
-        {% endfor %}
-      firewall_rules:
-        {% for firewall_rule in firewall_rules.split("\n") %}
-        - {{ firewall_rule }}
-        {% endfor %}
-      cdn_prefixes:
-        {% for prefix in cdn_prefixes %}
-        - {{ prefix }}
-        {% endfor %}
-      bbs_addrs:
-        {% for bbs_addr in bbs_addrs %}
-        - {{ bbs_addr }}
-        {% endfor %}
-      dns_servers:
-        {% for dns_server in dns_servers %}
-        - {{ dns_server }}
-        {% endfor %}
-      nat_ip: {{ nat_ip }}
-      nat_mac: {{ nat_mac }}
-      lan_ip: {{ lan_ip }}
-      lan_mac: {{ lan_mac }}
-      wan_ip: {{ wan_ip }}
-      wan_mac: {{ wan_mac }}
-      wan_container_mac: {{ wan_container_mac }}
-      wan_next_hop: 10.0.1.253   # FIX ME
-      private_ip: {{ private_ip }}
-      private_mac: {{ private_mac }}
-      hpc_client_ip: {{ hpc_client_ip }}
-      hpc_client_mac: {{ hpc_client_mac }}
-      keystone_tenant_id: {{ keystone_tenant_id }}
-      keystone_user_id: {{ keystone_user_id }}
-      rabbit_user: {{ rabbit_user }}
-      rabbit_password: {{ rabbit_password }}
-      rabbit_host: {{ rabbit_host }}
-      safe_browsing:
-        {% for mac in safe_browsing_macs %}
-        - {{ mac }}
-        {% endfor %}
-      uplink_speed: {{ uplink_speed }}
-      downlink_speed: {{ downlink_speed }}
-      status: {{ status }}
-      enable_uverse: {{ enable_uverse }}
-      url_filter_kind: {{ url_filter_kind }}
-
-  tasks:
-  - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
-    shell: pgrep -f [v]cpe_stats_notifier | wc -l
-    register: cron_job_pids_count
-
-#  - name: DEBUG
-#    debug: var=cron_job_pids_count.stdout
-
-  - name: make sure ~/bin exists
-    file: path=~/bin state=directory owner=root group=root
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: Copy cron job to destination
-    copy: src=/opt/xos/synchronizers/vsg/vcpe_stats_notifier.py
-      dest=~/bin/vcpe_stats_notifier.py
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: install python-kombu
-    apt: name=python-kombu state=present
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: Initiate vcpe_stats_notifier cron job
-    command: python ~/bin/vcpe_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
-    async: 9999999999999999
-    poll: 0
-    when: cron_job_pids_count.stdout == "0"
-
-  - name: vCPE basic dnsmasq config
-    copy: src=/opt/xos/synchronizers/vsg/files/vcpe.dnsmasq dest=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/vcpe.conf owner=root group=root
-    notify:
-    - restart dnsmasq
-
-  - name: dnsmasq config
-    template: src=/opt/xos/synchronizers/vsg/templates/dnsmasq_servers.j2 dest=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/servers.conf owner=root group=root
-    notify:
-    - restart dnsmasq
-
-  - name: create directory for "safe" config
-    file: path=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/safe state=directory
-
-  - name: dnsmasq "safe" config
-    template: src=/opt/xos/synchronizers/vsg/templates/dnsmasq_safe_servers.j2 dest=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/safe/servers.conf owner=root group=root
-    notify:
-    - restart dnsmasq
-
-  - name: copy base ufw files
-    synchronize: src=/opt/xos/synchronizers/vsg/files/etc/ufw/ dest=/var/container_volumes/{{ container_name }}/etc/ufw/
-    notify:
-    - reload ufw
-
-  - name: redirection rules for safe DNS
-    template: src=/opt/xos/synchronizers/vsg/templates/before.rules.j2 dest=/var/container_volumes/{{ container_name }}/etc/ufw/before.rules owner=root group=root
-    notify:
-    - reload ufw
-
-  - name: base ufw setup uses /etc/rc.local
-    copy: src=/opt/xos/synchronizers/vsg/files/etc/rc.local dest=/var/container_volumes/{{ container_name }}/etc/ owner=root group=root
-    notify:
-    - copy in /etc/rc.local
-
-  handlers:
-  # Dnsmasq is automatically restarted in the container
-  - name: restart dnsmasq
-    shell: docker exec {{ container_name }} /usr/bin/killall dnsmasq
-
-  - name: reload ufw
-    shell: docker exec {{ container_name }} bash -c "/sbin/iptables -t nat -F PREROUTING; /usr/sbin/ufw reload"
-
-  # Use docker cp instead of single-file volume
-  # The reason is that changes to external file volume don't show up inside the container
-  # Probably Ansible deletes and then recreates the external file, and container has old version
-  - name: copy in /etc/rc.local
-    shell: docker cp /var/container_volumes/{{ container_name }}/etc/rc.local {{ container_name }}:/etc/
diff --git a/xos/synchronizer/steps/sync_vcpetenant.py b/xos/synchronizer/steps/sync_vsgserviceinstance.py
similarity index 79%
rename from xos/synchronizer/steps/sync_vcpetenant.py
rename to xos/synchronizer/steps/sync_vsgserviceinstance.py
index a27c8ce..b063065 100644
--- a/xos/synchronizer/steps/sync_vcpetenant.py
+++ b/xos/synchronizer/steps/sync_vsgserviceinstance.py
@@ -34,34 +34,34 @@
 
 ENABLE_QUICK_UPDATE=False
 
-class SyncVSGTenant(SyncInstanceUsingAnsible):
-    provides=[VSGTenant]
-    observes=VSGTenant
+class SyncVSGServiceInstance(SyncInstanceUsingAnsible):
+    provides=[VSGServiceInstance]
+    observes=VSGServiceInstance
     requested_interval=0
-    template_name = "sync_vcpetenant.yaml"
+    template_name = "sync_vsgserviceinstance.yaml"
     watches = [ModelLink(ServiceDependency,via='servicedependency'), ModelLink(ServiceMonitoringAgentInfo,via='monitoringagentinfo')]
 
     def __init__(self, *args, **kwargs):
-        super(SyncVSGTenant, self).__init__(*args, **kwargs)
+        super(SyncVSGServiceInstance, self).__init__(*args, **kwargs)
 
-    def get_vcpe_service(self, o):
+    def get_vsg_service(self, o):
         if not o.owner:
             return None
 
-        vcpes = VSGService.objects.filter(id=o.owner.id)
-        if not vcpes:
+        vsg_services = VSGService.objects.filter(id=o.owner.id)
+        if not vsg_services:
             return None
 
-        return vcpes[0]
+        return vsg_services[0]
 
     def get_extra_attributes(self, o):
         # This is a place to include extra attributes that aren't part of the
-        # object itself. In the case of vCPE, we need to know:
-        #   1) the addresses of dnsdemux, to setup dnsmasq in the vCPE
+        # object itself. In the case of vSG, we need to know:
+        #   1) the addresses of dnsdemux, to setup dnsmasq in the vSG
         #   2) CDN prefixes, so we know what URLs to send to dnsdemux
-        #   4) vlan_ids, for setting up networking in the vCPE VM
+        #   4) vlan_ids, for setting up networking in the vSG VM
 
-        vcpe_service = self.get_vcpe_service(o)
+        vsg_service = self.get_vsg_service(o)
 
         dnsdemux_ip = None
         cdn_prefixes = []
@@ -87,7 +87,7 @@
         full_setup = True
 
         safe_macs=[]
-        if vcpe_service.url_filter_kind == "safebrowsing":
+        if vsg_service.url_filter_kind == "safebrowsing":
             if o.volt and o.volt.subscriber:
                 for user in o.volt.subscriber.devices:
                     level = user.get("level",None)
@@ -97,23 +97,23 @@
                             safe_macs.append(mac)
 
         docker_opts = []
-        if vcpe_service.docker_insecure_registry:
-            reg_name = vcpe_service.docker_image_name.split("/",1)[0]
+        if vsg_service.docker_insecure_registry:
+            reg_name = vsg_service.docker_image_name.split("/",1)[0]
             docker_opts.append("--insecure-registry " + reg_name)
 
         fields = {"s_tags": s_tags,
                 "c_tags": c_tags,
-                "docker_remote_image_name": vcpe_service.docker_image_name,
-                "docker_local_image_name": vcpe_service.docker_image_name,
+                "docker_remote_image_name": vsg_service.docker_image_name,
+                "docker_local_image_name": vsg_service.docker_image_name,
                 "docker_opts": " ".join(docker_opts),
                 "dnsdemux_ip": dnsdemux_ip,
                 "cdn_prefixes": cdn_prefixes,
                 "full_setup": full_setup,
                 "isolation": o.instance.isolation,
                 "safe_browsing_macs": safe_macs,
-                "container_name": "vcpe-%s-%s" % (s_tags[0], c_tags[0]),
-                "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")],
-                "url_filter_kind": vcpe_service.url_filter_kind }
+                "container_name": "vsg-%s-%s" % (s_tags[0], c_tags[0]),
+                "dns_servers": [x.strip() for x in vsg_service.dns_servers.split(",")],
+                "url_filter_kind": vsg_service.url_filter_kind }
 
         # add in the sync_attributes that come from the SubscriberRoot object
 
@@ -125,7 +125,7 @@
 
     def sync_fields(self, o, fields):
         # the super causes the playbook to be run
-        super(SyncVSGTenant, self).sync_fields(o, fields)
+        super(SyncVSGServiceInstance, self).sync_fields(o, fields)
 
     def run_playbook(self, o, fields):
         ansible_hash = hashlib.md5(repr(sorted(fields.items()))).hexdigest()
@@ -135,17 +135,16 @@
             logger.info("quick_update triggered; skipping ansible recipe",extra=o.tologdict())
         else:
             if o.instance.isolation in ["container", "container_vm"]:
-                raise Exception("probably not implemented")
-                super(SyncVSGTenant, self).run_playbook(o, fields, "sync_vcpetenant_new.yaml")
+                raise Exception("Not implemented")
             else:
-                super(SyncVSGTenant, self).run_playbook(o, fields, template_name="sync_vcpetenant_vtn.yaml")
+                super(SyncVSGServiceInstance, self).run_playbook(o, fields)
 
         o.last_ansible_hash = ansible_hash
 
     def sync_record(self, o):
         if (not o.policed) or (o.policed<o.updated):
             self.defer_sync(o, "waiting on model policy")
-        super(SyncVSGTenant, self).sync_record(o)
+        super(SyncVSGServiceInstance, self).sync_record(o)
 
     def delete_record(self, o):
         if (not o.policed) or (o.policed<o.updated):
@@ -161,7 +160,7 @@
             logger.info("handle watch notifications for service monitoring agent info...ignoring because target_uri attribute in monitoring agent info:%s is null" % (monitoring_agent_info))
             return
 
-        objs = VSGTenant.objects.all()
+        objs = VSGServiceInstance.objects.all()
         for obj in objs:
             if obj.owner.id != monitoring_agent_info.service.id:
                 logger.info("handle watch notifications for service monitoring agent info...ignoring because service attribute in monitoring agent info:%s is not matching" % (monitoring_agent_info))
@@ -172,7 +171,7 @@
                logger.warn("handle watch notifications for service monitoring agent info...: No valid instance found for object %s" % (str(obj)))
                return
 
-            logger.info("handling watch notification for monitoring agent info:%s for VSGTenant object:%s" % (monitoring_agent_info, obj))
+            logger.info("handling watch notification for monitoring agent info:%s for VSGServiceInstance object:%s" % (monitoring_agent_info, obj))
 
             #Run ansible playbook to update the routing table entries in the instance
             fields = self.get_ansible_fields(instance)
@@ -187,5 +186,5 @@
             fields["rabbit_host"] = url.hostname
 
             template_name = "sync_monitoring_agent.yaml"
-            super(SyncVSGTenant, self).run_playbook(obj, fields, template_name)
+            super(SyncVSGServiceInstance, self).run_playbook(obj, fields, template_name)
 
diff --git a/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizer/steps/sync_vsgserviceinstance.yaml
similarity index 86%
rename from xos/synchronizer/steps/sync_vcpetenant_vtn.yaml
rename to xos/synchronizer/steps/sync_vsgserviceinstance.yaml
index 81c9252..b7968b2 100644
--- a/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizer/steps/sync_vsgserviceinstance.yaml
@@ -125,14 +125,14 @@
     stat: path=/root/environment_is_setup
     register: environment_is_setup
 
-# Everything here is now baked into the vCPE image
+# Everything here is now baked into the vSG image
 # Leave this spot in place for future temporary setup stuff
 
   - name: Remember that the environment is setup, so we never do the above again
     shell: touch /root/environment_is_setup
 
-  - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
-    shell: pgrep -f [v]cpe_stats_notifier | wc -l
+  - name: Verify if vsg_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
+    shell: pgrep -f [v]sg_stats_notifier | wc -l
     register: cron_job_pids_count
 
 #  - name: DEBUG
@@ -143,16 +143,16 @@
 #    when: cron_job_pids_count.stdout == "0"
 
 #  - name: Copy cron job to destination
-#    copy: src=/opt/xos/synchronizers/vsg/vcpe_stats_notifier.py
-#      dest=/usr/local/sbin/vcpe_stats_notifier.py
+#    copy: src=/opt/xos/synchronizers/vsg/vsg_stats_notifier.py
+#      dest=/usr/local/sbin/vsg_stats_notifier.py
 #    when: cron_job_pids_count.stdout == "0"
 
 #  - name: install python-kombu
 #    apt: name=python-kombu state=present
 #    when: cron_job_pids_count.stdout == "0"
 
-#  - name: Initiate vcpe_stats_notifier cron job
-#    command: sudo python /usr/local/sbin/vcpe_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
+#  - name: Initiate vsg_stats_notifier cron job
+#    command: sudo python /usr/local/sbin/vsg_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
 #    async: 9999999999999999
 #    poll: 0
 #    when: cron_job_pids_count.stdout == "0"
@@ -163,22 +163,22 @@
     notify:
      - restart docker
 
-  - name: vCPE upstart
-    template: src=/opt/xos/synchronizers/vsg/templates/vcpe.conf.j2 dest=/etc/init/{{ container_name }}.conf
+  - name: vSG upstart
+    template: src=/opt/xos/synchronizers/vsg/templates/vsg.conf.j2 dest=/etc/init/{{ container_name }}.conf
 
-  - name: vCPE startup script
-    template: src=/opt/xos/synchronizers/vsg/templates/start-vcpe-vtn.sh.j2 dest=/usr/local/sbin/start-{{ container_name }}.sh mode=0755
+  - name: vSG startup script
+    template: src=/opt/xos/synchronizers/vsg/templates/start-vsg-vtn.sh.j2 dest=/usr/local/sbin/start-{{ container_name }}.sh mode=0755
     notify:
-#    - restart vcpe
-     - stop vcpe
+#    - restart vsg
+     - stop vsg
      - remove container
-     - start vcpe
+     - start vsg
 
   - name: create /var/container_volumes/{{ container_name }}/etc/dnsmasq.d/safe/
     file: path=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/safe state=directory owner=root group=root
 
-  - name: vCPE basic dnsmasq config
-    copy: src=/opt/xos/synchronizers/vsg/files/vcpe.dnsmasq dest=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/vcpe.conf owner=root group=root
+  - name: vSG basic dnsmasq config
+    copy: src=/opt/xos/synchronizers/vsg/files/vsg.dnsmasq dest=/var/container_volumes/{{ container_name }}/etc/dnsmasq.d/vsg.conf owner=root group=root
     notify:
     - restart dnsmasq
 
@@ -227,14 +227,14 @@
   - name: generate the message page
     template: src=/opt/xos/synchronizers/vsg/templates/message.html.j2 dest=/var/container_volumes/{{ container_name }}/etc/service/message/message.html owner=root group=root mode=0644
     when: status != "enabled"
-    #notify: restart vcpe
+    #notify: restart vsg
 
   - name: remove simple webserver
     file: path=/var/container_volumes/{{ container_name }}/etc/service/message/run state=absent
     when: status == "enabled"
-    #notify: restart vcpe
+    #notify: restart vsg
 
-  - name: Make sure vCPE service is running
+  - name: Make sure vSG service is running
     service: name={{ container_name }} state=started
 
   handlers:
@@ -242,13 +242,13 @@
   - name: restart dnsmasq
     shell: docker exec {{ container_name }} killall dnsmasq
 
-  - name: stop vcpe
+  - name: stop vsg
     service: name={{ container_name }} state=stopped
 
   - name: remove container
-    docker: name={{ container_name }} state=absent image=docker-vcpe
+    docker: name={{ container_name }} state=absent image=docker-vsg
 
-  - name: start vcpe
+  - name: start vsg
     service: name={{ container_name }} state=started
 
   - name: reload ufw
@@ -260,7 +260,7 @@
   - name: reset bwlimits
     shell: docker exec {{ container_name }} bash -c "/usr/local/sbin/bwlimit.sh restart"
 
-  - name: restart vcpe
+  - name: restart vsg
     shell: service {{ container_name }} stop; sleep 1; service {{ container_name }} start
 
   - name: restart docker