def setEntryPoint(self, instance_id, port, host_id):
for clone_guest in self.getCloneGuestList():
#if clone_guest.getGuestId() == "desktop" and clone_guest.getIndex() == 1:
if clone_guest.getIsEntryPoint() == True and clone_guest.getIndex() == 1:
self.entry_point.setAddr(clone_guest.getNicAddrDict()["eth0"])
self.entry_point.setPort(port)
# Generate random account and passwd for entry point.
s = string.lowercase+string.digits
# OLD VERSION: Random suffix of 5 digits
#account = "trainee{0}".format(''.join(random.sample(s,5)))
# NEW VERSION: Use instance id as suffix (add 1 so as to start from 1)
# Use leading zeros (up to 2 digits) to match current Moodle settings
account = "trainee{number:02d}".format(number=(instance_id+1))
passwd = ''.join(random.sample(s,10))
self.entry_point.setAccount(account)
self.entry_point.setPasswd(passwd)
self.entry_point.setHostId(host_id)
评论列表
文章目录