+"""
+hpa discovery
+"""
import traceback
import uuid
import json
def ignore_case_get(args, key, def_val=""):
+ """
+ get the value of key
+ """
if not key:
return def_val
if key in args:
return args[old_key]
return def_val
-class HPA_Discovery(base.HPA_DiscoveryBase):
+class HPADiscovery(base.HPADiscoveryBase):
"""HPA Discovery implementation.
"""
def __init__(self):
basic_capability['hpa-feature-attributes'].append(
{'hpa-attribute-key':'virtualMemSize',
'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['ram'],"MB")
+ '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['ram'], "MB")
})
except Exception as e:
self._logger.error(traceback.format_exc())
hugepages_capability['hpa-feature-attributes'].append(
{'hpa-attribute-key': 'memoryPageSize',
'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(2,"MB")
+ '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(2, "MB")
})
elif extra_specs['hw:mem_page_size'] == 'small':
hugepages_capability['hpa-feature-attributes'].append(
{'hpa-attribute-key': 'memoryPageSize',
'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(4,"KB")
+ '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(4, "KB")
})
elif extra_specs['hw:mem_page_size'] == 'any':
- self._logger.info("Currently HPA feature memoryPageSize did not support 'any' page!!")
- else :
+ self._logger.info("Currently HPA feature did not support 'any'!!")
+ else:
hugepages_capability['hpa-feature-attributes'].append(
{'hpa-attribute-key': 'memoryPageSize',
'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs['hw:mem_page_size'],"KB")
+ '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(
+ extra_specs['hw:mem_page_size'], "KB")
})
except Exception:
self._logger.error(traceback.format_exc())
numa_capability['hpa-feature-attributes'].append(
{'hpa-attribute-key': numamem_key,
'hpa-attribute-value':
- '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs[numa_mem_node],"MB")
+ '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(
+ extra_specs[numa_mem_node], "MB")
})
except Exception:
self._logger.error(traceback.format_exc())
{'hpa-attribute-key': 'pciDeviceId',
'hpa-attribute-value':
'{{\"value\":\"{0}\"}}'.format(value2[4])
- })
+ })
except Exception:
self._logger.error(traceback.format_exc())
cloud_extra_info_str = json.loads(cloud_extra_info_str)
except Exception as ex:
self._logger.error("Can not convert cloud extra info %s %s" % (
- str(ex), cloud_extra_info_str))
+ str(ex), cloud_extra_info_str))
return {}
- if cloud_extra_info_str :
+ if cloud_extra_info_str:
cloud_dpdk_info = cloud_extra_info_str.get("ovsDpdk")
- if cloud_dpdk_info :
+ if cloud_dpdk_info:
libname = cloud_dpdk_info.get("libname")
libversion = cloud_dpdk_info.get("libversion")
-
+
ovsdpdk_capability['hpa-feature-attributes'] = [
{
'hpa-attribute-key': str(libname),
[tox]
-envlist = py36
+envlist = py36,cov,pylint
+skipdist = true
+
+[tox:jenkins]
+downloadcache = ~cache/pip
+
+[flake8]
+ignore = E501,E722
+exclude = ./venv-tox,./.tox
+max-complexity = 27
[testenv]
-deps =
basepython =
py36: python3
cov: python3
pylint: python3
+deps =
+ -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
commands =
- python3 -m unittest discover
+ coverage run -m unittest discover
+
+[testenv:pep8]
+deps=flake8
+commands = python3 -m flake8
+
+[testenv:cov]
+commands = coverage xml --omit="./venv-tox/*,./.tox/*,*tests*,*__init__.py,*site-packages*"
+
+[testenv:pylint]
+whitelist_externals = bash
+commands =
+ bash -c "\
+ pylint -f parseable --reports=y hpa | tee pylint.out"