nova中在如下的code中可以拿到os type
E:\nova\nova\compute\api.py
def _inherit_properties_from_image(self, image, auto_disk_config):
#可见属性信息是包含在image的镜像当中的
image_properties = image.get('properties', {})
auto_disk_config_img = \
utils.get_auto_disk_config_from_image_props(image_properties)
self._ensure_auto_disk_config_is_valid(auto_disk_config_img,
auto_disk_config,
image.get("id"))
if auto_disk_config is None:
auto_disk_config = strutils.bool_from_string(auto_disk_config_img)
#这里从image 属性中拿到os type
return {
'os_type': image_properties.get('os_type'),
'architecture': image_properties.get('architecture'),
'vm_mode': image_properties.get('vm_mode'),
'auto_disk_config': auto_disk_config
}
拿到os type后,再创建虚拟机的时候E:\nova\nova\virt\libvirt\driver.py中的
def _set_clock(self, guest, os_type, image_meta, virt_type):
# NOTE(mikal): Microsoft Windows expects the clock to be in
# "localtime". If the clock is set to UTC, then you can use a
# registry key to let windows know, but Microsoft says this is
# buggy in http://support.microsoft.com/kb/2687252
clk = vconfig.LibvirtConfigGuestClock()
#可见这里会根据os type来设置clk。特别注意的是如果os type是window是的话
#clk的offset 会和linux系统不一样
if os_type == 'windows':
LOG.info('Configuring timezone for windows instance to localtime')
clk.offset = 'localtime'
else:
clk.offset = 'utc'
guest.set_clock(clk)
if virt_type == "kvm":
self._set_kvm_timers(clk, os_type, image_meta)
nova 中os_type为window时需要使用localtime
最新推荐文章于 2021-08-11 18:05:27 发布