1 ##############################################################################
2 # Copyright 2017 Parker Berberian and Others #
4 # Licensed under the Apache License, Version 2.0 (the "License"); #
5 # you may not use this file except in compliance with the License. #
6 # You may obtain a copy of the License at #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
10 # Unless required by applicable law or agreed to in writing, software #
11 # distributed under the License is distributed on an "AS IS" BASIS, #
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13 # See the License for the specific language governing permissions and #
14 # limitations under the License. #
15 ##############################################################################
18 from vpnAction import VPNAction
22 class Make_VPN_User(VPNAction):
24 def __init__(self, config=None):
25 super(Make_VPN_User, self).__init__(config=config)
27 def run(self, booking=None, user=None, passwd=None):
32 name, passwd, dn = self.makeNewUser(name=user, passwd=passwd)
35 vpn_info['username'] = name
36 vpn_info['password'] = passwd
37 now = datetime.date.today()
38 vpn_info['created'] = now.isoformat() # 'YYYY-MM-DD' today
39 self.action_service.set_value(
41 value=json.dumps(vpn_info),
45 if booking is not None:
46 self.addUserToBooking(vpn_info, booking)
48 def addUserToBooking(self, vpn_info, booking):
49 name = "booking_" + str(booking)
51 self.action_service.get_value(
56 booking['vpn_key'] = "vpn_" + vpn_info['username']
57 self.action_service.set_value(
59 value=json.dumps(booking),