Skip to content
This repository was archived by the owner on Jan 15, 2020. It is now read-only.

Commit d933f19

Browse files
committed
bug 5800: add cluster for KVM
TODO: need to make sure the host cpu is from the same vender in a cluster
1 parent 55ebf46 commit d933f19

8 files changed

Lines changed: 28 additions & 34 deletions

File tree

agent/bindir/cloud-setup-agent.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ backupdir = "@SHAREDSTATEDIR@/@AGENTPATH@/etcbackup"
4040

4141
try:
4242
# parse cmd line
43-
opts, args = getopt.getopt(sys.argv[1:], "a", ["host=", "zone=", "pod=", "no-kvm", "guid="])
43+
opts, args = getopt.getopt(sys.argv[1:], "a", ["host=", "zone=", "pod=", "cluster=", "no-kvm", "guid="])
4444
host=None
4545
zone=None
4646
pod=None
47+
cluster=None
4748
guid=None
4849
autoMode=False
4950
do_check_kvm = True
@@ -57,6 +58,9 @@ try:
5758
elif opt == "--pod":
5859
if arg != "":
5960
pod = arg
61+
elif opt == "--cluster":
62+
if arg != "":
63+
cluster = arg
6064
elif opt == "--guid":
6165
if arg != "":
6266
guid = arg
@@ -112,7 +116,7 @@ try:
112116
stderr(str(e))
113117
bail(cloud_utils.E_SETUPFAILED,"Cloud Agent setup failed")
114118

115-
setup_agent_config(configfile, host, zone, pod, guid)
119+
setup_agent_config(configfile, host, zone, pod, cluster, guid)
116120
stderr("Enabling and starting the Cloud Agent")
117121
stop_service(servicename)
118122
enable_service(servicename)

agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
222222
private String _host;
223223
private String _dcId;
224224
private String _pod;
225+
private String _clusterId;
225226
private long _hvVersion;
226227
private final String _SSHKEYSPATH = "/root/.ssh";
227228
private final String _SSHPRVKEYPATH = _SSHKEYSPATH + File.separator + "id_rsa.cloud";
@@ -561,8 +562,9 @@ public boolean configure(String name, Map<String, Object> params)
561562
if (_pod == null) {
562563
_pod = "default";
563564
}
564-
565565

566+
_clusterId = (String) params.get("cluster");
567+
566568
_createvnetPath = Script.findScript(networkScriptsDir, "createvnet.sh");
567569
if(_createvnetPath == null) {
568570
throw new ConfigurationException("Unable to find createvnet.sh");
@@ -2559,6 +2561,7 @@ private Map<String, String> getVersionStrings() {
25592561
fillNetworkInformation(cmd);
25602562
cmd.getHostDetails().putAll(getVersionStrings());
25612563
cmd.setPool(_pool);
2564+
cmd.setCluster(_clusterId);
25622565

25632566
return new StartupCommand[]{cmd};
25642567
}

client/tomcatconf/components.xml.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@
110110
<dao name="GuestOSDao" class="com.cloud.storage.dao.GuestOSDaoImpl"/>
111111
<dao name="GuestOSCategoryDao" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl"/>
112112
<dao name="ClusterDao" class="com.cloud.dc.dao.ClusterDaoImpl"/>
113-
<dao name="NetworkProfileDao" class="com.cloud.network.dao.NetworkProfileDaoImpl"/>
113+
<dao name="NetworkConfigurationDao" class="com.cloud.network.dao.NetworkConfigurationDaoImpl"/>
114114
<dao name="NetworkOfferingDao" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl"/>
115+
<dao name="NicDao" class="com.cloud.vm.dao.NicDaoImpl"/>
115116

116117
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
117118
<adapter name="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator"/>

core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
public class KvmDummyResourceBase extends ServerResourceBase implements ServerResource {
2121
private String _zoneId;
2222
private String _podId;
23+
private String _clusterId;
2324
private String _guid;
2425
private String _agentIp;
2526
@Override
@@ -33,6 +34,7 @@ public StartupCommand[] initialize() {
3334
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.Type.KVM, new HashMap<String, String>(), new HashMap<String, State>());
3435
cmd.setDataCenter(_zoneId);
3536
cmd.setPod(_podId);
37+
cmd.setCluster(_clusterId);
3638
cmd.setGuid(_guid);
3739
cmd.setName(_agentIp);
3840
cmd.setPrivateIpAddress(_agentIp);
@@ -63,6 +65,7 @@ protected String getDefaultScriptsDir() {
6365
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
6466
_zoneId = (String)params.get("zone");
6567
_podId = (String)params.get("pod");
68+
_clusterId = (String)params.get("cluster");
6669
_guid = (String)params.get("guid");
6770
_agentIp = (String)params.get("agentIp");
6871
return true;

python/lib/cloud_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ def prompt_for_hostpods(zonespods):
911911

912912
# this configures the agent
913913

914-
def setup_agent_config(configfile, host, zone, pod, guid):
914+
def setup_agent_config(configfile, host, zone, pod, cluster, guid):
915915
stderr("Examining Agent configuration")
916916
fn = configfile
917917
text = file(fn).read(-1)
@@ -949,6 +949,7 @@ def setup_agent_config(configfile, host, zone, pod, guid):
949949
else:
950950
confopts["zone"] = zone
951951
confopts["pod"] = pod
952+
confopts["cluster"] = cluster
952953
except (urllib2.URLError,urllib2.HTTPError),e:
953954
stderr("Query failed: %s. Defaulting to zone %s pod %s",str(e),confopts["zone"],confopts["pod"])
954955

scripts/vm/hypervisor/kvm/setup_agent.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,16 @@ cloud_agent_setup() {
126126
local host=$1
127127
local zone=$2
128128
local pod=$3
129-
local guid=$4
129+
local cluster=$4
130+
local guid=$5
130131
# disable selinux
131132
selenabled=`cat /selinux/enforce`
132133
if [ "$selenabled" == "1" ]
133134
then
134135
sed -i 's/\(SELINUX\)\(.*\)/\1=permissive/' /etc/selinux/config
135136
setenforce 0
136137
fi
137-
cloud-setup-agent --host=$host --zone=$zone --pod=$pod --guid=$guid -a > /dev/null
138+
cloud-setup-agent --host=$host --zone=$zone --pod=$pod --cluster=$cluster --guid=$guid -a > /dev/null
138139
}
139140

140141
cloud_consoleP_setup() {
@@ -147,9 +148,10 @@ cloud_consoleP_setup() {
147148
host=
148149
zone=
149150
pod=
151+
cluster=
150152
guid=
151153
dflag=
152-
while getopts 'h:z:p:u:d' OPTION
154+
while getopts 'h:z:p:u:c:d' OPTION
153155
do
154156
case $OPTION in
155157
h)
@@ -161,6 +163,9 @@ do
161163
p)
162164
pod="$OPTARG"
163165
;;
166+
c)
167+
cluster="$OPTARG"
168+
;;
164169
u)
165170
guid="$OPTARG"
166171
;;
@@ -173,5 +178,5 @@ done
173178

174179
#install_cloud_agent $dflag
175180
#install_cloud_consoleP $dflag
176-
cloud_agent_setup $host $zone $pod $guid
181+
cloud_agent_setup $host $zone $pod $cluster $guid
177182
#cloud_consoleP_setup $host $zone $pod

server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId,
211211
SCPClient scp = new SCPClient(sshConnection);
212212
scp.put(_setupAgentPath, "/usr/bin", "0755");
213213

214-
sshExecuteCmd(sshConnection, "/usr/bin/setup_agent.sh " + " -h " + _hostIp + " -z " + dcId + " -p " + podId + " -u " + guid + " 1>&2", 3);
214+
sshExecuteCmd(sshConnection, "/usr/bin/setup_agent.sh " + " -h " + _hostIp + " -z " + dcId + " -p " + podId + " -c " + clusterId + " -u " + guid + " 1>&2", 3);
215215

216216
KvmDummyResourceBase kvmResource = new KvmDummyResourceBase();
217217
Map<String, Object> params = new HashMap<String, Object>();
218218

219219
params.put("zone", Long.toString(dcId));
220220
params.put("pod", Long.toString(podId));
221+
params.put("cluster", Long.toString(clusterId));
221222
params.put("guid", guid + "-LibvirtComputingResource"); /*tail added by agent.java*/
222223
params.put("agentIp", agentIp);
223224
kvmResource.configure("kvm agent", params);

ui/scripts/cloud.core.hosts.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ function showHostsTab() {
3333

3434
var dialogAddRouting = $("#dialog_add_routing");
3535

36-
//xenserver supports cluster. kvm doesn't support cluster.
37-
if (getHypervisorType() == "kvm")
38-
dialogAddRouting.find("#cluster_options_container, #new_cluster_radio_container, #existing_cluster_radio_container, #no_cluster_radio_container").hide();
39-
4036
$.ajax({
4137
data: createURL("command=listZones&available=true&response=json"+maxPageSize),
4238
dataType: "json",
@@ -594,11 +590,6 @@ function showHostsTab() {
594590
isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg"));
595591
isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg"));
596592
isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg"));
597-
//xenserver supports cluster. kvm doesn't support cluster.
598-
if (getHypervisorType() != "kvm") {
599-
if(clusterRadio == "new_cluster_radio")
600-
isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg"));
601-
}
602593
if (!isValid) return;
603594

604595
var array1 = [];
@@ -615,21 +606,6 @@ function showHostsTab() {
615606
var password = trim(dialogBox.find("#host_password").val());
616607
array1.push("&password="+encodeURIComponent(password));
617608

618-
//xenserver supports cluster. kvm doesn't support cluster.
619-
if (getHypervisorType() != "kvm") {
620-
if(clusterRadio == "new_cluster_radio") {
621-
var newClusterName = trim(dialogBox.find("#new_cluster_name").val());
622-
array1.push("&clustername="+encodeURIComponent(newClusterName));
623-
}
624-
else if(clusterRadio == "existing_cluster_radio") {
625-
var clusterId = dialogBox.find("#cluster_select").val();
626-
// We will default to no cluster if someone selects Join Cluster with no cluster available.
627-
if (clusterId != '-1') {
628-
array1.push("&clusterid="+clusterId);
629-
}
630-
}
631-
}
632-
633609
var hostname = trim(dialogBox.find("#host_hostname").val());
634610
var url;
635611
if(hostname.indexOf("http://")==-1)

0 commit comments

Comments
 (0)