diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 54403b38612..50f505025fc 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -1317,7 +1317,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if ("untagged".equalsIgnoreCase(vlanId)) { vifr.network = Network.getByUuid(conn, _host.publicNetwork); } else { - Network vlanNetwork = enableVlanNetwork(Long.valueOf(vlanId), _host.publicNetwork, _host.publicPif); + Network vlanNetwork = enableVlanNetwork(Long.valueOf(vlanId), _host.publicPif); if (vlanNetwork == null) { throw new InternalErrorException("Failed to enable VLAN network with tag: " + vlanId); @@ -1975,7 +1975,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } else { continue; } - Network vlanNetwork = enableVlanNetwork(vlan, nwuuid, pifuuid); + Network vlanNetwork = enableVlanNetwork(vlan, pifuuid); if (vlanNetwork == null) { throw new InternalErrorException("Failed to enable VLAN network with tag: " + vlan); @@ -2845,7 +2845,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if ("untagged".equalsIgnoreCase(vlanTag)) { vlanNetwork = Network.getByUuid(conn, nwUuid); } else { - vlanNetwork = enableVlanNetwork(Long.valueOf(vlanTag), nwUuid, pifUuid); + vlanNetwork = enableVlanNetwork(Long.valueOf(vlanTag), pifUuid); } if (vlanNetwork == null) { @@ -3069,7 +3069,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR Connection conn = getConnection(); network = Network.getByUuid(conn, _host.guestNetwork); } else { - network = enableVlanNetwork(Long.parseLong(tag), _host.guestNetwork, _host.guestPif); + network = enableVlanNetwork(Long.parseLong(tag), _host.guestPif); } if (network == null) { @@ -3190,7 +3190,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if ("untagged".equalsIgnoreCase(vlanId)) { vifr.network = Network.getByUuid(conn, _host.publicNetwork); } else { - Network vlanNetwork = enableVlanNetwork(Long.valueOf(vlanId), _host.publicNetwork, _host.publicPif); + Network vlanNetwork = enableVlanNetwork(Long.valueOf(vlanId), _host.publicPif); if (vlanNetwork == null) { throw new InternalErrorException("Failed to enable VLAN network with tag: " + vlanId); @@ -3658,7 +3658,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return found; } - protected Network enableVlanNetwork(long tag, String networkUuid, String pifUuid) throws XenAPIException, XmlRpcException { + protected Network enableVlanNetwork(long tag, String pifUuid) throws XenAPIException, XmlRpcException { // In XenServer, vlan is added by // 1. creating a network. // 2. creating a vlan associating network with the pif. diff --git a/scripts/storage/secondary/installrtng.sh b/scripts/storage/secondary/installrtng.sh index 7c9e7d0d257..ff801b5d536 100755 --- a/scripts/storage/secondary/installrtng.sh +++ b/scripts/storage/secondary/installrtng.sh @@ -1,9 +1,9 @@ #!/bin/bash # $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $ usage() { - printf "Usage: %s: -m -f [-F]\n" $(basename $0) >&2 + printf "Usage: %s: -m -f [-F]\n" $(basename $0) >&2 printf "or\n" >&2 - printf "%s: -m -u [-F]\n" $(basename $0) >&2 + printf "%s: -m -u [-F]\n" $(basename $0) >&2 } mflag= @@ -93,7 +93,7 @@ then wget -O $tmpfile $url if [ $? -ne 0 ] then - echo "Failed to fetch routing template from $url" + echo "Failed to fetch system vm template from $url" exit 5 fi fi @@ -109,14 +109,14 @@ then fi -$(dirname $0)/createtmplt.sh -s 2 -d 'DomR Template' -n $localfile -t $destdir/ -f $tmpfile -u &> /dev/null +$(dirname $0)/createtmplt.sh -s 2 -d 'SystemVM Template' -n $localfile -t $destdir/ -f $tmpfile -u &> /dev/null if [ $? -ne 0 ] then - echo "Failed to install routing template $tmpltimg to $destdir" + echo "Failed to install system vm template $tmpltimg to $destdir" fi -tmpltfile=$destdir/$tmpfile +tmpltfile=$destdir/$localfile tmpltsize=$(ls -l $tmpltfile| awk -F" " '{print $5}') echo "vhd=true" >> $destdir/template.properties @@ -124,8 +124,8 @@ echo "id=1" >> $destdir/template.properties echo "public=true" >> $destdir/template.properties echo "vhd.filename=$localfile" >> $destdir/template.properties echo "uniquename=routing" >> $destdir/template.properties -echo "vhd.virtualsize=2147483648" >> $destdir/template.properties -echo "virtualsize=2147483648" >> $destdir/template.properties +echo "vhd.virtualsize=$tmpltsize" >> $destdir/template.properties +echo "virtualsize=$tmpltsize" >> $destdir/template.properties echo "vhd.size=$tmpltsize" >> $destdir/template.properties -echo "Successfully installed routing template $tmpltimg to $destdir" +echo "Successfully installed system VM template $tmpltimg to $destdir" diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 42e36cfb30f..1668906a671 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -404,7 +404,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory { Enumeration en = _hostAllocators.enumeration(); while (en.hasMoreElements()) { final HostAllocator allocator = en.nextElement(); - final Host host = allocator.allocateTo(vmc, offering, type, dc, pod, sp, template, avoid); + final Host host = allocator.allocateTo(vmc, offering, type, dc, pod, sp.getClusterId(), template, avoid); if (host == null) { continue; } else { diff --git a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java b/server/src/com/cloud/agent/manager/allocator/HostAllocator.java index 0eea1b99fb2..0cd8b462043 100755 --- a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/HostAllocator.java @@ -22,15 +22,15 @@ import java.util.Set; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.host.Host; +import com.cloud.host.Host.Type; import com.cloud.offering.ServiceOffering; -import com.cloud.storage.StoragePoolVO; import com.cloud.storage.VMTemplateVO; import com.cloud.uservm.UserVm; import com.cloud.utils.component.Adapter; import com.cloud.vm.VmCharacteristics; public interface HostAllocator extends Adapter { - Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod, StoragePoolVO sp, VMTemplateVO template, Set avoid); boolean isVirtualMachineUpgradable(final UserVm vm, final ServiceOffering offering); + Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Type type, DataCenterVO dc, HostPodVO pod, Long clusterId, VMTemplateVO template, Set avoid); } diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java index 04bc8e47b61..2465d7a01ae 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java @@ -51,6 +51,7 @@ import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.uservm.UserVm; import com.cloud.utils.NumbersUtil; import com.cloud.utils.component.ComponentLocator; +import com.cloud.utils.component.Inject; import com.cloud.vm.ConsoleProxyVO; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.SecondaryStorageVmVO; @@ -68,23 +69,22 @@ import com.cloud.vm.dao.UserVmDao; public class FirstFitAllocator implements HostAllocator { private static final Logger s_logger = Logger.getLogger(FirstFitAllocator.class); private String _name; - protected HostDao _hostDao; - protected DetailsDao _hostDetailsDao; - protected UserVmDao _vmDao; - protected ServiceOfferingDao _offeringDao; - protected DomainRouterDao _routerDao; - protected ConsoleProxyDao _consoleProxyDao; - protected SecondaryStorageVmDao _secStorgaeVmDao; - protected StoragePoolHostDao _storagePoolHostDao; - protected ConfigurationDao _configDao; - protected GuestOSDao _guestOSDao; - protected GuestOSCategoryDao _guestOSCategoryDao; + @Inject HostDao _hostDao = null; + @Inject DetailsDao _hostDetailsDao = null; + @Inject UserVmDao _vmDao = null; + @Inject ServiceOfferingDao _offeringDao = null; + @Inject DomainRouterDao _routerDao = null; + @Inject ConsoleProxyDao _consoleProxyDao = null; + @Inject SecondaryStorageVmDao _secStorgaeVmDao = null; + @Inject ConfigurationDao _configDao = null; + @Inject GuestOSDao _guestOSDao = null; + @Inject GuestOSCategoryDao _guestOSCategoryDao = null; float _factor = 1; protected String _allocationAlgorithm = "random"; @Override public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Type type, DataCenterVO dc, - HostPodVO pod, StoragePoolVO sp, VMTemplateVO template, + HostPodVO pod, Long clusterId, VMTemplateVO template, Set avoid) { if (type == Host.Type.Storage) { @@ -92,28 +92,21 @@ public class FirstFitAllocator implements HostAllocator { return null; } - s_logger.debug("Looking for hosts associated with storage pool " + sp.getId()); + s_logger.debug("Looking for hosts in dc: " + dc.getId() + " pod:" + pod.getId() + " cluster:" + clusterId); - List poolhosts = _storagePoolHostDao.listByPoolId(sp.getId()); - List hosts = new ArrayList(); - for( StoragePoolHostVO poolhost : poolhosts ){ - hosts.add(_hostDao.findById(poolhost.getHostId())); - } - - long podId = pod.getId(); - List podHosts = new ArrayList(hosts.size()); - Iterator it = hosts.iterator(); + List clusterHosts = _hostDao.listBy(type, clusterId, pod.getId(), dc.getId()); + Iterator it = clusterHosts.iterator(); while (it.hasNext()) { HostVO host = it.next(); - if (host.getPodId() == podId && !avoid.contains(host)) { + if (avoid.contains(host)) { + clusterHosts.remove(host); + } else { if (s_logger.isDebugEnabled()) { s_logger.debug("Adding host " + host + " as possible pod host"); } - podHosts.add(host); } - } - - return allocateTo(offering, template, avoid, podHosts); + } + return allocateTo(offering, template, avoid, clusterHosts); } protected Host allocateTo(ServiceOffering offering, VMTemplateVO template, Set avoid, List hosts) { @@ -335,17 +328,6 @@ public class FirstFitAllocator implements HostAllocator { public boolean configure(String name, Map params) { _name = name; ComponentLocator locator = ComponentLocator.getCurrentLocator(); - _hostDao = locator.getDao(HostDao.class); - _hostDetailsDao = locator.getDao(DetailsDao.class); - _vmDao = locator.getDao(UserVmDao.class); - _offeringDao = locator.getDao(ServiceOfferingDao.class); - _routerDao = locator.getDao(DomainRouterDao.class); - _consoleProxyDao = locator.getDao(ConsoleProxyDao.class); - _secStorgaeVmDao = locator.getDao(SecondaryStorageVmDao.class); - _storagePoolHostDao = locator.getDao(StoragePoolHostDao.class); - _configDao = locator.getDao(ConfigurationDao.class); - _guestOSDao = locator.getDao(GuestOSDao.class); - _guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class); if (_configDao != null) { Map configs = _configDao.getConfiguration(params); String opFactor = configs.get("cpu.overprovisioning.factor"); diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitRoutingAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitRoutingAllocator.java index 90aa10e3c12..aa34dea5437 100644 --- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitRoutingAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitRoutingAllocator.java @@ -37,7 +37,7 @@ import com.cloud.vm.VmCharacteristics; public class FirstFitRoutingAllocator extends FirstFitAllocator { @Override public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod, - StoragePoolVO sp, VMTemplateVO template, Set avoid) { + Long clusterId, VMTemplateVO template, Set avoid) { try { NDC.push("FirstFitRoutingAllocator"); if (type != Host.Type.Routing) { @@ -45,7 +45,7 @@ public class FirstFitRoutingAllocator extends FirstFitAllocator { return null; } //all hosts should be of type routing anyway. - return super.allocateTo(vm, offering, type, dc, pod, sp, template, avoid); + return super.allocateTo(vm, offering, type, dc, pod, clusterId, template, avoid); } finally { NDC.pop(); } diff --git a/server/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java index 75c23fd225c..cf43fd40e96 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java @@ -46,13 +46,13 @@ public class RandomAllocator implements HostAllocator { @Override public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod, - StoragePoolVO sp, VMTemplateVO template, Set avoid) { + Long clusterId, VMTemplateVO template, Set avoid) { if (type == Host.Type.Storage) { return null; } // list all computing hosts, regardless of whether they support routing...it's random after all - List hosts = _hostDao.listBy(type, sp.getClusterId(), sp.getPodId(), sp.getDataCenterId()); + List hosts = _hostDao.listBy(type, clusterId, pod.getId(), dc.getId()); if (hosts.size() == 0) { return null; } diff --git a/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java index 224b00e32f8..430747aff30 100644 --- a/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java @@ -54,8 +54,8 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { @Override public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod, - StoragePoolVO sp, VMTemplateVO template, Set avoid) { - Host host = super.allocateTo(vm, offering, type, dc, pod, sp, template, avoid); + Long clusterId, VMTemplateVO template, Set avoid) { + Host host = super.allocateTo(vm, offering, type, dc, pod, clusterId, template, avoid); if (host != null) { return host; } @@ -77,16 +77,15 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { s_logger.debug("Removing " + pcId + " from the list of available pods"); pcs.remove(new PodCluster(new HostPodVO(pcId.first()), pcId.second() != null ? new ClusterVO(pcId.second()) : null)); } - - for (PodCluster p : pcs) { - List pools = _poolDao.listBy(dc.getId(), p.getPod().getId(), p.getCluster() == null ? null : p.getCluster().getId()); - for (StoragePoolVO pool : pools) { - host = super.allocateTo(vm, offering, type, dc, p.getPod(), pool, template, avoid); - if (host != null) { - return host; - } - } - } + + for (PodCluster p : pcs) { + clusterId = p.getCluster() == null ? null : p.getCluster().getId(); + host = super.allocateTo(vm, offering, type, dc, p.getPod(), + clusterId, template, avoid); + if (host != null) { + return host; + } + } s_logger.debug("Unable to find any available pods at all!"); return null; diff --git a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java index 2f89fb8922e..05c59ba4996 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java @@ -48,7 +48,7 @@ public class TestingAllocator implements HostAllocator { @Override public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod, - StoragePoolVO sp, VMTemplateVO template, Set avoid) { + Long clusterId, VMTemplateVO template, Set avoid) { if (type == Host.Type.Routing && _routingHost != null) { return _hostDao.findById(_routingHost); } else if (type == Host.Type.Storage && _storageHost != null) { diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManager.java b/server/src/com/cloud/storage/snapshot/SnapshotManager.java index e445b437d3c..0e342460621 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotManager.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManager.java @@ -26,6 +26,7 @@ import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotScheduleVO; import com.cloud.storage.SnapshotVO; import com.cloud.storage.VolumeVO; +import com.cloud.storage.Storage.ImageFormat; import com.cloud.utils.component.Manager; import com.cloud.utils.db.Filter; @@ -155,4 +156,6 @@ public interface SnapshotManager extends Manager { void validateSnapshot(Long userId, SnapshotVO snapshot); + ImageFormat getImageFormat(Long volumeId); + } diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index d2cd55e2c68..4918cc346de 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -201,7 +201,8 @@ public class SnapshotManagerImpl implements SnapshotManager { return runSnap; } - private ImageFormat getImageFormat(Long volumeId) { + @Override + public ImageFormat getImageFormat(Long volumeId) { ImageFormat format = null; VolumeVO volume = _volsDao.findById(volumeId); Long templateId = volume.getTemplateId(); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 6e724f2a5b3..8ac5234660d 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -151,6 +151,7 @@ import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.template.VirtualMachineTemplate.BootloaderType; +import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.User; @@ -207,6 +208,7 @@ public class UserVmManagerImpl implements UserVmManager { @Inject CapacityDao _capacityDao = null; @Inject NetworkManager _networkMgr = null; @Inject StorageManager _storageMgr = null; + @Inject SnapshotManager _snapshotMgr = null; @Inject AgentManager _agentMgr = null; @Inject AccountDao _accountDao = null; @Inject UserDao _userDao = null; @@ -692,6 +694,7 @@ public class UserVmManagerImpl implements UserVmManager { _eventDao.persist(event); return null; } + if (!_vmDao.updateIf(vm, Event.StartRequested, host.getId())) { String description = "Unable to start VM " + vm.toString() + " because the state is not correct."; @@ -2483,10 +2486,11 @@ public class UserVmManagerImpl implements UserVmManager { Long accountId = volume.getAccountId(); String origTemplateInstallPath = null; - Long origTemplateId = volume.getTemplateId(); + - if (origTemplateId != null) { - VMTemplateHostVO vmTemplateHostVO = _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), origTemplateId); + if (ImageFormat.ISO != _snapshotMgr.getImageFormat(volumeId)) { + Long origTemplateId = volume.getTemplateId(); + VMTemplateHostVO vmTemplateHostVO = _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), origTemplateId); origTemplateInstallPath = vmTemplateHostVO.getInstallPath(); } diff --git a/ui/new/css/main.css b/ui/new/css/main.css index db4c9d171c5..ede5cacfae2 100644 --- a/ui/new/css/main.css +++ b/ui/new/css/main.css @@ -1708,8 +1708,8 @@ a:visited { .midmenu_icons { - width:8px; - height:8px; + width:14px; + height:12px; float:left; margin:4px 0 0 10px; display:inline; diff --git a/ui/new/images/account_admin_midmenuicon.png b/ui/new/images/account_admin_midmenuicon.png new file mode 100644 index 00000000000..4185a724487 Binary files /dev/null and b/ui/new/images/account_admin_midmenuicon.png differ diff --git a/ui/new/images/account_domain_midmenuicon.png b/ui/new/images/account_domain_midmenuicon.png new file mode 100644 index 00000000000..750ffb172d9 Binary files /dev/null and b/ui/new/images/account_domain_midmenuicon.png differ diff --git a/ui/new/images/account_user_midmenuicon.png b/ui/new/images/account_user_midmenuicon.png new file mode 100644 index 00000000000..a79926fe0c1 Binary files /dev/null and b/ui/new/images/account_user_midmenuicon.png differ diff --git a/ui/new/images/events_error_midmenuicon.png b/ui/new/images/events_error_midmenuicon.png new file mode 100644 index 00000000000..3a4105b9ba3 Binary files /dev/null and b/ui/new/images/events_error_midmenuicon.png differ diff --git a/ui/new/images/events_info_midmenuicon.png b/ui/new/images/events_info_midmenuicon.png new file mode 100644 index 00000000000..7635cc77d31 Binary files /dev/null and b/ui/new/images/events_info_midmenuicon.png differ diff --git a/ui/new/images/events_warning_midmenuicon.png b/ui/new/images/events_warning_midmenuicon.png new file mode 100644 index 00000000000..aedba1c9119 Binary files /dev/null and b/ui/new/images/events_warning_midmenuicon.png differ diff --git a/ui/new/images/network_ipadd_midmenuicon.png b/ui/new/images/network_ipadd_midmenuicon.png new file mode 100644 index 00000000000..9b24994fa10 Binary files /dev/null and b/ui/new/images/network_ipadd_midmenuicon.png differ diff --git a/ui/new/images/network_networkgroup_midmenuicon.png b/ui/new/images/network_networkgroup_midmenuicon.png new file mode 100644 index 00000000000..2107efa2038 Binary files /dev/null and b/ui/new/images/network_networkgroup_midmenuicon.png differ diff --git a/ui/new/index.jsp b/ui/new/index.jsp index ed776f8b057..0591dd46dda 100644 --- a/ui/new/index.jsp +++ b/ui/new/index.jsp @@ -94,7 +94,7 @@ long milliseconds = new Date().getTime(); display: none">
- Add VM
+ Add
@@ -635,7 +635,8 @@ long milliseconds = new Date().getTime();
-
  • Stop
  • + + diff --git a/ui/new/jsp/instance.jsp b/ui/new/jsp/instance.jsp index fd67c4f2f10..6b514d8a86c 100644 --- a/ui/new/jsp/instance.jsp +++ b/ui/new/jsp/instance.jsp @@ -759,7 +759,11 @@ + + + + + \ No newline at end of file diff --git a/ui/new/scripts/cloud.core2.init.js b/ui/new/scripts/cloud.core2.init.js index a3f9510d45e..828380aa88e 100644 --- a/ui/new/scripts/cloud.core2.init.js +++ b/ui/new/scripts/cloud.core2.init.js @@ -1,5 +1,3 @@ -var selectedItemIds = {}; - $(document).ready(function() { $("#accordion_menu").accordion({ autoHeight: false, @@ -45,11 +43,11 @@ $(document).ready(function() { var $rightPanel = $("#right_panel"); var $addLink = $("#add_link"); - var $actionLink = $("#action_link"); - var $actionMenu = $("#action_menu"); - var $actionList = $actionMenu.find("#action_list"); + //var $actionLink = $("#action_link"); + //var $actionMenu = $("#action_menu"); + //var $actionList = $("#action_menu #action_list"); var $midmenuContainer = $("#midmenu_container"); - var $actionListItem = $("#action_list_item"); + //var $actionListItem = $("#action_list_item"); $("#leftmenu_instance_group_header").bind("click", function(event) { var $arrowIcon = $(this).find("#arrow_icon"); @@ -100,16 +98,13 @@ $(document).ready(function() { listMidMenuItems("leftmenu_snapshot", "listSnapshots", "listsnapshotsresponse", "snapshot", "name", "volumename", "jsp/snapshot.jsp", loadSnapshotToRigntPanelFn); listMidMenuItems("leftmenu_ip", "listPublicIpAddresses", "listpublicipaddressesresponse", "publicipaddress", "ipaddress", "account", "jsp/ip_address.jsp", loadIpToRigntPanelFn); - - - - - $actionLink.bind("mouseover", function(event) { - $actionMenu.show(); + + $("#action_link").bind("mouseover", function(event) { + $("#action_menu").show(); return false; }); - $actionLink.bind("mouseout", function(event) { - $actionMenu.hide(); + $("#action_link").bind("mouseout", function(event) { + $("#action_menu").hide(); return false; }); diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index ce6765c9997..a4edcda1fb7 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -6,23 +6,23 @@ function clickInstanceGroupHeader($arrowIcon) { var $instanceGroupContainer = $("#leftmenu_instance_group_container"); var $instanceGroupTemplate = $("#leftmenu_instance_group_template"); - var $actionLink = $("#action_link"); - var $actionMenu = $("#action_menu"); - var $actionList = $actionMenu.find("#action_list"); + //var $actionLink = $("#action_link"); + //var $actionMenu = $("#action_menu"); + //var $actionList = $("#action_menu #action_list"); var $midmenuContainer = $("#midmenu_container"); - var $actionListItem = $("#action_list_item"); + //var $actionListItem = $("#action_list_item"); var $midmenuItem = $("#midmenu_item"); var noGroupName = "(no group name)"; - var listAPIMap = { + var vmListAPIMap = { listAPI: "listVirtualMachines", listAPIResponse: "listvirtualmachinesresponse", listAPIResponseObj: "virtualmachine" }; - var actionMap = { + var vmActionMap = { "Stop Instance": { api: "stopVirtualMachine", isAsyncJob: true, @@ -98,7 +98,7 @@ function clickInstanceGroupHeader($arrowIcon) { } } - function doAttachISO($t, selectedItemIds, listAPIMap) { + function doAttachISO($t, selectedItemIds, vmListAPIMap) { $.ajax({ data: createURL("command=listIsos&isReady=true"), dataType: "json", @@ -127,7 +127,7 @@ function clickInstanceGroupHeader($arrowIcon) { } for(var id in selectedItemIds) { var apiCommand = "command=attachIso&virtualmachineid="+id+"&id="+isoId; - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -136,7 +136,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doDetachISO($t, selectedItemIds, listAPIMap) { + function doDetachISO($t, selectedItemIds, vmListAPIMap) { $("#dialog_confirmation") .html("

    Please confirm you want to detach an ISO from the virtual machine(s)

    ") .dialog('option', 'buttons', { @@ -144,7 +144,7 @@ function clickInstanceGroupHeader($arrowIcon) { $(this).dialog("close"); for(var id in selectedItemIds) { var apiCommand = "command=detachIso&virtualmachineid="+id; - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -153,7 +153,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doResetPassword($t, selectedItemIds, listAPIMap) { + function doResetPassword($t, selectedItemIds, vmListAPIMap) { $("#dialog_confirmation") .html("

    Please confirm you want to change the ROOT password for your virtual machine(s)

    ") .dialog('option', 'buttons', { @@ -173,7 +173,7 @@ function clickInstanceGroupHeader($arrowIcon) { continue; } var apiCommand = "command=resetPasswordForVirtualMachine&id="+id; - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -182,7 +182,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doChangeName($t, selectedItemIds, listAPIMap) { + function doChangeName($t, selectedItemIds, vmListAPIMap) { $("#dialog_change_name") .dialog('option', 'buttons', { "Confirm": function() { @@ -198,7 +198,7 @@ function clickInstanceGroupHeader($arrowIcon) { for(var id in selectedItemIds) { var apiCommand = "command=updateVirtualMachine&id="+id+"&displayName="+todb(name); - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -207,7 +207,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doChangeService($t, selectedItemIds, listAPIMap) { + function doChangeService($t, selectedItemIds, vmListAPIMap) { $.ajax({ //data: createURL("command=listServiceOfferings&VirtualMachineId="+vmId), //can not specifiy VirtualMachineId since we allow multiple-item-selection. data: createURL("command=listServiceOfferings"), //can not specifiy VirtualMachineId since we support multiple-item-selection. @@ -240,7 +240,7 @@ function clickInstanceGroupHeader($arrowIcon) { continue; } var apiCommand = "command=changeServiceForVirtualMachine&id="+id+"&serviceOfferingId="+thisDialog.find("#change_service_offerings").val(); - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -249,7 +249,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doChangeGroup($t, selectedItemIds, listAPIMap) { + function doChangeGroup($t, selectedItemIds, vmListAPIMap) { $("#dialog_change_group") .dialog('option', 'buttons', { "Confirm": function() { @@ -266,7 +266,7 @@ function clickInstanceGroupHeader($arrowIcon) { var jsonObj = $midMenuItem.data("jsonObj"); var group = trim(thisDialog.find("#change_group_name").val()); var apiCommand = "command=updateVirtualMachine&id="+id+"&group="+todb(group); - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -275,7 +275,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doEnableHA($t, selectedItemIds, listAPIMap) { + function doEnableHA($t, selectedItemIds, vmListAPIMap) { var message = "

    Please confirm you want to enable HA for your virtual machine. Once HA is enabled, your Virtual Instance will be automatically restarted in the event it is detected to have failed.

    "; $("#dialog_confirmation") @@ -287,7 +287,7 @@ function clickInstanceGroupHeader($arrowIcon) { var $midMenuItem = selectedItemIds[id]; var jsonObj = $midMenuItem.data("jsonObj"); var apiCommand = "command=updateVirtualMachine&id="+id+"&haenable=true"; - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -296,7 +296,7 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } - function doDisableHA($t, selectedItemIds, listAPIMap) { + function doDisableHA($t, selectedItemIds, vmListAPIMap) { var message = "

    Please confirm you want to disable HA for your virtual machine. Once HA is disabled, your Virtual Instance will no longer be be automatically restarted in the event of a failure.

    "; $("#dialog_confirmation") @@ -308,7 +308,7 @@ function clickInstanceGroupHeader($arrowIcon) { var $midMenuItem = selectedItemIds[id]; var jsonObj = $midMenuItem.data("jsonObj"); var apiCommand = "command=updateVirtualMachine&id="+id+"&haenable=false"; - doAction(id, $t, apiCommand, listAPIMap); + doAction(id, $t, apiCommand, vmListAPIMap); } }, "Cancel": function() { @@ -444,23 +444,15 @@ function clickInstanceGroupHeader($arrowIcon) { template.find("#size").text((json.size == "0") ? "" : convertBytes(json.size)); setDateField(json.created, template.find("#created")); - /* - if(json.type=="ROOT") { - if (json.vmstate == "Stopped") { - template.find("#volume_action_detach_disk, #volume_acton_separator").hide(); - } else { - template.find("#volume_action_detach_disk, #volume_acton_separator, #volume_action_create_template").hide(); - } - } else { - if (json.vmstate != "Stopped") { - template.find("#volume_acton_separator, #volume_action_create_template").hide(); - } - } - */ + if(json.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed. + //if (json.vmstate == "Stopped") + buildActionLink("Create Template", volumeActionMap, $("#volume_action_menu"), volumeListAPIMap); + } + else { //json.type=="DATADISK": "detach disk" is allowed, "create template" is disallowed. + buildActionLink("Detach Disk", volumeActionMap, $("#volume_action_menu"), volumeListAPIMap); + } } - - - + $("#add_link").show(); if($arrowIcon.hasClass("close") == true) { $arrowIcon.removeClass("close").addClass("open"); @@ -525,35 +517,9 @@ function clickInstanceGroupHeader($arrowIcon) { //action menu $("#action_link").show(); - $actionList.empty(); - for(var label in actionMap) { - var apiInfo = actionMap[label]; - var $listItem = $("#action_list_item").clone(); - $actionList.append($listItem.show()); - var $link = $listItem.find("#link").text(label); - $link.data("label", label); - $link.data("api", apiInfo.api); - $link.data("isAsyncJob", apiInfo.isAsyncJob); - $link.data("asyncJobResponse", apiInfo.asyncJobResponse); - $link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn); - $link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn); - $link.bind("click", function(event) { - $actionMenu.hide(); - var $t = $(this); - var dialogBeforeActionFn = $t.data("dialogBeforeActionFn"); - if(dialogBeforeActionFn == null) { - for(var id in selectedItemIds) { - var apiCommand = "command="+$t.data("api")+"&id="+id; - doAction(id, $t, apiCommand, listAPIMap); - } - } - else { - dialogBeforeActionFn($t, selectedItemIds, listAPIMap); - } - selectedItemIds = {}; //clear selected items for action - return false; - }); - } + $("#action_menu #action_list").empty(); + for(var label in vmActionMap) + buildActionLink(label, vmActionMap, $("#action_menu"), vmListAPIMap); } }); } @@ -596,6 +562,13 @@ function clickInstanceGroupHeader($arrowIcon) { zIndex: 2000 })); + activateDialog($("#dialog_create_template").dialog({ + width: 400, + autoOpen: false, + modal: true, + zIndex: 2000 + })); + //***** switch to different tab (begin) ******************************************************************** $("#tab_details").bind("click", function(event){ $(this).removeClass("off").addClass("on"); @@ -1227,6 +1200,19 @@ function clickInstanceGroupHeader($arrowIcon) { return false; //event.preventDefault() + event.stopPropagation() }); //***** VM Wizard (end) ******************************************************************************** + + //***** Volume tab (begin) ***************************************************************************** + $("#volume_action_link").bind("mouseover", function(event) { + $("#volume_action_menu").show(); + return false; + }); + $("#volume_action_link").bind("mouseout", function(event) { + $("#volume_action_menu").hide(); + return false; + }); + //***** Volume tab (end) ******************************************************************************* + + }); } diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index 59c53cbc28d..75a548c1519 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -20,12 +20,43 @@ // Version: @VERSION@ -//var jobIdMap; -function doAction(id, $t, apiCommand, listAPIMap) { - var label = $t.data("label"); - var isAsyncJob = $t.data("isAsyncJob"); - var asyncJobResponse = $t.data("asyncJobResponse"); - var afterActionSeccessFn = $t.data("afterActionSeccessFn"); +var selectedItemIds = {}; + +function buildActionLink(label, actionMap, $actionMenu, listAPIMap) { + var apiInfo = actionMap[label]; + var $listItem = $("#action_list_item").clone(); + $actionMenu.find("#action_list").append($listItem.show()); + var $link = $listItem.find("#link").text(label); + $link.data("label", label); + $link.data("api", apiInfo.api); + $link.data("isAsyncJob", apiInfo.isAsyncJob); + $link.data("asyncJobResponse", apiInfo.asyncJobResponse); + $link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn); + $link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn); + $link.bind("click", function(event) { + $actionMenu.hide(); + var $actionLink = $(this); + var dialogBeforeActionFn = $actionLink.data("dialogBeforeActionFn"); + if(dialogBeforeActionFn == null) { + for(var id in selectedItemIds) { + var apiCommand = "command="+$actionLink.data("api")+"&id="+id; + doAction(id, $actionLink, apiCommand, listAPIMap); + } + } + else { + dialogBeforeActionFn($actionLink, selectedItemIds, listAPIMap); + } + selectedItemIds = {}; //clear selected items for action + return false; + }); +} + + +function doAction(id, $actionLink, apiCommand, listAPIMap) { + var label = $actionLink.data("label"); + var isAsyncJob = $actionLink.data("isAsyncJob"); + var asyncJobResponse = $actionLink.data("asyncJobResponse"); + var afterActionSeccessFn = $actionLink.data("afterActionSeccessFn"); var listAPI = listAPIMap["listAPI"]; var listAPIResponse = listAPIMap["listAPIResponse"]; var listAPIResponseObj = listAPIMap["listAPIResponseObj"]; diff --git a/ui/new/scripts/cloud.core2.volume.js b/ui/new/scripts/cloud.core2.volume.js index 7324d6d3d04..5c85fa1fd2f 100644 --- a/ui/new/scripts/cloud.core2.volume.js +++ b/ui/new/scripts/cloud.core2.volume.js @@ -20,4 +20,59 @@ function loadVolumeToRigntPanelFn($rightPanelContent) { $rightPanelContent.find("#vm_name").text(getVmName(jsonObj.vmname, jsonObj.vmdisplayname) + " (" + jsonObj.vmstate + ")"); setDateField(jsonObj.created, $rightPanelContent.find("#created")); -} \ No newline at end of file +} + + +var volumeListAPIMap = { + listAPI: "listVolumes", + listAPIResponse: "listvolumesresponse", + listAPIResponseObj: "volume" +}; + +var volumeActionMap = { + "Detach Disk": { + api: "detachVolume", + isAsyncJob: true, + asyncJobResponse: "detachvolumeresponse", + afterActionSeccessFn: function(){} + }, + "Create Template": { + isAsyncJob: true, + asyncJobResponse: "createtemplateresponse", + dialogBeforeActionFn : doCreateTemplate, + afterActionSeccessFn: function(){} + } +} + + + +function doCreateTemplate($t, selectedItemIds, listAPIMap) { + //$("#dialog_create_template").find("#volume_name").text(volumeName); + $("#dialog_create_template") + .dialog('option', 'buttons', { + "Create": function() { + debugger; + var thisDialog = $(this); + + // validate values + var isValid = true; + isValid &= validateString("Name", thisDialog.find("#create_template_name"), thisDialog.find("#create_template_name_errormsg")); + isValid &= validateString("Display Text", thisDialog.find("#create_template_desc"), thisDialog.find("#create_template_desc_errormsg")); + if (!isValid) return; + + var name = trim(thisDialog.find("#create_template_name").val()); + var desc = trim(thisDialog.find("#create_template_desc").val()); + var osType = thisDialog.find("#create_template_os_type").val(); + var isPublic = thisDialog.find("#create_template_public").val(); + var password = thisDialog.find("#create_template_password").val(); + + for(var id in selectedItemIds) { + var apiCommand = "command=createTemplate&volumeId="+id+"&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&osTypeId="+osType+"&isPublic="+isPublic+"&passwordEnabled="+password; + doAction(id, $t, apiCommand, listAPIMap); + } + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); +} \ No newline at end of file diff --git a/ui/scripts/cloud.core.instances.js b/ui/scripts/cloud.core.instances.js index e5a9865f48b..dc31000c00a 100644 --- a/ui/scripts/cloud.core.instances.js +++ b/ui/scripts/cloud.core.instances.js @@ -1017,6 +1017,7 @@ function showInstancesTab(p_domainId, p_account) { if(volumes[i].type=="ROOT") { if (volumes[i].vmstate == "Stopped") { detail.find("#volume_action_detach_disk, #volume_acton_separator").hide(); + detail.find("#volume_action_create_template").show(); } else { detail.find("#volume_action_detach_disk, #volume_acton_separator, #volume_action_create_template").hide(); }