From 1d47910c32da1db8fd23d2eaa76315aca21dab93 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 7 Sep 2010 10:24:56 -0700 Subject: [PATCH 01/13] bug 6044: Added functionality to ensure vms belonging to deleted accounts do not show up status 6044: resolved fixed --- server/src/com/cloud/api/commands/ListVMsCmd.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/src/com/cloud/api/commands/ListVMsCmd.java b/server/src/com/cloud/api/commands/ListVMsCmd.java index add2a51445d..68ffa17b314 100644 --- a/server/src/com/cloud/api/commands/ListVMsCmd.java +++ b/server/src/com/cloud/api/commands/ListVMsCmd.java @@ -182,6 +182,14 @@ public class ListVMsCmd extends BaseCmd { } for (UserVm vmInstance : virtualMachines) { + + //if the account is deleted, do not return the user vm + Account currentVmAccount = getManagementServer().getAccount(vmInstance.getAccountId()); + if(currentVmAccount.getRemoved()!=null) + { + continue; //not returning this vm + } + List> vmData = new ArrayList>(); AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("vm_instance", vmInstance.getId()); if(asyncJob != null) { From 47dbeaa87848c3ae60ba5c7ce1ee60d4ae08cee1 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Sep 2010 10:40:16 -0700 Subject: [PATCH 02/13] new UI - when accordion menu is changed, collapse submenu instance group under menu instance. --- ui/new/scripts/cloud.core.init.js | 6 +++++- ui/new/scripts/cloud.core.instance.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/new/scripts/cloud.core.init.js b/ui/new/scripts/cloud.core.init.js index c3f9a1ffb10..732adf89029 100755 --- a/ui/new/scripts/cloud.core.init.js +++ b/ui/new/scripts/cloud.core.init.js @@ -9,7 +9,11 @@ $(document).ready(function() { if(ui.newContent.length==0) //collapse ui.oldHeader.find("#arrow_icon").removeClass("open").addClass("close"); else //expand - ui.newHeader.find("#arrow_icon").removeClass("close").addClass("open"); + ui.newHeader.find("#arrow_icon").removeClass("close").addClass("open"); + + //collapse submenu instanceGroup under menu instance + $("#leftmenu_instance_group_header").find("#arrow_icon").removeClass("open").addClass("close"); + $("#leftmenu_instance_group_container").empty(); } }); $("#accordion_menu").show(); diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index d1dc3781820..78ce2d97683 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -452,7 +452,7 @@ function clickInstanceGroupHeader($arrowIcon) { var instance = instances[i]; var instanceGroup = instance.group; if(instanceGroup == null || instanceGroup == "") - instanceGroup = "(no group name)"; + instanceGroup = noGroupName; if(instanceGroup != groupName) continue; var $midmenuItemVm1 = $midmenuItemVm.clone(); From a6afbbe341623ae3d9532a647951cb1ac4f448ec Mon Sep 17 00:00:00 2001 From: NIKITA Date: Tue, 7 Sep 2010 10:55:00 -0700 Subject: [PATCH 03/13] Volume UI for instance --- ui/new/css/main.css | 40 +++++++++++++++++++--- ui/new/images/gird_actions.gif | Bin 0 -> 1110 bytes ui/new/images/gird_actions_hover.gif | Bin 0 -> 1106 bytes ui/new/images/grid_headerbg.gif | Bin 0 -> 182 bytes ui/new/jsp/tab_instance.jsp | 49 ++++++++++++++++++++++++++- 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 ui/new/images/gird_actions.gif create mode 100644 ui/new/images/gird_actions_hover.gif create mode 100644 ui/new/images/grid_headerbg.gif diff --git a/ui/new/css/main.css b/ui/new/css/main.css index a4f239d1334..1c6ac42a7d4 100644 --- a/ui/new/css/main.css +++ b/ui/new/css/main.css @@ -1467,7 +1467,7 @@ a:visited { height:auto; float:left; margin:0 0 5px 10px; - padding:0; + padding:0 0 10px 0; list-style:none; } @@ -1479,7 +1479,7 @@ a:visited { color:#CCC; font-size:11px; font-weight:normal; - margin:6px 0 0 0; + margin:8px 0 0 0; padding:0; list-style:none; } @@ -1998,7 +1998,39 @@ a:visited { color:#a90000; } -.thanks box { - +.grid_header { + width:100%; + height:20px; + float:left; + background:url(../images/grid_headerbg.gif) repeat-x top left; + margin:0; + padding:0; } +.grid_header_title { + width:auto; + height:auto; + float:left; + margin:4px 0 0 10px; + display:inline; + color:#434343; + text-align:left; + font-weight:bold; + font-size:11px; + padding:0; +} + +.grid_actionbox { + width:33px; + height:15px; + float:right; + background:url(../images/gird_actions.gif) no-repeat top left; + margin:2px 10px 0 0; + padding:0; + cursor:pointer; + cursor:hand; +} + +.grid_actionbox:hover { + background:url(../images/gird_actions_hover.gif) no-repeat top left; +} \ No newline at end of file diff --git a/ui/new/images/gird_actions.gif b/ui/new/images/gird_actions.gif new file mode 100644 index 0000000000000000000000000000000000000000..18a377f5704032851c0aebfa67e8b3376291d8f5 GIT binary patch literal 1110 zcmZ?wbhEHbRAk_1_|Cxa|NsAY@7{g*@ZrsyH~;?q`}FD4moH!b{{8#y+qWM-e*F6N z>-X>96%`e)UcLJI_3OuvA5WY(F=fh>Q>RYdxN+m*!-ub5zkc-SQF46Z#EBE1Jb7~A z!iBSE&wl^@{q5Vg@87?#t*)6fch1X~FTGq`bToA;%PY^HKX>uMrPk)=bLY+#6ciK} z6*-t&2Kf2Sn>+XHnX?Yo)=QTzO-o7E)zN+W^y%*1yS8lE*45P&9~;-$&~#w`f#u7W zFIloYE;_cZrYb)_KPxj6sKU$1v7x>pCNga1%sH(MjSChm`10jzLR7T3yVvulPkOq$ zU7VfU+S;BxeE9R{Pisp{T}_?2bLV=yy4F6GJ;{m5VL?HA_wHM| zWJza7r=pDF=~Jf<9Xd2=(uD2Xw#}F^tF)-7thi+1!iC?yea}iuPfbp)t*LqO;>EP- z({5b9o}XVB77(y{_3G(Ur*B%jHZLn{>Xa$P`2`J)4fpQdYinr<3kdG$Xpf7IY-(zn zHf`F&d-oPCSU73Yq(6WDtY5u`VH6BR2q^w!0b8pBB0+hAf#W{|I}gW%2Mi6(9Ku>L z6$SxK3{27-3L6BxdyRRFl~fcKI5Kx}9Q+~ZkmA#+9Bq=Oa^ZpFA^oyP4L2AMd&t|S zg&5U5XlU@C@2jMR`C|pN;x$tl%b4&K`~Ft)OR4z05LmG9@9!U!}s_-eB1Br`7?(OGwHwv zAPfM7g@sb76oz5BTwYvU%x1G&TU$jUkw74*s;c7i`CKlSAPAjKXEK?*UT<}Eb$xxk zP$;adtelydS;ld16l-p7=J9w2gTZL|v=GJH+S+=1dnFP{cXzjcm5|9~9*?KAwA5@i zcXf45O-LAGO3pxDDeVT#!;8F;~I2?}tgHfsK3*v;`AsS|4 zhjHBDa7=!mcDY=Wi1US13jE){EI>yofA!ga_~#Qq0s*8QgSAWwSd*}6=k@XuQhXvQ z?{>OY@hq>FvJc8RNn>sSn9_8*^0_vTPr1-^E{mDpn7e~7rz4rhj}J35sFUZxwawdD z2dR%XWzi^-bE546umc<;ZSz1qVBBa@W=`iZoB7Eue%#HJB;nW)DKU);vtYaQ!c|34 zQf|x9u%TA5HnhEPhCP~sZn4$}%w#y`zqC|hzlWaS-G zc2SOk=YCteE}`J%o6s{Vv^#%Qe(B=1UO_6Yh!H4(!)uOT2EkXOFNYfr?zy*%F*vP{ zCyyp)@lM@Z-@gBfQ1h5JpuX!*+mf(1HUEZIe4=c=i81ovK6&F-lBqra-5?fQbEL6k X4%UHGG9_ycq-;)22a^LSRN&}u5dOiJ literal 0 HcmV?d00001 diff --git a/ui/new/images/grid_headerbg.gif b/ui/new/images/grid_headerbg.gif new file mode 100644 index 0000000000000000000000000000000000000000..9004bfa474b6c93210d51ef5fa5dc9167cb79bdd GIT binary patch literal 182 zcmZ?wbhEHbWMdFvIKsei_UzeLuU?%xb?VHSGgq!$xqkinn>TMBJa};a{P`zOp4_^1 z>(Zr5`}XZSapJ_mg9kr;{CM=}(Ytr=K7aoF{rmR}L;%H~EMQeSAQEIJ1FP`^<-Xud zsSK$#Yo6@$)R8Zdy}M)4d)N2E2OcDOxJdLjEGasW!!_?hTM5_7DA^l2$)|Z48LR <%=t.t("Statistics")%> -
+ + From d801ead9f91d6cbe3b451ddf98abbeff7872885a Mon Sep 17 00:00:00 2001 From: NIKITA Date: Tue, 7 Sep 2010 11:00:38 -0700 Subject: [PATCH 04/13] no major change --- ui/index.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/index.jsp b/ui/index.jsp index 8be1f714663..3fe04850c2a 100755 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -25,7 +25,7 @@ long milliseconds = new Date().getTime(); - Default Cloud.com styling of the site. This file contains the easiest portion of the site that can be styled to your companie's need such as logo, top navigation, and dialogs. --> - + From 0ea1f370b8336b78db27c1661395097eabfa7c9f Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 7 Sep 2010 11:08:38 -0700 Subject: [PATCH 05/13] bug 5147: Adding the check to block create and destroy of system resources whilst the storage pool is in maintenance mode. This is based on checking if the pool is in UP state --- .../storage/allocator/AbstractStoragePoolAllocator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java index e0ae7a9e756..d29e51d11cf 100644 --- a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java @@ -142,7 +142,12 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement return false; } - + //if pool is NOT in up state, return false + if(!pool.getStatus().equals(com.cloud.host.Status.Up))//this is the pool status + { + return false; + } + // Check that the pool type is correct if (!poolIsCorrectType(dskCh, pool, vm, offering)) { return false; From 1a824bd19594676094ef6900fc6fb9ed6f1a5a63 Mon Sep 17 00:00:00 2001 From: alena Date: Tue, 7 Sep 2010 11:25:06 -0700 Subject: [PATCH 06/13] 1) Use transactions instead of global lock in AlertManagerImpl, StatsCollector. 2) Removed GlobalLock on read available capacity from UserConcentratedAllocator --- .../impl/UserConcentratedAllocator.java | 35 ++++---------- .../src/com/cloud/alert/AlertManagerImpl.java | 41 ++++++++--------- .../src/com/cloud/server/StatsCollector.java | 46 ++++++++----------- 3 files changed, 47 insertions(+), 75 deletions(-) diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index cab971738e1..ba612b71fc2 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -37,7 +37,6 @@ import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.dao.HostPodDao; import com.cloud.offering.NetworkOffering; -import com.cloud.offering.NetworkOffering.GuestIpType; import com.cloud.offering.ServiceOffering; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; @@ -50,7 +49,6 @@ import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.Inject; -import com.cloud.utils.db.GlobalLock; import com.cloud.utils.db.SearchCriteria; import com.cloud.vm.State; import com.cloud.vm.UserVmVO; @@ -76,7 +74,6 @@ public class UserConcentratedAllocator implements PodAllocator { @Inject VMInstanceDao _vmInstanceDao; Random _rand = new Random(System.currentTimeMillis()); - private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check"); private int _hoursToSkipStoppedVMs = 24; private int _secStorageVmRamSize = 1024; @@ -156,30 +153,14 @@ public class UserConcentratedAllocator implements PodAllocator { private boolean dataCenterAndPodHasEnoughCapacity(long dataCenterId, long podId, long capacityNeeded, short capacityType, long[] hostCandidate) { List capacities = null; - if (m_capacityCheckLock.lock(120)) { // 2 minutes - try { - SearchCriteria sc = _capacityDao.createSearchCriteria(); - sc.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType); - sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, dataCenterId); - sc.addAnd("podId", SearchCriteria.Op.EQ, podId); - capacities = _capacityDao.search(sc, null); - } finally { - m_capacityCheckLock.unlock(); - } - } else { - s_logger.error("Unable to acquire synchronization lock for pod allocation"); - - // we now try to enforce reservation-style allocation, waiting time has been adjusted - // to 2 minutes - return false; - -/* - // If we can't lock the table, just return that there is enough capacity and allow instance creation to fail on the agent - // if there is not enough capacity. All that does is skip the optimization of checking for capacity before sending the - // command to the agent. - return true; -*/ - } + + SearchCriteria sc = _capacityDao.createSearchCriteria(); + sc.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType); + sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, dataCenterId); + sc.addAnd("podId", SearchCriteria.Op.EQ, podId); + s_logger.trace("Executing search"); + capacities = _capacityDao.search(sc, null); + s_logger.trace("Done with a search"); boolean enoughCapacity = false; if (capacities != null) { diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 033b1ba3282..9250bb86557 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -65,8 +65,9 @@ import com.cloud.storage.dao.VolumeDao; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentLocator; -import com.cloud.utils.db.GlobalLock; +import com.cloud.utils.db.DB; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; import com.cloud.vm.ConsoleProxyVO; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.SecondaryStorageVmVO; @@ -118,8 +119,6 @@ public class AlertManagerImpl implements AlertManager { private double _publicIPCapacityThreshold = 0.75; private double _privateIPCapacityThreshold = 0.75; - private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check"); - @Override public boolean configure(String name, Map params) throws ConfigurationException { _name = name; @@ -319,7 +318,7 @@ public class AlertManagerImpl implements AlertManager { } } - @Override + @Override @DB public void recalculateCapacity() { // FIXME: the right way to do this is to register a listener (see RouterStatsListener, VMSyncListener) // for the vm sync state. The listener model has connects/disconnects to keep things in sync much better @@ -435,25 +434,23 @@ public class AlertManagerImpl implements AlertManager { newCapacities.add(newPrivateIPCapacity); } - if (m_capacityCheckLock.lock(5)) { // 5 second timeout - try { - // delete the old records - _capacityDao.clearNonStorageCapacities(); + Transaction txn = Transaction.currentTxn(); + try { + txn.start(); + // delete the old records + _capacityDao.clearNonStorageCapacities(); - for (CapacityVO newCapacity : newCapacities) { - _capacityDao.persist(newCapacity); - } - } finally { - m_capacityCheckLock.unlock(); - } - - if (s_logger.isTraceEnabled()) { - s_logger.trace("done recalculating system capacity"); - } - } else { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Skipping capacity check, unable to lock the capacity table for recalculation."); - } + for (CapacityVO newCapacity : newCapacities) { + s_logger.trace("Executing capacity update"); + _capacityDao.persist(newCapacity); + s_logger.trace("Done with capacity update"); + } + txn.commit(); + } catch (Exception ex) { + txn.rollback(); + s_logger.error("Unable to start transaction for capacity update"); + }finally { + txn.close(); } } diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 58cfe27cdf8..668d4674171 100644 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -61,6 +61,7 @@ import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.db.GlobalLock; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; import com.cloud.vm.UserVmManager; import com.cloud.vm.UserVmVO; import com.cloud.vm.VmStats; @@ -99,7 +100,7 @@ public class StatsCollector { long storageStatsInterval = -1L; long volumeStatsInterval = -1L; - private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check"); + //private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check"); public static StatsCollector getInstance() { return s_instance; @@ -335,32 +336,25 @@ public class StatsCollector { // _capacityDao.persist(capacity); } - if (m_capacityCheckLock.lock(5)) { // 5 second timeout - if (s_logger.isTraceEnabled()) { - s_logger.trace("recalculating system storage capacity"); - } - try { - // now update the capacity table with the new stats - // FIXME: the right way to do this is to register a listener (see RouterStatsListener) - // for the host stats, send the WatchCommand at a regular interval - // to collect the stats from an agent and update the database as needed. The - // listener model has connects/disconnects to keep things in sync much better - // than this model right now - _capacityDao.clearStorageCapacities(); + Transaction txn = Transaction.open(Transaction.CLOUD_DB); + try { + if (s_logger.isTraceEnabled()) { + s_logger.trace("recalculating system storage capacity"); + } + txn.start(); + _capacityDao.clearStorageCapacities(); - for (CapacityVO newCapacity : newCapacities) { - _capacityDao.persist(newCapacity); - } - } finally { - m_capacityCheckLock.unlock(); - } - if (s_logger.isTraceEnabled()) { - s_logger.trace("done recalculating system storage capacity"); - } - } else { - if (s_logger.isTraceEnabled()) { - s_logger.trace("not recalculating system storage capacity, unable to lock capacity table"); - } + for (CapacityVO newCapacity : newCapacities) { + s_logger.trace("Executing capacity update"); + _capacityDao.persist(newCapacity); + s_logger.trace("Done with capacity update"); + } + txn.commit(); + } catch (Exception ex) { + txn.rollback(); + s_logger.error("Unable to start transaction for storage capacity update"); + }finally { + txn.close(); } } catch (Throwable t) { s_logger.error("Error trying to retrieve storage stats", t); From 5aa70deae776d0b71ff026bfdc509a98638d0374 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Sep 2010 11:24:46 -0700 Subject: [PATCH 07/13] new UI - add a shared function fromdb() --- ui/new/scripts/cloud.core.account.js | 4 ++-- ui/new/scripts/cloud.core.event.js | 6 +++--- ui/new/scripts/cloud.core.instance.js | 16 ++++++++-------- ui/new/scripts/cloud.core.js | 14 +++++++++++--- ui/new/scripts/cloud.core.snapshot.js | 8 ++++---- ui/new/scripts/cloud.core.volume.js | 10 +++++----- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/ui/new/scripts/cloud.core.account.js b/ui/new/scripts/cloud.core.account.js index ed4475d3af1..6438c247731 100644 --- a/ui/new/scripts/cloud.core.account.js +++ b/ui/new/scripts/cloud.core.account.js @@ -2,8 +2,8 @@ function loadAccountToRigntPanelFn($rightPanelContent) { var jsonObj = $rightPanelContent.data("jsonObj"); var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#role").text(toRole(jsonObj.accounttype)); - $rightPanelContent.find("#account").text(jsonObj.name); - $rightPanelContent.find("#domain").text(jsonObj.domain); + $rightPanelContent.find("#account").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); $rightPanelContent.find("#vm_total").text(jsonObj.vmtotal); $rightPanelContent.find("#ip_total").text(jsonObj.iptotal); $rightPanelContent.find("#bytes_received").text(jsonObj.receivedbytes); diff --git a/ui/new/scripts/cloud.core.event.js b/ui/new/scripts/cloud.core.event.js index ca70c3b3096..72c54960e9c 100644 --- a/ui/new/scripts/cloud.core.event.js +++ b/ui/new/scripts/cloud.core.event.js @@ -1,11 +1,11 @@ function loadEventToRigntPanelFn($rightPanelContent) { var jsonObj = $rightPanelContent.data("jsonObj"); var $rightPanelContent = $("#right_panel_content"); - $rightPanelContent.find("#username").text(jsonObj.username); - $rightPanelContent.find("#account").text(jsonObj.account); + $rightPanelContent.find("#username").text(fromdb(jsonObj.username)); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); $rightPanelContent.find("#type").text(jsonObj.type); $rightPanelContent.find("#level").text(jsonObj.level); - $rightPanelContent.find("#description").text(jsonObj.description); + $rightPanelContent.find("#description").text(fromdb(jsonObj.description)); $rightPanelContent.find("#state").text(jsonObj.state); setDateField(jsonObj.created, $rightPanelContent.find("#created")); } \ No newline at end of file diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index 78ce2d97683..d44eb6bf51d 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -384,21 +384,21 @@ function clickInstanceGroupHeader($arrowIcon) { var jsonObj = $t.data("jsonObj"); var vmName = getVmName(jsonObj.name, jsonObj.displayname); - $rightPanelHeader.find("#vm_name").text(vmName); + $rightPanelHeader.find("#vm_name").text(fromdb(vmName)); updateVirtualMachineStateInRightPanel(jsonObj.state); $rightPanelContent.find("#ipAddress").text(jsonObj.ipaddress); - $rightPanelContent.find("#zoneName").text(jsonObj.zonename); - $rightPanelContent.find("#templateName").text(jsonObj.templatename); - $rightPanelContent.find("#serviceOfferingName").text(jsonObj.serviceofferingname); + $rightPanelContent.find("#zoneName").text(fromdb(jsonObj.zonename)); + $rightPanelContent.find("#templateName").text(fromdb(jsonObj.templatename)); + $rightPanelContent.find("#serviceOfferingName").text(fromdb(jsonObj.serviceofferingname)); if(jsonObj.haenable == "true") $rightPanelContent.find("#ha").removeClass("cross_icon").addClass("tick_icon").show(); else $rightPanelContent.find("#ha").removeClass("tick_icon").addClass("cross_icon").show(); $rightPanelContent.find("#created").text(jsonObj.created); - $rightPanelContent.find("#account").text(jsonObj.account); - $rightPanelContent.find("#domain").text(jsonObj.domain); - $rightPanelContent.find("#hostName").text(jsonObj.hostname); - $rightPanelContent.find("#group").text(jsonObj.group); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); + $rightPanelContent.find("#hostName").text(fromdb(jsonObj.hostname)); + $rightPanelContent.find("#group").text(fromdb(jsonObj.group)); if(jsonObj.isoid != null && jsonObj.isoid.length > 0) $rightPanelContent.find("#iso").removeClass("cross_icon").addClass("tick_icon").show(); else diff --git a/ui/new/scripts/cloud.core.js b/ui/new/scripts/cloud.core.js index d65d01b054a..c563805529c 100755 --- a/ui/new/scripts/cloud.core.js +++ b/ui/new/scripts/cloud.core.js @@ -165,6 +165,14 @@ function createURL(url) { return url +"&response=json&sessionkey=" + g_sessionKey; } +function fromdb(val) { + return sanitizeXSS(unescape(noNull(val))); +} + +function todb(val) { + return encodeURIComponent(escape(display)); +} + @@ -790,16 +798,16 @@ function sanitizeXSS(val) { function getVmName(p_vmName, p_vmDisplayname) { if(p_vmDisplayname == null) - return sanitizeXSS(p_vmName); + return sanitizeXSS(unescape(p_vmName)); var vmName = null; if (isAdmin()) { if (p_vmDisplayname != p_vmName) { - vmName = p_vmName + "(" + sanitizeXSS(p_vmDisplayname) + ")"; + vmName = p_vmName + "(" + sanitizeXSS(unescape(p_vmDisplayname)) + ")"; } else { vmName = p_vmName; } } else { - vmName = sanitizeXSS(p_vmDisplayname); + vmName = sanitizeXSS(unescape(p_vmDisplayname)); } return vmName; } diff --git a/ui/new/scripts/cloud.core.snapshot.js b/ui/new/scripts/cloud.core.snapshot.js index 279d38b0d95..c54a63d3b53 100644 --- a/ui/new/scripts/cloud.core.snapshot.js +++ b/ui/new/scripts/cloud.core.snapshot.js @@ -4,11 +4,11 @@ function loadSnapshotToRigntPanelFn($rightPanelContent) { var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#id").text(jsonObj.id); - $rightPanelContent.find("#name").text(jsonObj.name); - $rightPanelContent.find("#volume_name").text(jsonObj.volumename); + $rightPanelContent.find("#name").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#volume_name").text(fromdb(jsonObj.volumename)); $rightPanelContent.find("#interval_type").text(jsonObj.intervaltype); - $rightPanelContent.find("#account").text(jsonObj.account); - $rightPanelContent.find("#domain").text(jsonObj.domain); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); setDateField(jsonObj.created, $rightPanelContent.find("#created")); } \ No newline at end of file diff --git a/ui/new/scripts/cloud.core.volume.js b/ui/new/scripts/cloud.core.volume.js index 1a5493427af..7324d6d3d04 100644 --- a/ui/new/scripts/cloud.core.volume.js +++ b/ui/new/scripts/cloud.core.volume.js @@ -4,14 +4,14 @@ function loadVolumeToRigntPanelFn($rightPanelContent) { var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#id").text(jsonObj.id); - $rightPanelContent.find("#name").text(jsonObj.name); - $rightPanelContent.find("#zonename").text(jsonObj.zonename); + $rightPanelContent.find("#name").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#zonename").text(fromdb(jsonObj.zonename)); $rightPanelContent.find("#device_id").text(jsonObj.deviceid); $rightPanelContent.find("#state").text(jsonObj.state); - $rightPanelContent.find("#storage").text(jsonObj.storage); - $rightPanelContent.find("#account").text(jsonObj.account); + $rightPanelContent.find("#storage").text(fromdb(jsonObj.storage)); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); - $rightPanelContent.find("#type").text(noNull(jsonObj.type) + " (" + noNull(jsonObj.storagetype) + " storage)"); + $rightPanelContent.find("#type").text(jsonObj.type + " (" + jsonObj.storagetype + " storage)"); $rightPanelContent.find("#size").text((jsonObj.size == "0") ? "" : convertBytes(jsonObj.size)); if (jsonObj.virtualmachineid == null) From 2b590dbc5d3c6437107b4ade0a98361bdeb06b0d Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 7 Sep 2010 11:30:16 -0700 Subject: [PATCH 08/13] bug 5147: Now, we restart the system vms immediately on another pool after a successful stop on the current pool, if such a reserve pool exists --- .../com/cloud/storage/StorageManagerImpl.java | 60 ++++++++----------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index f6d9aa72de0..de19c3ba8f6 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1963,8 +1963,6 @@ public class StorageManagerImpl implements StorageManager { { boolean destroyVolumes = false; long count = 1; - long consoleProxyId = 0; - long ssvmId = 0; try { //1. Get the primary storage record @@ -2023,9 +2021,20 @@ public class StorageManagerImpl implements StorageManager { { if(destroyVolumes) { - //proxy vm is stopped, and we have another ps available - //get the id for restart - consoleProxyId = vmInstance.getId(); + //create a dummy event + long eventId1 = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_START, "starting console proxy with Id: "+vmInstance.getId()); + + //Restore config val for consoleproxy.restart to true + _configMgr.updateConfiguration(userId, "consoleproxy.restart", "true"); + + if(_consoleProxyMgr.startProxy(vmInstance.getId(), eventId1)==null) + { + s_logger.warn("There was an error starting the console proxy id: "+vmInstance.getId()+" on another storage pool, cannot enable primary storage maintenance"); + primaryStorage.setStatus(Status.ErrorInMaintenance); + _storagePoolDao.persist(primaryStorage); + return false; + } + } } } @@ -2064,9 +2073,15 @@ public class StorageManagerImpl implements StorageManager { { if(destroyVolumes) { - //ss vm is stopped, and we have another ps available - //get the id for restart - ssvmId = vmInstance.getId(); + //create a dummy event and restart the ssvm immediately + long eventId = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START, "starting ssvm with Id: "+vmInstance.getId()); + if(_secStorageMgr.startSecStorageVm(vmInstance.getId(), eventId)==null) + { + s_logger.warn("There was an error starting the ssvm id: "+vmInstance.getId()+" on another storage pool, cannot enable primary storage maintenance"); + primaryStorage.setStatus(Status.ErrorInMaintenance); + _storagePoolDao.persist(primaryStorage); + return false; + } } } @@ -2100,34 +2115,7 @@ public class StorageManagerImpl implements StorageManager { _volsDao.remove(vol.getId()); } - //5. Restart all the system vms conditionally - if(destroyVolumes) //this means we have another ps. Ok to restart - { - //create a dummy event - long eventId = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START, "starting ssvm with Id: "+ssvmId); - if(_secStorageMgr.startSecStorageVm(ssvmId, eventId)==null) - { - s_logger.warn("There was an error starting the ssvm id: "+ssvmId+" on another storage pool, cannot enable primary storage maintenance"); - primaryStorage.setStatus(Status.ErrorInMaintenance); - _storagePoolDao.persist(primaryStorage); - return false; - } - - //create a dummy event - long eventId1 = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_START, "starting console proxy with Id: "+consoleProxyId); - - //Restore config val for consoleproxy.restart to true - _configMgr.updateConfiguration(userId, "consoleproxy.restart", "true"); - - if(_consoleProxyMgr.startProxy(consoleProxyId, eventId1)==null) - { - s_logger.warn("There was an error starting the console proxy id: "+consoleProxyId+" on another storage pool, cannot enable primary storage maintenance"); - primaryStorage.setStatus(Status.ErrorInMaintenance); - _storagePoolDao.persist(primaryStorage); - return false; } - } - - //6. Update the status + //5. Update the status primaryStorage.setStatus(Status.Maintenance); _storagePoolDao.persist(primaryStorage); From afc181dd82317ea86c9e399b4e7b0fc6e89d5e77 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 7 Sep 2010 11:50:04 -0700 Subject: [PATCH 09/13] some code cleanup --- server/src/com/cloud/storage/StorageManagerImpl.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index de19c3ba8f6..552e13c1d44 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -19,11 +19,7 @@ package com.cloud.storage; import java.net.URI; import java.net.UnknownHostException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.Enumeration; @@ -33,7 +29,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TimeZone; import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -94,9 +89,9 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceInUseException; import com.cloud.exception.StorageUnavailableException; import com.cloud.host.Host; -import com.cloud.host.Host.Type; import com.cloud.host.HostVO; import com.cloud.host.Status; +import com.cloud.host.Host.Type; import com.cloud.host.dao.DetailsDao; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor; @@ -127,12 +122,9 @@ import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.User; -import com.cloud.user.UserContext; -import com.cloud.user.UserVO; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserDao; import com.cloud.uservm.UserVm; -import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.Adapters; From 673ed9821390cd99681f5dd87dbbefbf6ad247a8 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Sep 2010 11:46:15 -0700 Subject: [PATCH 10/13] new UI - use new shared function todb() to escape and encode parameters in API command. --- ui/new/scripts/cloud.core.instance.js | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index d44eb6bf51d..11ecdce7749 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -108,7 +108,7 @@ function clickInstanceGroupHeader($arrowIcon) { if (isos != null && isos.length > 0) { isoSelect.empty(); for (var i = 0; i < isos.length; i++) { - isoSelect.append("");; + isoSelect.append("");; } } } @@ -196,7 +196,7 @@ function clickInstanceGroupHeader($arrowIcon) { var name = trim(thisDialog.find("#change_instance_name").val()); for(var id in selectedItemIds) { - var apiCommand = "command=updateVirtualMachine&id="+id+"&displayName="+encodeURIComponent(escape(name)); + var apiCommand = "command=updateVirtualMachine&id="+id+"&displayName="+todb(name); doAction(id, $t, apiCommand, listAPIMap); } }, @@ -217,7 +217,7 @@ function clickInstanceGroupHeader($arrowIcon) { if (offerings != null && offerings.length > 0) { for (var i = 0; i < offerings.length; i++) { - var option = $("").data("name", sanitizeXSS(unescape(offerings[i].name))); + var option = $("").data("name", fromdb(offerings[i].name)); offeringSelect.append(option); } } @@ -264,7 +264,7 @@ function clickInstanceGroupHeader($arrowIcon) { var $midMenuItem = selectedItemIds[id]; var jsonObj = $midMenuItem.data("jsonObj"); var group = trim(thisDialog.find("#change_group_name").val()); - var apiCommand = "command=updateVirtualMachine&id="+id+"&group="+encodeURIComponent(group); + var apiCommand = "command=updateVirtualMachine&id="+id+"&group="+todb(group); doAction(id, $t, apiCommand, listAPIMap); } }, @@ -558,7 +558,7 @@ function clickInstanceGroupHeader($arrowIcon) { var $zoneSelect = $vmPopup.find("#wizard_zone").empty(); if (zones != null && zones.length > 0) { for (var i = 0; i < zones.length; i++) { - $zoneSelect.append(""); + $zoneSelect.append(""); } } listTemplatesInVmPopup(); @@ -582,15 +582,15 @@ function clickInstanceGroupHeader($arrowIcon) { var $t = $serviceOfferingTemplate.clone(); $t.find("input:radio[name=service_offering_radio]").val(offerings[i].id); - $t.find("#name").text(sanitizeXSS(unescape(offerings[i].name))); - $t.find("#description").text(sanitizeXSS(unescape(offerings[i].displaytext))); + $t.find("#name").text(fromdb(offerings[i].name)); + $t.find("#description").text(fromdb(offerings[i].displaytext)); if (i > 0) $t.find("input:radio[name=service_offering_radio]").removeAttr("checked"); //if(i == 0) // $t.find("input:radio[name=service_offering_radio]").attr("checked", true); - //var listItem = $("
  • "); + //var listItem = $("
  • "); $container.append($t.show()); } //Safari and Chrome are not smart enough to make checkbox checked if html markup is appended by JQuery.append(). So, the following 2 lines are added. @@ -628,8 +628,8 @@ function clickInstanceGroupHeader($arrowIcon) { for (var i = 0; i < offerings.length; i++) { var $t = $existingDiskOfferingTemplate.clone(); $t.find("input:radio").attr("name","data_disk_offering_radio").val(offerings[i].id).removeAttr("checked"); - $t.find("#name").text(sanitizeXSS(unescape(noNull(offerings[i].name)))); - $t.find("#description").text(sanitizeXSS(noNull(unescape(offerings[i].displaytext)))); + $t.find("#name").text(fromdb(noNull(offerings[i].name))); + $t.find("#description").text(fromdb(offerings[i].displaytext)); $dataDiskOfferingContainer.append($t.show()); } } @@ -655,8 +655,8 @@ function clickInstanceGroupHeader($arrowIcon) { $t.find("input:radio").attr("name","root_disk_offering_radio").val(offerings[i].id); if(i > 0) //default is the 1st existing disk offering. If there is no existing disk offering, default to "custom" radio button $t.find("input:radio").removeAttr("checked"); - $t.find("#name").text(sanitizeXSS(unescape(noNull(offerings[i].name)))); - $t.find("#description").text(sanitizeXSS(noNull(unescape(offerings[i].displaytext)))); + $t.find("#name").text(fromdb(offerings[i].name)); + $t.find("#description").text(fromdb(offerings[i].displaytext)); $rootDiskOfferingContainer.append($t.show()); } } @@ -684,14 +684,14 @@ function clickInstanceGroupHeader($arrowIcon) { var html = "
  • " +"" - +"" + +"" +"
  • "; $("#wizard_root_disk_offering").append(html); var html2 = "
  • " +"" - +"" + +"" +"
  • "; $("#wizard_data_disk_offering").append(html2); } @@ -843,8 +843,8 @@ function clickInstanceGroupHeader($arrowIcon) { var html = '
    ' +'
    ' - +'
    '+sanitizeXSS(items[i].displaytext)+'
    ' - +'
    '+sanitizeXSS(items[i].account)+'
    ' + +'
    '+fromdb(items[i].displaytext)+'
    ' + +'
    '+fromdb(items[i].account)+'
    ' +'
    '; container.append(html); } @@ -1067,11 +1067,11 @@ function clickInstanceGroupHeader($arrowIcon) { var name = trim($thisPopup.find("#wizard_vm_name").val()); if (name != null && name.length > 0) - moreCriteria.push("&displayname="+encodeURIComponent(name)); + moreCriteria.push("&displayname="+todb(name)); var group = trim($thisPopup.find("#wizard_vm_group").val()); if (group != null && group.length > 0) - moreCriteria.push("&group="+encodeURIComponent(group)); + moreCriteria.push("&group="+todb(group)); vmWizardClose(); @@ -1131,7 +1131,7 @@ function clickInstanceGroupHeader($arrowIcon) { // Failed $t.find("#vm_name").text("Adding failed"); $t.find("#info_icon").addClass("error").show(); - $t.data("afterActionInfo", ("Adding failed. Reason: " + sanitizeXSS(result.jobresult))); + $t.data("afterActionInfo", ("Adding failed. Reason: " + fromdb(result.jobresult))); $t.bind("click", function(event) { $rightPanelContent.find("#after_action_info").text($(this).data("afterActionInfo")); $rightPanelContent.find("#after_action_info_container").addClass("errorbox"); From 3bf19dcccbdc12f8886ddbe5417c98d934b86308 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Sep 2010 12:02:53 -0700 Subject: [PATCH 11/13] new UI - apply detail header text. --- ui/new/jsp/tab_account.jsp | 8 ++++++++ ui/new/jsp/tab_alert.jsp | 8 ++++++++ ui/new/jsp/tab_event.jsp | 8 ++++++++ ui/new/jsp/tab_instance.jsp | 2 +- ui/new/jsp/tab_snapshot.jsp | 8 ++++++++ ui/new/jsp/tab_volume.jsp | 8 ++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ui/new/jsp/tab_account.jsp b/ui/new/jsp/tab_account.jsp index a4b8c117648..c64d2ae9301 100644 --- a/ui/new/jsp/tab_account.jsp +++ b/ui/new/jsp/tab_account.jsp @@ -12,6 +12,14 @@ %> +
    + +

    Account +

    +