add scope to VTRTenant
diff --git a/xos/core/xoslib/methods/truckroll.py b/xos/core/xoslib/methods/truckroll.py
index ca59866..b3143d9 100644
--- a/xos/core/xoslib/methods/truckroll.py
+++ b/xos/core/xoslib/methods/truckroll.py
@@ -28,6 +28,7 @@
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)
@@ -38,7 +39,7 @@
class Meta:
model = VTRTenant
- fields = ('humanReadableName', 'id', 'provider_service', 'target_id', 'test', 'argument', 'result', 'is_synced', 'backend_status' )
+ fields = ('humanReadableName', 'id', 'provider_service', 'target_id', 'scope', 'test', 'argument', 'result', 'is_synced', 'backend_status' )
def getHumanReadableName(self, obj):
return obj.__unicode__()
diff --git a/xos/services/vtr/admin.py b/xos/services/vtr/admin.py
index 12b48af..d00e1a3 100644
--- a/xos/services/vtr/admin.py
+++ b/xos/services/vtr/admin.py
@@ -49,11 +49,8 @@
return VTRService.get_service_objects_by_user(request.user)
class VTRTenantForm(forms.ModelForm):
- simple_attributes = {"test": None,
- "argument": None,
- "result": None,
- "target": None}
test = forms.ChoiceField(choices=VTRTenant.TEST_CHOICES, required=True)
+ scope = forms.ChoiceField(choices=VTRTenant.SCOPE_CHOICES, required=True)
argument = 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())
@@ -66,10 +63,12 @@
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
self.fields['result'].initial = self.instance.result
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]
@@ -78,6 +77,7 @@
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.scope = self.cleaned_data.get("scope")
return super(VTRTenantForm, self).save(commit=commit)
class Meta:
@@ -87,7 +87,7 @@
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', 'test', 'argument', 'result'],
+ 'target', 'scope', 'test', 'argument', 'result'],
'classes':['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', 'service_specific_attribute')
form = VTRTenantForm
diff --git a/xos/services/vtr/models.py b/xos/services/vtr/models.py
index 1181faf..d3e6010 100644
--- a/xos/services/vtr/models.py
+++ b/xos/services/vtr/models.py
@@ -39,13 +39,15 @@
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),
- ("target_id", None) )
+ ("target_id", None),
+ ("scope", "container") )
- sync_attributes = ( 'test', 'argument' )
+ sync_attributes = ( 'test', 'argument', "scope" )
def __init__(self, *args, **kwargs):
vtr_services = VTRService.get_service_objects().all()