CORD-1849 Split XOS code out of OLT and VTN repos
Change-Id: I307b2a9a54fdcdab14e6bf96d9a9b060ff421a77
diff --git a/xos/attic/accessagent_model.py b/xos/attic/accessagent_model.py
new file mode 100644
index 0000000..b80d979
--- /dev/null
+++ b/xos/attic/accessagent_model.py
@@ -0,0 +1,17 @@
+
+# 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.
+
+
+def __unicode__(self): return u'%s' % (self.name)
diff --git a/xos/attic/accessdevice_model.py b/xos/attic/accessdevice_model.py
new file mode 100644
index 0000000..507cd58
--- /dev/null
+++ b/xos/attic/accessdevice_model.py
@@ -0,0 +1,17 @@
+
+# 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.
+
+
+def __unicode__(self): return u'%s-%d:%d' % (self.volt_device.name,self.uplink,self.vlan)
diff --git a/xos/attic/agentportmapping_model.py b/xos/attic/agentportmapping_model.py
new file mode 100644
index 0000000..d80baab
--- /dev/null
+++ b/xos/attic/agentportmapping_model.py
@@ -0,0 +1,17 @@
+
+# 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.
+
+
+def __unicode__(self): return u'%s-%s-%s' % (self.access_agent.name, self.port, self.mac)
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..0bb8be2
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,39 @@
+
+# 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.db import models
+from django.db.models import *
+from core.models import Service, XOSBase, Slice, Instance, ServiceInstance, ServiceInstanceLink, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool, User
+from core.models.xosbase 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.vrouter.models import VRouterService, VRouterTenant
+from services.rcord.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xosconfig import Config
+
+class ConfigurationError(Exception):
+ pass
+
+VOLT_KIND = "vOLT"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
diff --git a/xos/attic/voltdevice_model.py b/xos/attic/voltdevice_model.py
new file mode 100644
index 0000000..b80d979
--- /dev/null
+++ b/xos/attic/voltdevice_model.py
@@ -0,0 +1,17 @@
+
+# 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.
+
+
+def __unicode__(self): return u'%s' % (self.name)
diff --git a/xos/attic/volttenant_model.py b/xos/attic/volttenant_model.py
new file mode 100644
index 0000000..c7a3420
--- /dev/null
+++ b/xos/attic/volttenant_model.py
@@ -0,0 +1,69 @@
+
+# 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.
+
+
+def __init__(self, *args, **kwargs):
+ volt_services = VOLTService.objects.all()
+ if volt_services:
+ self._meta.get_field("owner").default = volt_services[0].id
+ super(VOLTTenant, self).__init__(*args, **kwargs)
+ self.cached_vcpe = None
+
+@property
+def vcpe(self):
+ # TODO: hardcoded service dependency
+ from services.vsg.models import VSGTenant
+
+ vsg = None
+ for link in self.subscribed_links:
+ # cast from base class to derived class
+ vsgs = VSGTenant.objects.filter(serviceinstance_ptr=link.provider_service_instance)
+ if vsgs:
+ vsg = vsgs[0]
+
+ if not vsg:
+ return None
+
+ # always return the same object when possible
+ if (self.cached_vcpe) and (self.cached_vcpe.id == vsg.id):
+ return self.cached_vcpe
+
+ vsg.caller = self.creator
+ self.cached_vcpe = vsg
+ return vsg
+
+@vcpe.setter
+def vcpe(self, value):
+ raise XOSConfigurationError("vOLT.vCPE cannot be set this way -- create a new vCPE object and set its subscriber_tenant instead")
+
+@property
+def subscriber(self):
+ for link in self.provided_links:
+ # cast from base class to derived class
+ roots = CordSubscriberRoot.objects.filter(serviceinstance_ptr=link.subscriber_service_instance)
+ if roots:
+ return roots[0]
+ return None
+
+def save(self, *args, **kwargs):
+ if not self.creator:
+ if not getattr(self, "caller", None):
+ # caller must be set when creating a vCPE since it creates a slice
+ raise XOSProgrammingError("VOLTTenant's self.caller was not set")
+ self.creator = self.caller
+ if not self.creator:
+ raise XOSProgrammingError("VOLTTenant's self.creator was not set")
+
+ super(VOLTTenant, self).save(*args, **kwargs)