Matteo Scandolo | c3ca49b | 2017-08-08 13:05:26 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Murat Parlakisik | b224cc9 | 2017-02-16 16:27:12 -0800 | [diff] [blame] | 17 | from django.db import models |
Sapan Bhatia | 99529ed | 2017-05-19 23:10:52 +0200 | [diff] [blame] | 18 | from core.models import Service, XOSBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, Port, AddressPool |
| 19 | from core.models.xosbase import StrippedCharField |
Murat Parlakisik | b224cc9 | 2017-02-16 16:27:12 -0800 | [diff] [blame] | 20 | import os |
| 21 | from django.db import models, transaction |
| 22 | from django.forms.models import model_to_dict |
| 23 | from django.db.models import Q |
| 24 | from operator import itemgetter, attrgetter, methodcaller |
| 25 | from core.models import Tag |
| 26 | from core.models.service import LeastLoadedNodeScheduler |
| 27 | import traceback |
| 28 | from xos.exceptions import * |
| 29 | from xos.config import Config |
| 30 | |
| 31 | |
| 32 | class ConfigurationError(Exception): |
| 33 | pass |
| 34 | |
| 35 | |
| 36 | PROGRAN_KIND = "Progran" |
| 37 | APP_LABEL = "progran" |
| 38 | |
| 39 | |
| 40 | |
| 41 | class VProgranService(Service): |
| 42 | KIND = PROGRAN_KIND |
| 43 | |
| 44 | class Meta: |
| 45 | app_label = APP_LABEL |
| 46 | verbose_name = "Progran Service" |
| 47 | proxy = True |
| 48 | |
| 49 | default_attributes = { |
| 50 | "rest_hostname": "10.6.0.1", |
| 51 | "rest_port": "8183", |
| 52 | "rest_user": "onos", |
| 53 | "rest_pass": "rocks" |
| 54 | } |
| 55 | |
| 56 | @property |
| 57 | def rest_hostname(self): |
| 58 | return self.get_attribute("rest_hostname", self.default_attributes["rest_hostname"]) |
| 59 | |
| 60 | @rest_hostname.setter |
| 61 | def rest_hostname(self, value): |
| 62 | self.set_attribute("rest_hostname", value) |
| 63 | |
| 64 | @property |
| 65 | def rest_port(self): |
| 66 | return self.get_attribute("rest_port", self.default_attributes["rest_port"]) |
| 67 | |
| 68 | @rest_port.setter |
| 69 | def rest_port(self, value): |
| 70 | self.set_attribute("rest_port", value) |
| 71 | |
| 72 | @property |
| 73 | def rest_user(self): |
| 74 | return self.get_attribute("rest_user", self.default_attributes["rest_user"]) |
| 75 | |
| 76 | @rest_user.setter |
| 77 | def rest_user(self, value): |
| 78 | self.set_attribute("rest_user", value) |
| 79 | |
| 80 | @property |
| 81 | def rest_pass(self): |
| 82 | return self.get_attribute("rest_pass", self.default_attributes["rest_pass"]) |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
Sapan Bhatia | 99529ed | 2017-05-19 23:10:52 +0200 | [diff] [blame] | 87 | class VProgranImsi(XOSBase): |
Murat Parlakisik | b224cc9 | 2017-02-16 16:27:12 -0800 | [diff] [blame] | 88 | class Meta: |
| 89 | app_label = APP_LABEL |
| 90 | verbose_name = "vProgran Imsi" |
| 91 | |
| 92 | uiid = models.IntegerField( help_text="uiid ", null=False, blank=False) |
| 93 | imsi = models.CharField(max_length=20, help_text="imsi ", null=False, blank=False) |
| 94 | profile = models.CharField(max_length=20, help_text="profile name", null=True, blank=True) |
| 95 | |
| 96 | |
Sapan Bhatia | 99529ed | 2017-05-19 23:10:52 +0200 | [diff] [blame] | 97 | class VProgranProfile(XOSBase): |
Murat Parlakisik | b224cc9 | 2017-02-16 16:27:12 -0800 | [diff] [blame] | 98 | |
| 99 | class Meta: |
| 100 | app_label = APP_LABEL |
| 101 | verbose_name = "vProgran Profile" |
| 102 | |
| 103 | uiid = models.IntegerField( help_text="uiid ", null=False, blank=False) |
| 104 | profile = models.CharField(max_length=20, help_text="profile name", null=False, blank=False) |
| 105 | dlrate = models.IntegerField( help_text="device download rate", null=False, blank=False) |
| 106 | ulrate = models.IntegerField( help_text="device upload rate", null=False, blank=False ) |
| 107 | |