forked from shaba/openuds
Several fixes:
* Loglevel now more "readable" for actor * Added "remove delete protection" for cloned machine to template on proxmox * Fixed bug on textbox
This commit is contained in:
parent
62313ae67f
commit
4dec86fe9d
@ -70,4 +70,4 @@ class LocalLogger: # pylint: disable=too-few-public-methods
|
||||
# logging levels are 10 (debug), 20 (info)
|
||||
# OTHER = logging.NOTSET
|
||||
if self.logger:
|
||||
self.logger.log(int(level / 1000) - 10, message)
|
||||
self.logger.log(int(level / 1000), message)
|
||||
|
@ -43,7 +43,7 @@ if typing.TYPE_CHECKING:
|
||||
from . import rest
|
||||
|
||||
# Valid logging levels, from UDS Broker (uds.core.utils.log)
|
||||
OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * (x + 1) for x in range(6))
|
||||
from .loglevel import OTHER, DEBUG, INFO, WARN, ERROR, FATAL
|
||||
|
||||
class Logger:
|
||||
remoteLogger: typing.Optional['rest.UDSServerApi']
|
||||
|
32
actor/src/udsactor/loglevel.py
Normal file
32
actor/src/udsactor/loglevel.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2020 Virtual Cable S.L.U.
|
||||
# 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
|
||||
'''
|
||||
|
||||
OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * x for x in range(6))
|
@ -37,7 +37,7 @@ import typing
|
||||
import servicemanager # @UnresolvedImport, pylint: disable=import-error
|
||||
|
||||
# Valid logging levels, from UDS Broker (uds.core.utils.log).
|
||||
OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * (x + 1) for x in range(6))
|
||||
from ..loglevel import OTHER, DEBUG, INFO, WARN, ERROR, FATAL
|
||||
|
||||
class LocalLogger: # pylint: disable=too-few-public-methods
|
||||
linux = False
|
||||
@ -67,7 +67,7 @@ class LocalLogger: # pylint: disable=too-few-public-methods
|
||||
# logging levels are 10 (debug), 20 (info)
|
||||
# OTHER = logging.NOTSET
|
||||
if self.logger:
|
||||
self.logger.log(int(level / 1000) - 10, message)
|
||||
self.logger.log(int(level / 1000), message)
|
||||
|
||||
if level <= INFO or self.serviceLogger is False: # Only information and above will be on event log
|
||||
return
|
||||
|
@ -316,6 +316,17 @@ class ProxmoxClient:
|
||||
except Exception:
|
||||
logger.exception('removeFromHA')
|
||||
|
||||
@ensureConected
|
||||
def setProtection(self, vmId: int, node: typing.Optional[str] = None, protection: bool=False) -> None:
|
||||
params: typing.List[typing.Tuple[str, str]] = [
|
||||
('protection', str(int(protection))),
|
||||
]
|
||||
node = node or self.getVmInfo(vmId).node
|
||||
self._post(
|
||||
'nodes/{}/qemu/{}/config'.format(node, vmId),
|
||||
data=params
|
||||
)
|
||||
|
||||
@ensureConected
|
||||
def deleteVm(self, vmId: int, node: typing.Optional[str] = None, purge: bool = True) -> types.UPID:
|
||||
node = node or self.getVmInfo(vmId).node
|
||||
|
@ -159,6 +159,9 @@ class ProxmoxProvider(services.ServiceProvider): # pylint: disable=too-many-pub
|
||||
def disableHA(self, vmId: int) -> None:
|
||||
self.__getApi().disableVmHA(vmId)
|
||||
|
||||
def setProtection(self, vmId: int, node: typing.Optional[str] = None, protection: bool = False) -> None:
|
||||
self.__getApi().setProtection(vmId, node, protection)
|
||||
|
||||
def listHaGroups(self) -> typing.List[str]:
|
||||
return self.__getApi().listHAGroups()
|
||||
|
||||
|
@ -132,6 +132,8 @@ class ProxmoxPublication(services.Publication):
|
||||
self.service().makeTemplate(int(self._vm))
|
||||
# And add it to HA if
|
||||
self.service().enableHA(int(self._vm))
|
||||
# Disable Protection (removal)
|
||||
self.service().setProtection(int(self._vm), protection=False)
|
||||
|
||||
return self._state
|
||||
|
||||
|
@ -274,6 +274,9 @@ class ProxmoxLinkedService(Service): # pylint: disable=too-many-public-methods
|
||||
return
|
||||
self.parent().disableHA(vmId)
|
||||
|
||||
def setProtection(self, vmId: int, node: typing.Optional[str] = None, protection: bool=False) -> None:
|
||||
self.parent().setProtection(vmId, node, protection)
|
||||
|
||||
def getBaseName(self) -> str:
|
||||
return self.baseName.value
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -92,6 +92,6 @@
|
||||
</svg>
|
||||
</div>
|
||||
</uds-root>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1589460501" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1589460501" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1589460501" defer></script><script src="/uds/res/admin/main.js?stamp=1589460501" defer></script></body>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1589465305" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1589465305" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1589465305" defer></script><script src="/uds/res/admin/main.js?stamp=1589465305" defer></script></body>
|
||||
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user