Initial attempt and renaming VPN to OpenVPN
diff --git a/views/ngXosViews/vpnDashboard/.bowerrc b/views/ngXosViews/openVPNDashboard/.bowerrc
similarity index 100%
rename from views/ngXosViews/vpnDashboard/.bowerrc
rename to views/ngXosViews/openVPNDashboard/.bowerrc
diff --git a/views/ngXosViews/vpnDashboard/.eslintrc b/views/ngXosViews/openVPNDashboard/.eslintrc
similarity index 100%
rename from views/ngXosViews/vpnDashboard/.eslintrc
rename to views/ngXosViews/openVPNDashboard/.eslintrc
diff --git a/views/ngXosViews/vpnDashboard/.gitignore b/views/ngXosViews/openVPNDashboard/.gitignore
similarity index 100%
rename from views/ngXosViews/vpnDashboard/.gitignore
rename to views/ngXosViews/openVPNDashboard/.gitignore
diff --git a/views/ngXosViews/vpnDashboard/bower.json b/views/ngXosViews/openVPNDashboard/bower.json
similarity index 87%
rename from views/ngXosViews/vpnDashboard/bower.json
rename to views/ngXosViews/openVPNDashboard/bower.json
index b7c354e..01b2715 100644
--- a/views/ngXosViews/vpnDashboard/bower.json
+++ b/views/ngXosViews/openVPNDashboard/bower.json
@@ -1,10 +1,10 @@
{
- "name": "xos-vpnDashboard",
+ "name": "xos-openVPNDashboard",
"version": "0.0.0",
"authors": [
"Jeremy Mowery <jermowery@email.arizona.edu>"
],
- "description": "The vpnDashboard view",
+ "description": "The OpenVPN Dashboard",
"license": "MIT",
"ignore": [
"**/.*",
diff --git a/views/ngXosViews/vpnDashboard/env/default.js b/views/ngXosViews/openVPNDashboard/env/default.js
similarity index 100%
rename from views/ngXosViews/vpnDashboard/env/default.js
rename to views/ngXosViews/openVPNDashboard/env/default.js
diff --git a/views/ngXosViews/vpnDashboard/gulp/build.js b/views/ngXosViews/openVPNDashboard/gulp/build.js
similarity index 84%
rename from views/ngXosViews/vpnDashboard/gulp/build.js
rename to views/ngXosViews/openVPNDashboard/gulp/build.js
index b7de9e5..625e3ee 100644
--- a/views/ngXosViews/vpnDashboard/gulp/build.js
+++ b/views/ngXosViews/openVPNDashboard/gulp/build.js
@@ -28,15 +28,15 @@
var csswring = require('csswring');
var TEMPLATE_FOOTER = `}]);
-angular.module('xos.vpnDashboard').run(function($location){$location.path('/')});
-angular.bootstrap(angular.element('#xosVpnDashboard'), ['xos.vpnDashboard']);`;
+angular.module('xos.openVPNDashboard').run(function($location){$location.path('/')});
+angular.bootstrap(angular.element('#xosOpenVPNDashboard'), ['xos.openVPNDashboard']);`;
module.exports = function(options){
// delete previous builded file
gulp.task('clean', function(){
return del(
- [options.dashboards + 'xosVpnDashboard.html'],
+ [options.dashboards + 'xosOpenVPNDashboard.html'],
{force: true}
);
});
@@ -59,7 +59,7 @@
gulp.task('copyCss', ['css'], function(){
return gulp.src([`${options.tmp}/css/*.css`])
- .pipe(concat('xosVpnDashboard.css'))
+ .pipe(concat('xosOpenVPNDashboard.css'))
.pipe(gulp.dest(options.static + 'css/'))
});
@@ -70,7 +70,7 @@
])
.pipe(ngAnnotate())
.pipe(angularFilesort())
- .pipe(concat('xosVpnDashboard.js'))
+ .pipe(concat('xosOpenVPNDashboard.js'))
.pipe(uglify())
.pipe(gulp.dest(options.static + 'js/'));
});
@@ -79,7 +79,7 @@
gulp.task('templates', function(){
return gulp.src('./src/templates/*.html')
.pipe(templateCache({
- module: 'xos.vpnDashboard',
+ module: 'xos.openVPNDashboard',
root: 'templates/',
templateFooter: TEMPLATE_FOOTER
}))
@@ -99,14 +99,14 @@
.pipe(
inject(
gulp.src([
- options.static + 'js/vendor/xosVpnDashboardVendor.js',
- options.static + 'js/xosVpnDashboard.js',
- options.static + 'css/xosVpnDashboard.css'
+ options.static + 'js/vendor/xosOpenVPNDashboardVendor.js',
+ options.static + 'js/xosOpenVPNDashboard.js',
+ options.static + 'css/xosOpenVPNDashboard.css'
]),
{ignorePath: '/../../../xos/core/xoslib'}
)
)
- .pipe(rename('xosVpnDashboard.html'))
+ .pipe(rename('xosOpenVPNDashboard.html'))
.pipe(gulp.dest(options.dashboards));
});
@@ -123,7 +123,7 @@
});
return gulp.src(bowerDeps)
- .pipe(concat('xosVpnDashboardVendor.js'))
+ .pipe(concat('xosOpenVPNDashboardVendor.js'))
.pipe(uglify())
.pipe(gulp.dest(options.static + 'js/vendor/'));
});
diff --git a/views/ngXosViews/vpnDashboard/gulp/server.js b/views/ngXosViews/openVPNDashboard/gulp/server.js
similarity index 100%
rename from views/ngXosViews/vpnDashboard/gulp/server.js
rename to views/ngXosViews/openVPNDashboard/gulp/server.js
diff --git a/views/ngXosViews/vpnDashboard/gulpfile.js b/views/ngXosViews/openVPNDashboard/gulpfile.js
similarity index 100%
rename from views/ngXosViews/vpnDashboard/gulpfile.js
rename to views/ngXosViews/openVPNDashboard/gulpfile.js
diff --git a/views/ngXosViews/vpnDashboard/karma.conf.js b/views/ngXosViews/openVPNDashboard/karma.conf.js
similarity index 100%
rename from views/ngXosViews/vpnDashboard/karma.conf.js
rename to views/ngXosViews/openVPNDashboard/karma.conf.js
diff --git a/views/ngXosViews/vpnDashboard/package.json b/views/ngXosViews/openVPNDashboard/package.json
similarity index 96%
rename from views/ngXosViews/vpnDashboard/package.json
rename to views/ngXosViews/openVPNDashboard/package.json
index a4d9e6f..412afec 100644
--- a/views/ngXosViews/vpnDashboard/package.json
+++ b/views/ngXosViews/openVPNDashboard/package.json
@@ -1,5 +1,5 @@
{
- "name": "xos-vpnDashboard",
+ "name": "xos-openVPNDashboard",
"version": "1.0.0",
"description": "Angular Application for XOS, created with generator-xos",
"scripts": {
diff --git a/views/ngXosViews/vpnDashboard/spec/sample.test.js b/views/ngXosViews/openVPNDashboard/spec/sample.test.js
similarity index 95%
rename from views/ngXosViews/vpnDashboard/spec/sample.test.js
rename to views/ngXosViews/openVPNDashboard/spec/sample.test.js
index ad20c13..822c114 100644
--- a/views/ngXosViews/vpnDashboard/spec/sample.test.js
+++ b/views/ngXosViews/openVPNDashboard/spec/sample.test.js
@@ -4,7 +4,7 @@
var scope, element, isolatedScope, httpBackend;
- beforeEach(module('xos.vpnDashboard'));
+ beforeEach(module('xos.openVPNDashboard'));
beforeEach(module('templates'));
beforeEach(inject(function($httpBackend, $compile, $rootScope){
diff --git a/views/ngXosViews/vpnDashboard/src/css/vpnDashboard.css b/views/ngXosViews/openVPNDashboard/src/css/openVPNDashboard.css
similarity index 87%
rename from views/ngXosViews/vpnDashboard/src/css/vpnDashboard.css
rename to views/ngXosViews/openVPNDashboard/src/css/openVPNDashboard.css
index 116051f..085d5d4 100644
--- a/views/ngXosViews/vpnDashboard/src/css/vpnDashboard.css
+++ b/views/ngXosViews/openVPNDashboard/src/css/openVPNDashboard.css
@@ -1,4 +1,4 @@
-#xosVpnDashboard{
+#xosOpenVPNDashboard{
width: 70%;
margin: auto;
}
diff --git a/views/ngXosViews/vpnDashboard/src/index.html b/views/ngXosViews/openVPNDashboard/src/index.html
similarity index 91%
rename from views/ngXosViews/vpnDashboard/src/index.html
rename to views/ngXosViews/openVPNDashboard/src/index.html
index 07f1017..83048df 100644
--- a/views/ngXosViews/vpnDashboard/src/index.html
+++ b/views/ngXosViews/openVPNDashboard/src/index.html
@@ -3,10 +3,10 @@
<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.css" />
<!-- endbower --><!-- endcss -->
<!-- inject:css -->
-<link rel="stylesheet" href="/css/vpnDashboard.css">
+<link rel="stylesheet" href="/css/openVPNDashboard.css">
<!-- endinject -->
-<div ng-app="xos.vpnDashboard" id="xosVpnDashboard">
+<div ng-app="xos.openVPNDashboard" id="xosOpenVPNDashboard">
<div ui-view></div>
</div>
diff --git a/views/ngXosViews/vpnDashboard/src/js/main.js b/views/ngXosViews/openVPNDashboard/src/js/main.js
similarity index 78%
rename from views/ngXosViews/vpnDashboard/src/js/main.js
rename to views/ngXosViews/openVPNDashboard/src/js/main.js
index 233051a..b59a701 100644
--- a/views/ngXosViews/vpnDashboard/src/js/main.js
+++ b/views/ngXosViews/openVPNDashboard/src/js/main.js
@@ -1,6 +1,6 @@
'use strict';
-angular.module('xos.vpnDashboard', [
+angular.module('xos.openVPNDashboard', [
'ngResource',
'ngCookies',
'ngLodash',
@@ -9,9 +9,9 @@
])
.config(($stateProvider) => {
$stateProvider
- .state('vpnList', {
+ .state('openVPNList', {
url: '/',
- template: '<vpn-list></vpn-list>'
+ template: '<openvpn-list></openvpn-list>'
});
})
.config(($compileProvider) => {
@@ -20,10 +20,10 @@
})
.service('Vpn', function($http, $q){
- this.getVpnTenants = () => {
+ this.getOpenVPNTenants = () => {
let deferred = $q.defer();
- $http.get('/xoslib/vpntenant/')
+ $http.get('/xoslib/openvpntenant/')
.then((res) => {
deferred.resolve(res.data)
})
@@ -37,15 +37,15 @@
.config(function($httpProvider){
$httpProvider.interceptors.push('NoHyperlinks');
})
-.directive('vpnList', function(){
+.directive('openVPNList', function(){
return {
restrict: 'E',
scope: {},
bindToController: true,
controllerAs: 'vm',
- templateUrl: 'templates/vpn-list.tpl.html',
+ templateUrl: 'templates/openvpn-list.tpl.html',
controller: function(Vpn){
- Vpn.getVpnTenants()
+ Vpn.getOpenVPNTenants()
.then((vpns) => {
this.vpns = vpns;
for (var i = 0; i < this.vpns.length; i++) {
diff --git a/views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html b/views/ngXosViews/openVPNDashboard/src/templates/openvpn-list.tpl.html
similarity index 100%
rename from views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html
rename to views/ngXosViews/openVPNDashboard/src/templates/openvpn-list.tpl.html
diff --git a/xos/core/xoslib/dashboards/xosVpnDashboard.html b/xos/core/xoslib/dashboards/xosVpnDashboard.html
deleted file mode 100644
index b63559e..0000000
--- a/xos/core/xoslib/dashboards/xosVpnDashboard.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!-- browserSync -->
-
-<!-- inject:css -->
-<link rel="stylesheet" href="/static/css/xosVpnDashboard.css">
-<!-- endinject -->
-
-<div id="xosVpnDashboard">
- <div ui-view></div>
-</div>
-
-
-<!-- inject:js -->
-<script src="/static/js/xosVpnDashboard.js"></script>
-<!-- endinject -->
diff --git a/xos/core/xoslib/methods/vpnview.py b/xos/core/xoslib/methods/openvpnview.py
similarity index 64%
rename from xos/core/xoslib/methods/vpnview.py
rename to xos/core/xoslib/methods/openvpnview.py
index bf8231d..d8cf39e 100644
--- a/xos/core/xoslib/methods/vpnview.py
+++ b/xos/core/xoslib/methods/openvpnview.py
@@ -2,7 +2,7 @@
from core.models import TenantPrivilege
from plus import PlusSerializerMixin
from rest_framework import serializers
-from services.vpn.models import VPNService, VPNTenant
+from services.openvpn.models import OpenVPNService, OpenVPNTenant
from xos.apibase import XOSListCreateAPIView
if hasattr(serializers, "ReadOnlyField"):
@@ -13,18 +13,18 @@
ReadOnlyField = serializers.Field
-def get_default_vpn_service():
- vpn_services = VPNService.get_service_objects().all()
- if vpn_services:
- return vpn_services[0].id
+def get_default_openvpn_service():
+ openvpn_services = OpenVPNService.get_service_objects().all()
+ if openvpn_services:
+ return openvpn_services[0].id
return None
-class VPNTenantSerializer(serializers.ModelSerializer, PlusSerializerMixin):
- """A Serializer for the VPNTenant that has the minimum information required for clients.
+class OpenVPNTenantSerializer(serializers.ModelSerializer, PlusSerializerMixin):
+ """A Serializer for the OpenVPNTenant that has the minimum information required for clients.
Attributes:
- id (ReadOnlyField): The ID of VPNTenant.
+ 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
@@ -36,7 +36,7 @@
script_text = serializers.SerializerMethodField()
class Meta:
- model = VPNTenant
+ model = OpenVPNTenant
fields = ('id', 'service_specific_attribute', 'vpn_subnet',
'server_network', 'script_text')
@@ -44,18 +44,19 @@
"""Gets the text of the client script for the requesting user.
Parameters:
- obj (services.vpn.models.VPNTenant): The VPNTenant to connect to.
+ 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/vpn/templates"))
+ 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 = VPNTenant.get_tenant_objects().filter(pk__in=remote_ids)
- pki_dir = VPNService.get_pki_dir(obj)
+ 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,
@@ -66,11 +67,11 @@
return template.render(fields)
-class VPNTenantList(XOSListCreateAPIView):
- """Class that provides a list of VPNTenants that the user has permission to access."""
- serializer_class = VPNTenantSerializer
+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 = "vpntenant"
+ method_name = "openvpntenant"
def get_queryset(self):
# Get every privilege for this user
@@ -79,5 +80,5 @@
vpn_tenants = []
for priv in tenants_privs:
vpn_tenants.append(
- VPNTenant.get_tenant_objects().filter(pk=priv.tenant.pk)[0])
+ OpenVPNTenant.get_tenant_objects().filter(pk=priv.tenant.pk)[0])
return vpn_tenants
diff --git a/xos/core/xoslib/static/css/xosVpnDashboard.css b/xos/core/xoslib/static/css/xosVpnDashboard.css
deleted file mode 100644
index d5a8ed4..0000000
--- a/xos/core/xoslib/static/css/xosVpnDashboard.css
+++ /dev/null
@@ -1 +0,0 @@
-#xosVpnDashboard{width:70%;margin:auto}.vpn-row{display:table-row}.vpn-cell{display:table-cell;padding:5px}.vpn-header{font-weight:700}
\ No newline at end of file
diff --git a/xos/core/xoslib/static/js/xosVpnDashboard.js b/xos/core/xoslib/static/js/xosVpnDashboard.js
deleted file mode 100644
index 7077f40..0000000
--- a/xos/core/xoslib/static/js/xosVpnDashboard.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";angular.module("xos.vpnDashboard",["ngResource","ngCookies","ngLodash","ui.router","xos.helpers"]).config(["$stateProvider",function(n){n.state("vpnList",{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,t){this.getVpnTenants=function(){var e=t.defer();return n.get("/xoslib/vpntenant/").then(function(n){e.resolve(n.data)})["catch"](function(n){e.reject(n)}),e.promise}}]).config(["$httpProvider",function(n){n.interceptors.push("NoHyperlinks")}]).directive("vpnList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/vpn-list.tpl.html",controller:["Vpn",function(n){var t=this;n.getVpnTenants().then(function(n){t.vpns=n;for(var e=0;e<t.vpns.length;e++){var i=new Blob([t.vpns[e].script_text],{type:"text/plain"});t.vpns[e].script_text=(window.URL||window.webkitURL).createObjectURL(i)}})["catch"](function(n){throw new Error(n)})}]}}),angular.module("xos.vpnDashboard").run(["$templateCache",function(n){n.put("templates/vpn-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.vpnDashboard").run(["$location",function(n){n.path("/")}]),angular.bootstrap(angular.element("#xosVpnDashboard"),["xos.vpnDashboard"]);
\ No newline at end of file
diff --git a/xos/services/vpn/__init__.py b/xos/services/openvpn/__init__.py
similarity index 100%
rename from xos/services/vpn/__init__.py
rename to xos/services/openvpn/__init__.py
diff --git a/xos/services/vpn/admin.py b/xos/services/openvpn/admin.py
similarity index 79%
rename from xos/services/vpn/admin.py
rename to xos/services/openvpn/admin.py
index 63040f9..28e778d 100644
--- a/xos/services/vpn/admin.py
+++ b/xos/services/openvpn/admin.py
@@ -4,16 +4,16 @@
from core.admin import ReadOnlyAwareAdmin, SliceInline, TenantPrivilegeInline
from core.middleware import get_request
from core.models import User
-from services.vpn.models import VPN_KIND, VPNService, VPNTenant
+from services.openvpn.models import OPENVPN_KIND, OpenVPNService, OpenVPNTenant
from xos.exceptions import XOSValidationError
-class VPNServiceForm(forms.ModelForm):
+class OpenVPNServiceForm(forms.ModelForm):
exposed_ports = forms.CharField(required=True)
def __init__(self, *args, **kwargs):
- super(VPNServiceForm, self).__init__(*args, **kwargs)
+ super(OpenVPNServiceForm, self).__init__(*args, **kwargs)
if self.instance:
self.fields['exposed_ports'].initial = (
@@ -21,7 +21,7 @@
def save(self, commit=True):
self.instance.exposed_ports = self.cleaned_data['exposed_ports']
- return super(VPNServiceForm, self).save(commit=commit)
+ return super(OpenVPNServiceForm, self).save(commit=commit)
def clean_exposed_ports(self):
exposed_ports = self.cleaned_data['exposed_ports']
@@ -63,14 +63,14 @@
return list(range(first, last))
class Meta:
- model = VPNService
+ model = OpenVPNService
-class VPNServiceAdmin(ReadOnlyAwareAdmin):
- """Defines the admin for the VPNService."""
- model = VPNService
- form = VPNServiceForm
- verbose_name = "VPN Service"
+class OpenVPNServiceAdmin(ReadOnlyAwareAdmin):
+ """Defines the admin for the OpenVPNService."""
+ model = OpenVPNService
+ form = OpenVPNServiceForm
+ verbose_name = "OpenVPN Service"
list_display = ("backend_status_icon", "name", "enabled")
@@ -90,19 +90,14 @@
user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
suit_form_tabs = (('general', 'VPN Service Details'),
- ('administration', 'Tenants'),
('slices', 'Slices'),)
- suit_form_includes = (('vpnserviceadmin.html',
- 'top',
- 'administration'),)
-
def queryset(self, request):
- return VPNService.get_service_objects_by_user(request.user)
+ return OpenVPNService.get_service_objects_by_user(request.user)
-class VPNTenantForm(forms.ModelForm):
- """The form used to create and edit a VPNTenant.
+class OpenVPNTenantForm(forms.ModelForm):
+ """The form used to create and edit a OpenVPNTenant.
Attributes:
creator (forms.ModelChoiceField): The XOS user that created this
@@ -113,10 +108,10 @@
this connection alive through failures.
clients_can_see_each_other (forms.BooleanField): Determines if the clients on the VPN can
communicate with each other.
- failover_servers (forms.ModelMultipleChoiceField): The other VPNTenants to use as failover
+ failover_servers (forms.ModelMultipleChoiceField): The other OpenVPNTenants to use as failover
servers.
protocol (forms.ChoiceField): The protocol to use.
- use_ca_from (forms.ModelChoiceField): Another VPNTenant to use the CA of, this is a very
+ use_ca_from (forms.ModelChoiceField): Another OpenVPNTenant to use the CA of, this is a very
hacky way to let VPNs have the same clients.
"""
creator = forms.ModelChoiceField(queryset=User.objects.all())
@@ -126,21 +121,21 @@
is_persistent = forms.BooleanField(required=False)
clients_can_see_each_other = forms.BooleanField(required=False)
failover_servers = forms.ModelMultipleChoiceField(
- required=False, queryset=VPNTenant.get_tenant_objects())
+ required=False, queryset=OpenVPNTenant.get_tenant_objects())
protocol = forms.ChoiceField(required=True, choices=[
("tcp", "tcp"), ("udp", "udp")])
use_ca_from = forms.ModelChoiceField(
- queryset=VPNTenant.get_tenant_objects(), required=False)
+ queryset=OpenVPNTenant.get_tenant_objects(), required=False)
def __init__(self, *args, **kwargs):
- super(VPNTenantForm, self).__init__(*args, **kwargs)
+ super(OpenVPNTenantForm, self).__init__(*args, **kwargs)
self.fields['kind'].widget.attrs['readonly'] = True
self.fields['failover_servers'].widget.attrs['rows'] = 300
self.fields[
'provider_service'].queryset = (
- VPNService.get_service_objects().all())
+ OpenVPNService.get_service_objects().all())
- self.fields['kind'].initial = VPN_KIND
+ self.fields['kind'].initial = OPENVPN_KIND
if self.instance:
self.fields['creator'].initial = self.instance.creator
@@ -153,14 +148,14 @@
self.fields['is_persistent'].initial = self.instance.is_persistent
self.initial['protocol'] = self.instance.protocol
self.fields['failover_servers'].queryset = (
- VPNTenant.get_tenant_objects().exclude(pk=self.instance.pk))
- self.initial['failover_servers'] = VPNTenant.get_tenant_objects().filter(
+ OpenVPNTenant.get_tenant_objects().exclude(pk=self.instance.pk))
+ self.initial['failover_servers'] = OpenVPNTenant.get_tenant_objects().filter(
pk__in=self.instance.failover_server_ids)
self.fields['use_ca_from'].queryset = (
- VPNTenant.get_tenant_objects().exclude(pk=self.instance.pk))
+ OpenVPNTenant.get_tenant_objects().exclude(pk=self.instance.pk))
if (self.instance.use_ca_from_id):
self.initial['use_ca_from'] = (
- VPNTenant.get_tenant_objects().filter(pk=self.instance.use_ca_from_id)[0])
+ OpenVPNTenant.get_tenant_objects().filter(pk=self.instance.use_ca_from_id)[0])
if (not self.instance) or (not self.instance.pk):
self.fields['creator'].initial = get_request().user
@@ -169,10 +164,10 @@
self.fields['clients_can_see_each_other'].initial = True
self.fields['is_persistent'].initial = True
self.fields['failover_servers'].queryset = (
- VPNTenant.get_tenant_objects())
- if VPNService.get_service_objects().exists():
+ OpenVPNTenant.get_tenant_objects())
+ if OpenVPNService.get_service_objects().exists():
self.fields["provider_service"].initial = (
- VPNService.get_service_objects().all()[0])
+ OpenVPNService.get_service_objects().all()[0])
def save(self, commit=True):
self.instance.creator = self.cleaned_data.get("creator")
@@ -199,14 +194,14 @@
else:
self.instance.use_ca_from_id = None
- return super(VPNTenantForm, self).save(commit=commit)
+ return super(OpenVPNTenantForm, self).save(commit=commit)
class Meta:
- model = VPNTenant
+ model = OpenVPNTenant
-class VPNTenantAdmin(ReadOnlyAwareAdmin):
- verbose_name = "VPN Tenant Admin"
+class OpenVPNTenantAdmin(ReadOnlyAwareAdmin):
+ verbose_name = "OpenVPN Tenant Admin"
list_display = ('id', 'backend_status_icon', 'instance',
'server_network', 'vpn_subnet')
list_display_links = ('id', 'backend_status_icon',
@@ -219,16 +214,16 @@
'failover_servers', "protocol"],
'classes': ['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', 'instance')
- form = VPNTenantForm
+ form = OpenVPNTenantForm
inlines = [TenantPrivilegeInline]
suit_form_tabs = (('general', 'Details'),
('tenantprivileges', 'Privileges'))
def queryset(self, request):
- return VPNTenant.get_tenant_objects_by_user(request.user)
+ return OpenVPNTenant.get_tenant_objects_by_user(request.user)
# Associate the admin forms with the models.
-admin.site.register(VPNService, VPNServiceAdmin)
-admin.site.register(VPNTenant, VPNTenantAdmin)
+admin.site.register(OpenVPNService, OpenVPNServiceAdmin)
+admin.site.register(OpenVPNTenant, OpenVPNTenantAdmin)
diff --git a/xos/services/vpn/models.py b/xos/services/openvpn/models.py
similarity index 89%
rename from xos/services/vpn/models.py
rename to xos/services/openvpn/models.py
index 66b1bf8..10a62ad 100644
--- a/xos/services/vpn/models.py
+++ b/xos/services/openvpn/models.py
@@ -5,12 +5,12 @@
from core.models import Service, TenantWithContainer
from xos.exceptions import XOSConfigurationError, XOSValidationError
-VPN_KIND = "vpn"
+OPENVPN_KIND = "openvpn"
-class VPNService(Service):
+class OpenVPNService(Service):
"""Defines the Service for creating VPN servers."""
- KIND = VPN_KIND
+ KIND = OPENVPN_KIND
OPENVPN_PREFIX = "/opt/openvpn/"
"""The location of the openvpn EASY RSA files and PKIs."""
SERVER_PREFIX = OPENVPN_PREFIX + "server-"
@@ -31,7 +31,7 @@
command (str): The command to execute using ESAY RSA.
"""
full_command = (
- VPNService.EASYRSA_COMMAND_PREFIX + " --pki-dir=" +
+ OpenVPNService.EASYRSA_COMMAND_PREFIX + " --pki-dir=" +
pki_dir + " " + command)
proc = Popen(
full_command, shell=True, stdout=PIPE, stderr=PIPE
@@ -47,12 +47,12 @@
"""Gets the directory of the PKI for the given tenant.
Parameters:
- tenant (services.vpn.models.VPNTenant): The tenant to get the PKI directory for.
+ tenant (services.openvpn.models.OpenVPNTenant): The tenant to get the PKI directory for.
Returns:
str: The pki directory for the tenant.
"""
- return VPNService.SERVER_PREFIX + str(tenant.id)
+ return OpenVPNService.SERVER_PREFIX + str(tenant.id)
class Meta:
proxy = True
@@ -102,7 +102,7 @@
raise XOSValidationError(
"No availble ports for protocol: " + protocol)
tenants = [
- tenant for tenant in VPNTenant.get_tenant_objects().all()
+ tenant for tenant in OpenVPNTenant.get_tenant_objects().all()
if tenant.protocol == protocol]
port_numbers = self.exposed_ports[protocol]
for port_number in port_numbers:
@@ -113,14 +113,14 @@
return port_number
-class VPNTenant(TenantWithContainer):
+class OpenVPNTenant(TenantWithContainer):
"""Defines the Tenant for creating VPN servers."""
class Meta:
proxy = True
verbose_name = "VPN Tenant"
- KIND = VPN_KIND
+ KIND = OPENVPN_KIND
sync_attributes = ("nat_ip", "nat_mac",)
@@ -134,19 +134,19 @@
'protocol': None}
def __init__(self, *args, **kwargs):
- vpn_services = VPNService.get_service_objects().all()
+ vpn_services = OpenVPNService.get_service_objects().all()
if vpn_services:
self._meta.get_field(
"provider_service").default = vpn_services[0].id
- super(VPNTenant, self).__init__(*args, **kwargs)
+ super(OpenVPNTenant, self).__init__(*args, **kwargs)
def save(self, *args, **kwargs):
- super(VPNTenant, self).save(*args, **kwargs)
+ super(OpenVPNTenant, self).save(*args, **kwargs)
model_policy_vpn_tenant(self.pk)
def delete(self, *args, **kwargs):
self.cleanup_container()
- super(VPNTenant, self).delete(*args, **kwargs)
+ super(OpenVPNTenant, self).delete(*args, **kwargs)
@property
def protocol(self):
@@ -160,7 +160,7 @@
@property
def use_ca_from_id(self):
- """int: The ID of VPNTenant to use to obtain a CA."""
+ """int: The ID of OpenVPNTenant to use to obtain a CA."""
return self.get_attribute(
"use_ca_from_id", self.default_attributes["use_ca_from_id"])
@@ -231,7 +231,7 @@
@property
def failover_server_ids(self):
- """list(int): The IDs of the VPNTenants to use as failover servers."""
+ """list(int): The IDs of the OpenVPNTenants to use as failover servers."""
return self.get_attribute(
"failover_server_ids", self.default_attributes["failover_server_ids"])
@@ -261,13 +261,13 @@
self.set_attribute("port", value)
def get_ca_crt(self, pki_dir):
- """Gets the lines fo the ca.crt file for this VPNTenant.
+ """Gets the lines fo the ca.crt file for this OpenVPNTenant.
Parameters:
pki_dir (str): The PKI directory to look in.
Returns:
- list(str): The lines of the ca.crt file for this VPNTenant.
+ list(str): The lines of the ca.crt file for this OpenVPNTenant.
"""
with open(pki_dir + "/ca.crt", 'r') as f:
return f.readlines()
@@ -303,12 +303,12 @@
"""Manages the container for the VPN Tenant.
Parameters
- pk (int): The ID of this VPNTenant.
+ pk (int): The ID of this OpenVPNTenant.
"""
# This section of code is atomic to prevent race conditions
with transaction.atomic():
# We find all of the tenants that are waiting to update
- tenant = VPNTenant.objects.select_for_update().filter(pk=pk)
+ tenant = OpenVPNTenant.objects.select_for_update().filter(pk=pk)
if not tenant:
return
# Since this code is atomic it is safe to always use the first tenant
diff --git a/xos/services/vpn/templates/connect.vpn.j2 b/xos/services/openvpn/templates/connect.vpn.j2
similarity index 94%
rename from xos/services/vpn/templates/connect.vpn.j2
rename to xos/services/openvpn/templates/connect.vpn.j2
index 4ce9894..2028cd9 100644
--- a/xos/services/vpn/templates/connect.vpn.j2
+++ b/xos/services/openvpn/templates/connect.vpn.j2
@@ -1,5 +1,5 @@
#! /bin/bash
-# This file autogenerated by VPNTenant.
+# This file autogenerated by OpenVPNTenant.
# It contains a script used to generate the OPENVPN client files.
printf "%b" "client
dev tun
diff --git a/xos/services/vpn/templates/vpnserviceadmin.html b/xos/services/vpn/templates/vpnserviceadmin.html
deleted file mode 100644
index d983771..0000000
--- a/xos/services/vpn/templates/vpnserviceadmin.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!-- Template used to for the button leading to the HelloWorldTenantComplete form. -->
-<div class = "left-nav">
- <ul>
- <li>
- <a href="/admin/vpn/vpntenant/">
- VPN Tenants
- </a>
- </li>
- </ul>
-</div>
diff --git a/xos/synchronizers/vpn/__init__.py b/xos/synchronizers/openvpn/__init__.py
similarity index 100%
rename from xos/synchronizers/vpn/__init__.py
rename to xos/synchronizers/openvpn/__init__.py
diff --git a/xos/synchronizers/vpn/model-deps b/xos/synchronizers/openvpn/model-deps
similarity index 100%
rename from xos/synchronizers/vpn/model-deps
rename to xos/synchronizers/openvpn/model-deps
diff --git a/xos/synchronizers/vpn/run.sh b/xos/synchronizers/openvpn/run.sh
similarity index 100%
rename from xos/synchronizers/vpn/run.sh
rename to xos/synchronizers/openvpn/run.sh
diff --git a/xos/synchronizers/vpn/steps/__init__.py b/xos/synchronizers/openvpn/steps/__init__.py
similarity index 100%
rename from xos/synchronizers/vpn/steps/__init__.py
rename to xos/synchronizers/openvpn/steps/__init__.py
diff --git a/xos/synchronizers/vpn/steps/roles/openvpn/handlers/main.yml b/xos/synchronizers/openvpn/steps/roles/openvpn/handlers/main.yml
similarity index 100%
rename from xos/synchronizers/vpn/steps/roles/openvpn/handlers/main.yml
rename to xos/synchronizers/openvpn/steps/roles/openvpn/handlers/main.yml
diff --git a/xos/synchronizers/vpn/steps/roles/openvpn/tasks/main.yml b/xos/synchronizers/openvpn/steps/roles/openvpn/tasks/main.yml
similarity index 100%
rename from xos/synchronizers/vpn/steps/roles/openvpn/tasks/main.yml
rename to xos/synchronizers/openvpn/steps/roles/openvpn/tasks/main.yml
diff --git a/xos/synchronizers/vpn/steps/roles/openvpn/templates/server.conf.j2 b/xos/synchronizers/openvpn/steps/roles/openvpn/templates/server.conf.j2
similarity index 90%
rename from xos/synchronizers/vpn/steps/roles/openvpn/templates/server.conf.j2
rename to xos/synchronizers/openvpn/steps/roles/openvpn/templates/server.conf.j2
index 3930d28..4766e7b 100644
--- a/xos/synchronizers/vpn/steps/roles/openvpn/templates/server.conf.j2
+++ b/xos/synchronizers/openvpn/steps/roles/openvpn/templates/server.conf.j2
@@ -1,4 +1,4 @@
-# This file autogenerated by VPNTenant synchronizer
+# This file autogenerated by OpenVPNTenant synchronizer
# It contains the OPENVPN config file for the server
script-security 3 system
port {{ port_number }}
diff --git a/xos/synchronizers/openvpn/steps/sync_openvpntenant.py b/xos/synchronizers/openvpn/steps/sync_openvpntenant.py
new file mode 100644
index 0000000..b58dd94
--- /dev/null
+++ b/xos/synchronizers/openvpn/steps/sync_openvpntenant.py
@@ -0,0 +1,75 @@
+import os
+import shutil
+import sys
+
+from django.db.models import F, Q
+
+from services.openvpn.models import OpenVPNService, OpenVPNTenant
+from synchronizers.base.SyncInstanceUsingAnsible import \
+ SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+
+class SyncOpenVPNTenant(SyncInstanceUsingAnsible):
+ """Class for syncing a OpenVPNTenant using Ansible.
+
+ This SyncStep creates any necessary files for the OpenVPNTenant using ESAY RSA and then runs the
+ Ansible template to start the server on an instance.
+ """
+ provides = [OpenVPNTenant]
+ observes = OpenVPNTenant
+ requested_interval = 0
+ template_name = "sync_openvpntenant.yaml"
+ service_key_name = "/opt/xos/synchronizers/openvpn/openvpn_private_key"
+
+ def fetch_pending(self, deleted):
+ if (not deleted):
+ objs = OpenVPNTenant.get_tenant_objects().filter(
+ Q(enacted__lt=F('updated')) |
+ Q(enacted=None), Q(lazy_blocked=False))
+ else:
+ objs = OpenVPNTenant.get_deleted_tenant_objects()
+
+ return objs
+
+ def get_extra_attributes(self, tenant):
+ return {"is_persistent": tenant.is_persistent,
+ "vpn_subnet": tenant.vpn_subnet,
+ "server_network": tenant.server_network,
+ "clients_can_see_each_other": (
+ tenant.clients_can_see_each_other),
+ "port_number": tenant.port_number,
+ "protocol": tenant.protocol,
+ "pki_dir": OpenVPNService.get_pki_dir(tenant)
+ }
+
+ def sync_fields(self, o, fields):
+ pki_dir = OpenVPNService.get_pki_dir(o)
+
+ if (not os.path.isdir(pki_dir)):
+ OpenVPNService.execute_easyrsa_command(pki_dir, "init-pki")
+ OpenVPNService.execute_easyrsa_command(
+ pki_dir, "--req-cn=XOS build-ca nopass")
+
+ # Very hacky way to handle VPNs that need to share CAs
+ if (o.use_ca_from_id):
+ tenant = OpenVPNTenant.get_tenant_objects().filter(
+ pk=o.use_ca_from_id)[0]
+ other_pki_dir = OpenVPNService.get_pki_dir(tenant)
+ shutil.copy2(other_pki_dir + "/ca.crt", pki_dir)
+ shutil.copy2(other_pki_dir + "/private/ca.key",
+ pki_dir + "/private")
+
+ # If the server has to be built then we need to build it
+ if (not os.path.isfile(pki_dir + "/issued/server.crt")):
+ OpenVPNService.execute_easyrsa_command(
+ pki_dir, "build-server-full server nopass")
+ OpenVPNService.execute_easyrsa_command(pki_dir, "gen-dh")
+
+ # Get the most recent list of revoked clients
+ OpenVPNService.execute_easyrsa_command(pki_dir, "gen-crl")
+
+ # Super runs the playbook
+ super(SyncOpenVPNTenant, self).sync_fields(o, fields)
diff --git a/xos/synchronizers/vpn/steps/sync_vpntenant.yaml b/xos/synchronizers/openvpn/steps/sync_openvpntenant.yaml
similarity index 100%
rename from xos/synchronizers/vpn/steps/sync_vpntenant.yaml
rename to xos/synchronizers/openvpn/steps/sync_openvpntenant.yaml
diff --git a/xos/synchronizers/vpn/steps/sync_tenantprivilege.py b/xos/synchronizers/openvpn/steps/sync_tenantprivilege.py
similarity index 76%
rename from xos/synchronizers/vpn/steps/sync_tenantprivilege.py
rename to xos/synchronizers/openvpn/steps/sync_tenantprivilege.py
index 81e5910..51ee6df 100644
--- a/xos/synchronizers/vpn/steps/sync_tenantprivilege.py
+++ b/xos/synchronizers/openvpn/steps/sync_tenantprivilege.py
@@ -2,7 +2,7 @@
import sys
from core.models import TenantPrivilege
-from services.vpn.models import VPN_KIND, VPNService, VPNTenant
+from services.openvpn.models import OPENVPN_KIND, OpenVPNService, OpenVPNTenant
from synchronizers.base.syncstep import DeferredException, SyncStep
parentdir = os.path.join(os.path.dirname(__file__), "..")
@@ -10,13 +10,13 @@
class SyncTenantPrivilege(SyncStep):
- """Class for syncing a TenantPrivilege for a VPNTenant.
+ """Class for syncing a TenantPrivilege for a OpenVPNTenant.
- This SyncStep isolates the updated TenantPrivileges that are for VPNTenants and performs
+ This SyncStep isolates the updated TenantPrivileges that are for OpenVPNTenants and performs
actions if the TenantPrivilege has been added or deleted. For added privileges a new client
- certificate and key are made, signed with the ca.crt file used by this VPNTenant. For deleted
+ certificate and key are made, signed with the ca.crt file used by this OpenVPNTenant. For deleted
privileges the client certificate is revoked and the files associated are deleted. In both
- cases the associated VPNTenant is saved causing the VPNTenant synchronizer to run.
+ cases the associated OpenVPNTenant is saved causing the OpenVPNTenant synchronizer to run.
"""
provides = [TenantPrivilege]
observes = TenantPrivilege
@@ -24,21 +24,21 @@
def fetch_pending(self, deleted):
privs = super(SyncTenantPrivilege, self).fetch_pending(deleted)
- # Get only the TenantPrivileges that relate to VPNTenants
- privs = [priv for priv in privs if priv.tenant.kind == VPN_KIND]
+ # Get only the TenantPrivileges that relate to OpenVPNTenants
+ privs = [priv for priv in privs if priv.tenant.kind == OPENVPN_KIND]
return privs
def sync_record(self, record):
if (not record.tenant.id):
raise DeferredException("Privilege waiting on VPN Tenant ID")
certificate = self.get_certificate_name(record)
- tenant = VPNTenant.get_tenant_objects().filter(pk=record.tenant.id)[0]
+ tenant = OpenVPNTenant.get_tenant_objects().filter(pk=record.tenant.id)[0]
if (not tenant):
raise DeferredException("Privilege waiting on VPN Tenant")
# Only add a certificate if ones does not yet exist
- pki_dir = VPNService.get_pki_dir(tenant)
+ pki_dir = OpenVPNService.get_pki_dir(tenant)
if (not os.path.isfile(pki_dir + "/issued/" + certificate + ".crt")):
- VPNService.execute_easyrsa_command(
+ OpenVPNService.execute_easyrsa_command(
pki_dir, "build-client-full " + certificate + " nopass")
tenant.save()
record.save()
@@ -47,13 +47,13 @@
if (not record.tenant.id):
return
certificate = self.get_certificate_name(record)
- tenant = VPNTenant.get_tenant_objects().filter(pk=record.tenant.id)[0]
+ tenant = OpenVPNTenant.get_tenant_objects().filter(pk=record.tenant.id)[0]
if (not tenant):
return
# If the client has already been reovked don't do it again
- pki_dir = VPNService.get_pki_dir(tenant)
+ pki_dir = OpenVPNService.get_pki_dir(tenant)
if (os.path.isfile(pki_dir + "/issued/" + certificate + ".crt")):
- VPNService.execute_easyrsa_command(
+ OpenVPNService.execute_easyrsa_command(
pki_dir, "revoke " + certificate)
# Revoking a client cert does not delete any of the files
# to make sure that we can add this user again we need to
diff --git a/xos/synchronizers/vpn/stop.sh b/xos/synchronizers/openvpn/stop.sh
similarity index 100%
rename from xos/synchronizers/vpn/stop.sh
rename to xos/synchronizers/openvpn/stop.sh
diff --git a/xos/synchronizers/vpn/vpn-synchronizer.py b/xos/synchronizers/openvpn/vpn-synchronizer.py
similarity index 100%
rename from xos/synchronizers/vpn/vpn-synchronizer.py
rename to xos/synchronizers/openvpn/vpn-synchronizer.py
diff --git a/xos/synchronizers/vpn/vpn_config b/xos/synchronizers/openvpn/vpn_config
similarity index 100%
rename from xos/synchronizers/vpn/vpn_config
rename to xos/synchronizers/openvpn/vpn_config
diff --git a/xos/synchronizers/vpn/steps/sync_vpntenant.py b/xos/synchronizers/vpn/steps/sync_vpntenant.py
deleted file mode 100644
index 586ffb2..0000000
--- a/xos/synchronizers/vpn/steps/sync_vpntenant.py
+++ /dev/null
@@ -1,75 +0,0 @@
-import os
-import shutil
-import sys
-
-from django.db.models import F, Q
-
-from services.vpn.models import VPNService, VPNTenant
-from synchronizers.base.SyncInstanceUsingAnsible import \
- SyncInstanceUsingAnsible
-
-parentdir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.insert(0, parentdir)
-
-
-class SyncVPNTenant(SyncInstanceUsingAnsible):
- """Class for syncing a VPNTenant using Ansible.
-
- This SyncStep creates any necessary files for the VPNTenant using ESAY RSA and then runs the
- Ansible template to start the server on an instance.
- """
- provides = [VPNTenant]
- observes = VPNTenant
- requested_interval = 0
- template_name = "sync_vpntenant.yaml"
- service_key_name = "/opt/xos/synchronizers/vpn/vpn_private_key"
-
- def fetch_pending(self, deleted):
- if (not deleted):
- objs = VPNTenant.get_tenant_objects().filter(
- Q(enacted__lt=F('updated')) |
- Q(enacted=None), Q(lazy_blocked=False))
- else:
- objs = VPNTenant.get_deleted_tenant_objects()
-
- return objs
-
- def get_extra_attributes(self, tenant):
- return {"is_persistent": tenant.is_persistent,
- "vpn_subnet": tenant.vpn_subnet,
- "server_network": tenant.server_network,
- "clients_can_see_each_other": (
- tenant.clients_can_see_each_other),
- "port_number": tenant.port_number,
- "protocol": tenant.protocol,
- "pki_dir": VPNService.get_pki_dir(tenant)
- }
-
- def sync_fields(self, o, fields):
- pki_dir = VPNService.get_pki_dir(o)
-
- if (not os.path.isdir(pki_dir)):
- VPNService.execute_easyrsa_command(pki_dir, "init-pki")
- VPNService.execute_easyrsa_command(
- pki_dir, "--req-cn=XOS build-ca nopass")
-
- # Very hacky way to handle VPNs that need to share CAs
- if (o.use_ca_from_id):
- tenant = VPNTenant.get_tenant_objects().filter(
- pk=o.use_ca_from_id)[0]
- other_pki_dir = VPNService.get_pki_dir(tenant)
- shutil.copy2(other_pki_dir + "/ca.crt", pki_dir)
- shutil.copy2(other_pki_dir + "/private/ca.key",
- pki_dir + "/private")
-
- # If the server has to be built then we need to build it
- if (not os.path.isfile(pki_dir + "/issued/server.crt")):
- VPNService.execute_easyrsa_command(
- pki_dir, "build-server-full server nopass")
- VPNService.execute_easyrsa_command(pki_dir, "gen-dh")
-
- # Get the most recent list of revoked clients
- VPNService.execute_easyrsa_command(pki_dir, "gen-crl")
-
- # Super runs the playbook
- super(SyncVPNTenant, self).sync_fields(o, fields)
diff --git a/xos/xos/settings.py b/xos/xos/settings.py
index ec6055b..1fafe20 100644
--- a/xos/xos/settings.py
+++ b/xos/xos/settings.py
@@ -180,7 +180,7 @@
'services.ceilometer',
'services.requestrouter',
'services.syndicate_storage',
- 'services.vpn',
+ 'services.openvpn',
'services.vtr',
'services.vrouter',
'geoposition',