mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-24 02:04:09 +03:00
Updating to 3.7
refactoring portions
This commit is contained in:
parent
47721db3f5
commit
999a23fb6d
@ -132,7 +132,7 @@ class Authenticators(ModelHandler):
|
||||
# self.invalidResponseException('{}'.format(e))
|
||||
|
||||
def test(self, type_):
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
|
||||
authType = auths.factory().lookup(type_)
|
||||
self.ensureAccess(authType, permissions.PERMISSION_MANAGEMENT, root=True)
|
||||
|
@ -150,7 +150,7 @@ class Providers(ModelHandler):
|
||||
return self.item_as_dict(item)
|
||||
|
||||
def test(self, type_):
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
|
||||
logger.debug('Type: %s', type_)
|
||||
spType = services.factory().lookup(type_)
|
||||
|
@ -41,7 +41,7 @@ from uds.core.services import Service as coreService
|
||||
from uds.core.util import log
|
||||
from uds.core.util import permissions
|
||||
from uds.core.util.model import processUuid
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.ui.images import DEFAULT_THUMB_BASE64
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.core.util.State import State
|
||||
|
@ -87,7 +87,7 @@ class SampleAuth(auths.Authenticator):
|
||||
|
||||
# : Icon file, used to represent this authenticator at administration interface
|
||||
# : This file should be at same folder as this class is, except if you provide
|
||||
# : your own :py:meth:uds.core.BaseModule.BaseModule.icon method.
|
||||
# : your own :py:meth:uds.core.module.BaseModule.icon method.
|
||||
iconFile = 'auth.png'
|
||||
|
||||
# : Mark this authenticator as that the users comes from outside the UDS
|
||||
|
@ -35,9 +35,9 @@ This package contains all core-related code for UDS
|
||||
import time
|
||||
|
||||
# Core needs tasks manager to register scheduled jobs, so we ensure of that here
|
||||
from uds.core.Environment import Environmentable
|
||||
from uds.core.Serializable import Serializable
|
||||
from uds.core.BaseModule import Module
|
||||
from .environment import Environmentable
|
||||
from .serializable import Serializable
|
||||
from .module import Module
|
||||
|
||||
|
||||
VERSION = '3.x.x-DEVEL'
|
||||
|
@ -38,7 +38,7 @@ from django.utils.translation import ugettext_noop as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from uds.core import Module
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.auths.GroupsManager import GroupsManager
|
||||
from uds.core.auths.Exceptions import InvalidUserException
|
||||
|
||||
@ -118,7 +118,7 @@ class Authenticator(Module): # pylint: disable=too-many-public-methods
|
||||
|
||||
# : Icon file, used to represent this authenticator at administration interface
|
||||
# : This file should be at same folder as this class is, except if you provide
|
||||
# : your own :py:meth:uds.core.BaseModule.BaseModule.icon method.
|
||||
# : your own :py:meth:uds.core.module.BaseModule.icon method.
|
||||
iconFile = 'auth.png'
|
||||
|
||||
# : Mark this authenticator as that the users comes from outside the UDS
|
||||
|
@ -153,7 +153,7 @@ class Environment:
|
||||
return Environment(GLOBAL_ENV) # This environment is a global environment for general utility.
|
||||
|
||||
|
||||
class Environmentable(object):
|
||||
class Environmentable:
|
||||
"""
|
||||
This is a base class provided for all objects that have an environment associated. These are mainly modules
|
||||
"""
|
@ -32,7 +32,7 @@
|
||||
"""
|
||||
import logging
|
||||
|
||||
from uds.core.Environment import Environmentable
|
||||
from uds.core.environment import Environmentable
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -40,7 +40,7 @@ from django.db import transaction, connection
|
||||
from django.db.models import Q
|
||||
from uds.models import DelayedTask as DBDelayedTask
|
||||
from uds.models import getSqlDatetime
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import encoders
|
||||
|
||||
from .DelayedTask import DelayedTask
|
||||
|
@ -39,11 +39,11 @@ import logging
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from uds.core.ui.UserInterface import UserInterface
|
||||
from uds.core import Environmentable
|
||||
from uds.core import Serializable
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.util import encoders
|
||||
|
||||
from .serializable import Serializable
|
||||
from .environment import Environment, Environmentable
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# Copyright (c) 2012-2019 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -30,7 +30,7 @@
|
||||
"""
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
import typing
|
||||
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.services import types as serviceTypes
|
||||
@ -40,12 +40,11 @@ from uds.core.util import log
|
||||
from uds.core.util.Config import GlobalConfig
|
||||
from uds.core import Module
|
||||
|
||||
import six
|
||||
|
||||
__updated__ = '2019-02-24'
|
||||
|
||||
STORAGE_KEY = 'osmk'
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.models import UserService
|
||||
from uds.core.environmentable import Environment
|
||||
|
||||
class OSManager(Module):
|
||||
"""
|
||||
@ -69,11 +68,11 @@ class OSManager(Module):
|
||||
# : Defaults to all. (list or tuple)
|
||||
servicesType = serviceTypes.ALL
|
||||
|
||||
def __init__(self, environment, values):
|
||||
super(OSManager, self).__init__(environment, values)
|
||||
def __init__(self, environment: 'Environment', values: Module.ValuesType):
|
||||
super().__init__(environment, values)
|
||||
self.initialize(values)
|
||||
|
||||
def initialize(self, values):
|
||||
def initialize(self, values: Module.ValuesType):
|
||||
"""
|
||||
This method will be invoked from __init__ constructor.
|
||||
This is provided so you don't have to provide your own __init__ method,
|
||||
@ -88,25 +87,22 @@ class OSManager(Module):
|
||||
|
||||
Default implementation does nothing
|
||||
"""
|
||||
pass
|
||||
|
||||
def release(self, service):
|
||||
def release(self, userService: 'UserService') -> None:
|
||||
"""
|
||||
Called by a service that is in Usable state before destroying it so osmanager can release data associated with it
|
||||
Only invoked for services that reach the state "removed"
|
||||
@return nothing
|
||||
"""
|
||||
pass
|
||||
|
||||
# These methods must be overriden
|
||||
def process(self, userService, message, data, options=None):
|
||||
def process(self, userService: 'UserService', message: str, data: str, options=None):
|
||||
"""
|
||||
This method must be overriden so your so manager can manage requests and responses from agent.
|
||||
@param userService: Service that sends the request (virtual machine or whatever)
|
||||
@param message: message to process (os manager dependent)
|
||||
@param data: Data for this message
|
||||
"""
|
||||
pass
|
||||
|
||||
def checkState(self, service):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# Copyright (c) 2012-2019 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -32,7 +32,6 @@ UDS os managers related interfaces and classes
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from .BaseOsManager import OSManager
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ class Service(Module):
|
||||
|
||||
# : Icon file, used to represent this service at administration interface
|
||||
# : This file should be at same folder as this class is, except if you provide
|
||||
# : your own :py:meth:uds.core.BaseModule.BaseModule.icon method.
|
||||
# : your own :py:meth:uds.core.module.BaseModule.icon method.
|
||||
iconFile = 'service.png'
|
||||
|
||||
# Functional related data
|
||||
|
@ -34,7 +34,7 @@ import logging
|
||||
import typing
|
||||
|
||||
from uds.core import Module
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
|
||||
from uds.core.util.Config import GlobalConfig
|
||||
from uds.core.ui.UserInterface import gui
|
||||
@ -103,7 +103,7 @@ class ServiceProvider(Module):
|
||||
|
||||
# : Icon file, used to represent this provider at administration interface
|
||||
# : This file should be at same folder as this class is, except if you provide
|
||||
# : your own py:meth:`uds.core.BaseModule.BaseModule.icon` method.
|
||||
# : your own py:meth:`uds.core.module.BaseModule.icon` method.
|
||||
iconFile = 'provider.png'
|
||||
|
||||
# : This defines the maximum number of concurrent services that should be in state "in preparation" for this provider
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core.Serializable import Serializable
|
||||
from uds.core.serializable import Serializable
|
||||
from uds.core.util import encoders
|
||||
import pickle
|
||||
import six
|
||||
|
@ -32,7 +32,7 @@
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core.BaseModule import Module
|
||||
from uds.core.module import Module
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
import re
|
||||
|
@ -7,7 +7,7 @@ from uds.core.util import encoders
|
||||
from uds.transports.RDP.RDPTransport import RDPTransport
|
||||
from uds.transports.RDP.TRDPTransport import TRDPTransport
|
||||
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
|
||||
|
||||
def unmarshalRDP(str_):
|
||||
|
@ -34,7 +34,7 @@ import logging
|
||||
import typing
|
||||
|
||||
from django.db import models
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core import Module
|
||||
from uds.models.UUIDModel import UUIDModel
|
||||
|
||||
|
@ -37,7 +37,7 @@ from django.db import models
|
||||
from django.db.models import signals
|
||||
|
||||
from uds.core.util.State import State
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.jobs.JobsFactory import JobsFactory
|
||||
|
||||
from uds.models.Util import NEVER
|
||||
|
@ -35,7 +35,7 @@ import logging
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import log
|
||||
from uds.core.util import unique
|
||||
from uds.models.ManagedObjectModel import ManagedObjectModel
|
||||
|
@ -38,7 +38,7 @@ from datetime import datetime, timedelta
|
||||
from django.db import models, transaction
|
||||
from django.db.models import signals
|
||||
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import log
|
||||
from uds.core.util import states
|
||||
from uds.core.services.Exceptions import InvalidServiceException
|
||||
|
@ -37,7 +37,7 @@ from django.db import models
|
||||
from django.db.models import signals
|
||||
|
||||
from uds.core.util.State import State
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import log
|
||||
|
||||
from uds.models.ServicesPool import DeployedService
|
||||
|
@ -36,7 +36,7 @@ import typing
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import log
|
||||
from uds.core.util import unique
|
||||
from uds.core.util.State import State
|
||||
|
@ -201,14 +201,14 @@ class WinDomainOsManager(WindowsOsManager):
|
||||
if self._removeOnExit != 'y':
|
||||
return
|
||||
|
||||
if not '.' in self._domain:
|
||||
if '.' not in self._domain:
|
||||
logger.info('Releasing from a not FQDN domain is not supported')
|
||||
return
|
||||
|
||||
try:
|
||||
l = self.__connectLdap()
|
||||
except dns.resolver.NXDOMAIN: # No domain found, log it and pass
|
||||
logger.warning('Could not find _ldap._tcp.' + self._domain)
|
||||
logger.warning('Could not find _ldap._tcp.%s', self._domain)
|
||||
log.doLog(service, log.WARN, "Could not remove machine from domain (_ldap._tcp.{0} not found)".format(self._domain), log.OSMANAGER)
|
||||
return
|
||||
except ldaputil.LDAPError:
|
||||
|
@ -22,7 +22,7 @@ class oVirtHelpers(object):
|
||||
This helper is designed as a callback for machine selector, so we can provide valid clusters and datastores domains based on it
|
||||
"""
|
||||
from OVirtProvider import Provider
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
logger.debug('Parameters received by getResources Helper: {0}'.format(parameters))
|
||||
env = Environment(parameters['ev'])
|
||||
provider = Provider(env)
|
||||
|
@ -21,7 +21,7 @@ def getResources(parameters):
|
||||
This helper is designed as a callback for Project Selector
|
||||
"""
|
||||
from .Provider import OGProvider
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
logger.debug('Parameters received by getResources Helper: {0}'.format(parameters))
|
||||
env = Environment(parameters['ev'])
|
||||
provider = OGProvider(env)
|
||||
|
@ -23,7 +23,7 @@ def getResources(parameters):
|
||||
from .ProviderLegacy import ProviderLegacy as Provider
|
||||
else:
|
||||
from .Provider import Provider
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
logger.debug('Parameters received by getResources Helper: {0}'.format(parameters))
|
||||
env = Environment(parameters['ev'])
|
||||
provider = Provider(env)
|
||||
@ -55,7 +55,7 @@ def getVolumes(parameters):
|
||||
from .ProviderLegacy import ProviderLegacy as Provider
|
||||
else:
|
||||
from .Provider import Provider
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.environment import Environment
|
||||
logger.debug('Parameters received by getVolumes Helper: {0}'.format(parameters))
|
||||
env = Environment(parameters['ev'])
|
||||
provider = Provider(env)
|
||||
|
@ -51,7 +51,7 @@ class SamplePublication(Publication):
|
||||
* :py:meth:`.checkState`
|
||||
* :py:meth:`.finish`
|
||||
|
||||
Also, of course, methods from :py:class:`uds.core.Serializable.Serializable`
|
||||
Also, of course, methods from :py:class:`uds.core.serializable.Serializable`
|
||||
|
||||
|
||||
Publication do not have an configuration interface, all data contained
|
||||
|
Loading…
x
Reference in New Issue
Block a user