Merge branch 'master' into feature/monthly-invoices

This commit is contained in:
PCoder 2019-04-13 12:13:38 +02:00
commit 3bf4f4dca7
5 changed files with 30 additions and 6 deletions

View File

@ -1,3 +1,6 @@
2.5: 2019-04-11
* #6589: [vm creation, listing] Fix obtaining ip address/template related info from oca api call (MR!690, MR!691 and MR!692)
[python-oca] VirtualMachinePool infoextended (https://github.com/ungleich/python-oca/pull/3)
2.4.10: 2019-02-14
* #6451: [dg, gdpr banner] Update phone number (MR!688 by pcoder)
2.4.9: 2019-02-01

View File

@ -245,6 +245,8 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id):
}
email = EmailMessage(**email_data)
email.send()
else:
logger.debug("VM's ipv6 is None. Hence not created VMDetail")
except Exception as e:
logger.error(str(e))
try:

View File

@ -686,18 +686,26 @@ if ENABLE_LOGGING:
custom_handler_item = {
'custom_file': {
'level': LOG_LEVEL,
'class': 'logging.FileHandler',
'class': 'logging.handlers.RotatingFileHandler',
'filename':
"{PROJECT_DIR}/{LEVEL}.log".format(
"{PROJECT_DIR}/logs/{LEVEL}.log".format(
LEVEL=LOG_LEVEL.lower(),
PROJECT_DIR=PROJECT_DIR
)
),
'maxBytes': 1024 * 1024 * 5,
'backupCount': 10,
'formatter': 'standard',
}
}
handlers_dict.update(custom_handler_item)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(name)s: %(message)s'
}
},
'handlers': handlers_dict,
'loggers': loggers_dict
}

0
logs/.gitkeep Normal file
View File

View File

@ -168,10 +168,21 @@ class OpenNebulaManager():
raise
return user_pool
def _get_vm_pool(self):
def _get_vm_pool(self, vm_id=None, infoextended=True):
"""
vm_id: int - the id of the VM that needs to looked up in the vm pool;
when set to None, looks for everything in the infoextended
"""
try:
vm_pool = oca.VirtualMachinePool(self.client)
vm_pool.info()
if infoextended:
vm_pool.infoextended(
filter_key_value_str='ID={vm_id}'.format(vm_id=vm_id) if
vm_id is not None else '',
vm_state=-1 # Look for VMs in any state, except DONE
)
else:
vm_pool.info()
return vm_pool
except AttributeError:
logger.error('Could not connect via client, using oneadmin instead')
@ -202,7 +213,7 @@ class OpenNebulaManager():
def get_vm(self, vm_id):
vm_id = int(vm_id)
try:
vm_pool = self._get_vm_pool()
vm_pool = self._get_vm_pool(vm_id)
return vm_pool.get_by_id(vm_id)
except WrongIdError:
raise WrongIdError