move over vtr service from XOS repo
diff --git a/xos/admin.py b/xos/admin.py
new file mode 100644
index 0000000..0120e66
--- /dev/null
+++ b/xos/admin.py
@@ -0,0 +1,111 @@
+from django.contrib import admin
+
+from django import forms
+from django.utils.safestring import mark_safe
+from django.contrib.auth.admin import UserAdmin
+from django.contrib.admin.widgets import FilteredSelectMultiple
+from django.contrib.auth.forms import ReadOnlyPasswordHashField
+from django.contrib.auth.signals import user_logged_in
+from django.utils import timezone
+from django.contrib.contenttypes import generic
+from suit.widgets import LinkedSelect
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
+from core.middleware import get_request
+
+from services.vtr.models import *
+from services.volt.models import CordSubscriberRoot
+
+from functools import update_wrapper
+from django.contrib.admin.views.main import ChangeList
+from django.core.urlresolvers import reverse
+from django.contrib.admin.utils import quote
+
+class VTRServiceAdmin(ReadOnlyAwareAdmin):
+ model = VTRService
+ verbose_name = "vTR Service"
+ verbose_name_plural = "vTR Service"
+ list_display = ("backend_status_icon", "name", "enabled")
+ list_display_links = ('backend_status_icon', 'name', )
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
+
+ extracontext_registered_admins = True
+
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+ suit_form_tabs =(('general', 'vTR Service Details'),
+ ('administration', 'Administration'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ ('serviceprivileges','Privileges'),
+ )
+
+ suit_form_includes = (('vtradmin.html', 'top', 'administration'),
+ ) #('hpctools.html', 'top', 'tools') )
+
+ def queryset(self, request):
+ return VTRService.get_service_objects_by_user(request.user)
+
+class VTRTenantForm(forms.ModelForm):
+ test = forms.ChoiceField(choices=VTRTenant.TEST_CHOICES, required=True)
+ scope = forms.ChoiceField(choices=VTRTenant.SCOPE_CHOICES, required=True)
+ argument = forms.CharField(required=False)
+ result_code = forms.CharField(required=False)
+ result = forms.CharField(required=False, widget=forms.Textarea(attrs={'rows': 10, 'cols': 80, 'class': 'input-xxlarge'}))
+ target = forms.ModelChoiceField(queryset=CordSubscriberRoot.objects.all())
+
+ def __init__(self,*args,**kwargs):
+ super (VTRTenantForm,self ).__init__(*args,**kwargs)
+ self.fields['provider_service'].queryset = VTRService.get_service_objects().all()
+ if self.instance:
+ # fields for the attributes
+ self.fields['test'].initial = self.instance.test
+ self.fields['argument'].initial = self.instance.argument
+ self.fields['target'].initial = self.instance.target
+ self.fields['scope'].initial = self.instance.scope
+ if (self.instance.enacted is not None) and (self.instance.enacted >= self.instance.updated):
+ self.fields['result'].initial = self.instance.result
+ self.fields['result_code'].initial = self.instance.result_code
+ else:
+ self.fields['result'].initial = ""
+ self.fields['result_code'].initial= ""
+ if (not self.instance) or (not self.instance.pk):
+ # default fields for an 'add' form
+ self.fields['kind'].initial = VTR_KIND
+ self.fields["scope"].initial = VTRTenant.get_default_attribute("scope")
+ if VTRService.get_service_objects().exists():
+ self.fields["provider_service"].initial = VTRService.get_service_objects().all()[0]
+
+ def save(self, commit=True):
+ self.instance.test = self.cleaned_data.get("test")
+ self.instance.argument = self.cleaned_data.get("argument")
+ self.instance.target = self.cleaned_data.get("target")
+ self.instance.result = self.cleaned_data.get("result")
+ self.instance.result_code = self.cleaned_data.get("result_code")
+ self.instance.scope = self.cleaned_data.get("scope")
+ return super(VTRTenantForm, self).save(commit=commit)
+
+ class Meta:
+ model = VTRTenant
+
+class VTRTenantAdmin(ReadOnlyAwareAdmin):
+ list_display = ('backend_status_icon', 'id', 'target', 'test', 'argument' )
+ list_display_links = ('backend_status_icon', 'id')
+ fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', # 'subscriber_root', 'service_specific_id', 'service_specific_attribute',
+ 'target', 'scope', 'test', 'argument', 'is_synced', 'result_code', 'result'],
+ 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', 'service_specific_attribute', 'is_synced')
+ form = VTRTenantForm
+
+ suit_form_tabs = (('general','Details'),)
+
+ def is_synced(self, obj):
+ return (obj.enacted is not None) and (obj.enacted >= obj.updated)
+
+ def queryset(self, request):
+ return VTRTenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(VTRService, VTRServiceAdmin)
+admin.site.register(VTRTenant, VTRTenantAdmin)
+
diff --git a/xos/api/tenant/truckroll.py b/xos/api/tenant/truckroll.py
new file mode 100644
index 0000000..cc8d62b
--- /dev/null
+++ b/xos/api/tenant/truckroll.py
@@ -0,0 +1,67 @@
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.reverse import reverse
+from rest_framework import serializers
+from rest_framework import generics
+from rest_framework import status
+from core.models import *
+from django.forms import widgets
+from services.vtr.models import VTRTenant, VTRService
+from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
+from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
+
+def get_default_vtr_service():
+ vtr_services = VTRService.get_service_objects().all()
+ if vtr_services:
+ return vtr_services[0]
+ return None
+
+class VTRTenantForAPI(VTRTenant):
+ class Meta:
+ proxy = True
+ app_label = "cord"
+
+class VTRTenantSerializer(PlusModelSerializer):
+ id = ReadOnlyField()
+ target_id = serializers.IntegerField()
+ test = serializers.CharField()
+ scope = serializers.CharField()
+ argument = serializers.CharField(required=False)
+ provider_service = serializers.PrimaryKeyRelatedField(queryset=VTRService.get_service_objects().all(), default=get_default_vtr_service)
+ result = serializers.CharField(required=False)
+ result_code = serializers.CharField(required=False)
+ backend_status = ReadOnlyField()
+
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ is_synced = serializers.SerializerMethodField("isSynced")
+
+ class Meta:
+ model = VTRTenantForAPI
+ fields = ('humanReadableName', 'id', 'provider_service', 'target_id', 'scope', 'test', 'argument', 'result', 'result_code', 'is_synced', 'backend_status' )
+
+ def getHumanReadableName(self, obj):
+ return obj.__unicode__()
+
+ def isSynced(self, obj):
+ return (obj.enacted is not None) and (obj.enacted >= obj.updated)
+
+class TruckRollViewSet(XOSViewSet):
+ base_name = "truckroll"
+ method_name = "truckroll"
+ method_kind = "viewset"
+ queryset = VTRTenantForAPI.get_tenant_objects().all() # select_related().all()
+ serializer_class = VTRTenantSerializer
+
+ @classmethod
+ def get_urlpatterns(self, api_path="^"):
+ patterns = super(TruckRollViewSet, self).get_urlpatterns(api_path=api_path)
+
+ return patterns
+
+ def list(self, request):
+ queryset = self.filter_queryset(self.get_queryset())
+
+ serializer = self.get_serializer(queryset, many=True)
+
+ return Response(serializer.data)
+
diff --git a/xos/models.py b/xos/models.py
new file mode 100644
index 0000000..ce2e345
--- /dev/null
+++ b/xos/models.py
@@ -0,0 +1,89 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models.plcorebase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import Q
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+from services.volt.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xos.config import Config
+
+class ConfigurationError(Exception):
+ pass
+
+VTR_KIND = "vTR"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
+# -------------------------------------------
+# VOLT
+# -------------------------------------------
+
+class VTRService(Service):
+ KIND = VTR_KIND
+
+ class Meta:
+ app_label = "vtr"
+ verbose_name = "vTR Service"
+ proxy = True
+
+class VTRTenant(Tenant):
+ class Meta:
+ proxy = True
+
+ KIND = VTR_KIND
+
+ TEST_CHOICES = ( ("ping", "Ping"), ("traceroute", "Trace Route"), ("tcpdump", "Tcp Dump") )
+ SCOPE_CHOICES = ( ("container", "Container"), ("vm", "VM") )
+
+ simple_attributes = ( ("test", None),
+ ("argument", None),
+ ("result", None),
+ ("result_code", None),
+ ("target_id", None),
+ ("scope", "container") )
+
+ sync_attributes = ( 'test', 'argument', "scope" )
+
+ def __init__(self, *args, **kwargs):
+ vtr_services = VTRService.get_service_objects().all()
+ if vtr_services:
+ self._meta.get_field("provider_service").default = vtr_services[0].id
+ super(VTRTenant, self).__init__(*args, **kwargs)
+
+ @property
+ def target(self):
+ if getattr(self, "cached_target", None):
+ return self.cached_target
+ target_id=self.target_id
+ if not target_id:
+ return None
+ users=CordSubscriberRoot.objects.filter(id=target_id)
+ if not users:
+ return None
+ user=users[0]
+ self.cached_target = users[0]
+ return user
+
+ @target.setter
+ def target(self, value):
+ if value:
+ value = value.id
+ if (value != self.get_attribute("target_id", None)):
+ self.cached_target=None
+ self.target_id = value
+
+ def save(self, *args, **kwargs):
+ super(VTRTenant, self).save(*args, **kwargs)
+
+ def delete(self, *args, **kwargs):
+ super(VTRTenant, self).delete(*args, **kwargs)
+
+
+VTRTenant.setup_simple_attributes()
+
diff --git a/xos/synchronizer/files/run_tcpdump.sh b/xos/synchronizer/files/run_tcpdump.sh
new file mode 100644
index 0000000..ed75bf0
--- /dev/null
+++ b/xos/synchronizer/files/run_tcpdump.sh
@@ -0,0 +1,9 @@
+#! /bin/bash
+INTERFACE=$1
+tcpdump -n -e -i $INTERFACE -c 100 &
+PID_TCPDUMP=$!
+curl http://www.xosproject.org/ &> /dev/null &
+PID_CURL=$!
+sleep 30s
+kill $PID_TCPDUMP
+kill $PIUD_CURL
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
new file mode 100644
index 0000000..61ffb39
--- /dev/null
+++ b/xos/synchronizer/manifest
@@ -0,0 +1,10 @@
+manifest
+vtr-synchronizer.py
+vtn_vtr_synchronizer_config
+steps/sync_vtrtenant.py
+steps/sync_vtrtenant.yaml
+vtr_synchronizer_config
+files/run_tcpdump.sh
+run-vtn.sh
+model-deps
+run.sh
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/run-vtn.sh b/xos/synchronizer/run-vtn.sh
new file mode 100755
index 0000000..b2f9518
--- /dev/null
+++ b/xos/synchronizer/run-vtn.sh
@@ -0,0 +1,4 @@
+export XOS_DIR=/opt/xos
+cp /root/setup/node_key $XOS_DIR/synchronizers/vtr/node_key
+chmod 0600 $XOS_DIR/synchronizers/vtr/node_key
+python vtr-synchronizer.py -C $XOS_DIR/synchronizers/vtr/vtn_vtr_synchronizer_config
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
new file mode 100755
index 0000000..388fdf9
--- /dev/null
+++ b/xos/synchronizer/run.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python vtr-synchronizer.py -C $XOS_DIR/synchronizers/vtr/vtr_synchronizer_config
diff --git a/xos/synchronizer/steps/sync_vtrtenant.py b/xos/synchronizer/steps/sync_vtrtenant.py
new file mode 100644
index 0000000..f0f7ef3
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vtrtenant.py
@@ -0,0 +1,147 @@
+import os
+import socket
+import sys
+import base64
+import time
+from django.db.models import F, Q
+from xos.config import Config
+from synchronizers.base.syncstep import SyncStep
+from synchronizers.base.ansible import run_template_ssh
+from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from core.models import Service, Slice, Tag
+from services.vsg.models import VSGService, VCPE_KIND
+from services.vtr.models import VTRService, VTRTenant
+from services.hpc.models import HpcService, CDNPrefix
+from xos.logger import Logger, logging
+
+# hpclibrary will be in steps/..
+parentdir = os.path.join(os.path.dirname(__file__),"..")
+sys.path.insert(0,parentdir)
+
+logger = Logger(level=logging.INFO)
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
+class SyncVTRTenant(SyncInstanceUsingAnsible):
+ provides=[VTRTenant]
+ observes=VTRTenant
+ requested_interval=0
+ template_name = "sync_vtrtenant.yaml"
+ #service_key_name = "/opt/xos/services/vtr/vcpe_private_key"
+
+ def __init__(self, *args, **kwargs):
+ super(SyncVTRTenant, self).__init__(*args, **kwargs)
+
+ def fetch_pending(self, deleted):
+ if (not deleted):
+ objs = VTRTenant.get_tenant_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
+ else:
+ objs = VTRTenant.get_deleted_tenant_objects()
+
+ return objs
+
+ def get_vtr_service(self, o):
+ if not o.provider_service:
+ return None
+
+ vtrs = VTRService.get_service_objects().filter(id=o.provider_service.id)
+ if not vtrs:
+ return None
+
+ return vtrs[0]
+
+ def get_vcpe_service(self, o):
+ if o.target:
+ # o.target is a CordSubscriberRoot
+ if o.target.volt and o.target.volt.vcpe:
+ vcpes = VSGService.get_service_objects().filter(id=o.target.volt.vcpe.provider_service.id)
+ if not vcpes:
+ return None
+ return vcpes[0]
+ return None
+
+ def get_instance(self, o):
+ if o.target and o.target.volt and o.target.volt.vcpe:
+ return o.target.volt.vcpe.instance
+ else:
+ return None
+
+ def get_key_name(self, instance):
+ if instance.slice.service and (instance.slice.service.kind==VCPE_KIND):
+ # We need to use the vsg service's private key. Onboarding won't
+ # by default give us another service's private key, so let's assume
+ # onboarding has been configured to add vsg_rsa to the vtr service.
+ return "/opt/xos/services/vtr/keys/vsg_rsa"
+ else:
+ raise Exception("VTR doesn't know how to get the private key for this instance")
+
+ def get_extra_attributes(self, o):
+ vtr_service = self.get_vtr_service(o)
+ vcpe_service = self.get_vcpe_service(o)
+
+ if not vcpe_service:
+ raise Exception("No vcpeservice")
+
+ instance = self.get_instance(o)
+
+ if not instance:
+ raise Exception("No instance")
+
+ s_tags = []
+ c_tags = []
+ if o.target and o.target.volt:
+ s_tags.append(o.target.volt.s_tag)
+ c_tags.append(o.target.volt.c_tag)
+
+ fields = {"s_tags": s_tags,
+ "c_tags": c_tags,
+ "isolation": instance.isolation,
+ "container_name": "vcpe-%s-%s" % (s_tags[0], c_tags[0]),
+ "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")],
+
+ "result_fn": "%s-vcpe-%s-%s" % (o.test, s_tags[0], c_tags[0]),
+ "resultcode_fn": "code-%s-vcpe-%s-%s" % (o.test, s_tags[0], c_tags[0]) }
+
+ # add in the sync_attributes that come from the vSG object
+ # this will be wan_ip, wan_mac, wan_container_ip, wan_container_mac, ...
+ if o.target and o.target.volt and o.target.volt.vcpe:
+ for attribute_name in o.target.volt.vcpe.sync_attributes:
+ fields[attribute_name] = getattr(o.target.volt.vcpe, attribute_name)
+
+ # add in the sync_attributes that come from the SubscriberRoot object
+ if o.target and hasattr(o.target, "sync_attributes"):
+ for attribute_name in o.target.sync_attributes:
+ fields[attribute_name] = getattr(o.target, attribute_name)
+
+ for attribute_name in o.sync_attributes:
+ fields[attribute_name] = getattr(o,attribute_name)
+
+ return fields
+
+ def sync_fields(self, o, fields):
+ # the super causes the playbook to be run
+
+ super(SyncVTRTenant, self).sync_fields(o, fields)
+
+ def run_playbook(self, o, fields):
+ o.result = ""
+
+ result_fn = os.path.join("/opt/xos/synchronizers/vtr/result", fields["result_fn"])
+ if os.path.exists(result_fn):
+ os.remove(result_fn)
+
+ resultcode_fn = os.path.join("/opt/xos/synchronizers/vtr/result", fields["resultcode_fn"])
+ if os.path.exists(resultcode_fn):
+ os.remove(resultcode_fn)
+
+ super(SyncVTRTenant, self).run_playbook(o, fields)
+
+ if os.path.exists(result_fn):
+ o.result = open(result_fn).read()
+
+ if os.path.exists(resultcode_fn):
+ o.result_code = open(resultcode_fn).read()
+
+
+ def delete_record(self, m):
+ pass
diff --git a/xos/synchronizer/steps/sync_vtrtenant.yaml b/xos/synchronizer/steps/sync_vtrtenant.yaml
new file mode 100644
index 0000000..35d9032
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vtrtenant.yaml
@@ -0,0 +1,123 @@
+---
+- hosts: {{ instance_name }}
+ #gather_facts: False
+ connection: ssh
+ user: ubuntu
+ sudo: yes
+ vars:
+ container_name: {{ container_name }}
+ wan_container_ip: {{ wan_container_ip }}
+ wan_container_netbits: {{ wan_container_netbits }}
+ wan_container_mac: {{ wan_container_mac }}
+ wan_container_gateway_ip: {{ wan_container_gateway_ip }}
+ wan_vm_ip: {{ wan_vm_ip }}
+ wan_vm_mac: {{ wan_vm_mac }}
+
+ scope: {{ scope }}
+ test: {{ test }}
+ argument: {{ argument }}
+ result_fn: {{ result_fn }}
+ resultcode_fn: {{ resultcode_fn }}
+
+
+ tasks:
+ - name: Remove any old result file
+ shell: rm -f /tmp/{{ result_fn }}
+
+ - name: Copy run_tcpdump.sh to VM
+ copy: src=/opt/xos/synchronizers/vtr/files/run_tcpdump.sh dest=/root/run_tcpdump.sh mode=0755
+ when: (test=="tcpdump")
+
+
+# -----------------
+# scope == VM
+# -----------------
+
+ - name: Send the pings from VM
+ shell: ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: vm_ping_result
+ when: (scope=="vm") and (test=="ping")
+
+ - name: Store VM ping resultcode to file
+ shell: echo "{{ '{{' }} vm_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="vm") and (test=="ping")
+
+ - name: Install traceroute
+ apt: name=traceroute state=present
+ when: (scope=="vm") and (test=="traceroute")
+
+ - name: Send traceroute from VM
+ shell: traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: vm_traceroute_result
+ when: (scope=="vm") and (test=="traceroute")
+
+ - name: Store VM traceroute resultcode to file
+ shell: echo "{{ '{{' }} vm_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="vm") and (test=="traceroute")
+
+ - name: Run tcpdump for 30 seconds on VM
+ shell: /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: vm_tcpdump_result
+ when: (scope=="vm") and (test=="tcpdump")
+
+ - name: Store VM tcpdump resultcode to file
+ shell: echo "{{ '{{' }} vm_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="vm") and (test=="tcpdump")
+
+# ------------------
+# scope == container
+# ------------------
+
+ - name: Send the pings from Container
+ shell: docker exec {{ container_name }} ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: ctr_ping_result
+ when: (scope=="container") and (test=="ping")
+
+ - name: Store ctr ping resultcode to file
+ shell: echo "{{ '{{' }} ctr_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="container") and (test=="ping")
+
+ - name: Install traceroute into Container
+ shell: docker exec {{ container_name }} apt-get -y install traceroute
+ when: (scope=="container") and (test=="traceroute")
+
+ - name: Send traceroute from Container
+ shell: docker exec {{ container_name }} traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: ctr_traceroute_result
+ when: (scope=="container") and (test=="traceroute")
+
+ - name: Store ctr traceroute resultcode to file
+ shell: echo "{{ '{{' }} ctr_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="container") and (test=="traceroute")
+
+ - name: Copy run_tcpdump.sh to container
+ command: docker cp /root/run_tcpdump.sh {{ container_name }}:/root/run_tcpdump.sh
+ when: (scope=="container") and (test=="tcpdump")
+
+ - name: Run tcpdump for 30 seconds from Container
+ shell: docker exec {{ container_name }} /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
+ ignore_errors: yes
+ register: diagresult
+ when: (scope=="container") and (test=="tcpdump")
+
+ - name: Store ctr tcpdump resultcode to file
+ shell: echo "{{ '{{' }} ctr_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
+ when: (scope=="container") and (test=="tcpdump")
+
+# ------------------
+# scope == *
+# ------------------
+ - name: Fetch the result
+ fetch: src=/tmp/{{ result_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ result_fn }} flat=yes
+
+ - name: Fetch the resultcode
+ fetch: src=/tmp/{{ resultcode_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ resultcode_fn }} flat=yes
+
+
+
+
diff --git a/xos/synchronizer/vtn_vtr_synchronizer_config b/xos/synchronizer/vtn_vtr_synchronizer_config
new file mode 100644
index 0000000..2c9140a
--- /dev/null
+++ b/xos/synchronizer/vtn_vtr_synchronizer_config
@@ -0,0 +1,47 @@
+
+[plc]
+name=plc
+deployment=VICCI
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=128.112.171.237
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+
+[observer]
+name=vtr
+dependency_graph=/opt/xos/synchronizers/vtr/model-deps
+steps_dir=/opt/xos/synchronizers/vtr/steps
+sys_dir=/opt/xos/synchronizers/vtr/sys
+deleters_dir=/opt/xos/synchronizers/vtr/deleters
+log_file=console
+#/var/log/hpc.log
+driver=None
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+# set proxy_ssh to false on cloudlab
+full_setup=True
+proxy_ssh=True
+proxy_ssh_key=/opt/xos/synchronizers/vtr/node_key
+proxy_ssh_user=root
+
+[networking]
+use_vtn=True
+
+[feefie]
+client_id='vicci_dev_central'
+user_id='pl'
diff --git a/xos/synchronizer/vtr-synchronizer.py b/xos/synchronizer/vtr-synchronizer.py
new file mode 100755
index 0000000..84bec4f
--- /dev/null
+++ b/xos/synchronizer/vtr-synchronizer.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../../synchronizers/base")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/vtr_synchronizer_config b/xos/synchronizer/vtr_synchronizer_config
new file mode 100644
index 0000000..51bf25a
--- /dev/null
+++ b/xos/synchronizer/vtr_synchronizer_config
@@ -0,0 +1,41 @@
+
+[plc]
+name=plc
+deployment=VICCI
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=128.112.171.237
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+
+[observer]
+name=vtr
+dependency_graph=/opt/xos/synchronizers/vtr/model-deps
+steps_dir=/opt/xos/synchronizers/vtr/steps
+sys_dir=/opt/xos/synchronizers/vtr/sys
+deleters_dir=/opt/xos/synchronizers/vtr/deleters
+log_file=console
+driver=None
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+# set proxy_ssh to false on cloudlab
+proxy_ssh=False
+full_setup=True
+
+[feefie]
+client_id='vicci_dev_central'
+user_id='pl'
diff --git a/xos/templates/vtradmin.html b/xos/templates/vtradmin.html
new file mode 100644
index 0000000..e8a33bc
--- /dev/null
+++ b/xos/templates/vtradmin.html
@@ -0,0 +1,6 @@
+<div class = "row text-center">
+ <div class="col-xs-12">
+ <a href="/admin/vtr/vtrtenant/">vTR Tenants</a>
+ </div>
+</div>
+
diff --git a/xos/vtr-onboard.yaml b/xos/vtr-onboard.yaml
new file mode 100644
index 0000000..0110aad
--- /dev/null
+++ b/xos/vtr-onboard.yaml
@@ -0,0 +1,24 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+ servicecontroller#vtr:
+ type: tosca.nodes.ServiceController
+ properties:
+ base_url: file:///opt/xos_services/vtr/xos/
+ # The following will concatenate with base_url automatically, if
+ # base_url is non-null.
+ models: models.py
+ admin: admin.py
+ admin_template: templates/vtradmin.html
+ synchronizer: synchronizer/manifest
+ synchronizer_run: vtr-synchronizer.py
+ rest_tenant: api/tenant/truckroll.py
+ private_key: file:///opt/xos/key_import/vsg_rsa
+ public_key: file:///opt/xos/key_import/vsg_rsa.pub
+