cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/ui-cisco-asa1000v-support to 6323b2e
Date Wed, 08 May 2013 19:05:23 GMT
Updated Branches:
  refs/heads/ui-cisco-asa1000v-support c1e9e4de6 -> 6323b2e71


CLOUDSTACK-1816: Cisco VNMC ASA1000v - UI - implement Add Cisco VNMC action.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6323b2e7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6323b2e7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6323b2e7

Branch: refs/heads/ui-cisco-asa1000v-support
Commit: 6323b2e71b0d1295fb91ba8735130973b484cdbe
Parents: c1e9e4d
Author: Jessica Wang <jessicawang@apache.org>
Authored: Wed May 8 12:02:30 2013 -0700
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Wed May 8 12:04:37 2013 -0700

----------------------------------------------------------------------
 .../vnmcNetworkProvider/vnmcNetworkProvider.js     |  190 ++++++++++++++-
 1 files changed, 182 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6323b2e7/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
----------------------------------------------------------------------
diff --git a/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js b/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
index 6add2c5..220a0b9 100644
--- a/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
+++ b/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
@@ -33,14 +33,188 @@
           'Disabled': 'off'
         }}
       },
-      dataProvider: function(args) {
-        args.response.success({
-          data: [
-            { name: 'device1', ipaddress: '192.168.1.12', state: 'Enabled' },
-            { name: 'device2', ipaddress: '192.168.1.13', state: 'Disabled' },
-            { name: 'device3', ipaddress: '192.168.1.14', state: 'Enabled' }
-          ]
-        });
+          
+      actions: {
+        add: {
+          label: 'Add VNMC device',
+
+          messages: {
+            /*
+            confirm: function(args) {
+              return 'Add VNMC device';
+            },
+            */
+            notification: function(args) {
+              return 'Add VNMC device';
+            }
+          },
+
+          createForm: {
+            title: 'Add VNMC device',
+            fields: {
+              hostname: {
+                label: 'label.host',                
+                validation: { required: true }
+              },
+              username: {
+                label: 'label.username',                
+                validation: { required: true }
+              },
+              password: {
+                label: 'label.password', 
+                isPassword: true,
+                validation: { required: true }
+              }            
+            }
+          },
+
+          action: function(args) {
+            //debugger;
+            $.ajax({
+              url: createURL('listNetworkServiceProviders'),
+              data: {
+                name: 'CiscoVnmc',
+                physicalnetworkid: args.context.physicalNetworks[0].id      
+              },
+              success: function(json){
+                //debugger;
+                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                if(items != null && items.length > 0) {
+                  var ciscoVnmcProvider = items[0];
+                  if(ciscoVnmcProvider.state == 'Enabled') {
+                    addCiscoVnmcResourceFn();                    
+                  }
+                  else {                    
+                    enableCiscoVnmcProviderFn(ciscoVnmcProvider);                    
+                  }                  
+                }   
+                else {                  
+                  $.ajax({
+                    url: createURL("addNetworkServiceProvider"),
+                    data: {
+                      name: 'CiscoVnmc',
+                      physicalnetworkid: args.context.physicalNetworks[0].id            
   
+                    },              
+                    success: function(json) {
+                      var jobId = json.addnetworkserviceproviderresponse.jobid;         
              
+                      var addVnmcProviderIntervalID = setInterval(function() {  
+                        $.ajax({
+                          url: createURL("queryAsyncJobResult&jobId="+jobId),
+                          dataType: "json",
+                          success: function(json) {
+                            var result = json.queryasyncjobresultresponse;
+                            //debugger;
+                            if (result.jobstatus == 0) {
+                              return; //Job has not completed
+                            }
+                            else {
+                              clearInterval(addVnmcProviderIntervalID ); 
+                              if (result.jobstatus == 1) {
+                                //nspMap["CiscoVnmc"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
+                                var ciscoVnmcProvider = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
 
+                                enableCiscoVnmcProviderFn(ciscoVnmcProvider);    
+                              }
+                              else if (result.jobstatus == 2) {
+                                args.response.error(_s(result.jobresult.errortext));    
                     
+                              }
+                            }
+                          },
+                          error: function(XMLHttpResponse) {
+                            args.response.error(parseXMLHttpResponse(data));
+                          }
+                        });
+                      }, g_queryAsyncJobResultInterval);    
+                    }
+                  });                   
+                }
+              }
+            });
+            //debugger;      
+            
+            var enableCiscoVnmcProviderFn = function(ciscoVnmcProvider){              
+              $.ajax({
+                url: createURL('updateNetworkServiceProvider'),
+                data: {
+                  id: ciscoVnmcProvider.id,
+                  state: 'Enabled'
+                },
+                success: function(json) {
+                  var jid = json.updatenetworkserviceproviderresponse.jobid;
+                  var enableVnmcProviderIntervalID = setInterval(function(){
+                    $.ajax({
+                      url: createURL('queryAsyncJobResult'),
+                      data: {
+                        jobid: jid
+                      },
+                      success: function(json){
+                        var result = json.queryasyncjobresultresponse;
+                        if (result.jobstatus == 0) {
+                          return; //Job has not completed
+                        }
+                        else {
+                          clearInterval(enableVnmcProviderIntervalID);
+                          if (result.jobstatus == 1) {
+                            addCiscoVnmcResourceFn();
+                          }                                      
+                          else if (result.jobstatus == 2) {
+                            args.response.error(_s(result.jobresult.errortext));        
                 
+                          }                                      
+                        }
+                      }
+                    });                                
+                  }, g_queryAsyncJobResultInterval);                               
+                }
+              });              
+            }                        
+            
+            var addCiscoVnmcResourceFn = function(){
+              //debugger;
+              var data = {
+                physicalnetworkid: args.context.physicalNetworks[0].id,
+                hostname: args.data.hostname,
+                username: args.data.username,
+                password: args.data.password
+              };                             
+             
+              $.ajax({
+                url: createURL('addCiscoVnmcResource'),
+                data: data,                 
+                success: function(json) {
+                  //debugger;
+                  var item = json.addciscovnmcresourceresponse.ciscovnmcresource;
+                  args.response.success({data: item});
+                },
+                error: function(data) {
+                  args.response.error(parseXMLHttpResponse(data));
+                }
+              });
+            }
+          },
+
+          notification: {
+            poll: function(args) {
+              args.complete();
+            }
+          }
+        }
+      },
+           
+      dataProvider: function(args) {        
+        $.ajax({
+          url: createURL('listCiscoVnmcResources'),
+          data: {
+            physicalnetworkid: args.context.physicalNetworks[0].id
+          },
+          success: function(json){   
+            args.response.success({
+              data: [
+                { name: 'device1', ipaddress: '192.168.1.12', state: 'Enabled' },
+                { name: 'device2', ipaddress: '192.168.1.13', state: 'Disabled' },
+                { name: 'device3', ipaddress: '192.168.1.14', state: 'Enabled' }
+              ]
+            });            
+          }
+        });  
       }
     };
 


Mime
View raw message