Fixed several proxmox issues

This commit is contained in:
Adolfo Gómez García 2020-06-11 17:34:36 +02:00
parent 6f8b67f3b8
commit c23f95e903
4 changed files with 14 additions and 7 deletions

View File

@ -277,7 +277,6 @@ class ProxmoxClient:
if linkedClone is False:
params.append(('format', 'qcow2')) # Ensure clone for templates is on qcow2 format
logger.debug('PARAMS: %s', params)
return types.VmCreationResult(

View File

@ -2,7 +2,7 @@ import datetime
import re
import typing
networkRe = re.compile(r'([a-zA-Z0-9]+)=([^,]+)(,bridge=([^,]*),firewall=(.*))?')
networkRe = re.compile(r'([a-zA-Z0-9]+)=([^,]+)(,bridge=([^,]*),firewall=([^,]*))?') # May have vla id at end
# Conversor from dictionary to NamedTuple
conversors: typing.MutableMapping[typing.Type, typing.Callable] = {

View File

@ -55,6 +55,8 @@ def getStorage(parameters: typing.Any) -> typing.List[typing.Dict[str, typing.An
res = []
# Get storages for that datacenter
for storage in sorted(provider.listStorages(vmInfo.node), key=lambda x: int(not x.shared)):
if storage.type in ('lvm', 'iscsi', 'iscsidirect'):
continue
space, free = storage.avail / 1024 / 1024 / 1024, (storage.avail - storage.used) / 1024 / 1024 / 1024
extra = _(' shared') if storage.shared else _(' (bound to {})').format(vmInfo.node)
res.append({'id': storage.storage, 'text': "%s (%4.2f GB/%4.2f GB)%s" % (storage.storage, space, free, extra)})

View File

@ -29,6 +29,7 @@
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
"""
from datetime import datetime
import time
import logging
import typing
@ -126,13 +127,18 @@ class ProxmoxPublication(services.Publication):
return self.destroy()
self._state = State.FINISHED
if self._operation == 'p': # not Destroying
logger.debug('Marking as template')
# Mark vm as template
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)
time.sleep(0.5) # Give some tome to proxmox. We have observed some concurrency issues
# And add it to HA if
self.service().enableHA(int(self._vm))
time.sleep(0.5)
# Mark vm as template
self.service().makeTemplate(int(self._vm))
# This seems to cause problems on Proxmox
# makeTemplate --> setProtection (that calls "config"). Seems that the HD dissapears...
# Seems a concurrency problem?
return self._state