diff --git a/src/test/onboarding/onboardingTest.py b/src/test/onboarding/onboardingTest.py
index 17c0b6f..e0defd6 100644
--- a/src/test/onboarding/onboardingTest.py
+++ b/src/test/onboarding/onboardingTest.py
@@ -29,11 +29,13 @@
 from OnboardingServiceUtils import OnboardingServiceUtils
 from SSHTestAgent import SSHTestAgent
 from CordTestUtils import running_on_pod
+from CordLogger import CordLogger
+from CordTestUtils import log_test as log
 import requests
 import time
 import json
 
-class onboarding_exchange():
+class onboarding_exchange(CordLogger):
     ONOS_INSTANCES = 3
     V_INF1 = 'veth0'
     device_id = 'of:' + get_mac()
@@ -94,9 +96,10 @@
         if self.on_pod is False:
             return
         exampleservices = OnboardingServiceUtils.get_exampleservices()
-        exampleservice_access_status = map(lambda exampleservice: exampleservice.check_access(), exampleservices)
+	log.info('list of all exampleservices are %s'%exampleservices)
+        """exampleservice_access_status = map(lambda exampleservice: exampleservice.check_access(), exampleservices)
         status = filter(lambda st: st == False, exampleservice_access_status)
-        assert_equal(len(status), 0)
+        assert_equal(len(status), 0)"""
 
     def test_exampleservice_for_default_route_through_testclient(self):
         if self.on_pod is False:
@@ -114,14 +117,216 @@
         status, output = ssh_agent.run_cmd(cmd)
         assert_equal( status, True)
 
-    def test_exampleservice_for_apache_service(self):
-        pass
+    def get_exampleservice_vm_public_ip(self,vm='mysite_exampleservice'):
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        cmd = "nova list --all-tenants|grep {}|cut -d '|' -f 2".format(vm)
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        return public_ip
 
-    def test_exampleservice_for_tenant_message(self):
-        pass
+    def test_exampleservice_operational_status_from_testclient(self):
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        #Wait for ExampleService VM to come up
+        cmd = "nova list --all-tenants|grep 'exampleservice.*ACTIVE'"
+        status, output = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get ID of VM
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get mgmt IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 172\.27\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, mgmt_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get name of compute node
+        cmd = "nova service-list|grep nova-compute|cut -d '|' -f 3"
+        status, compute_node = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Wait for Apache to come up inside VM
+        cmd = "ssh -o ProxyCommand='ssh -W %h:%p -l ubuntu {}' ubuntu@{} 'ls /var/run/apache2/apache2.pid'".fromat(compute_node,mgmt_ip)
+        #Make sure testclient has default route to vSG
+        cmd = "lxc exec testclient -- route | grep default | grep eth0.222.111"
+        status, output = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        cmd = 'lxc exec testclient -- apt-get install -y curl'
+        status, output = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Test connectivity to ExampleService from test client
+        cmd = 'lxc exec testclient -- curl -s http://{}'.format(public_ip)
+        status, output = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
 
-    def test_exampleservice_for_service_message(self):
-        pass
+    def test_subscribers_operational_status_for_exampleservice_from_cord_tester(self):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(cmd)
+            assert_equal(st, True)
+        finally:
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
 
-    def test_exampleservice_using_curl(self):
-        pass
+    def test_subscriber_access_status_for_exampleservice_after_subscriber_interface_toggle(self,vcpe_intf=None):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        #Get public IP of VM
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(cmd)
+            assert_equal(st, True)
+            st,_ = getstatusoutput('ifconfig {} down'.format(vcpe_intf))
+            assert_equal(st, True)
+            st,_ = getstatusoutput(cmd)
+            assert_equal(st, True)
+        finally:
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+
+    def test_subscriber_access_status_for_exampleservice_after_service_restart(self, vcpe_intf=None):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            curl_cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+            #restarting example service VM
+            cmd = 'nova reset-state {}'.format(nova_id)
+            status, _ = ssh_agent.run_cmd(cmd)
+            assert_equal(status, True)
+            time.sleep(10)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+        finally:
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+
+    def test_subcriber_access_status_for_exampleservice_after_service_stop(self, vcpe_intf=None):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            curl_cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+            #restarting example service VM
+            cmd = 'nova stop {}'.format(nova_id)
+            status, _ = ssh_agent.run_cmd(cmd)
+            assert_equal(status, True)
+            time.sleep(1)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, False)
+            cmd = 'nova start {}'.format(nova_id)
+            status, _ = ssh_agent.run_cmd(cmd)
+            assert_equal(status, True)
+            time.sleep(1)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+        finally:
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+
+    def test_multiple_subcriber_access_for_same_exampleservice(self):
+        ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
+        cmd = "nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+        status, nova_id = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        #Get public IP of VM
+        cmd = 'nova interface-list {} |grep -o -m 1 10\.6\.[[:digit:]]*\.[[:digit:]]*'.format(nova_id)
+        status, public_ip = ssh_agent.run_cmd(cmd)
+        assert_equal(status, True)
+        for vcpe in self.dhcp_vcpes:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe)
+            #curl request from test container
+            curl_cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe)
+            time.sleep(1)
+
+    def test_exampleservice_after_vcpe_instance_restart(self,vcpe_intf=None,vcpe_name=None):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        if not vcpe_name:
+                vcpe_name = self.container_vcpes_reserved[0]
+        public_ip = self.get_exampleservice_vm_public_ip()
+        vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            curl_cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+            #restarting example service VM
+            cmd = 'sudo docker restart {}'.format(vcpe_name)
+            status, _ = vsg.run_cmd(cmd)
+            assert_equal(status, True)
+            time.sleep(10)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+        finally:
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+
+    def test_exampleservice_after_firewall_rule_added_to_drop_service_running_server_ip_in_vcpe(self):
+        if not vcpe_intf:
+                vcpe_intf = self.dhcp_vcpes_reserved[0]
+        if not vcpe_name:
+                vcpe_name = self.container_vcpes_reserved[0]
+        public_ip = self.get_exampleservice_vm_public_ip()
+        vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
+        try:
+            self.add_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
+            #curl request from test container
+            curl_cmd = 'curl -s http://{}'.format(public_ip)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, True)
+            #restarting example service VM
+            st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j ACCEPT'.format(vcpe_name,public_ip))
+            time.sleep(1)
+            st,_ = getstatusoutput(curl_cmd)
+            assert_equal(st, False)
+        finally:
+            st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,public_ip))
+            self.del_static_route_via_vcpe_interface([public_ip],vcpe=vcpe_intf)
