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>
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
# See the License for the specific language governing permissions and\r
# limitations under the License.\r
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
# See the License for the specific language governing permissions and\r
# limitations under the License.\r
+from os import R_OK, access\r
+from lcm.pub.exceptions import NSLCMException\r
\r
def parse_nsd_model(path, input_parameters):\r
\r
def parse_nsd_model(path, input_parameters):\r
- check_file_exist(path)\r
- nsd_tpl = parse_nsd_csar(path, input_parameters)\r
+ isexist = check_file_exist(path)\r
+ if isexist:\r
+ nsd_tpl = parse_nsd_csar(path, input_parameters)\r
+ else:\r
+ raise NSLCMException('%s is not exist.' % path)\r
return nsd_tpl\r
\r
\r
def parse_vnfd_model(path, input_parameters):\r
return nsd_tpl\r
\r
\r
def parse_vnfd_model(path, input_parameters):\r
- check_file_exist(path)\r
- vnfd_tpl = parse_vnfd_csar(path, input_parameters)\r
+ isexist = check_file_exist(path)\r
+ if isexist:\r
+ vnfd_tpl = parse_vnfd_csar(path, input_parameters)\r
+ else:\r
+ raise NSLCMException('%s is not exist.' % path)\r
return vnfd_tpl\r
\r
def check_file_exist(path):\r
return vnfd_tpl\r
\r
def check_file_exist(path):\r
+ if path.exists(path) and path.isfile(path) and access(path, R_OK):\r
+ return True\r
+ else:\r
+ return False\r
\r
def parse_nsd_csar(path, input_parameters=[], a_file=True):\r
\r
def parse_nsd_csar(path, input_parameters=[], a_file=True):\r
+ nsd_object = None\r
+ from toscaparser.tosca_template import ToscaTemplate\r
+ nsd_object = ToscaTemplate(path, input_parameters)\r
+ return nsd_object\r
+\r
\r
def parse_vnfd_csar(path, input_parameters=[], a_file=True):\r
\r
def parse_vnfd_csar(path, input_parameters=[], a_file=True):\r
- pass
\ No newline at end of file
+ vnfd_object = None\r
+ from toscaparser.tosca_template import ToscaTemplate\r
+ vnfd_object = ToscaTemplate(path, input_parameters)\r
+ return vnfd_object
\ No newline at end of file