def add(self, fail_on_error=True, fail_on_invalid_params=True, **kwargs):
"""This is a hack to associate a key with the VM hosting this cloud"""
super(LibvirtMainController, self).add(
fail_on_error=fail_on_error,
fail_on_invalid_params=fail_on_invalid_params,
add=True, **kwargs
)
# FIXME: Don't use self.cloud.host as machine_id, this prevents us from
# changing the cloud's host.
# FIXME: Add type field to differentiate between actual vm's and the
# host.
try:
machine = Machine.objects.get(cloud=self.cloud,
machine_id=self.cloud.host)
except me.DoesNotExist:
machine = Machine.objects(cloud=self.cloud,
machine_id=self.cloud.host).save()
if self.cloud.key:
machine.ctl.associate_key(self.cloud.key,
username=self.cloud.username,
port=self.cloud.port)
评论列表
文章目录