国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

OpenStack之虛機熱遷移的代碼詳細解析

2019-11-02 16:27:55
字體:
來源:轉載
供稿:網友

話說虛機遷移分為冷遷移以及熱遷移,所謂熱遷移用度娘的話說即是:熱遷移(Live Migration,又叫動態遷移、實時遷移),即虛機保存/恢復(Save/Restore):將整個虛擬機的運行狀態完整保存下來,同時可以快速的恢復到原有硬件平臺甚至是不同硬件平臺上。恢復以后,虛機仍舊平滑運行,用戶不會察覺到任何差異。OpenStack的虛機遷移是基于Libvirt實現的,下面來看看Openstack虛機熱遷移的具體代碼實現。

首先,由API入口進入到nova/api/openstack/compute/contrib/admin_actions.py

@wsgi.action('os-migrateLive')  def _migrate_live(self, req, id, body):    """Permit admins to (live) migrate a server to a new host."""    context = req.environ["nova.context"]    authorize(context, 'migrateLive')    try:      block_migration = body["os-migrateLive"]["block_migration"]      disk_over_commit = body["os-migrateLive"]["disk_over_commit"]      host = body["os-migrateLive"]["host"]    except (TypeError, KeyError):      msg = _("host, block_migration and disk_over_commit must "          "be specified for live migration.")      raise exc.HTTPBadRequest(explanation=msg)    try:      block_migration = strutils.bool_from_string(block_migration,                            strict=True)      disk_over_commit = strutils.bool_from_string(disk_over_commit,                             strict=True)    except ValueError as err:      raise exc.HTTPBadRequest(explanation=str(err))    try:      instance = self.compute_api.get(context, id, want_objects=True)      self.compute_api.live_migrate(context, instance, block_migration,                     disk_over_commit, host)    except (exception.ComputeServiceUnavailable,        exception.InvalidHypervisorType,        exception.UnableToMigrateToSelf,        exception.DestinationHypervisorTooOld,        exception.NoValidHost,        exception.InvalidLocalStorage,        exception.InvalidSharedStorage,        exception.MigrationPreCheckError) as ex:      raise exc.HTTPBadRequest(explanation=ex.format_message())    except exception.InstanceNotFound as e:      raise exc.HTTPNotFound(explanation=e.format_message())    except exception.InstanceInvalidState as state_error:      common.raise_http_conflict_for_instance_invalid_state(state_error,          'os-migrateLive')    except Exception:      if host is None:        msg = _("Live migration of instance %s to another host "            "failed") % id      else:        msg = _("Live migration of instance %(id)s to host %(host)s "            "failed") % {'id': id, 'host': host}      LOG.exception(msg)      # Return messages from scheduler      raise exc.HTTPBadRequest(explanation=msg)    return webob.Response(status_int=202)

   這里第一行可以看到是與API文檔的第二行照應的:

  

 {  "os-migrateLive": {    "host": "0443e9a1254044d8b99f35eace132080",    "block_migration": false,    "disk_over_commit": false  }}

好了,源碼中其實執行遷移工作的就是第26、27行的一條語句:

self.compute_api.live_migrate(context, instance, block_migration,                 disk_over_commit, host)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亳州市| 南阳市| 乌苏市| 宜州市| 凌海市| 青河县| 东明县| 焦作市| 贵溪市| 自贡市| 冀州市| 毕节市| 平乐县| 五莲县| 汉阴县| 崇仁县| 青神县| 宁波市| 文水县| 施甸县| 鄂托克前旗| 乃东县| 鱼台县| 盖州市| 安图县| 塔河县| 宜城市| 桐城市| 天长市| 通道| 伊吾县| 开原市| 喜德县| 濮阳市| 朔州市| 临颍县| 泰和县| 临颍县| 西乌珠穆沁旗| 嘉定区| 西宁市|