Test: Adding Initial XOS based test scenarios .
This checks for XOS containers launched , container status,
reach status and ports listening for particular services.

Change-Id: I4c491e4e7033afa84fab4f1c0b0324a236f864af
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 5992eba..acb1fd3 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -48,7 +48,9 @@
     basename = 'cord-tester'
     switch_on_olt = False
     IMAGE = 'cord-test/nose'
-    ALL_TESTS = ('tls', 'dhcp', 'dhcprelay','igmp', 'subscriber', 'cordSubscriber', 'vrouter', 'flows', 'proxyarp', 'acl')
+    ALL_TESTS = ('tls', 'dhcp', 'dhcprelay','igmp', 'subscriber',
+    'cordSubscriber', 'vrouter', 'flows', 'proxyarp', 'acl', 'xos', 'fabric',
+    'cbench', 'cluster')
 
     def __init__(self, tests, instance = 0, num_instances = 1, ctlr_ip = None,
                  name = '', image = IMAGE, prefix = '', tag = 'candidate',
@@ -713,7 +715,6 @@
             Container.dckr.kill(onos)
             Container.dckr.remove_container(onos, force=True)
         Onos.cleanup_runtime()
-
     return 0
 
 def listTests(args):
@@ -842,6 +843,62 @@
 
     return 0
 
+def xosContainers(args):
+    update_map = {  'xos-base' : False, 'xos-synchronizer-openstack' : False, 'openvpn' : False, 'postgresql' :False,
+                    'xos' : False, 'syndicate-ms': False, 'xos-synchronizer-vtr' : False, 'xos-synchronizer-vsg' : False,
+                    'xos-synchronizer-onos' : False, 'xos-synchronizer-fabric' : False, 'xos-synchronizer-vtn' : False,
+                    'xos-synchronizer-onboarding' : False, }
+
+    if args.xosAllContainers == True or args.xosBase == True:
+        #Start xos base container. Builds container if required
+        xosBase = Xos_base(prefix = Container.IMAGE_PREFIX, update = update_map['xos-base'])
+
+    if args.xosAllContainers == True or args.xosSynOpenstack == True:
+        #Start xos base container. Builds container if required
+        xosSynOpenstack = Xos_sync_openstack(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-openstack'])
+    if args.xosAllContainers == True or args.xosOpenvpn == True:
+        #Start xos base container. Builds container if required
+        xosOpenvpn = Xos_openvpn(prefix = Container.IMAGE_PREFIX, update = update_map['openvpn'])
+
+    if args.xosAllContainers == True or args.xosPostgresql == True:
+        #Start xos postgresql container. Builds container if required
+        xosPostgresql = Xos_postgresql(prefix = Container.IMAGE_PREFIX, update = update_map['postgresql'])
+
+    if args.xosAllContainers == True or args.xosSynchronizer == True:
+        #Start xos synchronizer container. Builds container if required
+        xosSynchronizer = Xos_synchronizer(prefix = Container.IMAGE_PREFIX, update = update_map['xos'])
+
+    if args.xosAllContainers == True or args.xosSyndicateMs == True:
+        #Start xos syndicateMs container. Builds container if required
+        xosSyndicateMs = Xos_syndicate_ss(prefix = Container.IMAGE_PREFIX, update = update_map['syndicate-ms'])
+
+    if args.xosAllContainers == True or args.xosSynVtr == True:
+        #Start xos synchronizer vtr container. Builds container if required
+        xosSynVtr = Xos_syn_vtr(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-vtr'])
+
+    if args.xosAllContainers == True or args.xosSynVsg == True:
+        #Start xos synchronizer vsg container. Builds container if required
+        xosSynVsg = Xos_syn_vsg(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-vsg'])
+
+    if args.xosAllContainers == True or args.xosSynOnos == True:
+        #Start xos synchronizer Onos container. Builds container if required
+        xosSynOnos = Xos_syn_onos(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-onos'])
+
+    if args.xosAllContainers == True or args.xosSynFabric == True:
+        #Start xos synchronizer fabric container. Builds container if required
+        xosSynFabric = Xos_syn_fabric(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-fabric'])
+
+    if args.xosAllContainers == True or args.xosSynVtn == True:
+        #Start xos synchronizer vtn container. Builds container if required
+        xosSynVtn = Xos_syn_vtn(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-vtn'])
+
+    if args.xosAllContainers == True or args.xosSynOnboarding == True:
+        #Start xos synchronizer Onboarding container. Builds container if required
+        xosSynOnboarding = Xos_syn_onboarding(prefix = Container.IMAGE_PREFIX, update = update_map['xos-synchronizer-onboarding'])
+
+    print('Done building xos containers')
+    return 0
+
 if __name__ == '__main__':
     parser = ArgumentParser(description='Cord Tester')
     subparser = parser.add_subparsers()
@@ -898,6 +955,22 @@
                             help='Specify number of test onos instances to spawn')
     parser_setup.set_defaults(func=setupCordTester)
 
+    parser_xos = subparser.add_parser('xos', help='Building xos into cord tester environment')
+    parser_xos.add_argument('-x', '--xosAllContainers', action='store_true',help='Provision all containers of XOS for CORD')
+    parser_xos.add_argument('-xb', '--xosBase',action='store_true',help='Provision xos base container')
+    parser_xos.add_argument('-xsos', '--xosSyncOpenstack',action='store_true',help='Provision xos synchronizer openstack container')
+    parser_xos.add_argument('-xo', '--xosOpenvpn',action='store_true',help='Provision xos openvpn container')
+    parser_xos.add_argument('-xp', '--xosPostgresql',action='store_true',help='Provision xos postgresql')
+    parser_xos.add_argument('-xs', '--xosSynchronizer',action='store_true',help='Provision xos synchronizer')
+    parser_xos.add_argument('-xsm', '--xosSyndicateMs',action='store_true',help='Provision xos syndicate-ms')
+    parser_xos.add_argument('-xsvtr', '--xosSyncVtr',action='store_true',help='Provision xos synchronizer vtr container')
+    parser_xos.add_argument('-xsvsg', '--xosSyncVsg',action='store_true',help='Provision xos synchronizer vsg container')
+    parser_xos.add_argument('-xsonos', '--xosSyncOnos',action='store_true',help='Provision xos synchronizer onos container')
+    parser_xos.add_argument('-xsfabric', '--xosSyncFabric',action='store_true',help='Provision xos synchronizer fabric container')
+    parser_xos.add_argument('-xsvtn', '--xosSyncVtn',action='store_true',help='Provision xos synchronizer vtn container')
+    parser_xos.add_argument('-xsonb', '--xosSyncOnboarding',action='store_true',help='Provision xos synchronizer onboarding container')
+    parser_xos.set_defaults(func=xosContainers)
+
     parser_list = subparser.add_parser('list', help='List test cases')
     parser_list.add_argument('-t', '--test', default='all', help='Specify test type to list test cases. '
                              'Eg: -t tls to list tls test cases.'
@@ -906,8 +979,8 @@
     parser_list.set_defaults(func=listTests)
 
     parser_build = subparser.add_parser('build', help='Build cord test container images')
-    parser_build.add_argument('image', choices=['quagga', 'radius', 'test', 'all'])
-    parser_build.add_argument('-p', '--prefix', default='', type=str, help='Provide container image prefix')
+    parser_build.add_argument('image', choices=['quagga', 'radius', 'test','all'])
+    parser_build.add_argument('-p', '--prefix', default='xosproject', type=str, help='Provide container image prefix')
     parser_build.set_defaults(func=buildImages)
 
     parser_metrics = subparser.add_parser('metrics', help='Info of container')
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index e764757..fbd8f31 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -369,6 +369,11 @@
 
         if not self.exists():
             self.remove_container(name, force=True)
+            host_config = self.create_host_config(port_list = self.ports,
+                                                  host_guest_map = self.host_guest_map)
+            volumes = []
+            for _,g in self.host_guest_map:
+                volumes.append(g)
             if network_cfg is not None:
                 json_data = json.dumps(network_cfg, indent=4)
                 with open('{}/network-cfg.json'.format(self.host_config_dir), 'w') as f:
@@ -610,3 +615,894 @@
 def reinitContainerClients():
     docker_netns.dckr = Client()
     Container.dckr = Client()
+
+class Xos(Container):
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name, image, dockerfile = None, prefix = PREFIX, tag = TAG,
+                 boot_delay = 30, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, check github repo')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              print('Waiting %d seconds for XOS Base Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS base image %s' %image)
+        super(Xos, cls).build_image(self.dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_base(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8000,9998,9999 ]
+    env = { 'XOS_GIT_REPO' : 'https://github.com/opencord/xos.git', 'XOS_GIT_BRANCH' : 'master', 'NG_XOS_LIB_URL' : ' https://github.com/opencord/ng-xos-lib.git', 'NG_XOS_LIB_VERSION' : '1.0.0',}
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-base'
+    IMAGE = 'xosproject/xos-base'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-base', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_base, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS base container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS Base Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS base image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-base
+MAINTAINER chetan@ciena.com
+ADD local_certs.crt /usr/local/share/ca-certificates/local_certs.crt
+RUN update-ca-certificates
+RUN git clone $XOS_GIT_REPO -b $XOS_GIT_BRANCH /tmp/xos && \
+    mv /tmp/xos/xos /opt/ && \
+    chmod +x /opt/xos/tools/xos-manage && \
+    /opt/xos/tools/xos-manage genkeys
+
+RUN git clone $NG_XOS_LIB_URL /tmp/ng-xos-lib
+RUN cd /tmp/ng-xos-lib && git checkout tags/$NG_XOS_LIB_VERSION
+RUN cp /tmp/ng-xos-lib/dist/ngXosHelpers.min.js /opt/xos/core/xoslib/static/vendor/
+RUN cp /tmp/ng-xos-lib/dist/ngXosVendor.min.js /opt/xos/core/xoslib/static/vendor/
+WORKDIR /opt/xos
+CMD python /opt/xos/manage.py runserver 0.0.0.0:8000 --insecure --makemigrations
+'''
+        super(Xos_base, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_openstack(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 2375 ]
+    env = {'DOCKER_URL' : 'https://get.docker.com/builds/Linux/x86_64/docker-1.10.3', 'DOCKER_SHA256' : 'd0df512afa109006a450f41873634951e19ddabf8c7bd419caeb5a526032d86d', 'DOCKER_COMPOSE_URL' : ' https://github.com/docker/compose/releases/download/1.5.2/docker-compose-Linux-x86_64', 'DOCKER_COMPOSE_SHA256' : ' b6b975badc5389647ef1c16fe8a33bdc5935c61f6afd5a15a28ff765427d01e3' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-openstack'
+    IMAGE = 'xosproject/xos-synchronizer-openstack'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-openstack', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_openstack, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS Synchronizer Openstack container %s' %self.name)
+              self.start(environment = self.env,
+                       tty = True)
+              if not restart:
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS Synchronizer Openstack Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer Openstack image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-openstack
+RUN curl -fLsS $DOCKER_URL -o docker && \
+    echo "${DOCKER_SHA256}  docker" | sha256sum -c - && \
+    mv docker /usr/local/bin/docker && \
+    chmod +x /usr/local/bin/docker
+RUN curl -fLsS $DOCKER_COMPOSE_URL -o docker-compose && \
+    echo "${DOCKER_COMPOSE_SHA256}  docker-compose" | sha256sum -c - && \
+    mv docker-compose /usr/local/bin/docker-compose && \
+    chmod +x /usr/local/bin/docker-compose
+CMD /usr/bin/supervisord -c /etc/supervisor/conf.d/synchronizer.conf
+'''
+        super(Xos_sync_openstack, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_openvpn(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [8000]
+    env = {'DOCKER_URL' : 'https://get.docker.com/builds/Linux/x86_64/docker-1.10.3', 'DOCKER_SHA256' : 'd0df512afa109006a450f41873634951e19ddabf8c7bd419caeb5a526032d86d', 'DOCKER_COMPOSE_URL' : ' https://github.com/docker/compose/releases/download/1.5.2/docker-compose-Linux-x86_64', 'DOCKER_COMPOSE_SHA256' : ' b6b975badc5389647ef1c16fe8a33bdc5935c61f6afd5a15a28ff765427d01e3' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'openvpn'
+    IMAGE = 'xosproject/xos-synchronizer-openstack'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-openstack', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_openvpn, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS Openvpn container %s' %self.name)
+              self.start(ports = self.ports, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS Openvpn Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer Openstack image %s' %image)
+        dockerfile = '''
+FROM       xosproject/xos-synchronizer-openstack
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
+    openvpn
+RUN mkdir -p /opt/openvpn
+RUN chmod 777 /opt/openvpn
+RUN git clone https://github.com/OpenVPN/easy-rsa.git /opt/openvpn
+RUN git -C /opt/openvpn pull origin master
+RUN echo 'set_var EASYRSA	"/opt/openvpn/easyrsa3"' | tee /opt/openvpn/vars
+RUN echo 'set_var EASYRSA_BATCH	"true"' | tee -a /opt/openvpn/vars
+'''
+        super(Xos_openvpn, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_postgresql(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 5432 ]
+    NAME = 'xos-postgresql'
+    IMAGE = 'xosproject/xos-postgres'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'ubuntu', prefix = '', tag = '14.04',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_postgresql, self).__init__(name, image, prefix = prefix, tag = tag)
+        if restart is True and self.exists():
+            self.kill()
+        if not self.exists():
+            self.remove_container(name, force=True)
+            host_config = self.create_host_config(port_list = self.ports)
+            volumes = ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
+            print('Starting Xos postgresql container %s' %self.name)
+            self.start(ports = self.ports, host_config = host_config, volumes = volumes, tty = True)
+            if not restart:
+                ##wait a bit before fetching IP to regenerate cluster cfg
+                time.sleep(5)
+                ip = self.ip()
+            print('Waiting %d seconds for Xos postgresql to boot' %(boot_delay))
+            time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS postgresql image %s' %image)
+        dockerfile = '''
+FROM ubuntu:14.04
+RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
+RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    python-software-properties \
+    software-properties-common \
+    postgresql-9.3 \
+    postgresql-client-9.3 \
+    postgresql-contrib-9.3
+
+RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private
+USER postgres
+RUN /etc/init.d/postgresql start && \
+    psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'password' " && \
+    psql --command "CREATE DATABASE xos"
+RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/9.3/main/pg_hba.conf
+RUN echo "host all  all    0.0.0.0/0  password" >> /etc/postgresql/9.3/main/pg_hba.conf
+RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
+VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
+CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
+'''
+        super(Xos_postgresql, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_synchronizer(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8000 ]
+    env = { 'XOS_GIT_REPO' : 'https://github.com/opencord/xos.git', 'XOS_GIT_BRANCH' : 'master', 'NG_XOS_LIB_URL' : ' https://github.com/opencord/ng-xos-lib.git', 'NG_XOS_LIB_VERSION' : '1.0.0',}
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos'
+    IMAGE = 'xosproject/xos'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_synchronizer, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS synchronizer container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS Synchronizer Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos
+MAINTAINER chetan@ciena.com
+COPY conf/synchronizer.conf /etc/supervisor/conf.d/
+CMD /usr/bin/supervisord -c /etc/supervisor/conf.d/synchronizer.conf
+'''
+        super(Xos_synchronizer, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_syndicate_ms(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'syndicate-ms'
+    IMAGE = 'xosproject/syndicate-ms'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'ubuntu', prefix = '', tag = '14.04.4',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_syndicate_ms, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS syndicate-ms container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS syndicate-ms Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Syndicate-ms image %s' %image)
+        dockerfile = '''
+FROM ubuntu:14.04.4
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_syndicate_ms, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_vtr(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-vtr'
+    IMAGE = 'xosproject/xos-synchronizer-vtr'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-vtr', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_vtr, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-vtr container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-vtr Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-vtr image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-vtr
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_vtr, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_vsg(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-vsg'
+    IMAGE = 'xosproject/xos-synchronizer-vsg'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-vsg', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_vsg, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-vsg container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-vsg Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-vsg image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-vsg
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_vsg, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_onos(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-onos'
+    IMAGE = 'xosproject/xos-synchronizer-onos'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-onos', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_onos, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-onos container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-onos Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-onos image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-onos
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_onos, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_fabric(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-fabric'
+    IMAGE = 'xosproject/xos-synchronizer-fabric'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-fabric', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_fabric, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-fabric container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-fabric Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-fabric image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-fabric
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_fabric, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_vtn(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-vtn'
+    IMAGE = 'xosproject/xos-synchronizer-vtn'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-vtn', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_vtn, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-vtn container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-vtn Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-vtn image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-vtn
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_vtn, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+class Xos_sync_onboarding(Container):
+    SYSTEM_MEMORY = (get_mem(),) * 2
+    ports = [ 8080 ]
+    env = { 'APT_KEY' : 'butler_opencloud_cs_arizona_edu_pub.gpg', 'MS_PORT': '8080', 'GAE_SDK' : 'google_appengine_1.9.35.zip', 'HOME' : '/home/syndicate' }
+    setup_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup')
+    NAME = 'xos-synchronizer-onboarding'
+    IMAGE = 'xosproject/xos-synchronizer-onboarding'
+    TAG = 'latest'
+    PREFIX = ''
+
+    def __init__(self, name = NAME, image = 'xosproject/xos-synchronizer-onboarding', prefix = '', tag = 'latest',
+                 boot_delay = 60, restart = False, network_cfg = None, update = False):
+        GITHUB_ERROR = False
+        if restart is True:
+            ##Find the right image to restart
+            running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
+            if running_image:
+                image_name = running_image[0]['Image']
+                try:
+                    image = image_name.split(':')[0]
+                    tag = image_name.split(':')[1]
+                except: pass
+
+        super(Xos_sync_onboarding, self).__init__(name, image, prefix = prefix, tag = tag)
+        if update is True or not self.img_exists():
+            self.build_image(self.image_name)
+            if not self.img_exists():
+               print ('Xos base container image is not built on host, have to check github repository ')
+               GITHUB_ERROR = True
+        if GITHUB_ERROR is not True:
+           if restart is True and self.exists():
+              self.kill()
+           if not self.exists():
+              self.remove_container(name, force=True)
+              host_config = self.create_host_config(port_list = self.ports)
+              print('Starting XOS xos-synchronizer-onboarding container %s' %self.name)
+              self.start(ports = self.ports, environment = self.env, host_config = host_config,
+                       tty = True)
+              if not restart:
+                 ##wait a bit before fetching IP to regenerate cluster cfg
+                 time.sleep(5)
+                 ip = self.ip()
+              print('Waiting %d seconds for XOS synchronizer-onboarding Container to boot' %(boot_delay))
+              time.sleep(boot_delay)
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building XOS Synchronizer-onboarding image %s' %image)
+        dockerfile = '''
+FROM xosproject/xos-synchronizer-onboarding
+MAINTAINER chetan@ciena.com
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    apt-transport-https
+COPY butler.crt /usr/local/share/ca-certificates
+RUN update-ca-certificates
+COPY $APT_KEY /tmp/
+RUN apt-key add /tmp/$APT_KEY
+RUN echo "deb https://butler.opencloud.cs.arizona.edu/repos/release/syndicate syndicate main" > /etc/apt/sources.list.d/butler.list
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
+    syndicate-core \
+    syndicate-ms \
+    wget \
+    unzip
+
+RUN groupadd -r syndicate && useradd -m -r -g syndicate syndicate
+USER syndicate
+ENV HOME /home/syndicate
+WORKDIR $HOME
+RUN wget -nv https://storage.googleapis.com/appengine-sdks/featured/$GAE_SDK
+RUN unzip -q $GAE_SDK
+RUN mkdir $HOME/datastore
+CMD $HOME/google_appengine/dev_appserver.py --admin_host=0.0.0.0 --host=0.0.0.0 --storage_path=$HOME/datastore --skip_sdk_update_check=true /usr/src/syndicate/ms
+'''
+        super(Xos_sync_onboarding, cls).build_image(dockerfile, image)
+        print('Done building image %s' %image)
+
+
diff --git a/src/test/xos/__init__.py b/src/test/xos/__init__.py
new file mode 100644
index 0000000..c38f621
--- /dev/null
+++ b/src/test/xos/__init__.py
@@ -0,0 +1,26 @@
+#
+# Copyright 2016-present Ciena Corporation
+#
+# 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.
+#
+import os,sys
+##add the python path to lookup the utils
+working_dir = os.path.dirname(os.path.realpath(sys.argv[-1]))
+utils_dir = os.path.join(working_dir, '../utils')
+fsm_dir = os.path.join(working_dir, '../fsm')
+cli_dir = os.path.join(working_dir, '../cli')
+subscriber_dir = os.path.join(working_dir, '../subscriber')
+__path__.append(utils_dir)
+__path__.append(fsm_dir)
+__path__.append(cli_dir)
+__path__.append(subscriber_dir)
diff --git a/src/test/xos/xosTest.py b/src/test/xos/xosTest.py
new file mode 100644
index 0000000..19d4228
--- /dev/null
+++ b/src/test/xos/xosTest.py
@@ -0,0 +1,272 @@
+#
+# Copyright 2016-present Ciena Corporation
+#
+# 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.
+#
+import unittest
+import subprocess
+from docker import Client
+from itertools import chain
+from nose.tools import *
+from scapy.all import *
+from CordContainer import *
+import threading
+import time
+import os
+import json
+import pexpect
+log.setLevel('INFO')
+
+
+flatten = lambda l: chain.from_iterable(l)
+
+class xos_exchange(unittest.TestCase):
+
+    dckr = Client()
+    test_path = os.path.dirname(os.path.realpath(__file__))
+    XOS_BASE_CONTAINER_IMAGE = 'xosproject/xos-base:latest'
+    XOS_BASE_CONTAINER_NAME = 'xos-base'
+    XOS_BASE_CONTAINER_PORTS = [8000]
+    XOS_SYN_OPENSTACK_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-openstack'
+    XOS_SYN_OPENSTACK_CONTAINER_NAME = 'xos-synchronizer-openstack'
+    XOS_SYN_OPENSTACK_CONTAINER_PORTS = [8000]
+    XOS_POSTGRESQL_CONTAINER_IMAGE = 'ubuntu:14.04'
+    XOS_POSTGRESQL_CONTAINER_NAME = 'xos-postgresql'
+    XOS_POSTGRESQL_CONTAINER_PORTS = [5432]
+    XOS_SYNDICATE_MS_CONTAINER_IMAGE = 'ubuntu:14.04.4'
+    XOS_SYNDICATE_MS_CONTAINER_NAME = 'syndicate-ms'
+    XOS_SYNDICATE_MS_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_VTR_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-vtr'
+    XOS_SYNCHRONIZER_VTR_CONTAINER_NAME = 'xos-synchronizer-vtr'
+    XOS_SYNCHRONIZER_VTR_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_VSG_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-vsg'
+    XOS_SYNCHRONIZER_VSG_CONTAINER_NAME = 'xos-synchronizer-vsg'
+    XOS_SYNCHRONIZER_VSG_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_ONOS_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-onos'
+    XOS_SYNCHRONIZER_ONOS_CONTAINER_NAME = 'xos-synchronizer-onos'
+    XOS_SYNCHRONIZER_ONOS_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_FABRIC_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-fabric'
+    XOS_SYNCHRONIZER_FABRIC_CONTAINER_NAME = 'xos-synchronizer-fabric'
+    XOS_SYNCHRONIZER_FABRIC_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_VTN_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-vtn'
+    XOS_SYNCHRONIZER_VTN_CONTAINER_NAME = 'xos-synchronizer-vtn'
+    XOS_SYNCHRONIZER_VTN_CONTAINER_PORTS = [8080]
+    XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE = 'xosproject/xos-synchronizer-onboarding'
+    XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_NAME = 'xos-synchronizer-onboarding'
+    XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_PORTS = [8080]
+
+    def setUp(self):
+        ''' Activate the XOS containers'''
+        self.maxDiff = None ##for assert_equal compare outputs on failure
+
+    def tearDown(self):
+        '''Deactivate the xos containers'''
+        log.info('Tear down setup')
+        self.CURRENT_PORT_NUM = 4
+
+    def exists(self, name):
+        return '/{0}'.format(name) in list(flatten(n['Names'] for n in self.dckr.containers()))
+
+
+    def img_exists(self, image):
+        cnt = filter(lambda c: c['Image'] == image, self.dckr.containers())
+        return image in [ctn['RepoTags'][0] if ctn['RepoTags'] else '' for ctn in self.dckr.images()]
+
+    def xos_containers_check(self, name, image):
+           if self.exists(name) != True:
+              if name == self.XOS_BASE_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosBase = Xos_base(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYN_OPENSTACK_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_openstack(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_POSTGRESQL_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosPostgresql = Xos_postgresql(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNDICATE_MS_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSyndicateMs = Xos_syndicate_ms(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_VTR_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_vtr(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_VSG_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_vsg(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_ONOS_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_onos(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_fabric(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_VTN_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_vtn(prefix = Container.IMAGE_PREFIX, update = False)
+              if name == self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_NAME:
+                 log.info('%s container is not running, hence build and run it, waiting until container is up' %name)
+                 xosSynOpenstack = Xos_sync_onboarding(prefix = Container.IMAGE_PREFIX, update = False)
+              if self.img_exists(image) != True:
+                 log.info('%s container image is not built on host, its a github issue' %name)
+                 assert_equal(False, True)
+              if self.exists(name) != True:
+                 log.info('%s container image is build on host, but its not up and running' %name)
+                 assert_equal(False, True)
+
+    def container_status(self, image, name):
+        ''' This function is checking that container is up and running'''
+        self.xos_containers_check(name, image)
+        container_info = self.dckr.containers(filters ={'name':name, 'status':'running'})
+        log.info('Xos container info= %s' %container_info)
+
+        if not container_info:
+           ## forcely failing test case
+           log.info('%s container is not running, container info %s' %(name,container_info))
+           assert_equal(False, True)
+        else:
+           container_status = container_info[0]['Status']
+           log.info('Xos container status= %s' %container_status)
+           assert_equal(container_status.split(' ')[0], 'Up')
+           return container_info
+
+    def container_ping(self, image, name):
+        ''' This function is checking that container is able to ping to its ip '''
+        container_info = self.container_status(image= image, name= name)
+        container_ip = container_info[0]['NetworkSettings']['Networks']['bridge']['IPAddress']
+        ping_status = os.system('ping {} -c 3'.format(container_ip))
+        if ping_status != 0:
+           log.info('%s container is not able to reach and ip is not ping, response %s = '%(name,ping_status))
+           assert_equal(ping_status, 0)
+        log.info('%s container is able to reach and ip is ping, response = %s'%(name,ping_status))
+        assert_equal(ping_status, 0)
+
+    def container_listening_ports_info(self, image, name, ports_list):
+        ''' This function is checking that container ports are as excpeted '''
+        container_public_ports = []
+        container_info = self.container_status(image= image, name= name)
+        container_ports = container_info[0]['Ports']
+        container_public_ports.append(container_ports[0]['PublicPort'])
+        log.info('%s container is listening on these ports = %s'%(name,container_ports))
+        log.info('%s container is listening on these public ports = %s'%(name,container_public_ports))
+        for n in range(0,len(ports_list)):
+            port = ports_list[n]
+            if port in container_public_ports:
+               assert_equal(True, True)
+            else:
+               log.info('%s container is not listening on %s port which is not expected' %(name,n))
+               assert_equal(False, True)
+
+    def container_stop_start(self):
+        ''' This function is checking container is stop and running if we start again'''
+
+    def test_xos_base_container_status(self):
+        self.container_status(image = self.XOS_BASE_CONTAINER_IMAGE, name = self.XOS_BASE_CONTAINER_NAME)
+
+    def test_xos_base_container_ping(self):
+        self.container_ping(image = self.XOS_BASE_CONTAINER_IMAGE, name = self.XOS_BASE_CONTAINER_NAME)
+
+    def test_xos_base_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_BASE_CONTAINER_IMAGE, name = self.XOS_BASE_CONTAINER_NAME,
+                                             ports_list = self.XOS_BASE_CONTAINER_PORTS)
+
+    def test_xos_sync_openstack_container_status(self):
+        self.container_status(image = self.XOS_SYN_OPENSTACK_CONTAINER_IMAGE, name = self.XOS_SYN_OPENSTACK_CONTAINER_NAME)
+
+    def test_xos_sync_openstack_container_ping(self):
+        self.container_ping(image = self.XOS_SYN_OPENSTACK_CONTAINER_IMAGE, name = self.XOS_SYN_OPENSTACK_CONTAINER_NAME)
+
+    def test_xos_sync_openstack_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYN_OPENSTACK_CONTAINER_IMAGE,
+                                            name = self.XOS_SYN_OPENSTACK_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYN_OPENSTACK_CONTAINER_PORTS)
+
+    def test_xos_postgresql_container_status(self):
+        self.container_status(image = self.XOS_POSTGRESQL_CONTAINER_IMAGE, name = self.XOS_POSTGRESQL_CONTAINER_NAME)
+
+    def test_xos_postgresql_container_ping(self):
+        self.container_ping(image = self.XOS_POSTGRESQL_CONTAINER_IMAGE, name = self.XOS_POSTGRESQL_CONTAINER_NAME)
+
+    def test_xos_postgresql_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_POSTGRESQL_CONTAINER_IMAGE,
+                                            name = self.XOS_POSTGRESQL_CONTAINER_NAME,
+                                            ports_list = self.XOS_POSTGRESQL_CONTAINER_PORTS)
+
+    def test_xos_syndicate_ms_container_status(self):
+        self.container_status(image = self.XOS_SYNDICATE_MS_CONTAINER_IMAGE, name = self.XOS_SYNDICATE_MS_CONTAINER_NAME)
+
+    def test_xos_syndicate_ms_container_ping(self):
+        self.container_ping(image = self.XOS_SYNDICATE_MS_CONTAINER_IMAGE, name = self.XOS_SYNDICATE_MS_CONTAINER_NAME)
+
+    def test_xos_syndicate_ms_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNDICATE_MS_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNDICATE_MS_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNDICATE_MS_CONTAINER_PORTS)
+
+    def test_xos_sync_vtr_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_VTR_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VTR_CONTAINER_NAME)
+
+    def test_xos_sync_vtr_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_VTR_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VTR_CONTAINER_NAME)
+
+    def test_xos_sync_vtr_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_VTR_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_VTR_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_VTR_CONTAINER_PORTS)
+    def test_xos_sync_vsg_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_VSG_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VSG_CONTAINER_NAME)
+
+    def test_xos_sync_vsg_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_VSG_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VSG_CONTAINER_NAME)
+
+    def test_xos_sync_vsg_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_VSG_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_VSG_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_VSG_CONTAINER_PORTS)
+    def test_xos_sync_onos_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_NAME)
+
+    def test_xos_sync_onos_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_NAME)
+
+    def test_xos_sync_onos_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_ONOS_CONTAINER_PORTS)
+    def test_xos_sync_fabric_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_NAME)
+
+    def test_xos_sync_fabric_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_NAME)
+
+    def test_xos_sync_fabric_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_FABRIC_CONTAINER_PORTS)
+    def test_xos_sync_vtn_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_VTN_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VTN_CONTAINER_NAME)
+
+    def test_xos_sync_vtn_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_VTN_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_VTN_CONTAINER_NAME)
+
+    def test_xos_sync_vtn_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_VTN_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_VTN_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_VTN_CONTAINER_PORTS)
+    def test_xos_sync_onboarding_container_status(self):
+        self.container_status(image = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE)
+
+    def test_xos_sync_onboarding_container_ping(self):
+        self.container_ping(image = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE, name = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE)
+
+    def test_xos_sync_onboarding_container_listening_ports(self):
+        self.container_listening_ports_info(image = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_IMAGE,
+                                            name = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_NAME,
+                                            ports_list = self.XOS_SYNCHRONIZER_ONBOARDING_CONTAINER_PORTS)