update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[osm/SO.git] / rwlaunchpad / plugins / rwpkgmgr / rift / tasklets / rwpkgmgr / downloader / url.py
index ec1abf0..e708012 100644 (file)
@@ -1,3 +1,21 @@
+# 
+#   Copyright 2016 RIFT.IO Inc
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   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.
+#
+
+import gi
+
 import rift.downloader as downloader
 from gi.repository import RwPkgMgmtYang
 
@@ -15,7 +33,7 @@ class PackageFileDownloader(downloader.UrlDownloader):
         }
 
     @classmethod
-    def from_rpc_input(cls, rpc_input, file_obj, proxy, log=None, auth=None):
+    def from_rpc_input(cls, rpc_input, file_obj, proxy, log=None, auth=None, project=None):
         """Convenience class to set up an instance form RPC data
         """
         url_downloader = cls(
@@ -23,10 +41,13 @@ class PackageFileDownloader(downloader.UrlDownloader):
             rpc_input.package_id,
             rpc_input.package_path,
             rpc_input.package_type,
+            rpc_input.vnfd_file_type, 
+            rpc_input.nsd_file_type,
             auth=auth,
             proxy=proxy,
             file_obj=file_obj,
-            log=log)
+            log=log,
+            project=project)
 
         return url_downloader
 
@@ -35,12 +56,15 @@ class PackageFileDownloader(downloader.UrlDownloader):
                  package_id,
                  package_path,
                  package_type,
+                 vnfd_file_type, 
+                 nsd_file_type,
                  proxy,
                  file_obj=None,
                  delete_on_fail=True,
                  decompress_on_fly=False,
                  auth=None,
-                 log=None):
+                 log=None,
+                 project=None):
         super().__init__(
                 url,
                 file_obj=file_obj,
@@ -52,11 +76,14 @@ class PackageFileDownloader(downloader.UrlDownloader):
         self.package_id = package_id
         self.package_type = package_type
         self.package_path = package_path
+        self.package_file_type = vnfd_file_type.lower() \
+                if package_type == 'VNFD' else nsd_file_type.lower()
         self.proxy = proxy
+        self.project = project
 
     def convert_to_yang(self):
 
-        job = RwPkgMgmtYang.DownloadJob.from_dict({
+        job = RwPkgMgmtYang.YangData_RwProject_Project_DownloadJobs_Job.from_dict({
                 "url": self.meta.url,
                 "download_id": self.meta.download_id,
                 "package_id": self.package_id,
@@ -91,11 +118,13 @@ class PackageFileDownloader(downloader.UrlDownloader):
                 self.meta.filepath,
                 self.package_type,
                 self.package_id,
-                self.package_path)
+                self.package_path, 
+                self.package_file_type,
+                self.project)
 
         except Exception as e:
             self.log.exception(e)
-            self.job.detail = str(e)
+            self.meta.detail = str(e)
             self.download_failed()
             return