forked from shaba/openuds
Bug fix in LDAP & Regldap related to unicode literals
Fixes in new admin interface
This commit is contained in:
parent
b64928f1e6
commit
4565f00174
@ -43,7 +43,7 @@ import ldap
|
||||
import re
|
||||
import logging
|
||||
|
||||
__updated__ = '2014-02-19'
|
||||
__updated__ = '2014-03-19'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -188,7 +188,7 @@ class RegexLdap(auths.Authenticator):
|
||||
self._userNameAttr)
|
||||
|
||||
def marshal(self):
|
||||
return str.join('\t', [
|
||||
return '\t'.join([
|
||||
'v2',
|
||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||
self._ldapBase, self._userClass, self._userIdAttr, self._groupNameAttr, self._userNameAttr
|
||||
|
@ -42,7 +42,7 @@ from uds.core.auths.Exceptions import AuthenticatorException
|
||||
import ldap
|
||||
import logging
|
||||
|
||||
__updated__ = '2014-02-19'
|
||||
__updated__ = '2014-03-19'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -128,7 +128,7 @@ class SimpleLDAPAuthenticator(Authenticator):
|
||||
self._userNameAttr)
|
||||
|
||||
def marshal(self):
|
||||
return str.join('\t', ['v1',
|
||||
return '\t'.join(['v1',
|
||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||
self._ldapBase, self._userClass, self._groupClass, self._userIdAttr, self._groupIdAttr, self._memberAttr, self._userNameAttr])
|
||||
|
||||
|
@ -97,7 +97,9 @@ class gui(object):
|
||||
|
||||
@staticmethod
|
||||
def convertToList(vals):
|
||||
return [unicode(v) for v in vals]
|
||||
if vals is not None:
|
||||
return [unicode(v) for v in vals]
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def choiceItem(id_, text):
|
||||
|
@ -4,27 +4,27 @@
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@ -36,51 +36,51 @@ from uds.core import services
|
||||
from uds.core.util.AutoAttributes import AutoAttributes
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from IPMachineDeployed import IPMachineDeployed
|
||||
import logging, cPickle
|
||||
import logging
|
||||
import cPickle
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IPMachinesService(services.Service):
|
||||
|
||||
|
||||
# Gui
|
||||
ipList = gui.EditableList(label=_('List of IPS'))
|
||||
|
||||
# Description of service
|
||||
typeName = _('Physical machines accesed by ip')
|
||||
|
||||
# Description of service
|
||||
typeName = _('Physical machines accesed by ip')
|
||||
typeType = 'IPMachinesService'
|
||||
typeDescription = _('This service provides access to POWERED-ON Machines by ip')
|
||||
iconFile = 'machine.png'
|
||||
|
||||
|
||||
# Characteristics of service
|
||||
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
||||
usesCache = False # Cache are running machine awaiting to be assigned
|
||||
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
||||
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
||||
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
||||
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
||||
usesCache = False # Cache are running machine awaiting to be assigned
|
||||
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
||||
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
||||
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
||||
|
||||
deployedType = IPMachineDeployed
|
||||
|
||||
def __init__(self, environment, parent, values = None):
|
||||
|
||||
def __init__(self, environment, parent, values=None):
|
||||
super(IPMachinesService, self).__init__(environment, parent, values)
|
||||
if values is None:
|
||||
if values is None or values.get('ipList', None) is None:
|
||||
self._ips = []
|
||||
else:
|
||||
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
||||
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
||||
self._ips.sort()
|
||||
|
||||
|
||||
|
||||
def valuesDict(self):
|
||||
return { 'ipList' : gui.convertToList(self._ips) }
|
||||
return {'ipList': gui.convertToList(self._ips)}
|
||||
|
||||
def marshal(self):
|
||||
self.storage().saveData('ips', cPickle.dumps(self._ips))
|
||||
return 'v1'
|
||||
|
||||
|
||||
def unmarshal(self, vals):
|
||||
if vals == 'v1':
|
||||
self._ips = cPickle.loads( self.storage().readData('ips') )
|
||||
|
||||
|
||||
self._ips = cPickle.loads(self.storage().readData('ips'))
|
||||
|
||||
def getUnassignedMachine(self):
|
||||
# Search first unassigned machine
|
||||
try:
|
||||
@ -95,7 +95,7 @@ class IPMachinesService(services.Service):
|
||||
return None
|
||||
finally:
|
||||
self.storage().unlock()
|
||||
|
||||
|
||||
def unassignMachine(self, ip):
|
||||
try:
|
||||
self.storage().lock()
|
||||
|
@ -87,7 +87,7 @@
|
||||
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-switch.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
|
@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
@ -31,9 +30,11 @@ from django.utils.safestring import mark_safe
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||
from django import forms
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.forms.forms import NON_FIELD_ERRORS
|
||||
from django.forms.util import ErrorDict
|
||||
from uds.models import Authenticator
|
||||
@ -41,18 +42,20 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomSelect(forms.Select):
|
||||
def render(self, name, value, attrs=None):
|
||||
if len(self.choices) < 2:
|
||||
visible = ' style="display: none;"'
|
||||
else:
|
||||
visible = '';
|
||||
visible = ''
|
||||
res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator'))
|
||||
for choice in self.choices:
|
||||
res += '<option value="{0}">{1}</option>'.format(choice[0], choice[1])
|
||||
res += '</select>'
|
||||
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
||||
|
||||
|
||||
class BaseForm(forms.Form):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -65,6 +68,7 @@ class BaseForm(forms.Form):
|
||||
self._errors[NON_FIELD_ERRORS] = self.error_class()
|
||||
self._errors[NON_FIELD_ERRORS].append(message)
|
||||
|
||||
|
||||
class LoginForm(BaseForm):
|
||||
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
|
||||
@ -99,6 +103,8 @@ class LoginForm(BaseForm):
|
||||
for a in auths:
|
||||
if a.getType() is None:
|
||||
continue
|
||||
if a.getType().isCustom() and smallName == 'disabled':
|
||||
continue
|
||||
choices.append((a.id, a.name))
|
||||
if a.getType().isCustom():
|
||||
nonStandard.append(str(a.id))
|
||||
|
Loading…
Reference in New Issue
Block a user