Finish moving
diff --git a/xos/core/xoslib/methods/openvpnview.py b/xos/core/xoslib/methods/openvpnview.py
deleted file mode 100644
index d8cf39e..0000000
--- a/xos/core/xoslib/methods/openvpnview.py
+++ /dev/null
@@ -1,84 +0,0 @@
-import jinja2
-from core.models import TenantPrivilege
-from plus import PlusSerializerMixin
-from rest_framework import serializers
-from services.openvpn.models import OpenVPNService, OpenVPNTenant
-from xos.apibase import XOSListCreateAPIView
-
-if hasattr(serializers, "ReadOnlyField"):
- # rest_framework 3.x
- ReadOnlyField = serializers.ReadOnlyField
-else:
- # rest_framework 2.x
- ReadOnlyField = serializers.Field
-
-
-def get_default_openvpn_service():
- openvpn_services = OpenVPNService.get_service_objects().all()
- if openvpn_services:
- return openvpn_services[0].id
- return None
-
-
-class OpenVPNTenantSerializer(serializers.ModelSerializer, PlusSerializerMixin):
- """A Serializer for the OpenVPNTenant that has the minimum information required for clients.
-
- Attributes:
- id (ReadOnlyField): The ID of OpenVPNTenant.
- server_network (ReadOnlyField): The network of the VPN.
- vpn_subnet (ReadOnlyField): The subnet of the VPN.
- script_text (SerializerMethodField): The text of the script for the client to use to
- connect.
- """
- id = ReadOnlyField()
- server_network = ReadOnlyField()
- vpn_subnet = ReadOnlyField()
- script_text = serializers.SerializerMethodField()
-
- class Meta:
- model = OpenVPNTenant
- fields = ('id', 'service_specific_attribute', 'vpn_subnet',
- 'server_network', 'script_text')
-
- def get_script_text(self, obj):
- """Gets the text of the client script for the requesting user.
-
- Parameters:
- obj (services.openvpn.models.OpenVPNTenant): The OpenVPNTenant to connect to.
-
- Returns:
- str: The client script as a str.
- """
- env = jinja2.Environment(
- loader=jinja2.FileSystemLoader("/opt/xos/services/openvpn/templates"))
- template = env.get_template("connect.vpn.j2")
- client_name = self.context['request'].user.email + "-" + str(obj.id)
- remote_ids = list(obj.failover_server_ids)
- remote_ids.insert(0, obj.id)
- remotes = OpenVPNTenant.get_tenant_objects().filter(pk__in=remote_ids)
- pki_dir = OpenVPNService.get_pki_dir(obj)
- fields = {"client_name": client_name,
- "remotes": remotes,
- "is_persistent": obj.is_persistent,
- "ca_crt": obj.get_ca_crt(pki_dir),
- "client_crt": obj.get_client_cert(client_name, pki_dir),
- "client_key": obj.get_client_key(client_name, pki_dir)
- }
- return template.render(fields)
-
-
-class OpenVPNTenantList(XOSListCreateAPIView):
- """Class that provides a list of OpenVPNTenants that the user has permission to access."""
- serializer_class = OpenVPNTenantSerializer
- method_kind = "list"
- method_name = "openvpntenant"
-
- def get_queryset(self):
- # Get every privilege for this user
- tenants_privs = TenantPrivilege.objects.all().filter(
- user=self.request.user)
- vpn_tenants = []
- for priv in tenants_privs:
- vpn_tenants.append(
- OpenVPNTenant.get_tenant_objects().filter(pk=priv.tenant.pk)[0])
- return vpn_tenants
diff --git a/xos/core/xoslib/static/js/xosOpenVPNDashboard.js b/xos/core/xoslib/static/js/xosOpenVPNDashboard.js
index 8723888..b28322f 100644
--- a/xos/core/xoslib/static/js/xosOpenVPNDashboard.js
+++ b/xos/core/xoslib/static/js/xosOpenVPNDashboard.js
@@ -1 +1 @@
-"use strict";angular.module("xos.openVPNDashboard",["ngResource","ngCookies","ngLodash","ui.router","xos.helpers"]).config(["$stateProvider",function(n){n.state("openVPNList",{url:"/",template:"<vpn-list></vpn-list>"})}]).config(["$compileProvider",function(n){n.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/)}]).service("Vpn",["$http","$q",function(n,e){this.getOpenVpnTenants=function(){var t=e.defer();return n.get("/xoslib/openvpntenant/").then(function(n){t.resolve(n.data)})["catch"](function(n){t.reject(n)}),t.promise}}]).config(["$httpProvider",function(n){n.interceptors.push("NoHyperlinks")}]).directive("vpnList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/openvpn-list.tpl.html",controller:["Vpn",function(n){var e=this;n.getOpenVpnTenants().then(function(n){e.vpns=n;for(var t=0;t<e.vpns.length;t++){var i=new Blob([e.vpns[t].script_text],{type:"text/plain"});e.vpns[t].script_text=(window.URL||window.webkitURL).createObjectURL(i)}})["catch"](function(n){throw new Error(n)})}]}}),angular.module("xos.openVPNDashboard").run(["$templateCache",function(n){n.put("templates/openvpn-list.tpl.html",'<div style="display: table;">\n <div class="vpn-row">\n <h1 class="vpn-cell">VPN List</h1>\n </div>\n <div class="vpn-row">\n <div class="vpn-cell vpn-header">ID</div>\n <div class="vpn-cell vpn-header">VPN Network</div>\n <div class="vpn-cell vpn-header">VPN Subnet</div>\n <div class="vpn-cell vpn-header">Script Link</div>\n </div>\n <div class="vpn-row" ng-repeat="vpn in vm.vpns">\n <div class="vpn-cell">{{ vpn.id }}</div>\n <div class="vpn-cell">{{ vpn.server_network }}</div>\n <div class="vpn-cell">{{ vpn.vpn_subnet }}</div>\n <div class="vpn-cell">\n <a download="connect-{{ vpn.id }}.vpn" ng-href="{{ vpn.script_text }}">Script</a>\n </div>\n </div>\n</div>\n')}]),angular.module("xos.openVPNDashboard").run(["$location",function(n){n.path("/")}]),angular.bootstrap(angular.element("#xosOpenVPNDashboard"),["xos.openVPNDashboard"]);
\ No newline at end of file
+"use strict";angular.module("xos.openVPNDashboard",["ngResource","ngCookies","ngLodash","ui.router","xos.helpers"]).config(["$stateProvider",function(n){n.state("openVPNList",{url:"/",template:"<vpn-list></vpn-list>"})}]).config(["$compileProvider",function(n){n.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/)}]).service("Vpn",["$http","$q",function(n,e){this.getOpenVpnTenants=function(){var t=e.defer();return n.get("/api/tenant/openvpn/list/").then(function(n){t.resolve(n.data)})["catch"](function(n){t.reject(n)}),t.promise}}]).config(["$httpProvider",function(n){n.interceptors.push("NoHyperlinks")}]).directive("vpnList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/openvpn-list.tpl.html",controller:["Vpn",function(n){var e=this;n.getOpenVpnTenants().then(function(n){e.vpns=n;for(var t=0;t<e.vpns.length;t++){var i=new Blob([e.vpns[t].script_text],{type:"text/plain"});e.vpns[t].script_text=(window.URL||window.webkitURL).createObjectURL(i)}})["catch"](function(n){throw new Error(n)})}]}}),angular.module("xos.openVPNDashboard").run(["$templateCache",function(n){n.put("templates/openvpn-list.tpl.html",'<div style="display: table;">\n <div class="vpn-row">\n <h1 class="vpn-cell">VPN List</h1>\n </div>\n <div class="vpn-row">\n <div class="vpn-cell vpn-header">ID</div>\n <div class="vpn-cell vpn-header">VPN Network</div>\n <div class="vpn-cell vpn-header">VPN Subnet</div>\n <div class="vpn-cell vpn-header">Script Link</div>\n </div>\n <div class="vpn-row" ng-repeat="vpn in vm.vpns">\n <div class="vpn-cell">{{ vpn.id }}</div>\n <div class="vpn-cell">{{ vpn.server_network }}</div>\n <div class="vpn-cell">{{ vpn.vpn_subnet }}</div>\n <div class="vpn-cell">\n <a download="connect-{{ vpn.id }}.vpn" ng-href="{{ vpn.script_text }}">Script</a>\n </div>\n </div>\n</div>\n')}]),angular.module("xos.openVPNDashboard").run(["$location",function(n){n.path("/")}]),angular.bootstrap(angular.element("#xosOpenVPNDashboard"),["xos.openVPNDashboard"]);
\ No newline at end of file