diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-08-16 16:13:13 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-08-16 17:35:59 +0800 |
commit | 45677b6c956664422537367b1874e001f6c4c05b (patch) | |
tree | c9a3eb21698b538c691e74f7aa4f59575bcc109c | |
parent | fb4160ad891151d0fbb15cdf887905f06b875009 (diff) |
Add parse package logic
Call tosca parser to parse nsd and
vnfd package.
Change-Id: I07ae89e314f70e99d929fc2eb929d6549d819b57
Issue-ID: VFC-97
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-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 |