升级 8.2.4 版本之后,你不需要修改任何内容。在选择创建 vm 的时候,make os type is any windows version. And boot the vm , install the cloudbase-init. you can click this link to get the latest stable version of cloudbase-init. 对不起,懒得切中文了
# Copyright 2020 Cloudbase Solutions Srl # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
from oslo_log import log as oslo_logging from cloudbaseinit import conf as cloudbaseinit_conf from cloudbaseinit.metadata.services import baseconfigdrive from cloudbaseinit.metadata.services import baseopenstackservice import os import shutil import ctypes
# 方法1:现代 PowerShell CIM 方法 (Windows Server 2016+) try: LOG.debug('Attempting to find config-2 drive using PowerShell CIM') ps_cmd = 'powershell "Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object {$_.VolumeName -eq \'config-2\'} | Select-Object -ExpandProperty DeviceID"' result = os.popen(ps_cmd).read().strip()
if result and':'in result: LOG.debug('Found drive using PowerShell CIM: %s', result) return result except Exception as e: LOG.debug('PowerShell CIM method failed: %s', e)
# 方法2:兼容旧系统的 wmic 方法 (Windows Server 2012/2019) try: LOG.debug('Attempting to find config-2 drive using wmic (legacy)') result = os.popen('wmic logicaldisk where VolumeName="config-2" get Caption | findstr /I ":"').read().strip()
if result and':'in result: LOG.debug('Found drive using wmic: %s', result) return result except Exception as e: LOG.debug('WMIC method failed: %s', e)
if result and':'in result: LOG.debug('Found drive using PowerShell WMI: %s', result) return result except Exception as e: LOG.debug('PowerShell WMI method failed: %s', e)
LOG.warning('All methods failed to find config-2 drive') returnNone
if result == 0: LOG.info('Successfully dismounted %s using PowerShell WMI', drive_letter) returnTrue else: LOG.debug('PowerShell WMI dismount failed with code: %d', result) except Exception as e: LOG.debug('PowerShell WMI dismount exception: %s', e)
LOG.error('All eject methods failed for drive: %s', drive_letter) LOG.info('Please manually eject the drive from Windows Explorer if needed') returnFalse
# Copyright 2020 Cloudbase Solutions Srl # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
from oslo_log import log as oslo_logging from cloudbaseinit import conf as cloudbaseinit_conf from cloudbaseinit.metadata.services import baseconfigdrive from cloudbaseinit.metadata.services import baseopenstackservice import os import shutil import ctypes