controllers.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:mist.api 作者: mistio 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号