CORD-2476 migrate vtr service to dynamic load
Change-Id: I77d8363f0d789e923d63ecf3295b6da209bf49c3
diff --git a/xos/admin.py b/xos/admin.py
deleted file mode 100644
index 42c9f96..0000000
--- a/xos/admin.py
+++ /dev/null
@@ -1,109 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-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
-from core.middleware import get_request
-
-from services.vtr.models import *
-from services.rcord.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
-from django.contrib.contenttypes.models import ContentType
-
-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 get_queryset(self, request):
- return VTRService.select_by_user(request.user)
-
-class VTRTenantForm(forms.ModelForm):
- target = forms.ModelChoiceField(queryset=CordSubscriberRoot.objects.all())
-
- def __init__(self,*args,**kwargs):
- super (VTRTenantForm,self ).__init__(*args,**kwargs)
- self.fields['owner'].queryset = VTRService.objects.all()
- if self.instance:
- if self.instance.target_id:
- self.fields["target"].initial = CordSubscriberRoot.get_content_object(self.instance.target_type, self.instance.target_id)
- if (not self.instance) or (not self.instance.pk):
- if VTRService.objects.exists():
- self.fields["owner"].initial = VTRService.objects.all()[0]
-
- def save(self, commit=True):
- if self.cleaned_data.get("target"):
- self.instance.target_type = self.cleaned_data.get("target").get_content_type_key()
- self.instance.target_id = self.cleaned_data.get("target").id
- return super(VTRTenantForm, self).save(commit=commit)
-
- class Meta:
- model = VTRTenant
- fields = '__all__'
-
-class VTRTenantAdmin(ReadOnlyAwareAdmin):
- list_display = ('backend_status_icon', 'id', 'target_type', 'target_id', 'test', 'argument' )
- list_display_links = ('backend_status_icon', 'id')
- fieldsets = [ (None, {'fields': ['backend_status_text', 'owner',
- '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 get_queryset(self, request):
- return VTRTenant.select_by_user(request.user)
-
-admin.site.register(VTRService, VTRServiceAdmin)
-admin.site.register(VTRTenant, VTRTenantAdmin)
-
diff --git a/xos/header.py b/xos/header.py
deleted file mode 120000
index 721b5c0..0000000
--- a/xos/header.py
+++ /dev/null
@@ -1 +0,0 @@
-attic/header.py
\ No newline at end of file
diff --git a/xos/models/vtrservice.xproto b/xos/models/vtrservice.xproto
deleted file mode 100644
index a8e4c3c..0000000
--- a/xos/models/vtrservice.xproto
+++ /dev/null
@@ -1,15 +0,0 @@
-message VTRService {
- optional string description = 1 [help_text = "Description of Service", max_length = 254, null = True, db_index = False, blank = True];
- required bool enabled = 2 [default = True, null = False, db_index = False, blank = True];
- required string kind = 3 [default = "generic", max_length = 30, content_type = "stripped", blank = False, help_text = "Kind of service", null = False, db_index = False];
- required string name = 4 [max_length = 30, content_type = "stripped", blank = False, help_text = "Service Name", null = False, db_index = False];
- optional string versionNumber = 5 [max_length = 30, content_type = "stripped", blank = True, help_text = "Version of Service Definition", null = True, db_index = False];
- required bool published = 6 [default = True, null = False, db_index = False, blank = True];
- optional string view_url = 7 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True];
- optional string icon_url = 8 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True];
- optional string public_key = 9 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True];
- optional string private_key_fn = 10 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True];
- optional string service_specific_id = 11 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True];
- optional string service_specific_attribute = 12 [db_index = False, null = True, blank = True];
- optional manytoone controller->ServiceController:services = 13 [help_text = "The Service Controller this Service uses", null = True, db_index = True, blank = True];
-}
diff --git a/xos/models/vtrtenant.xproto b/xos/models/vtrtenant.xproto
deleted file mode 100644
index d1e2a3e..0000000
--- a/xos/models/vtrtenant.xproto
+++ /dev/null
@@ -1,20 +0,0 @@
-message VTRTenant {
- optional string name = 1 [db_index = False, max_length = 200, null = True, content_type = "stripped", blank = True];
- required string kind = 2 [default = "generic", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
- required manytoone provider_service->Service:provided_tenants = 3 [db_index = True, null = False, blank = False];
- optional manytoone subscriber_service->Service:subscribed_tenants = 4 [db_index = True, null = True, blank = True];
- optional manytoone subscriber_tenant->Tenant:subscribed_tenants = 5 [db_index = True, null = True, blank = True];
- optional manytoone subscriber_user->User:subscribed_tenants = 6 [db_index = True, null = True, blank = True];
- optional manytoone subscriber_root->TenantRoot:subscribed_tenants = 7 [db_index = True, null = True, blank = True];
- optional manytoone subscriber_network->Network:subscribed_tenants = 8 [db_index = True, null = True, blank = True];
- optional string service_specific_id = 9 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True];
- optional string service_specific_attribute = 10 [db_index = False, null = True, blank = True];
- required string connect_method = 11 [default = "na", choices = "(('public', 'Public'), ('private', 'Private'), ('private-unidirectional', 'Private Unidirectional'), ('na', 'Not Applicable'))", max_length = 30, blank = False, null = False, db_index = False];
- required string test = 12 [choices = "(('ping', 'Ping'), ('traceroute', 'Trace Route'), ('tcpdump', 'Tcp Dump'))", max_length = 30, content_type = "stripped", blank = False, help_text = "type of test", null = False, db_index = False];
- required string scope = 13 [choices = "(('container', 'Container'), ('vm', 'VM'))", max_length = 30, content_type = "stripped", blank = False, help_text = "scope of test", null = False, db_index = False];
- optional string argument = 14 [db_index = False, max_length = 40, null = True, content_type = "stripped", blank = True];
- optional string result = 15 [db_index = False, null = True, blank = True];
- optional string result_code = 16 [db_index = False, max_length = 32, null = True, content_type = "stripped", blank = True];
- required manytoone target_type->ContentType:vtrtenant = 17 [db_index = True, null = False, blank = False];
- required uint32 target_id = 18 [db_index = False, null = False, blank = False];
-}
diff --git a/xos/attic/header.py b/xos/synchronizer/models/attic/header.py
similarity index 100%
rename from xos/attic/header.py
rename to xos/synchronizer/models/attic/header.py
diff --git a/xos/attic/vtrtenant_model.py b/xos/synchronizer/models/attic/vtrtenant_model.py
similarity index 100%
rename from xos/attic/vtrtenant_model.py
rename to xos/synchronizer/models/attic/vtrtenant_model.py
diff --git a/xos/vtr.xproto b/xos/synchronizer/models/vtr.xproto
similarity index 100%
rename from xos/vtr.xproto
rename to xos/synchronizer/models/vtr.xproto
diff --git a/xos/synchronizer/vtr_config.yaml b/xos/synchronizer/vtr_config.yaml
index fc95df3..e954487 100644
--- a/xos/synchronizer/vtr_config.yaml
+++ b/xos/synchronizer/vtr_config.yaml
@@ -14,7 +14,7 @@
# limitations under the License.
-name: vtr-synchronizer
+name: vtr
accessor:
username: xosadmin@opencord.org
password: "@/opt/xos/services/vtr/credentials/xosadmin@opencord.org"
@@ -25,4 +25,5 @@
- CordSubscriberRoot
dependency_graph: "/opt/xos/synchronizers/vtr/model-deps"
steps_dir: "/opt/xos/synchronizers/vtr/steps"
-sys_dir: "/opt/xos/synchronizers/vtr/sys"
\ No newline at end of file
+sys_dir: "/opt/xos/synchronizers/vtr/sys"
+models_dir: "/opt/xos/synchronizers/vtr/models"
diff --git a/xos/templates/vtradmin.html b/xos/templates/vtradmin.html
deleted file mode 100644
index 20161f7..0000000
--- a/xos/templates/vtradmin.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-<!--
-Copyright 2017-present Open Networking Foundation
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-
-<div class = "row text-center">
- <div class="col-xs-12">
- <a href="/admin/vtr/vtrtenant/">vTR Tenants</a>
- </div>
-</div>
-
diff --git a/xos/tosca/custom_types/macros.m4 b/xos/tosca/custom_types/macros.m4
deleted file mode 100644
index 391aafd..0000000
--- a/xos/tosca/custom_types/macros.m4
+++ /dev/null
@@ -1,100 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# Note: Tosca derived_from isn't working the way I think it should, it's not
-# inheriting from the parent template. Until we get that figured out, use
-# m4 macros do our inheritance
-
-define(xos_base_props,
- no-delete:
- type: boolean
- default: false
- description: Do not allow Tosca to delete this object
- no-create:
- type: boolean
- default: false
- description: Do not allow Tosca to create this object
- no-update:
- type: boolean
- default: false
- description: Do not allow Tosca to update this object
- replaces:
- type: string
- required: false
- descrption: Replaces/renames this object)
-# Service
-define(xos_base_service_caps,
- scalable:
- type: tosca.capabilities.Scalable
- service:
- type: tosca.capabilities.xos.Service)
-define(xos_base_service_props,
- kind:
- type: string
- default: generic
- description: Type of service.
- view_url:
- type: string
- required: false
- description: URL to follow when icon is clicked in the Service Directory.
- icon_url:
- type: string
- required: false
- description: ICON to display in the Service Directory.
- enabled:
- type: boolean
- default: true
- published:
- type: boolean
- default: true
- description: If True then display this Service in the Service Directory.
- public_key:
- type: string
- required: false
- description: Public key to install into Instances to allows Services to SSH into them.
- private_key_fn:
- type: string
- required: false
- description: Location of private key file
- versionNumber:
- type: string
- required: false
- description: Version number of Service.)
-# Subscriber
-define(xos_base_subscriber_caps,
- subscriber:
- type: tosca.capabilities.xos.Subscriber)
-define(xos_base_subscriber_props,
- kind:
- type: string
- default: generic
- description: Kind of subscriber
- service_specific_id:
- type: string
- required: false
- description: Service specific ID opaque to XOS but meaningful to service)
-define(xos_base_tenant_props,
- kind:
- type: string
- default: generic
- description: Kind of tenant
- service_specific_id:
- type: string
- required: false
- description: Service specific ID opaque to XOS but meaningful to service)
-
-# end m4 macros
-
diff --git a/xos/tosca/custom_types/vtr.m4 b/xos/tosca/custom_types/vtr.m4
deleted file mode 100644
index 7d5ba79..0000000
--- a/xos/tosca/custom_types/vtr.m4
+++ /dev/null
@@ -1,34 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-# compile this with "m4 vtr.m4 > vtr.yaml"
-
-# include macros
-include(macros.m4)
-
-node_types:
- tosca.nodes.VTRService:
- derived_from: tosca.nodes.Root
- description: >
- VTR Service
- capabilities:
- xos_base_service_caps
- properties:
- xos_base_props
- xos_base_service_props
-
diff --git a/xos/tosca/custom_types/vtr.yaml b/xos/tosca/custom_types/vtr.yaml
deleted file mode 100644
index a28dfc7..0000000
--- a/xos/tosca/custom_types/vtr.yaml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-# compile this with "m4 vtr.m4 > vtr.yaml"
-
-# include macros
-# Note: Tosca derived_from isn't working the way I think it should, it's not
-# inheriting from the parent template. Until we get that figured out, use
-# m4 macros do our inheritance
-
-
-# Service
-
-
-# Subscriber
-
-
-
-
-# end m4 macros
-
-
-
-node_types:
- tosca.nodes.VTRService:
- derived_from: tosca.nodes.Root
- description: >
- VTR Service
- capabilities:
- scalable:
- type: tosca.capabilities.Scalable
- service:
- type: tosca.capabilities.xos.Service
- properties:
- no-delete:
- type: boolean
- default: false
- description: Do not allow Tosca to delete this object
- no-create:
- type: boolean
- default: false
- description: Do not allow Tosca to create this object
- no-update:
- type: boolean
- default: false
- description: Do not allow Tosca to update this object
- replaces:
- type: string
- required: false
- descrption: Replaces/renames this object
- kind:
- type: string
- default: generic
- description: Type of service.
- view_url:
- type: string
- required: false
- description: URL to follow when icon is clicked in the Service Directory.
- icon_url:
- type: string
- required: false
- description: ICON to display in the Service Directory.
- enabled:
- type: boolean
- default: true
- published:
- type: boolean
- default: true
- description: If True then display this Service in the Service Directory.
- public_key:
- type: string
- required: false
- description: Public key to install into Instances to allows Services to SSH into them.
- private_key_fn:
- type: string
- required: false
- description: Location of private key file
- versionNumber:
- type: string
- required: false
- description: Version number of Service.
-
diff --git a/xos/tosca/resources/vtrservice.py b/xos/tosca/resources/vtrservice.py
deleted file mode 100644
index 623c282..0000000
--- a/xos/tosca/resources/vtrservice.py
+++ /dev/null
@@ -1,24 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-from xosresource import XOSResource
-from service import XOSService
-from services.vtr.models import VTRService
-
-class XOSVTRService(XOSService):
- provides = "tosca.nodes.VTRService"
- xos_model = VTRService
-
diff --git a/xos/vtr-onboard.yaml b/xos/vtr-onboard.yaml
index 90d3208..c443b73 100644
--- a/xos/vtr-onboard.yaml
+++ b/xos/vtr-onboard.yaml
@@ -29,11 +29,6 @@
base_url: file:///opt/xos_services/vtr/xos/
# The following will concatenate with base_url automatically, if
# base_url is non-null.
- xproto: ./
- admin: admin.py
- admin_template: templates/vtradmin.html
- tosca_custom_types: tosca/custom_types/vtr.yaml
- tosca_resource: tosca/resources/vtrservice.py
private_key: file:///opt/xos/key_import/vsg_rsa
public_key: file:///opt/xos/key_import/vsg_rsa.pub