ovirtclient.py 文件源码

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

项目:ovirt-desktop-client 作者: nkovacne 项目源码 文件源码
def change_status(self, rowid):
        """
            Description: If the user clicks on the column which determines VM's status, we'll allow them
                         to change VM's status. This method shows a confirmation dialog and if accepted,
                         it will be notified to oVirt.
            Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
            Returns: Nothing
        """

        global conf

        self.lastclick = int(time())         # Last click timestamp update

        curvmstatus = self.vmdata[rowid].vmstatus
        if curvmstatus != 'up' and curvmstatus != 'down':
            QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
            return

        reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), '%s <b>%s</b>. %s: <b>%s</b>.' % (_('current_vm_status'), self.current_vm_status(curvmstatus), _('confirm_vm_status_change'), self.toggle_vm_action(curvmstatus)), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            try:
                vm = conf.OVIRTCONN.vms.get(id=self.vmdata[rowid].vmid)
            except ConnectionError:
                QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop'))
                quit()

            if curvmstatus == 'up':
                try:
                    vm.shutdown()
                    QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('shutting_down_vm'))
                except RequestError:
                    QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
            if curvmstatus == 'down':
                try:
                    vm.start()
                    QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('powering_up_vm'))
                except RequestError:
                    QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号