Fix reversed logic 53/10053/1
authorbeierlm <mark.beierl@canonical.com>
Sat, 28 Nov 2020 17:04:16 +0000 (12:04 -0500)
committerbeierlm <mark.beierl@canonical.com>
Sat, 28 Nov 2020 17:04:21 +0000 (12:04 -0500)
Fixes code to call sol006 if catalog found in descriptor,
not to call original code.

Change-Id: I20cf3b293a15457fbb4339dce36b788d71f4cc74
Signed-off-by: beierlm <mark.beierl@canonical.com>
osmclient/common/package_tool.py

index ac0421f..7d582ec 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from osmclient.common.exceptions import ClientException
-import os
 import glob
-import time
-import tarfile
 import hashlib
-from osm_im.validation import Validation as validation_im
-from jinja2 import Environment, PackageLoader
-import subprocess
+import logging
+import os
 import shutil
+import subprocess
+import tarfile
+import time
+
+from jinja2 import Environment, PackageLoader
+from osm_im.validation import Validation as validation_im
+from osmclient.common.exceptions import ClientException
 import yaml
-import logging
 
 
 class PackageTool(object):
@@ -284,18 +285,18 @@ class PackageTool(object):
                 listCharms = self.charms_search(file, 'ns')
         print("List of charms in the descriptor: {}".format(listCharms))
         if not descriptor_file:
-            raise ClientException ('descriptor name is not correct in: {}'.format(package_folder))
+            raise ClientException('descriptor name is not correct in: {}'.format(package_folder))
         if listCharms and not skip_charm_build:
             for charmName in listCharms:
-                if os.path.isdir('{}/charms/layers/{}'.format(package_folder,charmName)):
+                if os.path.isdir('{}/charms/layers/{}'.format(package_folder, charmName)):
                     print('Building charm {}/charms/layers/{}'.format(package_folder, charmName))
                     self.charm_build(package_folder, charmName)
                     print('Charm built: {}'.format(charmName))
                 else:
-                    if not os.path.isdir('{}/charms/{}'.format(package_folder,charmName)):
-                        raise ClientException ('The charm: {} referenced in the descriptor file '
-                                               'is not present either in {}/charms or in {}/charms/layers'.
-                                               format(charmName, package_folder,package_folder))
+                    if not os.path.isdir('{}/charms/{}'.format(package_folder, charmName)):
+                        raise ClientException('The charm: {} referenced in the descriptor file '
+                                              'is not present either in {}/charms or in {}/charms/layers'.
+                                              format(charmName, package_folder, package_folder))
         self._logger.debug("Return list of charms: {}".format(listCharms))
         return listCharms
 
@@ -426,13 +427,13 @@ class PackageTool(object):
                             shutil.copytree(s_charm, d_temp, symlinks=True, ignore=ignore)
                             self._logger.debug("DONE")
                     else:
-                        self._logger.debug("Copying tree: {} -> {}".format(s,d))
+                        self._logger.debug("Copying tree: {} -> {}".format(s, d))
                         shutil.copytree(s, d, symlinks=True, ignore=ignore)
                         self._logger.debug("DONE")
                 else:
                     if item in ignore_patterns:
                         continue
-                    self._logger.debug("Copying file: {} -> {}".format(s,d))
+                    self._logger.debug("Copying file: {} -> {}".format(s, d))
                     shutil.copy2(s, d)
                     self._logger.debug("DONE")
         return directory_name, package_name
@@ -441,10 +442,10 @@ class PackageTool(object):
         self._logger.debug("")
         with open("{}".format(descriptor_file)) as yaml_desc:
             descriptor_dict = yaml.safe_load(yaml_desc)
-            if "catalog" in descriptor_dict: # Match OSM-IM vnfd-catalog and nsd-catalog
-                charms_list = self._charms_search_on_osm_im_dict(descriptor_dict, desc_type)
-            else:
+            if "catalog" in descriptor_dict:  # Match OSM-IM vnfd-catalog and nsd-catalog
                 charms_list = self._charms_search_on_sol006_dict(descriptor_dict, desc_type)
+            else:
+                charms_list = self._charms_search_on_osm_im_dict(descriptor_dict, desc_type)
 
         return charms_list
 
@@ -482,4 +483,3 @@ class PackageTool(object):
                             if 'charm' in v3:
                                 charms_list.append((v3['charm']))
         return charms_list
-