mirror of https://github.com/apache/cloudstack.git
Make AddClusterCmd API generic to all hypervisors, change UI accordingly also
This commit is contained in:
parent
2dd9eb84ee
commit
e03693f0aa
|
|
@ -35,6 +35,7 @@ public class ApiConstants {
|
|||
public static final String CLEANUP = "cleanup";
|
||||
public static final String CLUSTER_ID = "clusterid";
|
||||
public static final String CLUSTER_NAME = "clustername";
|
||||
public static final String CLUSTER_TYPE = "clustertype";
|
||||
public static final String COMPONENT = "component";
|
||||
public static final String CPU_NUMBER = "cpunumber";
|
||||
public static final String CPU_SPEED = "cpuspeed";
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.HostResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.host.Host;
|
||||
|
||||
@Implementation(description="Adds a new external cluster", responseObject=HostResponse.class)
|
||||
public class AddExternalClusterCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddExternalClusterCmd.class.getName());
|
||||
|
||||
private static final String s_name = "addexternalclusterresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, description="the cluster name")
|
||||
private String clusterName;
|
||||
|
||||
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the password for the host")
|
||||
private String password;
|
||||
|
||||
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the host")
|
||||
private Long podId;
|
||||
|
||||
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the host URL")
|
||||
private String url;
|
||||
|
||||
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host")
|
||||
private String username;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the host")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=false, description="hypervisor type of the host")
|
||||
private String hypervisor;
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
List<? extends Host> result = _resourceService.discoverExternalCluster(this);
|
||||
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
|
||||
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
|
||||
if (result != null) {
|
||||
for (Host host : result) {
|
||||
HostResponse hostResponse = _responseGenerator.createHostResponse(host);
|
||||
hostResponses.add(hostResponse);
|
||||
}
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add external host cluster");
|
||||
}
|
||||
|
||||
response.setResponses(hostResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
this.setResponseObject(response);
|
||||
} catch (DiscoveryException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@ public class ClusterResponse extends BaseResponse {
|
|||
@SerializedName("zonename") @Param(description="the Zone name of the cluster")
|
||||
private String zoneName;
|
||||
|
||||
@SerializedName("hypervisortype") @Param(description="the hypervisor type of the cluster")
|
||||
private String hypervisorType;
|
||||
|
||||
@SerializedName("clustertype") @Param(description="the type of the cluster")
|
||||
private String clusterType;
|
||||
|
||||
|
|
@ -98,4 +101,12 @@ public class ClusterResponse extends BaseResponse {
|
|||
public void setClusterType(String clusterType) {
|
||||
this.clusterType = clusterType;
|
||||
}
|
||||
|
||||
public String getHypervisorType() {
|
||||
return this.hypervisorType;
|
||||
}
|
||||
|
||||
public void setHypervisorType(String hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package com.cloud.resource;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.commands.AddExternalClusterCmd;
|
||||
import com.cloud.api.commands.AddClusterCmd;
|
||||
import com.cloud.api.commands.AddHostCmd;
|
||||
import com.cloud.api.commands.AddSecondaryStorageCmd;
|
||||
import com.cloud.api.commands.CancelMaintenanceCmd;
|
||||
|
|
@ -55,7 +55,7 @@ public interface ResourceService {
|
|||
* @throws DiscoveryException
|
||||
* @throws InvalidParameterValueException
|
||||
*/
|
||||
List<? extends Host> discoverExternalCluster(AddExternalClusterCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
List<? extends Host> discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
||||
List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
List<? extends Host> discoverHosts(AddSecondaryStorageCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ label.add=Add
|
|||
label.add.zone=Add Zone
|
||||
label.adding.zone=Adding Zone
|
||||
label.add.host=Add Host
|
||||
label.add.cluster=Add External Cluster
|
||||
label.add.cluster=Add Cluster
|
||||
label.add.primarystorage=Add Primary Storage
|
||||
label.add.secondarystorage=Add Secondary Storage
|
||||
label.add.pod=Add Pod
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ label.add=Add
|
|||
label.add.zone=Add Zone
|
||||
label.adding.zone=Adding Zone
|
||||
label.add.host=Add Host
|
||||
label.add.cluster=Add External Cluster
|
||||
label.add.cluster=Add Cluster
|
||||
label.add.primarystorage=Add Primary Storage
|
||||
label.add.secondarystorage=Add Secondary Storage
|
||||
label.add.pod=Add Pod
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ listCapacity=com.cloud.api.commands.ListCapacityCmd;1
|
|||
|
||||
#### host commands
|
||||
addHost=com.cloud.api.commands.AddHostCmd;1
|
||||
addExternalCluster=com.cloud.api.commands.AddExternalClusterCmd;1
|
||||
addCluster=com.cloud.api.commands.AddClusterCmd;1
|
||||
add=com.cloud.api.commands.AddHostCmd;1
|
||||
reconnectHost=com.cloud.api.commands.ReconnectHostCmd;1
|
||||
updateHost=com.cloud.api.commands.UpdateHostCmd;1
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import com.cloud.agent.transport.Response;
|
|||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.commands.AddExternalClusterCmd;
|
||||
import com.cloud.api.commands.AddClusterCmd;
|
||||
import com.cloud.api.commands.AddHostCmd;
|
||||
import com.cloud.api.commands.AddSecondaryStorageCmd;
|
||||
import com.cloud.api.commands.CancelMaintenanceCmd;
|
||||
|
|
@ -545,7 +545,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Host> discoverExternalCluster(AddExternalClusterCmd cmd)
|
||||
public List<? extends Host> discoverCluster(AddClusterCmd cmd)
|
||||
throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException {
|
||||
Long dcId = cmd.getZoneId();
|
||||
Long podId = cmd.getPodId();
|
||||
|
|
@ -587,6 +587,13 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
throw new InvalidParameterValueException("Please specify a valid hypervisor name");
|
||||
}
|
||||
|
||||
Cluster.ClusterType clusterType = null;
|
||||
if(cmd.getClusterType() != null && !cmd.getClusterType().isEmpty()) {
|
||||
clusterType = Cluster.ClusterType.valueOf(cmd.getClusterType());
|
||||
}
|
||||
if(clusterType == null)
|
||||
clusterType = Cluster.ClusterType.CloudManaged;
|
||||
|
||||
Discoverer discoverer = getMatchingDiscover(hypervisorType);
|
||||
if(discoverer == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid hypervisor");
|
||||
|
|
@ -596,7 +603,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
if (clusterName != null) {
|
||||
ClusterVO cluster = new ClusterVO(dcId, podId, clusterName);
|
||||
cluster.setHypervisorType(cmd.getHypervisor());
|
||||
cluster.setClusterType(Cluster.ClusterType.ExternalManaged);
|
||||
|
||||
cluster.setClusterType(clusterType);
|
||||
try {
|
||||
cluster = _clusterDao.persist(cluster);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -608,6 +616,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
clusterId = cluster.getId();
|
||||
}
|
||||
|
||||
if(clusterType == Cluster.ClusterType.CloudManaged)
|
||||
return _hostDao.listByCluster(clusterId);
|
||||
|
||||
boolean success = false;
|
||||
try {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -869,6 +869,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
clusterResponse.setName(cluster.getName());
|
||||
clusterResponse.setPodId(cluster.getPodId());
|
||||
clusterResponse.setZoneId(cluster.getDataCenterId());
|
||||
clusterResponse.setHypervisorType(cluster.getHypervisorType().toString());
|
||||
clusterResponse.setClusterType(cluster.getClusterType().toString());
|
||||
HostPodVO pod = ApiDBUtils.findPodById(cluster.getPodId());
|
||||
clusterResponse.setPodName(pod.getName());
|
||||
|
|
|
|||
|
|
@ -239,7 +239,6 @@
|
|||
<option value="XenServer" SELECTED>Xen Server</option>
|
||||
<option value="KVM">KVM</option>
|
||||
<option value="VmWare">VMware</option>
|
||||
<option value="">Auto</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -317,32 +316,43 @@
|
|||
<li>
|
||||
<label for="cluster_hypervisor">Hypervisor:</label>
|
||||
<select class="select" id="cluster_hypervisor">
|
||||
<option value="VmWare" SELECTED>VMware</option>
|
||||
<option value="XenServer" SELECTED>Xen Server</option>
|
||||
<option value="KVM">KVM</option>
|
||||
<option value="VmWare">VMware</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware">
|
||||
<label>
|
||||
Cluster Type:</label>
|
||||
<select class="select" id="type_dropdown">
|
||||
<option value="CloudManaged">CloudManaged</option>
|
||||
<option value="ExternalManaged" SELECTED>ExternalManaged</option>
|
||||
</select>
|
||||
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_hostname">
|
||||
vCenter Server:</label>
|
||||
<input class="text" type="text" name="cluster_hostname" id="cluster_hostname" />
|
||||
<div id="cluster_hostname_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_username">
|
||||
vCenter user:</label>
|
||||
vCenter User:</label>
|
||||
<input class="text" type="text" name="cluster_username" id="cluster_username" />
|
||||
<div id="cluster_username_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_password">
|
||||
Password:</label>
|
||||
<input class="text" type="password" name="cluster_password" id="cluster_password" autocomplete="off" />
|
||||
<div id="cluster_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_datacenter">
|
||||
vCenter Datacenter:</label>
|
||||
<input class="text" type="text" name="cluster_datacenter" id="cluster_datacenter" />
|
||||
|
|
|
|||
|
|
@ -580,9 +580,21 @@
|
|||
<li>
|
||||
<label for="cluster_hypervisor">Hypervisor:</label>
|
||||
<select class="select" id="cluster_hypervisor">
|
||||
<option value="VmWare" SELECTED>VMware</option>
|
||||
<option value="XenServer" SELECTED>Xen Server</option>
|
||||
<option value="KVM">KVM</option>
|
||||
<option value="VmWare">VMware</option>
|
||||
</select>
|
||||
</li>
|
||||
<li input_group="vmware">
|
||||
<label>
|
||||
Cluster Type:</label>
|
||||
<select class="select" id="type_dropdown">
|
||||
<option value="CloudManaged">CloudManaged</option>
|
||||
<option value="ExternalManaged" SELECTED>ExternalManaged</option>
|
||||
</select>
|
||||
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
Pod:</label>
|
||||
|
|
@ -591,29 +603,28 @@
|
|||
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_hostname">
|
||||
vCenter Server:</label>
|
||||
<input class="text" type="text" name="cluster_hostname" id="cluster_hostname" />
|
||||
<div id="cluster_hostname_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_username">
|
||||
vCenter user:</label>
|
||||
vCenter User:</label>
|
||||
<input class="text" type="text" name="cluster_username" id="cluster_username" />
|
||||
<div id="cluster_username_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_password">
|
||||
Password:</label>
|
||||
<input class="text" type="password" name="cluster_password" id="cluster_password" autocomplete="off" />
|
||||
<div id="cluster_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li input_group="vmware" input_sub_group="external">
|
||||
<label for="cluster_datacenter">
|
||||
vCenter Datacenter:</label>
|
||||
<input class="text" type="text" name="cluster_datacenter" id="cluster_datacenter" />
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ function afterLoadClusterJSP($leftmenuItem1) {
|
|||
function clusterJsonToRightPanel($leftmenuItem1) {
|
||||
var objCluster = $leftmenuItem1.data("jsonObj");
|
||||
|
||||
clearAddButtonsOnTop();
|
||||
if(objCluster.clustertype == "CloudManaged")
|
||||
initAddHostButton($("#midmenu_add_host_button"), "cluster_page", $leftmenuItem1);
|
||||
|
||||
|
|
|
|||
|
|
@ -278,17 +278,41 @@ function initAddClusterButton($button, currentPageInRightPanel, $leftmenuItem1)
|
|||
dialogAddCluster.find("#zone_name").text(fromdb(podObj.zonename));
|
||||
dialogAddCluster.find("#pod_name").text(fromdb(podObj.name));
|
||||
}
|
||||
|
||||
dialogAddCluster.find("#cluster_hypervisor").change(function() {
|
||||
if($(this).val() == "VmWare") {
|
||||
$('li[input_group]="vmware"', dialogAddCluster).show();
|
||||
dialogAddCluster.find("#type_dropdown").change();
|
||||
} else {
|
||||
$('li[input_group]="vmware"', dialogAddCluster).hide();
|
||||
}
|
||||
}).change();
|
||||
|
||||
dialogAddCluster.find("#type_dropdown").change(function() {
|
||||
if($(this).val() == "ExternalManaged") {
|
||||
$('li[input_sub_group]="external"', dialogAddCluster).show();
|
||||
} else {
|
||||
$('li[input_sub_group]="external"', dialogAddCluster).hide();
|
||||
}
|
||||
});
|
||||
|
||||
dialogAddCluster.dialog('option', 'buttons', {
|
||||
"Add": function() {
|
||||
var $thisDialog = $(this);
|
||||
|
||||
|
||||
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
|
||||
var clusterType="CloudManaged";
|
||||
if(hypervisor == "VmWare")
|
||||
clusterType = $thisDialog.find("#type_dropdown").val();
|
||||
|
||||
// validate values
|
||||
var isValid = true;
|
||||
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
|
||||
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
|
||||
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
|
||||
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
|
||||
var isValid = true;
|
||||
if(hypervisor == "VmWare" && clusterType != "CloudManaged") {
|
||||
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
|
||||
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
|
||||
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
|
||||
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
|
||||
}
|
||||
isValid &= validateString("Cluster name", $thisDialog.find("#cluster_name"), $thisDialog.find("#cluster_name_errormsg"));
|
||||
if (!isValid)
|
||||
return;
|
||||
|
|
@ -298,32 +322,37 @@ function initAddClusterButton($button, currentPageInRightPanel, $leftmenuItem1)
|
|||
var array1 = [];
|
||||
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
|
||||
array1.push("&hypervisor="+hypervisor);
|
||||
|
||||
array1.push("&clustertype=" + clusterType);
|
||||
array1.push("&zoneId="+zoneId);
|
||||
array1.push("&podId="+podId);
|
||||
|
||||
var username = trim($thisDialog.find("#cluster_username").val());
|
||||
array1.push("&username="+todb(username));
|
||||
|
||||
var password = trim($thisDialog.find("#cluster_password").val());
|
||||
array1.push("&password="+todb(password));
|
||||
|
||||
var hostname = trim($thisDialog.find("#cluster_hostname").val());
|
||||
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
|
||||
|
||||
var clusterName = trim($thisDialog.find("#cluster_name").val());
|
||||
if(hypervisor == "VmWare" && clusterType != "CloudManaged") {
|
||||
|
||||
var username = trim($thisDialog.find("#cluster_username").val());
|
||||
array1.push("&username="+todb(username));
|
||||
|
||||
var password = trim($thisDialog.find("#cluster_password").val());
|
||||
array1.push("&password="+todb(password));
|
||||
|
||||
var hostname = trim($thisDialog.find("#cluster_hostname").val());
|
||||
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
|
||||
|
||||
var url;
|
||||
if(hostname.indexOf("http://")==-1)
|
||||
url = "http://" + todb(hostname);
|
||||
else
|
||||
url = hostname;
|
||||
url += "/" + todb(dcName) + "/" + todb(clusterName);
|
||||
array1.push("&url=" + todb(url));
|
||||
|
||||
clusterName = hostname + "/" + dcName + "/" + clusterName
|
||||
}
|
||||
|
||||
array1.push("&clustername=" + todb(clusterName));
|
||||
|
||||
array1.push("&clustername=" + todb(hostname + "/" + dcName + "/" + clusterName));
|
||||
|
||||
var url;
|
||||
if(hostname.indexOf("http://")==-1)
|
||||
url = "http://" + todb(hostname);
|
||||
else
|
||||
url = hostname;
|
||||
url += "/" + todb(dcName) + "/" + todb(clusterName);
|
||||
array1.push("&url=" + todb(url));
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=addExternalCluster" + array1.join("")),
|
||||
data: createURL("command=addCluster" + array1.join("")),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
$thisDialog.find("#spinning_wheel").hide();
|
||||
|
|
@ -331,7 +360,7 @@ function initAddClusterButton($button, currentPageInRightPanel, $leftmenuItem1)
|
|||
|
||||
showMiddleMenu();
|
||||
|
||||
clickClusterNodeAfterAddHost("new_cluster_radio", podId, hostname + "/" + dcName + "/" + clusterName, null, $thisDialog);
|
||||
clickClusterNodeAfterAddHost("new_cluster_radio", podId, clusterName, null, $thisDialog);
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
|
|
|
|||
|
|
@ -1002,16 +1002,40 @@ function initAddClusterButtonOnZonePage($button, zoneId, zoneName) {
|
|||
}
|
||||
});
|
||||
|
||||
$dialogAddCluster.find("#cluster_hypervisor").change(function() {
|
||||
if($(this).val() == "VmWare") {
|
||||
$('li[input_group]="vmware"', $dialogAddCluster).show();
|
||||
$dialogAddCluster.find("#type_dropdown").change();
|
||||
} else {
|
||||
$('li[input_group]="vmware"', $dialogAddCluster).hide();
|
||||
}
|
||||
}).change();
|
||||
|
||||
$dialogAddCluster.find("#type_dropdown").change(function() {
|
||||
if($(this).val() == "ExternalManaged") {
|
||||
$('li[input_sub_group]="external"', $dialogAddCluster).show();
|
||||
} else {
|
||||
$('li[input_sub_group]="external"', $dialogAddCluster).hide();
|
||||
}
|
||||
});
|
||||
|
||||
$dialogAddCluster.dialog('option', 'buttons', {
|
||||
"Add": function() {
|
||||
var $thisDialog = $(this);
|
||||
|
||||
// validate values
|
||||
var isValid = true;
|
||||
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
|
||||
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
|
||||
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
|
||||
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
|
||||
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
|
||||
var clusterType="CloudManaged";
|
||||
if(hypervisor == "VmWare")
|
||||
clusterType = $thisDialog.find("#type_dropdown").val();
|
||||
|
||||
var isValid = true;
|
||||
if(hypervisor == "VmWare" && clusterType != "CloudManaged") {
|
||||
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
|
||||
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
|
||||
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
|
||||
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
|
||||
}
|
||||
isValid &= validateString("Cluster name", $thisDialog.find("#cluster_name"), $thisDialog.find("#cluster_name_errormsg"));
|
||||
if (!isValid)
|
||||
return;
|
||||
|
|
@ -1019,9 +1043,8 @@ function initAddClusterButtonOnZonePage($button, zoneId, zoneName) {
|
|||
$thisDialog.find("#spinning_wheel").show();
|
||||
|
||||
var array1 = [];
|
||||
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
|
||||
array1.push("&hypervisor="+hypervisor);
|
||||
|
||||
array1.push("&clustertype=" + clusterType);
|
||||
array1.push("&zoneId="+zoneId);
|
||||
|
||||
//expand zone in left menu tree (to show pod, cluster under the zone)
|
||||
|
|
@ -1031,29 +1054,32 @@ function initAddClusterButtonOnZonePage($button, zoneId, zoneName) {
|
|||
|
||||
var podId = $thisDialog.find("#pod_dropdown").val();
|
||||
array1.push("&podId="+podId);
|
||||
|
||||
var username = trim($thisDialog.find("#cluster_username").val());
|
||||
array1.push("&username="+todb(username));
|
||||
|
||||
var password = trim($thisDialog.find("#cluster_password").val());
|
||||
array1.push("&password="+todb(password));
|
||||
|
||||
var hostname = trim($thisDialog.find("#cluster_hostname").val());
|
||||
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
|
||||
|
||||
var clusterName = trim($thisDialog.find("#cluster_name").val());
|
||||
if(hypervisor == "VmWare" && clusterType != "CloudManaged") {
|
||||
var username = trim($thisDialog.find("#cluster_username").val());
|
||||
array1.push("&username="+todb(username));
|
||||
|
||||
var password = trim($thisDialog.find("#cluster_password").val());
|
||||
array1.push("&password="+todb(password));
|
||||
|
||||
var hostname = trim($thisDialog.find("#cluster_hostname").val());
|
||||
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
|
||||
var url;
|
||||
if(hostname.indexOf("http://")==-1)
|
||||
url = "http://" + todb(hostname);
|
||||
else
|
||||
url = hostname;
|
||||
url += "/" + todb(dcName) + "/" + todb(clusterName);
|
||||
array1.push("&url=" + todb(url));
|
||||
|
||||
clusterName = hostname + "/" + dcName + "/" + clusterName
|
||||
}
|
||||
|
||||
array1.push("&clustername=" + todb(hostname + "/" + dcName + "/" + clusterName));
|
||||
|
||||
var url;
|
||||
if(hostname.indexOf("http://")==-1)
|
||||
url = "http://" + todb(hostname);
|
||||
else
|
||||
url = hostname;
|
||||
url += "/" + todb(dcName) + "/" + todb(clusterName);
|
||||
array1.push("&url=" + todb(url));
|
||||
array1.push("&clustername=" + todb(clusterName));
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=addExternalCluster" + array1.join("")),
|
||||
data: createURL("command=addCluster" + array1.join("")),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
$thisDialog.find("#spinning_wheel").hide();
|
||||
|
|
@ -1061,7 +1087,7 @@ function initAddClusterButtonOnZonePage($button, zoneId, zoneName) {
|
|||
|
||||
showMiddleMenu();
|
||||
|
||||
clickClusterNodeAfterAddHost("new_cluster_radio", podId, hostname + "/" + dcName + "/" + clusterName, null, $thisDialog);
|
||||
clickClusterNodeAfterAddHost("new_cluster_radio", podId, clusterName, null, $thisDialog);
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
|
|
@ -1110,7 +1136,7 @@ function initAddHostButtonOnZonePage($button, zoneId, zoneName) {
|
|||
}
|
||||
$podSelect.change();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$dialogAddHost
|
||||
.dialog('option', 'buttons', {
|
||||
|
|
|
|||
Loading…
Reference in New Issue