Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss

This commit is contained in:
Alex Huang 2010-09-09 17:49:27 -07:00
commit dc4c4549d0
28 changed files with 302 additions and 170 deletions

View File

@ -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.

View File

@ -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 <secondary storage mount point> -f <routing template file> [-F]\n" $(basename $0) >&2
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-F]\n" $(basename $0) >&2
printf "or\n" >&2
printf "%s: -m <secondary storage mount point> -u <http url for routing template> [-F]\n" $(basename $0) >&2
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-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"

View File

@ -404,7 +404,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
Enumeration<HostAllocator> 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 {

View File

@ -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<Host> 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<Host> avoid);
}

View File

@ -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<Host> 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<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(sp.getId());
List<HostVO> hosts = new ArrayList<HostVO>();
for( StoragePoolHostVO poolhost : poolhosts ){
hosts.add(_hostDao.findById(poolhost.getHostId()));
}
long podId = pod.getId();
List<HostVO> podHosts = new ArrayList<HostVO>(hosts.size());
Iterator<HostVO> it = hosts.iterator();
List<HostVO> clusterHosts = _hostDao.listBy(type, clusterId, pod.getId(), dc.getId());
Iterator<HostVO> 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<Host> avoid, List<HostVO> hosts) {
@ -335,17 +328,6 @@ public class FirstFitAllocator implements HostAllocator {
public boolean configure(String name, Map<String, Object> 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<String, String> configs = _configDao.getConfiguration(params);
String opFactor = configs.get("cpu.overprovisioning.factor");

View File

@ -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<Host> avoid) {
Long clusterId, VMTemplateVO template, Set<Host> 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();
}

View File

@ -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<Host> avoid) {
Long clusterId, VMTemplateVO template, Set<Host> avoid) {
if (type == Host.Type.Storage) {
return null;
}
// list all computing hosts, regardless of whether they support routing...it's random after all
List<? extends Host> hosts = _hostDao.listBy(type, sp.getClusterId(), sp.getPodId(), sp.getDataCenterId());
List<? extends Host> hosts = _hostDao.listBy(type, clusterId, pod.getId(), dc.getId());
if (hosts.size() == 0) {
return null;
}

View File

@ -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<Host> avoid) {
Host host = super.allocateTo(vm, offering, type, dc, pod, sp, template, avoid);
Long clusterId, VMTemplateVO template, Set<Host> 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<StoragePoolVO> 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;

View File

@ -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<Host> avoid) {
Long clusterId, VMTemplateVO template, Set<Host> avoid) {
if (type == Host.Type.Routing && _routingHost != null) {
return _hostDao.findById(_routingHost);
} else if (type == Host.Type.Storage && _storageHost != null) {

View File

@ -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);
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -94,7 +94,7 @@ long milliseconds = new Date().getTime();
display: none">
<div class="actionpanel_button">
<div class="actionpanel_button_icons">
<img src="images/actions_actionicon.png" alt="Add VM" /></div>
<img src="images/actions_actionicon.png" alt="Add" /></div>
<div class="actionpanel_button_links">
Actions</div>
<div class="action_ddarrow">
@ -635,7 +635,8 @@ long milliseconds = new Date().getTime();
</div>
<!-- action list item -->
<li id="action_list_item"><a id="link" href="#">Stop</a></li>
<li id="action_list_item" style="display:none"><a id="link" href="#">(action)</a></li>
<!-- templates ends here-->
</body>
</html>

View File

@ -759,7 +759,11 @@
<div class="grid_container" id="volume_tab_template" style="display:none">
<div class="grid_header">
<div class="grid_header_title" id="name"></div>
<div class="grid_actionbox"></div>
<div class="grid_actionbox" id="volume_action_link"></div>
<div class="actionsdropdown_box" id="volume_action_menu" style="display: none;">
<ul class="actionsdropdown_boxlist" id="action_list">
</ul>
</div>
</div>
<div class="grid_rows even">
<div class="grid_row_cell" style="width: 20%;">
@ -797,4 +801,74 @@
<div class="row_celltitles" id="created"></div>
</div>
</div>
</div>
<!-- Create Template Dialog -->
<div id="dialog_create_template" title="Create Template" style="display:none">
<p>
Please specify the following information before creating a template of your disk
volume: <b><span id="volume_name"></span></b>. Creating a template could take up
to several hours depending on the size of your disk volume.</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<li>
<label for="user_name">
Name:</label>
<input class="text" type="text" name="create_template_name" id="create_template_name" />
<div id="create_template_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="user_name">
Display Text:</label>
<input class="text" type="text" name="create_template_desc" id="create_template_desc" />
<div id="create_template_desc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="create_template_os_type">
OS Type:</label>
<select class="select" name="create_template_os_type" id="create_template_os_type">
</select>
</li>
<li>
<label for="create_template_public">
Public:</label>
<select class="select" name="create_template_public" id="create_template_public">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</li>
<li>
<label for="user_name">
Password Enabled?:</label>
<select class="select" name="create_template_password" id="create_template_password">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</li>
</ol>
</form>
</div>
</div>
<!-- Detach Volume Dialog (begin) -->
<div id="dialog_detach_volume" title="Detach Volume" style="display: none">
<p>
Please confirm you want to detach the volume</p>
<div class="dialog_formcontent">
<div class="selectable_errorbox" style="display: none; width: 250px">
<p>
<span style="font-style: bold; color: red"><strong>Error</strong>: </span><span id="apply_error_text">
Error text will appear here</span>
</p>
</div>
<div class="selectable_commentbox" style="display: none; width: 250px">
<div class="selectable_loader">
</div>
<p>
<strong>Please wait...</strong>
</p>
</div>
</div>
</div>

View File

@ -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;
});

View File

@ -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("<p>Please confirm you want to detach an ISO from the virtual machine(s)</p>")
.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("<p>Please confirm you want to change the ROOT password for your virtual machine(s)</p>")
.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 = "<p>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.</p>";
$("#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 = "<p>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.</p>";
$("#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) *******************************************************************************
});
}

View File

@ -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"];

View File

@ -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"));
}
}
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");
}

View File

@ -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();
}