+class VnfpkgUploadThread(threading.Thread):
+ def __init__(self, data, vnfPkgId):
+ threading.Thread.__init__(self)
+ self.vnfPkgId = vnfPkgId
+ self.data = data
+
+ def run(self):
+ try:
+ self.upload_vnfPkg_from_uri()
+ except CatalogException as e:
+ logger.error(e.message)
+ except Exception as e:
+ logger.error(e.message)
+ logger.error(traceback.format_exc())
+ logger.error(str(sys.exc_info()))
+
+ def upload_vnfPkg_from_uri(self):
+ logger.debug("UploadVnf %s" % self.vnfPkgId)
+ uri = ignore_case_get(self.data, "addressInformation")
+ upload_path = os.path.join(CATALOG_ROOT_PATH, self.vnfPkgId)
+ if not os.path.exists(upload_path):
+ os.makedirs(upload_path, 0o777)
+ r = urllib2.Request(uri)
+ req = urllib2.urlopen(r)
+
+ upload_file_name = os.path.join(upload_path, os.path.basename(uri))
+ save_file = open(upload_file_name, "wb")
+ save_file.write(req.read())
+ save_file.close()
+ req.close()
+
+