add c_tag and s_tag
diff --git a/xos/cord/admin.py b/xos/cord/admin.py
index dbe0b35..981f275 100644
--- a/xos/cord/admin.py
+++ b/xos/cord/admin.py
@@ -51,7 +51,8 @@
return VOLTService.get_service_objects_by_user(request.user)
class VOLTTenantForm(forms.ModelForm):
- vlan_id = forms.CharField()
+ s_tag = forms.CharField()
+ c_tag = forms.CharField()
creator = forms.ModelChoiceField(queryset=User.objects.all())
def __init__(self,*args,**kwargs):
@@ -60,7 +61,8 @@
self.fields['provider_service'].queryset = VOLTService.get_service_objects().all()
if self.instance:
# fields for the attributes
- self.fields['vlan_id'].initial = self.instance.vlan_id
+ self.fields['c_tag'].initial = self.instance.c_tag
+ self.fields['s_tag'].initial = self.instance.s_tag
self.fields['creator'].initial = self.instance.creator
if (not self.instance) or (not self.instance.pk):
# default fields for an 'add' form
@@ -70,7 +72,8 @@
self.fields["provider_service"].initial = VOLTService.get_service_objects().all()[0]
def save(self, commit=True):
- self.instance.vlan_id = self.cleaned_data.get("vlan_id")
+ self.instance.s_tag = self.cleaned_data.get("s_tag")
+ self.instance.c_tag = self.cleaned_data.get("c_tag")
self.instance.creator = self.cleaned_data.get("creator")
return super(VOLTTenantForm, self).save(commit=commit)
@@ -78,10 +81,10 @@
model = VOLTTenant
class VOLTTenantAdmin(ReadOnlyAwareAdmin):
- list_display = ('backend_status_icon', 'id', 'service_specific_id', 'vlan_id', 'subscriber_root' )
+ list_display = ('backend_status_icon', 'id', 'service_specific_id', 's_tag', 'c_tag', 'subscriber_root' )
list_display_links = ('backend_status_icon', 'id')
fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_root', 'service_specific_id', # 'service_specific_attribute',
- 'vlan_id', 'creator'],
+ 's_tag', 'c_tag', 'creator'],
'classes':['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', 'service_specific_attribute')
form = VOLTTenantForm
diff --git a/xos/cord/models.py b/xos/cord/models.py
index 4227f52..afbe3ef 100644
--- a/xos/cord/models.py
+++ b/xos/cord/models.py
@@ -254,7 +254,7 @@
KIND = VOLT_KIND
- default_attributes = {"vlan_id": None, }
+ default_attributes = {"vlan_id": None, "s_tag": None, "c_tag": None}
def __init__(self, *args, **kwargs):
volt_services = VOLTService.get_service_objects().all()
if volt_services:
@@ -263,12 +263,30 @@
self.cached_vcpe = None
@property
+ def s_tag(self):
+ return self.get_attribute("s_tag", self.default_attributes["s_tag"])
+
+ @s_tag.setter
+ def s_tag(self, value):
+ self.set_attribute("s_tag", value)
+
+ @property
+ def c_tag(self):
+ return self.get_attribute("c_tag", self.default_attributes["c_tag"])
+
+ @c_tag.setter
+ def c_tag(self, value):
+ self.set_attribute("c_tag", value)
+
+ # for now, vlan_id is a synonym for c_tag
+
+ @property
def vlan_id(self):
- return self.get_attribute("vlan_id", self.default_attributes["vlan_id"])
+ return self.c_tag
@vlan_id.setter
def vlan_id(self, value):
- self.set_attribute("vlan_id", value)
+ self.c_tag = value
@property
def vcpe(self):
diff --git a/xos/cord/rest_examples/add_volt_tenant.sh b/xos/cord/rest_examples/add_volt_tenant.sh
index 5dd3dd4..4bbe2bb 100755
--- a/xos/cord/rest_examples/add_volt_tenant.sh
+++ b/xos/cord/rest_examples/add_volt_tenant.sh
@@ -3,8 +3,9 @@
source ./config.sh
SERVICE_SPECIFIC_ID=1238
-VLAN_ID=1238
+C_TAG=1238
+S_TAG=3333
-echo curl "-H \"Accept: application/json; indent=4\" -H \"Content-Type: application/json\" -u $AUTH -X POST -d \"{\\\"service_specific_id\\\": \\\"$SERVICE_SPECIFIC_ID\\\", \\\"vlan_id\\\": \\\"$VLAN_ID\\\"}\" $HOST/xoslib/volttenant/"
+echo curl "-H \"Accept: application/json; indent=4\" -H \"Content-Type: application/json\" -u $AUTH -X POST -d \"{\\\"service_specific_id\\\": \\\"$SERVICE_SPECIFIC_ID\\\", \\\"c_tag\\\": \\\"$C_TAG\\\", \\\"s_tag\\\": \\\"$S_TAG\\\"}\" $HOST/xoslib/volttenant/"
-curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X POST -d "{\"service_specific_id\": \"$SERVICE_SPECIFIC_ID\", \"vlan_id\": \"$VLAN_ID\"}" $HOST/xoslib/volttenant/
+curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X POST -d "{\"service_specific_id\": \"$SERVICE_SPECIFIC_ID\", \"c_tag\": \"$C_TAG\", \"s_tag\": \"$S_TAG\"}" $HOST/xoslib/volttenant/
diff --git a/xos/cord/rest_examples/config.sh b/xos/cord/rest_examples/config.sh
index 7b8c8e1..06162ee 100644
--- a/xos/cord/rest_examples/config.sh
+++ b/xos/cord/rest_examples/config.sh
@@ -1,5 +1,6 @@
#HOST=198.0.0.44:8000
-HOST=10.254.1.22:8000
+#HOST=10.254.1.22:8000
+HOST=clnode050.clemson.cloudlab.us:9999
#AUTH=scott@onlab.us:letmein
AUTH=padmin@vicci.org:letmein
diff --git a/xos/core/xoslib/methods/cordsubscriber.py b/xos/core/xoslib/methods/cordsubscriber.py
index c26ac54..297ac4a 100644
--- a/xos/core/xoslib/methods/cordsubscriber.py
+++ b/xos/core/xoslib/methods/cordsubscriber.py
@@ -28,7 +28,9 @@
class CordSubscriberIdSerializer(serializers.ModelSerializer, PlusSerializerMixin):
id = ReadOnlyField()
service_specific_id = ReadOnlyField()
- vlan_id = ReadOnlyField()
+ vlan_id = ReadOnlyField() # XXX remove this
+ c_tag = ReadOnlyField()
+ s_tag = ReadOnlyField()
vcpe_id = ReadOnlyField()
instance = ReadOnlyField()
image = ReadOnlyField()
@@ -59,7 +61,7 @@
class Meta:
model = CordSubscriber
fields = ('humanReadableName', 'id',
- 'service_specific_id', 'vlan_id',
+ 'service_specific_id', 'vlan_id', 's_tag', 'c_tag',
'vcpe_id', 'instance', 'instance_name', 'image', 'image_name',
'firewall_enable', 'firewall_rules',
'url_filter_enable', 'url_filter_rules', 'url_filter_level',
diff --git a/xos/core/xoslib/methods/volttenant.py b/xos/core/xoslib/methods/volttenant.py
index e5998da..bf48290 100644
--- a/xos/core/xoslib/methods/volttenant.py
+++ b/xos/core/xoslib/methods/volttenant.py
@@ -26,7 +26,9 @@
class VOLTTenantIdSerializer(serializers.ModelSerializer, PlusSerializerMixin):
id = ReadOnlyField()
service_specific_id = serializers.CharField()
- vlan_id = serializers.CharField()
+ #vlan_id = serializers.CharField()
+ s_tag = serializers.CharField()
+ c_tag = serializers.CharField()
provider_service = serializers.PrimaryKeyRelatedField(queryset=VOLTService.get_service_objects().all(), default=get_default_volt_service)
humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
@@ -35,7 +37,7 @@
class Meta:
model = VOLTTenant
- fields = ('humanReadableName', 'id', 'provider_service', 'service_specific_id', 'vlan_id', 'computeNodeName' )
+ fields = ('humanReadableName', 'id', 'provider_service', 'service_specific_id', 's_tag', 'c_tag', 'computeNodeName' )
def getHumanReadableName(self, obj):
return obj.__unicode__()
@@ -62,9 +64,19 @@
if service_specific_id is not None:
queryset = queryset.filter(service_specific_id=service_specific_id)
- vlan_id = self.request.QUERY_PARAMS.get('vlan_id', None)
- if vlan_id is not None:
- ids = [x.id for x in queryset if x.get_attribute("vlan_id", None)==vlan_id]
+# vlan_id = self.request.QUERY_PARAMS.get('vlan_id', None)
+# if vlan_id is not None:
+# ids = [x.id for x in queryset if x.get_attribute("vlan_id", None)==vlan_id]
+# queryset = queryset.filter(id__in=ids)
+
+ c_tag = self.request.QUERY_PARAMS.get('c_tag', None)
+ if c_tag is not None:
+ ids = [x.id for x in queryset if x.get_attribute("c_tag", None)==c_tag]
+ queryset = queryset.filter(id__in=ids)
+
+ s_tag = self.request.QUERY_PARAMS.get('s_tag', None)
+ if s_tag is not None:
+ ids = [x.id for x in queryset if x.get_attribute("s_tag", None)==s_tag]
queryset = queryset.filter(id__in=ids)
return queryset
@@ -74,7 +86,7 @@
existing_obj = None
for obj in VOLTTenant.get_tenant_objects().all():
- if (obj.vlan_id == data.get("vlan_id", None)) and (obj.service_specific_id == data.get("service_specific_id",None)):
+ if (obj.c_tag == data.get("c_tag", None)) and (obj.s_tag == data.get("s_tag", None)) and (obj.service_specific_id == data.get("service_specific_id",None)):
existing_obj = obj
if existing_obj:
diff --git a/xos/core/xoslib/objects/cordsubscriber.py b/xos/core/xoslib/objects/cordsubscriber.py
index 318d54c..089c91b 100644
--- a/xos/core/xoslib/objects/cordsubscriber.py
+++ b/xos/core/xoslib/objects/cordsubscriber.py
@@ -113,7 +113,9 @@
# ("services", "vcpe.services"),
# ("cdn_enable", "vcpe.cdn_enable"),
- ("vlan_id", "volt.vlan_id"),
+ ("vlan_id", "volt.vlan_id"), # XXX remove this
+ ("c_tag", "volt.c_tag"),
+ ("s_tag", "volt.s_tag"),
("bbs_account", "volt.vcpe.bbs_account"),
("ssh_command", "volt.vcpe.ssh_command"),
diff --git a/xos/core/xoslib/templates/xosCordSubscriber.html b/xos/core/xoslib/templates/xosCordSubscriber.html
index b7e2163..db42fb8 100644
--- a/xos/core/xoslib/templates/xosCordSubscriber.html
+++ b/xos/core/xoslib/templates/xosCordSubscriber.html
@@ -7,7 +7,8 @@
<table class="xos-detail-table cord-subscriber-table">
<tr><td class="xos-label-cell">Id:</td><td><%= model.attributes.id %></td></tr>
<tr><td class="xos-label-cell">Service Specific Id:</td><td><%= model.attributes.service_specific_id %></td></tr>
- <tr><td class="xos-label-cell">VLAN Id:</td><td><%= model.attributes.vlan_id %></td></tr>
+ <tr><td class="xos-label-cell">S-Tag:</td><td><%= model.attributes.s_tag %></td></tr>
+ <tr><td class="xos-label-cell">C-Tag:</td><td><%= model.attributes.c_tag %></td></tr>
</table>
</div>
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.py b/xos/observers/vcpe/steps/sync_vcpetenant.py
index 1a45b54..120954b 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.py
@@ -113,15 +113,21 @@
logger.info("neither bbs_slice nor bbs_server is configured in the vCPE")
vlan_ids = []
+ s_tags = []
+ c_tags = []
if o.volt:
- vlan_ids.append(o.volt.vlan_id)
+ vlan_ids.append(o.volt.vlan_id) # XXX remove this
+ s_tags.append(o.volt.s_tag)
+ c_tags.append(o.volt.c_tag)
try:
full_setup = Config().observer_full_setup
except:
full_setup = True
- fields = {"vlan_ids": vlan_ids,
+ fields = {"vlan_ids": vlan_ids, # XXX remove this
+ "s_tags": s_tags,
+ "c_tags": c_tags,
"dnsdemux_ip": dnsdemux_ip,
"cdn_prefixes": cdn_prefixes,
"bbs_addrs": bbs_addrs,
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.yaml b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
index b5a112a..e4d3167 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.yaml
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
@@ -13,6 +13,14 @@
{% for vlan_id in vlan_ids %}
- {{ vlan_id }}
{% endfor %}
+ c_tags:
+ {% for c_tag in c_tags %}
+ - {{ c_tag }}
+ {% endfor %}
+ s_tags:
+ {% for s_tag in s_tags %}
+ - {{ s_tag }}
+ {% endfor %}
firewall_rules:
{% for firewall_rule in firewall_rules.split("\n") %}
- {{ firewall_rule }}