Skip to content

Commit ccee282

Browse files
Kishan Kavalayadvr
authored andcommitted
CLOUDSTACK-6931: Set hypervisor.type in agent.properties using cloudstack-setup -t option. Default is kvm.
(cherry picked from commit 89854de) Signed-off-by: Rohit Yadav <[email protected]>
1 parent f956ae9 commit ccee282

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

agent/bindir/cloud-setup-agent.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def getUserInputs():
6161
if clusterId == "":
6262
clusterId = oldCluster
6363

64+
oldHypervisor = cfo.getEntry("hypervisor")
65+
if oldHypervisor == "":
66+
oldHypervisor = "kvm"
67+
68+
hypervisor = raw_input("Please input the Hypervisor type kvm/lxc:[%s]"%oldCluster)
69+
if hypervisor == "":
70+
hypervisor = oldHypervisor
71+
6472
try:
6573
defaultNic = networkConfig.getDefaultNetwork()
6674
except:
@@ -76,7 +84,7 @@ def getUserInputs():
7684
elif network == "":
7785
network = defNic
7886

79-
return [mgtSvr, zoneToken, network, podId, clusterId]
87+
return [mgtSvr, zoneToken, network, podId, clusterId, hypervisor]
8088

8189
if __name__ == '__main__':
8290
initLoging("@AGENTLOGDIR@/setup.log")
@@ -90,6 +98,7 @@ if __name__ == '__main__':
9098
parser.add_option("-z", "--zone", dest="zone", help="zone id")
9199
parser.add_option("-p", "--pod", dest="pod", help="pod id")
92100
parser.add_option("-c", "--cluster", dest="cluster", help="cluster id")
101+
parser.add_option("-t", "--hypervisor", default="kvm", dest="hypervisor", help="hypervisor type")
93102
parser.add_option("-g", "--guid", dest="guid", help="guid")
94103
parser.add_option("--pubNic", dest="pubNic", help="Public traffic interface")
95104
parser.add_option("--prvNic", dest="prvNic", help="Private traffic interface")
@@ -108,6 +117,7 @@ if __name__ == '__main__':
108117
glbEnv.defaultNic = userInputs[2]
109118
glbEnv.pod = userInputs[3]
110119
glbEnv.cluster = userInputs[4]
120+
glbEnv.hypervisor = userInputs[5]
111121
#generate UUID
112122
glbEnv.uuid = old_config.getEntry("guid")
113123
if glbEnv.uuid == "":
@@ -124,6 +134,7 @@ if __name__ == '__main__':
124134
glbEnv.zone = options.zone
125135
glbEnv.pod = options.pod
126136
glbEnv.cluster = options.cluster
137+
glbEnv.hypervisor = options.hypervisor
127138
glbEnv.nics.append(options.prvNic)
128139
glbEnv.nics.append(options.pubNic)
129140
glbEnv.nics.append(options.guestNic)

agent/conf/agent.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ domr.scripts.dir=scripts/network/domr/kvm
9393
#libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver
9494

9595
# set the hypervisor type, values are: kvm, lxc
96-
# hypervisor.type=kvm
96+
hypervisor.type=kvm
9797

9898
# set the hypervisor URI. Usually there is no need for changing this
9999
# For KVM: qemu:///system

python/lib/cloudutils/globalEnv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def __init__(self):
3232
self.pod = None
3333
#cluster id or cluster name
3434
self.cluster = None
35+
#hypervisor type. KVM/LXC. Default is KVM
36+
self.hypervisor = "kvm"
3537
#nics: 0: private nic, 1: guest nic, 2: public nic used by agent
3638
self.nics = []
3739
#uuid

python/lib/cloudutils/serviceConfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ def configAgent(self):
671671
cfo.addEntry("zone", self.syscfg.env.zone)
672672
cfo.addEntry("pod", self.syscfg.env.pod)
673673
cfo.addEntry("cluster", self.syscfg.env.cluster)
674+
cfo.addEntry("hypervisor.type", self.syscfg.env.hypervisor)
674675
cfo.addEntry("port", "8250")
675676
cfo.addEntry("private.network.device", self.syscfg.env.nics[0])
676677
cfo.addEntry("public.network.device", self.syscfg.env.nics[1])

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public boolean processTimeout(long agentId, long seq) {
203203
parameters += " --pubNic=" + kvmPublicNic;
204204
parameters += " --prvNic=" + kvmPrivateNic;
205205
parameters += " --guestNic=" + kvmGuestNic;
206+
parameters += " --hypervisor=" + cluster.getHypervisorType().toString().toLowerCase();
206207

207208
SSHCmdHelper.sshExecuteCmd(sshConnection, "cloudstack-setup-agent " + parameters, 3);
208209

0 commit comments

Comments
 (0)