Added a Physical "single machine" service to physicals machines

provider.
Fixed textbox admin template to honor "required"
This commit is contained in:
Adolfo Gómez García 2016-12-02 12:13:46 +01:00
parent 54c751e4c5
commit df17a86820
8 changed files with 96 additions and 6 deletions

1
actors/.gitignore vendored
View File

@ -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

View File

@ -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}},
]

View File

@ -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}},
]

View File

@ -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

View File

@ -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

View File

@ -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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

View File

@ -1,6 +1,6 @@
{% extends "uds/admin/tmpl/fld/form-group.html" %}
{% block field %}
{% verbatim %}
<textarea class="form-control {{ css }}" rows="{{ multiline }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" {{# if readonly }} readonly{{/ if }} tabindex="{{ index }}">{{ value }}</textarea>
<textarea class="form-control {{ css }}" rows="{{ multiline }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" {{# if required }} required {{/ if }} {{# if readonly }} readonly{{/ if }} tabindex="{{ index }}">{{ value }}</textarea>
{% endverbatim %}
{% endblock %}