diff --git a/agent/bindir/cloud-setup-agent.in b/agent/bindir/cloud-setup-agent.in index 9c5913b6926..26bf1a0f0ac 100755 --- a/agent/bindir/cloud-setup-agent.in +++ b/agent/bindir/cloud-setup-agent.in @@ -40,10 +40,11 @@ backupdir = "@SHAREDSTATEDIR@/@AGENTPATH@/etcbackup" try: # parse cmd line - opts, args = getopt.getopt(sys.argv[1:], "a", ["host=", "zone=", "pod=", "no-kvm", "guid="]) + opts, args = getopt.getopt(sys.argv[1:], "a", ["host=", "zone=", "pod=", "cluster=", "no-kvm", "guid="]) host=None zone=None pod=None + cluster=None guid=None autoMode=False do_check_kvm = True @@ -57,6 +58,9 @@ try: elif opt == "--pod": if arg != "": pod = arg + elif opt == "--cluster": + if arg != "": + cluster = arg elif opt == "--guid": if arg != "": guid = arg @@ -112,7 +116,7 @@ try: stderr(str(e)) bail(cloud_utils.E_SETUPFAILED,"Cloud Agent setup failed") - setup_agent_config(configfile, host, zone, pod, guid) + setup_agent_config(configfile, host, zone, pod, cluster, guid) stderr("Enabling and starting the Cloud Agent") stop_service(servicename) enable_service(servicename) diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java index f1d2d36e29b..900508b1fbb 100644 --- a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java +++ b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java @@ -222,6 +222,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private String _host; private String _dcId; private String _pod; + private String _clusterId; private long _hvVersion; private final String _SSHKEYSPATH = "/root/.ssh"; private final String _SSHPRVKEYPATH = _SSHKEYSPATH + File.separator + "id_rsa.cloud"; @@ -561,8 +562,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (_pod == null) { _pod = "default"; } - + _clusterId = (String) params.get("cluster"); + _createvnetPath = Script.findScript(networkScriptsDir, "createvnet.sh"); if(_createvnetPath == null) { throw new ConfigurationException("Unable to find createvnet.sh"); @@ -2559,6 +2561,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv fillNetworkInformation(cmd); cmd.getHostDetails().putAll(getVersionStrings()); cmd.setPool(_pool); + cmd.setCluster(_clusterId); return new StartupCommand[]{cmd}; } diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in index d4fd563f2b3..5298e5b4cee 100755 --- a/client/tomcatconf/components.xml.in +++ b/client/tomcatconf/components.xml.in @@ -110,8 +110,9 @@ - + + diff --git a/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java b/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java index 78451bced48..fce1ce38c8d 100644 --- a/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java +++ b/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java @@ -20,6 +20,7 @@ import com.cloud.vm.State; public class KvmDummyResourceBase extends ServerResourceBase implements ServerResource { private String _zoneId; private String _podId; + private String _clusterId; private String _guid; private String _agentIp; @Override @@ -33,6 +34,7 @@ public class KvmDummyResourceBase extends ServerResourceBase implements ServerRe StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.Type.KVM, new HashMap(), new HashMap()); cmd.setDataCenter(_zoneId); cmd.setPod(_podId); + cmd.setCluster(_clusterId); cmd.setGuid(_guid); cmd.setName(_agentIp); cmd.setPrivateIpAddress(_agentIp); @@ -63,6 +65,7 @@ public class KvmDummyResourceBase extends ServerResourceBase implements ServerRe public boolean configure(final String name, final Map params) throws ConfigurationException { _zoneId = (String)params.get("zone"); _podId = (String)params.get("pod"); + _clusterId = (String)params.get("cluster"); _guid = (String)params.get("guid"); _agentIp = (String)params.get("agentIp"); return true; diff --git a/python/lib/cloud_utils.py b/python/lib/cloud_utils.py index 3c4d5598d62..86d2471b336 100644 --- a/python/lib/cloud_utils.py +++ b/python/lib/cloud_utils.py @@ -911,7 +911,7 @@ def prompt_for_hostpods(zonespods): # this configures the agent -def setup_agent_config(configfile, host, zone, pod, guid): +def setup_agent_config(configfile, host, zone, pod, cluster, guid): stderr("Examining Agent configuration") fn = configfile text = file(fn).read(-1) @@ -949,6 +949,7 @@ def setup_agent_config(configfile, host, zone, pod, guid): else: confopts["zone"] = zone confopts["pod"] = pod + confopts["cluster"] = cluster except (urllib2.URLError,urllib2.HTTPError),e: stderr("Query failed: %s. Defaulting to zone %s pod %s",str(e),confopts["zone"],confopts["pod"]) diff --git a/scripts/vm/hypervisor/kvm/setup_agent.sh b/scripts/vm/hypervisor/kvm/setup_agent.sh index 1c0a18112df..89bcfb0dc10 100755 --- a/scripts/vm/hypervisor/kvm/setup_agent.sh +++ b/scripts/vm/hypervisor/kvm/setup_agent.sh @@ -126,7 +126,8 @@ cloud_agent_setup() { local host=$1 local zone=$2 local pod=$3 - local guid=$4 + local cluster=$4 + local guid=$5 # disable selinux selenabled=`cat /selinux/enforce` if [ "$selenabled" == "1" ] @@ -134,7 +135,7 @@ cloud_agent_setup() { sed -i 's/\(SELINUX\)\(.*\)/\1=permissive/' /etc/selinux/config setenforce 0 fi - cloud-setup-agent --host=$host --zone=$zone --pod=$pod --guid=$guid -a > /dev/null + cloud-setup-agent --host=$host --zone=$zone --pod=$pod --cluster=$cluster --guid=$guid -a > /dev/null } cloud_consoleP_setup() { @@ -147,9 +148,10 @@ cloud_consoleP_setup() { host= zone= pod= +cluster= guid= dflag= -while getopts 'h:z:p:u:d' OPTION +while getopts 'h:z:p:u:c:d' OPTION do case $OPTION in h) @@ -161,6 +163,9 @@ do p) pod="$OPTARG" ;; + c) + cluster="$OPTARG" + ;; u) guid="$OPTARG" ;; @@ -173,5 +178,5 @@ done #install_cloud_agent $dflag #install_cloud_consoleP $dflag -cloud_agent_setup $host $zone $pod $guid +cloud_agent_setup $host $zone $pod $cluster $guid #cloud_consoleP_setup $host $zone $pod diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java index a17536db1a0..9b910ec0f3b 100644 --- a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java @@ -211,13 +211,14 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer, SCPClient scp = new SCPClient(sshConnection); scp.put(_setupAgentPath, "/usr/bin", "0755"); - sshExecuteCmd(sshConnection, "/usr/bin/setup_agent.sh " + " -h " + _hostIp + " -z " + dcId + " -p " + podId + " -u " + guid + " 1>&2", 3); + sshExecuteCmd(sshConnection, "/usr/bin/setup_agent.sh " + " -h " + _hostIp + " -z " + dcId + " -p " + podId + " -c " + clusterId + " -u " + guid + " 1>&2", 3); KvmDummyResourceBase kvmResource = new KvmDummyResourceBase(); Map params = new HashMap(); params.put("zone", Long.toString(dcId)); params.put("pod", Long.toString(podId)); + params.put("cluster", Long.toString(clusterId)); params.put("guid", guid + "-LibvirtComputingResource"); /*tail added by agent.java*/ params.put("agentIp", agentIp); kvmResource.configure("kvm agent", params); diff --git a/ui/scripts/cloud.core.hosts.js b/ui/scripts/cloud.core.hosts.js index d89c2249f0b..3f6cd6a6158 100644 --- a/ui/scripts/cloud.core.hosts.js +++ b/ui/scripts/cloud.core.hosts.js @@ -33,10 +33,6 @@ function showHostsTab() { var dialogAddRouting = $("#dialog_add_routing"); - //xenserver supports cluster. kvm doesn't support cluster. - if (getHypervisorType() == "kvm") - dialogAddRouting.find("#cluster_options_container, #new_cluster_radio_container, #existing_cluster_radio_container, #no_cluster_radio_container").hide(); - $.ajax({ data: createURL("command=listZones&available=true&response=json"+maxPageSize), dataType: "json", @@ -594,11 +590,6 @@ function showHostsTab() { isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg")); isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg")); isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg")); - //xenserver supports cluster. kvm doesn't support cluster. - if (getHypervisorType() != "kvm") { - if(clusterRadio == "new_cluster_radio") - isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg")); - } if (!isValid) return; var array1 = []; @@ -615,21 +606,6 @@ function showHostsTab() { var password = trim(dialogBox.find("#host_password").val()); array1.push("&password="+encodeURIComponent(password)); - //xenserver supports cluster. kvm doesn't support cluster. - if (getHypervisorType() != "kvm") { - if(clusterRadio == "new_cluster_radio") { - var newClusterName = trim(dialogBox.find("#new_cluster_name").val()); - array1.push("&clustername="+encodeURIComponent(newClusterName)); - } - else if(clusterRadio == "existing_cluster_radio") { - var clusterId = dialogBox.find("#cluster_select").val(); - // We will default to no cluster if someone selects Join Cluster with no cluster available. - if (clusterId != '-1') { - array1.push("&clusterid="+clusterId); - } - } - } - var hostname = trim(dialogBox.find("#host_hostname").val()); var url; if(hostname.indexOf("http://")==-1)