From df17a868204eb499cc85ca2ffd66afb7379f145c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 2 Dec 2016 12:13:46 +0100 Subject: [PATCH] Added a Physical "single machine" service to physicals machines provider. Fixed textbox admin template to honor "required" --- actors/.gitignore | 1 + server/src/uds/REST/methods/authenticators.py | 2 +- server/src/uds/REST/methods/services.py | 2 +- .../PhysicalMachines/IPMachinesService.py | 4 +- .../IPSingleMachineService.py | 88 ++++++++++++++++++ .../PhysicalMachines/ServiceProvider.py | 3 +- .../services/PhysicalMachines/machines.png | Bin 0 -> 544 bytes .../templates/uds/admin/tmpl/fld/textbox.html | 2 +- 8 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 server/src/uds/services/PhysicalMachines/IPSingleMachineService.py create mode 100644 server/src/uds/services/PhysicalMachines/machines.png diff --git a/actors/.gitignore b/actors/.gitignore index 4d038f60..3d772e26 100644 --- a/actors/.gitignore +++ b/actors/.gitignore @@ -6,3 +6,4 @@ udsactor*.changes /udsactor_1.7.0.dsc /udsactor_1.7.0.tar.xz /udsactor*.rpm +/udsactor_2.1.0_amd64.buildinfo diff --git a/server/src/uds/REST/methods/authenticators.py b/server/src/uds/REST/methods/authenticators.py index b7b4011b..6fef4283 100644 --- a/server/src/uds/REST/methods/authenticators.py +++ b/server/src/uds/REST/methods/authenticators.py @@ -59,7 +59,7 @@ class Authenticators(ModelHandler): {'name': {'title': _('Name'), 'visible': True, 'type': 'iconType'}}, {'comments': {'title': _('Comments')}}, {'priority': {'title': _('Priority'), 'type': 'numeric', 'width': '5em'}}, - {'small_name': {'title': _('Tag')}}, + {'small_name': {'title': _('Label')}}, {'users_count': {'title': _('Users'), 'type': 'numeric', 'width': '5em'}}, {'tags': {'title': _('tags'), 'visible': False}}, ] diff --git a/server/src/uds/REST/methods/services.py b/server/src/uds/REST/methods/services.py index ac86c5c8..da2e780b 100644 --- a/server/src/uds/REST/methods/services.py +++ b/server/src/uds/REST/methods/services.py @@ -188,7 +188,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods {'name': {'title': _('Service name'), 'visible': True, 'type': 'iconType'}}, {'comments': {'title': _('Comments')}}, {'type_name': {'title': _('Type')}}, - {'deployed_services_count': {'title': _('Deployed services'), 'type': 'numeric'}}, + {'deployed_services_count': {'title': _('Services Pools'), 'type': 'numeric'}}, {'user_services_count': {'title': _('User services'), 'type': 'numeric'}}, {'tags': {'title': _('tags'), 'visible': False}}, ] diff --git a/server/src/uds/services/PhysicalMachines/IPMachinesService.py b/server/src/uds/services/PhysicalMachines/IPMachinesService.py index e5182c47..b840565a 100644 --- a/server/src/uds/services/PhysicalMachines/IPMachinesService.py +++ b/server/src/uds/services/PhysicalMachines/IPMachinesService.py @@ -48,10 +48,10 @@ class IPMachinesService(services.Service): ipList = gui.EditableList(label=_('List of IPS')) # Description of service - typeName = _('Static IP machines service') + typeName = _('Static Multiple IP') typeType = 'IPMachinesService' typeDescription = _('This service provides access to POWERED-ON Machines by IP') - iconFile = 'machine.png' + iconFile = 'machines.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 diff --git a/server/src/uds/services/PhysicalMachines/IPSingleMachineService.py b/server/src/uds/services/PhysicalMachines/IPSingleMachineService.py new file mode 100644 index 00000000..72392c67 --- /dev/null +++ b/server/src/uds/services/PhysicalMachines/IPSingleMachineService.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- + +# +# Copyright (c) 2012 Virtual Cable S.L. +# All rights reserved. +# +# 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, +# 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 +# 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 +# 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 +# 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 +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +''' +@author: Adolfo Gómez, dkmaster at dkmon dot com +''' + +from django.utils.translation import ugettext_lazy as _ +from uds.core import services +from uds.core.services import types as serviceTypes +from uds.core.ui.UserInterface import gui +from .IPMachineDeployed import IPMachineDeployed +import logging +import pickle + +logger = logging.getLogger(__name__) + + +class IPSingleMachineService(services.Service): + + # Gui + ip = gui.TextField(length=64, label=_('Machine IP'), order=1, tooltip=_('Machine IP'), required=True) + + + # Description of service + typeName = _('Static Single IP') + typeType = 'IPSingleMachineService' + typeDescription = _('This service provides access to POWERED-ON Machine 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 + + deployedType = IPMachineDeployed + + servicesTypeProvided = (serviceTypes.VDI,) + + def initialize(self, values): + pass + + def getUnassignedMachine(self): + ip = None + try: + self.storage.lock() + counter = self.storage.getPickle('counter') + counter = counter + 1 if counter is not None else 1 + self.storage.putPickle('counter', counter) + ip = '{}~{}'.format(self.ip.value, counter) + except Exception: + ip = None + logger.exception("Exception at getUnassignedMachine") + finally: + self.storage.unlock() + + return ip + + def unassignMachine(self, ip): + pass diff --git a/server/src/uds/services/PhysicalMachines/ServiceProvider.py b/server/src/uds/services/PhysicalMachines/ServiceProvider.py index 37aa17cc..b92b6f04 100644 --- a/server/src/uds/services/PhysicalMachines/ServiceProvider.py +++ b/server/src/uds/services/PhysicalMachines/ServiceProvider.py @@ -46,7 +46,8 @@ class PhysicalMachinesProvider(services.ServiceProvider): iconFile = 'provider.png' from .IPMachinesService import IPMachinesService - offers = [IPMachinesService] + from .IPSingleMachineService import IPSingleMachineService + offers = [IPMachinesService, IPSingleMachineService] def __unicode__(self): return "Physical Machines Provider" diff --git a/server/src/uds/services/PhysicalMachines/machines.png b/server/src/uds/services/PhysicalMachines/machines.png new file mode 100644 index 0000000000000000000000000000000000000000..4d7a891e984e97de970ceda6a536a8174279d167 GIT binary patch literal 544 zcmV+*0^j|KP)eVh(Q?rIwS-5`n@#P{DId@H+ZtuLI$q^kg}R1^99S?kHcLPVoC@3iJ`PnzYUnjCt$IP-A+#F^&G_aG%H z#BUSTg^DBA@M!7exZeHWL=FdzYjP-XT$93&{%f)@v;1o1p9wODXupjK70mIX0AtMd zOkfZ0M3EyUh`5VLRXA+woGiPvVH2bTCIki(u6pkLrK!@uu!#^tSes=1em@B#+blo! iArk-sK*ktL0N@ulCmbYo$=E{x0000{{ value }} + {% endverbatim %} {% endblock %}