diff options
author | 2017-08-16 12:00:03 +0000 | |
---|---|---|
committer | 2017-08-16 12:00:03 +0000 | |
commit | b01b0ffe63b61d2877a388cc2fb21f699763c7a0 (patch) | |
tree | a473e83cab20a698ba2f778e90b2a438ef9d1994 | |
parent | f76b634a3049bc992b2b46f4e2973e5a76c7bffc (diff) | |
parent | 45677b6c956664422537367b1874e001f6c4c05b (diff) |
Merge "Add parse package logic"
-rw-r--r-- | lcm/pub/utils/toscaparser/parser.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lcm/pub/utils/toscaparser/parser.py b/lcm/pub/utils/toscaparser/parser.py index e1692ed4..9b7e655b 100644 --- a/lcm/pub/utils/toscaparser/parser.py +++ b/lcm/pub/utils/toscaparser/parser.py @@ -11,24 +11,42 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+from os import R_OK, access
+from lcm.pub.exceptions import NSLCMException
def parse_nsd_model(path, input_parameters):
- check_file_exist(path)
- nsd_tpl = parse_nsd_csar(path, input_parameters)
+ isexist = check_file_exist(path)
+ if isexist:
+ nsd_tpl = parse_nsd_csar(path, input_parameters)
+ else:
+ raise NSLCMException('%s is not exist.' % path)
return nsd_tpl
def parse_vnfd_model(path, input_parameters):
- check_file_exist(path)
- vnfd_tpl = parse_vnfd_csar(path, input_parameters)
+ isexist = check_file_exist(path)
+ if isexist:
+ vnfd_tpl = parse_vnfd_csar(path, input_parameters)
+ else:
+ raise NSLCMException('%s is not exist.' % path)
return vnfd_tpl
def check_file_exist(path):
- pass
+ if path.exists(path) and path.isfile(path) and access(path, R_OK):
+ return True
+ else:
+ return False
def parse_nsd_csar(path, input_parameters=[], a_file=True):
- pass
+ nsd_object = None
+ from toscaparser.tosca_template import ToscaTemplate
+ nsd_object = ToscaTemplate(path, input_parameters)
+ return nsd_object
+
def parse_vnfd_csar(path, input_parameters=[], a_file=True):
- pass
\ No newline at end of file + vnfd_object = None
+ from toscaparser.tosca_template import ToscaTemplate
+ vnfd_object = ToscaTemplate(path, input_parameters)
+ return vnfd_object
\ No newline at end of file |