Make the xoslib method better
diff --git a/xos/core/xoslib/methods/vpnview.py b/xos/core/xoslib/methods/vpnview.py
index 2a08914..0a9612f 100644
--- a/xos/core/xoslib/methods/vpnview.py
+++ b/xos/core/xoslib/methods/vpnview.py
@@ -32,34 +32,25 @@
failover_servers = ReadOnlyField()
creator = ReadOnlyField()
instance = ReadOnlyField()
- script_text = ReadOnlyField()
+ use_ca_from = ReadOnlyField()
provider_service = serializers.PrimaryKeyRelatedField(
queryset=VPNService.get_service_objects().all(),
default=get_default_vpn_service)
-
- humanReadableName = serializers.SerializerMethodField(
- "getHumanReadableName")
-
- computeNodeName = serializers.SerializerMethodField(
- "getComputeNodeName")
+ script_text = serializers.SerializerMethodField(
+ "get_script_text")
class Meta:
model = VPNTenant
- fields = ('humanReadableName', 'id', 'provider_service',
+ fields = ('id', 'provider_service', 'use_ca_from',
'service_specific_attribute', 'vpn_subnet',
'server_network', 'creator', 'instance', 'protocol',
- 'computeNodeName', 'is_persistent',
+ 'is_persistent',
'clients_can_see_each_other', 'ca_crt', 'port_number',
'script_text', 'failover_servers')
- def getHumanReadableName(self, obj):
- return obj.__unicode__()
-
- def getComputeNodeName(self, obj):
- instance = obj.instance
- if not instance:
- return None
- return instance.node.name
+ def get_script_text(self, obj):
+ return obj.create_client_script(
+ self.context['request'].user.email + "-" + str(obj.id))
class VPNTenantList(XOSListCreateAPIView):
@@ -69,14 +60,10 @@
def get_queryset(self):
# Get every privilege for this user
- tenants_privs = TenantPrivilege.objects.all().filter(user=self.request.user)
+ tenants_privs = TenantPrivilege.objects.all().filter(
+ user=self.request.user)
vpn_tenants = []
for priv in tenants_privs:
vpn_tenants.append(
VPNTenant.get_tenant_objects().filter(pk=priv.tenant.pk)[0])
-
- for tenant in vpn_tenants:
- tenant.script_text = (
- tenant.create_client_script(
- self.request.user.email + "-" + str(tenant.id)))
return vpn_tenants