aboutsummaryrefslogtreecommitdiffstats
path: root/vnfsdk_pkgtools/packager/utils.py
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2019-11-28 15:12:22 +0800
committerLianhao Lu <lianhao.lu@intel.com>2019-11-29 10:11:46 +0800
commitfdb7c576cf4238228a786aa7cdb808aad2cb72cb (patch)
tree0a704125fdcfebbb8cba9748daf45922a337ae11 /vnfsdk_pkgtools/packager/utils.py
parent6bdd924968ceccf33a86482aa720609d1c156741 (diff)
Adapt to TOSCA.meta chagnes in SOL004 v2.6.1
Adapted to changes made in SOL004 v2.6.1 about TOSCA.meta file content, while still keeps the backward ability to generate SOL004 v2.4.1 compatible csar file. Issue-ID: VNFSDK-420 Change-Id: I2ea8d001211ea15c8409ee2e2802798a0945f390 Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 'vnfsdk_pkgtools/packager/utils.py')
-rw-r--r--vnfsdk_pkgtools/packager/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/vnfsdk_pkgtools/packager/utils.py b/vnfsdk_pkgtools/packager/utils.py
index f16a961..539a242 100644
--- a/vnfsdk_pkgtools/packager/utils.py
+++ b/vnfsdk_pkgtools/packager/utils.py
@@ -29,6 +29,21 @@ from six.moves.urllib import parse as urlparse
LOG = logging.getLogger(__name__)
+def check_file_dir(root, entry, msg, check_for_non=False, check_dir=False):
+ path = os.path.join(root, entry)
+ if check_for_non:
+ ret = not os.path.exists(path)
+ error_msg = '{0} already exists. ' + msg
+ elif check_dir:
+ ret = os.path.isdir(path)
+ error_msg = '{0} is not an existing directory. ' + msg
+ else:
+ ret = os.path.isfile(path)
+ error_msg = '{0} is not an existing file. ' + msg
+ if not ret:
+ raise ValueError(error_msg.format(path))
+
+
def _hash_value_for_file(f, hash_function, block_size=2**20):
while True:
data = f.read(block_size)