Better error reporting on instantiate page
[osm/UI.git] / skyquake / plugins / launchpad / src / instantiate / instantiateStore.js
index 3ec2a80..0d9e1b6 100644 (file)
@@ -140,7 +140,7 @@ class LaunchNetworkServiceStore {
             Alt.actions.global.showNotification.defer({type: 'warning', msg: 'One or more VIM accounts have failed to connect'});
         }
         if(cloudAccounts && cloudAccounts.length > 0) {
-            newState.selectedCloudAccount = cloudAccounts[0];
+            newState.selectedCloudAccount = newState.cloudAccounts[0];
             if (cloudAccounts[0]['account-type'] == 'openstack') {
                 newState.displayPlacementGroups = true;
             } else {
@@ -189,10 +189,13 @@ class LaunchNetworkServiceStore {
         });
         return window.location.hash = 'launchpad/' + tokenizedHash[2];
     }
-    launchNSRError(error) {
+    launchNSRError(data) {
         var msg = 'Something went wrong while trying to instantiate. Check the error logs for more information';
-        if(error) {
-            msg = error;
+        if(data) {
+            msg = data;
+        }
+        if (data.error) {
+            msg = data.error;
         }
         Alt.actions.global.showNotification.defer(msg);
         Alt.actions.global.hideScreenLoader.defer();
@@ -707,6 +710,10 @@ class LaunchNetworkServiceStore {
         if (this.state.ro && this.state.ro['account-type'] == 'openmano') {
             payload['om-datacenter'] = this.state.dataCenterID;
         } else {
+            if(!this.state.selectedCloudAccount) {
+                Alt.actions.global.showNotification.defer("No VIM Account Selected");
+                return;
+            }
             payload["cloud-account"] = this.state.selectedCloudAccount.name;
         }
         if (this.state.hasConfigureNSD) {