aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2019-04-26 11:07:14 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2019-04-26 11:07:14 +0800
commit4715e9de59c877c6ee9615df9fb1ff61b73d66e1 (patch)
tree1512843e0c55b93d7e58c5a46de98744898b2fd6
parent5f005b8bcb667b7e1635e714c4997462c6a2a4e0 (diff)
Add job_error,etc in const
Add job_error,etc in const Change-Id: Ifcf3ca669056c2eaa4c26336a793fb805f576fd5 Issue-ID: VFC-1241 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
-rw-r--r--lcm/ns_vnfs/biz/grant_vnf.py9
-rw-r--r--lcm/ns_vnfs/biz/grant_vnfs.py9
-rw-r--r--lcm/ns_vnfs/biz/heal_vnfs.py2
-rw-r--r--lcm/ns_vnfs/biz/scale_vnfs.py3
-rw-r--r--lcm/ns_vnfs/biz/update_vnfs.py3
-rw-r--r--lcm/ns_vnfs/biz/verify_vnfs.py4
-rw-r--r--lcm/ns_vnfs/const.py12
7 files changed, 27 insertions, 15 deletions
diff --git a/lcm/ns_vnfs/biz/grant_vnf.py b/lcm/ns_vnfs/biz/grant_vnf.py
index 4d87c231..c393614a 100644
--- a/lcm/ns_vnfs/biz/grant_vnf.py
+++ b/lcm/ns_vnfs/biz/grant_vnf.py
@@ -21,6 +21,7 @@ from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi.sdc_run_catalog import query_vnfpackage_by_id
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.msapi import resmgr
+from lcm.ns_vnfs.const import SCALAR_UNIT_DICT
logger = logging.getLogger(__name__)
@@ -163,11 +164,11 @@ class GrantVnf(object):
def parse_unit(val, base_unit):
- recognized_units = ["B", "kB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB"]
- units_rate = [1, 1000, 1024, 1000000, 1048576, 1000000000, 1073741824, 1000000000000, 1099511627776]
- unit_rate_map = {unit.upper(): rate for unit, rate in zip(recognized_units, units_rate)}
+ # recognized_units = ["B", "kB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB"]
+ # units_rate = [1, 1000, 1024, 1000000, 1048576, 1000000000, 1073741824, 1000000000000, 1099511627776]
+ # unit_rate_map = {unit.upper(): rate for unit, rate in zip(recognized_units, units_rate)}
num_unit = val.strip().split(" ")
if len(num_unit) != 2:
return val.strip()
num, unit = num_unit[0], num_unit[1]
- return int(num) * unit_rate_map[unit.upper()] / unit_rate_map[base_unit.upper()]
+ return int(num) * SCALAR_UNIT_DICT[unit.upper()] / SCALAR_UNIT_DICT[base_unit.upper()]
diff --git a/lcm/ns_vnfs/biz/grant_vnfs.py b/lcm/ns_vnfs/biz/grant_vnfs.py
index e64bfd1c..e6b5dbfb 100644
--- a/lcm/ns_vnfs/biz/grant_vnfs.py
+++ b/lcm/ns_vnfs/biz/grant_vnfs.py
@@ -20,6 +20,7 @@ from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi import resmgr
from lcm.pub.msapi.sdc_run_catalog import query_vnfpackage_by_id
from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import SCALAR_UNIT_DICT
logger = logging.getLogger(__name__)
@@ -118,11 +119,11 @@ class GrantVnfs(object):
def parse_unit(val, base_unit):
- recognized_units = ["B", "kB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB"]
- units_rate = [1, 1000, 1024, 1000000, 1048576, 1000000000, 1073741824, 1000000000000, 1099511627776]
- unit_rate_map = {unit.upper(): rate for unit, rate in zip(recognized_units, units_rate)}
+ # recognized_units = ["B", "kB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB"]
+ # units_rate = [1, 1000, 1024, 1000000, 1048576, 1000000000, 1073741824, 1000000000000, 1099511627776]
+ # unit_rate_map = {unit.upper(): rate for unit, rate in zip(recognized_units, units_rate)}
num_unit = val.strip().split(" ")
if len(num_unit) != 2:
return val.strip()
num, unit = num_unit[0], num_unit[1]
- return int(num) * unit_rate_map[unit.upper()] / unit_rate_map[base_unit.upper()]
+ return int(num) * SCALAR_UNIT_DICT[unit.upper()] / SCALAR_UNIT_DICT[base_unit.upper()]
diff --git a/lcm/ns_vnfs/biz/heal_vnfs.py b/lcm/ns_vnfs/biz/heal_vnfs.py
index 9b574dfa..9821878b 100644
--- a/lcm/ns_vnfs/biz/heal_vnfs.py
+++ b/lcm/ns_vnfs/biz/heal_vnfs.py
@@ -25,10 +25,10 @@ from lcm.pub.msapi.vnfmdriver import send_nf_heal_request
from lcm.pub.utils import restcall
from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import JOB_ERROR
from lcm.ns_vnfs.enum import VNF_STATUS
from lcm.ns_vnfs.biz.wait_job import wait_job_finish
-JOB_ERROR = 255
logger = logging.getLogger(__name__)
diff --git a/lcm/ns_vnfs/biz/scale_vnfs.py b/lcm/ns_vnfs/biz/scale_vnfs.py
index c405a40c..07dfbcbc 100644
--- a/lcm/ns_vnfs/biz/scale_vnfs.py
+++ b/lcm/ns_vnfs/biz/scale_vnfs.py
@@ -21,11 +21,10 @@ from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi.vnfmdriver import send_nf_scaling_request
from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import JOB_ERROR
from lcm.ns_vnfs.enum import VNF_STATUS
from lcm.ns_vnfs.biz.wait_job import wait_job_finish
-JOB_ERROR = 255
-SCALE_TYPE = ("SCALE_OUT", "SCALE_IN")
logger = logging.getLogger(__name__)
diff --git a/lcm/ns_vnfs/biz/update_vnfs.py b/lcm/ns_vnfs/biz/update_vnfs.py
index a4073f18..1098a1d2 100644
--- a/lcm/ns_vnfs/biz/update_vnfs.py
+++ b/lcm/ns_vnfs/biz/update_vnfs.py
@@ -22,11 +22,10 @@ from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi.vnfmdriver import send_nf_operate_request
from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import JOB_ERROR
from lcm.ns_vnfs.enum import VNF_STATUS
from lcm.ns_vnfs.biz.wait_job import wait_job_finish
-JOB_ERROR = 255
-
logger = logging.getLogger(__name__)
diff --git a/lcm/ns_vnfs/biz/verify_vnfs.py b/lcm/ns_vnfs/biz/verify_vnfs.py
index 7c23dd59..650cb255 100644
--- a/lcm/ns_vnfs/biz/verify_vnfs.py
+++ b/lcm/ns_vnfs/biz/verify_vnfs.py
@@ -18,14 +18,14 @@ import threading
import traceback
import time
+from lcm.ns_vnfs.const import JOB_ERROR
from lcm.pub.exceptions import NSLCMException
from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.utils.restcall import req_by_msb
-logger = logging.getLogger(__name__)
-JOB_ERROR = 255
+logger = logging.getLogger(__name__)
class VerifyVnfs(threading.Thread):
diff --git a/lcm/ns_vnfs/const.py b/lcm/ns_vnfs/const.py
index 4a67826b..d3edfe47 100644
--- a/lcm/ns_vnfs/const.py
+++ b/lcm/ns_vnfs/const.py
@@ -13,4 +13,16 @@
# limitations under the License.
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
+JOB_ERROR = 255
NFVO_VNF_INST_TIMEOUT_SECOND = 3000
+SCALAR_UNIT_DICT = {
+ "B": 1,
+ "kB": 1000,
+ "KiB": 1024,
+ "MB": 1000000,
+ "MiB": 1048576,
+ "GB": 1000000000,
+ "GiB": 1073741824,
+ "TB": 1000000000000,
+ "TiB": 1099511627776
+}