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/object_store to b082e23
Date Mon, 13 May 2013 23:22:32 GMT
Updated Branches:
  refs/heads/object_store 9777e56e8 -> b082e23af


CLOUDSTACK-2351: object store - UI - restore UI change that was overwriten by the sync from
master branch.


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

Branch: refs/heads/object_store
Commit: b082e23af30d784043f10ff215c2276fd916f73e
Parents: 9777e56
Author: Jessica Wang <jessicawang@apache.org>
Authored: Mon May 13 16:21:43 2013 -0700
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Mon May 13 16:22:20 2013 -0700

----------------------------------------------------------------------
 ui/scripts/system.js |  373 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 329 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b082e23a/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 34ba64c..7b4cb58 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -279,12 +279,12 @@
               pagesize: 1  //specifying pagesize as 1 because we don't need any embedded
objects to be returned here. The only thing we need from API response is "count" property.
             };            
             $.ajax({
-              url: createURL('listHosts'),
+              url: createURL('listImageStores'),
               data: data2,
               success: function(json) {
                 dataFns.systemVmCount($.extend(data, {
-                  secondaryStorageCount: json.listhostsresponse.count ?
-                    json.listhostsresponse.count : 0
+                  secondaryStorageCount: json.listimagestoreresponse.imagestore ?
+                      json.listimagestoreresponse.count : 0
                 }));
               }
             });
@@ -5762,10 +5762,10 @@
                   };                  
 
                   $.ajax({
-                    url: createURL('listHosts' + searchByArgs),
+                    url: createURL('listImageStores' + searchByArgs),
                     data: data,
                     success: function (json) {
-                      args.response.success({ data: json.listhostsresponse.host });
+                      args.response.success({ data: json.listimagestoreresponse.imagestore
});
                     },
                     error: function (json) {
                       args.response.error(parseXMLHttpResponse(json));
@@ -10902,11 +10902,11 @@
             array1.push("&zoneid=" + args.context.zones[0].id);
 
             $.ajax({
-              url: createURL("listHosts&type=SecondaryStorage&page=" + args.page
+ "&pagesize=" + pageSize + array1.join("")),
+              url: createURL("listImageStores&page=" + args.page + "&pagesize=" +
pageSize + array1.join("")),
               dataType: "json",
               async: true,
               success: function(json) {
-                var items = json.listhostsresponse.host;
+                var items = json.listimagestoreresponse.imagestore;
                 args.response.success({
                   actionFilter: secondarystorageActionfilter,
                   data:items
@@ -10921,29 +10921,150 @@
 
               createForm: {
                 title: 'label.add.secondary.storage',
-                fields: {
+                               
+                fields: {                  
+                  provider: {
+                    label: 'Provider',
+                    select: function(args){                  
+                      $.ajax({
+                        url: createURL('listStorageProviders'),
+                        data: {
+                          type: 'image'
+                        },
+                        success: function(json){                  
+                          var objs = json.liststorageprovidersresponse.dataStoreProvider;
                 
+                          var items = [];
+                          if(objs != null) {
+                            for(var i = 0; i < objs.length; i++){
+                              if(objs[i].name == 'NFS')
+                                items.unshift({id: objs[i].name, description: objs[i].name});

+                              else
+                                items.push({id: objs[i].name, description: objs[i].name});

+                            }                    
+                          }                  
+                          args.response.success({
+                            data: items            
+                          });
+                                            
+                          args.$select.change(function() {                           
+                            var $form = $(this).closest('form');
+                            if($(this).val() == "NFS") {
+                              //NFS
+                              $form.find('.form-item[rel=zoneid]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=nfsServer]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=path]').css('display', 'inline-block');
+
+                              //S3
+                              $form.find('.form-item[rel=accesskey]').hide();
+                              $form.find('.form-item[rel=secretkey]').hide();
+                              $form.find('.form-item[rel=bucket]').hide();
+                              $form.find('.form-item[rel=endpoint]').hide();
+                              $form.find('.form-item[rel=usehttps]').hide();
+                              $form.find('.form-item[rel=connectiontimeout]').hide();
+                              $form.find('.form-item[rel=maxerrorretry]').hide();
+                              $form.find('.form-item[rel=sockettimeout]').hide();
+                              $form.find('.form-item[rel=createNfsCache]').hide();
+                              $form.find('.form-item[rel=nfsCacheZoneid]').hide();
+                              $form.find('.form-item[rel=nfsCacheNfsServer]').hide();
+                              $form.find('.form-item[rel=nfsCachePath]').hide();
+                              
+                              //Swift
+                              $form.find('.form-item[rel=url]').hide();
+                              $form.find('.form-item[rel=account]').hide();
+                              $form.find('.form-item[rel=username]').hide();
+                              $form.find('.form-item[rel=key]').hide();
+                            }
+                            else if ($(this).val() == "S3") {
+                              //NFS
+                              $form.find('.form-item[rel=zoneid]').hide();
+                              $form.find('.form-item[rel=nfsServer]').hide();
+                              $form.find('.form-item[rel=path]').hide();
+
+                              //S3
+                              $form.find('.form-item[rel=accesskey]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=secretkey]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=bucket]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=endpoint]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=usehttps]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=connectiontimeout]').css('display',
'inline-block');
+                              $form.find('.form-item[rel=maxerrorretry]').css('display',
'inline-block');
+                              $form.find('.form-item[rel=sockettimeout]').css('display',
'inline-block');                              
+                             
+                              $form.find('.form-item[rel=createNfsCache]').find('input').attr('checked','checked');
+                              $form.find('.form-item[rel=createNfsCache]').css('display',
'inline-block');                         
+                              $form.find('.form-item[rel=nfsCacheZoneid]').css('display',
'inline-block');
+                              $form.find('.form-item[rel=nfsCacheNfsServer]').css('display',
'inline-block');
+                              $form.find('.form-item[rel=nfsCachePath]').css('display', 'inline-block');
+                          
+
+                              //Swift
+                              $form.find('.form-item[rel=url]').hide();
+                              $form.find('.form-item[rel=account]').hide();
+                              $form.find('.form-item[rel=username]').hide();
+                              $form.find('.form-item[rel=key]').hide();
+                            }
+                            else if($(this).val() == "Swift") {
+                              //NFS
+                              $form.find('.form-item[rel=zoneid]').hide();
+                              $form.find('.form-item[rel=nfsServer]').hide();
+                              $form.find('.form-item[rel=path]').hide();
+
+                              //S3
+                              $form.find('.form-item[rel=accesskey]').hide();
+                              $form.find('.form-item[rel=secretkey]').hide();
+                              $form.find('.form-item[rel=bucket]').hide();
+                              $form.find('.form-item[rel=endpoint]').hide();
+                              $form.find('.form-item[rel=usehttps]').hide();
+                              $form.find('.form-item[rel=connectiontimeout]').hide();
+                              $form.find('.form-item[rel=maxerrorretry]').hide();
+                              $form.find('.form-item[rel=sockettimeout]').hide();
+                              $form.find('.form-item[rel=createNfsCache]').hide();
+                              $form.find('.form-item[rel=nfsCacheZoneid]').hide();
+                              $form.find('.form-item[rel=nfsCacheNfsServer]').hide();
+                              $form.find('.form-item[rel=nfsCachePath]').hide();
+                              
+                              //Swift
+                              $form.find('.form-item[rel=url]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=account]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=username]').css('display', 'inline-block');
+                              $form.find('.form-item[rel=key]').css('display', 'inline-block');
+                            }                    
+                          });     
+                          
+                          args.$select.change();
+                        }
+                      });             
+                    }            
+                  },
+                  
+                  
+                  //NFS (begin)
                   zoneid: {
                     label: 'Zone',
                     docID: 'helpSecondaryStorageZone',
                     validation: { required: true },
-                    select: function(args) {
-                      var data = args.context.zones ?
-                      { id: args.context.zones[0].id } : { listAll: true };
-
+                    select: function(args) {                      
                       $.ajax({
                         url: createURL('listZones'),
-                        data: data,
+                        data: { 
+                          listAll: true 
+                        },
                         success: function(json) {
                           var zones = json.listzonesresponse.zone;
 
-                          args.response.success({
-                            data: $.map(zones, function(zone) {
-                              return {
-                                id: zone.id,
-                                description: zone.name
-                              };
-                            })
-                          });
+                          if(zones != null){ //$.map(items, fn) - items can not be null
+                            args.response.success({
+                              data: $.map(zones, function(zone) {
+                                return {
+                                  id: zone.id,
+                                  description: zone.name
+                                };
+                              })
+                            });
+                          }
+                          else {
+                            args.response.success({data: null});
+                          }                          
                         }
                       });
                     }
@@ -10957,30 +11078,194 @@
                     label: 'label.path',
                     docID: 'helpSecondaryStoragePath',
                     validation: { required: true }
-                  }
+                  },
+                  //NFS (end)
+                  
+                  
+                  //S3 (begin)
+                  accesskey: { label: 'label.s3.access_key', validation: { required: true
} },
+                  secretkey: { label: 'label.s3.secret_key', validation: { required: true}
},
+                  bucket: { label: 'label.s3.bucket', validation: { required: true} },
+                  endpoint: { label: 'label.s3.endpoint' },
+                  usehttps: { 
+                    label: 'label.s3.use_https', 
+                    isEditable: true,
+                    isBoolean: true,
+                    isChecked: true,
+                    converter:cloudStack.converters.toBooleanText 
+                  },
+                  connectiontimeout: { label: 'label.s3.connection_timeout' },
+                  maxerrorretry: { label: 'label.s3.max_error_retry' },
+                  sockettimeout: { label: 'label.s3.socket_timeout' },
+                  
+                  createNfsCache: {
+                    label: 'Create NFS Cache Storage',
+                    isBoolean: true,                    
+                    isChecked: true                    
+                  },                  
+                  nfsCacheZoneid: {
+                    dependsOn: 'createNfsCache',
+                    label: 'Zone',                    
+                    validation: { required: true },
+                    select: function(args) {                      
+                      $.ajax({
+                        url: createURL('listZones'),
+                        data: { 
+                          listAll: true 
+                        },
+                        success: function(json) {
+                          var zones = json.listzonesresponse.zone;
+
+                          if(zones != null){ //$.map(items, fn) - items can not be null
+                            args.response.success({
+                              data: $.map(zones, function(zone) {
+                                return {
+                                  id: zone.id,
+                                  description: zone.name
+                                };
+                              })
+                            });
+                          }
+                          else {
+                            args.response.success({data: null});
+                          }                          
+                        }
+                      });
+                    }
+                  },
+                  nfsCacheNfsServer: {
+                    dependsOn: 'createNfsCache',
+                    label: 'label.nfs.server',                    
+                    validation: { required: true }
+                  },
+                  nfsCachePath: {
+                    dependsOn: 'createNfsCache',
+                    label: 'label.path',                    
+                    validation: { required: true }
+                  },                  
+                  //S3 (end)
+                  
+                  
+                  //Swift (begin)
+                  url: { label: 'label.url', validation: { required: true } },
+                  account: { label: 'label.account' },
+                  username: { label: 'label.username' },
+                  key: { label: 'label.key' }
+                  //Swift (end)          
                 }
               },
 
               action: function(args) {
-                var zoneId = args.data.zoneid;
-                var nfs_server = args.data.nfsServer;
-                var path = args.data.path;
-                var url = nfsURL(nfs_server, path);
-
-                $.ajax({
-                  url: createURL("addSecondaryStorage&zoneId=" + zoneId + "&url="
+ todb(url)),
-                  dataType: "json",
-                  success: function(json) {
-                    var item = json.addsecondarystorageresponse.secondarystorage;
-                    args.response.success({
-										  data:item
-										});
-                  },
-                  error: function(XMLHttpResponse) {
-                    var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
-                    args.response.error(errorMsg);
-                  }
-                });
+                if(args.data.provider == 'NFS') {
+                  var zoneid = args.data.zoneid;
+                  var nfs_server = args.data.nfsServer;
+                  var path = args.data.path;
+                  var url = nfsURL(nfs_server, path);
+                  
+                  var data = {
+                    provider: args.data.provider,
+                    zoneid: zoneid,
+                    url: url                    
+                  };
+                    
+                  $.ajax({
+                    url: createURL('addImageStore'),
+                    data: data,
+                    success: function(json) {
+                      var item = json.addimagestoreresponse.secondarystorage;
+                      args.response.success({
+                        data:item
+                      });
+                    },
+                    error: function(XMLHttpResponse) {
+                      var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                      args.response.error(errorMsg);
+                    }
+                  });
+                }
+                else if(args.data.provider == 'S3') {                  
+                  $.ajax({
+                    url: createURL('addImageStore'),
+                    data: {
+                      provider: args.data.provider,                                     
     
+                      'details[0].key': 'accesskey',
+                      'details[0].value': args.data.accesskey,                          
                 
+                      'details[1].key': 'secretkey',
+                      'details[1].value': args.data.secretkey,                          
                 
+                      'details[2].key': 'bucket',
+                      'details[2].value': args.data.bucket,                             
              
+                      'details[3].key': 'endpoint',
+                      'details[3].value': args.data.endpoint,                           
              
+                      'details[4].key': 'usehttps',
+                      'details[4].value': (args.data.usehttps != null && args.data.usehttps
== 'on' ? 'true' : 'false'),    
+                      'details[5].key': 'connectiontimeout',
+                      'details[5].value': args.data.connectiontimeout,                  
                       
+                      'details[6].key': 'maxerrorretry',
+                      'details[6].value': args.data.maxerrorretry,                      
                    
+                      'details[7].key': 'sockettimeout',
+                      'details[7].value': args.data.sockettimeout
+                    },
+                    success: function(json) {
+                      havingS3 = true;
+                      var item = json.addimagestoreresponse.secondarystorage;
+                      args.response.success({
+                        data:item
+                      });
+                    },
+                    error: function(json) {
+                      args.response.error(parseXMLHttpResponse(json));
+                    }
+                  });
+                              
+                  if(args.data.createNfsCache == 'on') {
+                    var zoneid = args.data.nfsCacheZoneid;
+                    var nfs_server = args.data.nfsCacheNfsServer;
+                    var path = args.data.nfsCachePath;
+                    var url = nfsURL(nfs_server, path);
+                    
+                    var nfsCacheData = {
+                      provider: 'NFS',
+                      zoneid: zoneid,
+                      url: url                    
+                    };        
+                    
+                    $.ajax({
+                      url: createURL('createCacheStore'),
+                      data: nfsCacheData,
+                      success: function(json) {
+                        //do nothing                        
+                      },
+                      error: function(json) {
+                        args.response.error(parseXMLHttpResponse(json));
+                      }
+                    }); 
+                  }   
+                }
+                else if(args.data.provider == 'Swift') {
+                  $.ajax({
+                    url: createURL('addImageStore'),
+                    data: {
+                      provider: args.data.provider,
+                      url: args.data.url,
+                      'details[0].key': 'account',
+                      'details[0].value': args.data.account,
+                      'details[1].key': 'username',
+                      'details[1].value': args.data.username,
+                      'details[2].key': 'key',
+                      'details[2].value': args.data.key                      
+                    },
+                    success: function(json) {
+                      havingSwift = true;
+                      var item = json.addimagestoreresponse.secondarystorage;
+                      args.response.success({
+                        data:item
+                      });
+                    },
+                    error: function(json) {
+                      args.response.error(parseXMLHttpResponse(json));
+                    }
+                  });
+                }                 
               },
 
               notification: {
@@ -11015,7 +11300,7 @@
                 },
                 action: function(args) {
                   $.ajax({
-                    url: createURL("deleteHost&id=" + args.context.secondarystorages[0].id),
+                    url: createURL("deleteImageStore&id=" + args.context.secondarystorages[0].id),
                     dataType: "json",
                     async: true,
                     success: function(json) {
@@ -11045,11 +11330,11 @@
 
                 dataProvider: function(args) {								  
 									$.ajax({
-										url: createURL("listHosts&type=SecondaryStorage&id=" + args.context.secondarystorages[0].id),
+										url: createURL("listImageStores&id=" + args.context.secondarystorages[0].id),
 										dataType: "json",
 										async: true,
 										success: function(json) {										  
-											var item = json.listhostsresponse.host[0];
+										  var item = json.listimagestoreresponse.imagestore[0];
 											args.response.success({
 												actionFilter: secondarystorageActionfilter,
 												data:item


Mime
View raw message