windows auto activate
目前所支持的windows镜像都是未激活状态,未激活状态下很多功能无法使用。
以后将要实现的功能是,windows虚机启动后,网络正常后能与KMS服务器通信,自动激活key

目前想到两种办法:
1、bat批处理脚本,开启自动运行,利用slmgr激活
2、cloudbase-init的LocalScriptsPlugin功能,将写好的脚本放在 cloudbaseinit.plugins.common.localscripts目录下
3、cloudbaseinit.plugins.windows.licensing.WindowsLicensingPlugin插件,该插件在代码里能实现set kms主机,及slmgr直接注入key
from oslo_log import log as oslo_logging
from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import constant
from cloudbaseinit.osutils import factory as osutils_factory
from cloudbaseinit.plugins.common import base
from cloudbaseinit.utils.windows import licensing CONF = cloudbaseinit_conf.CONF
LOG = oslo_logging.getLogger(__name__) class WindowsLicensingPlugin(base.BasePlugin): def _set_product_key(self, service, manager):
if not CONF.set_kms_product_key and not CONF.set_avma_product_key:
return description, license_family, is_current = manager.get_kms_product()
if is_current:
LOG.info('Product "%s" is already the current one, no need to set '
'a product key', description)
else:
use_avma = service.get_use_avma_licensing()
if use_avma is None:
use_avma = CONF.set_avma_product_key
LOG.debug("Use AVMA: %s", use_avma) product_key = None
if use_avma:
product_key = manager.get_volume_activation_product_key(
license_family, constant.VOL_ACT_AVMA)
if not product_key:
LOG.error("AVMA product key not found for this OS") if not product_key and CONF.set_kms_product_key:
product_key = manager.get_volume_activation_product_key(
license_family, constant.VOL_ACT_KMS)
if not product_key:
LOG.error("KMS product key not found for this OS") if product_key:
LOG.info("Setting product key: %s", product_key)
manager.set_product_key(product_key) def _set_kms_host(self, service, manager):
kms_host = service.get_kms_host() or CONF.kms_host
if kms_host:
LOG.info("Setting KMS host: %s", kms_host)
manager.set_kms_host(*kms_host.split(':')) def _activate_windows(self, service, manager):
if CONF.activate_windows:
# note(alexpilotti): KMS clients activate themselves
# so this could be skipped if a KMS host is set
LOG.info("Activating Windows")
activation_result = manager.activate_windows()
LOG.debug("Activation result:\n%s" % activation_result) def _log_licensing_info(self, manager):
if CONF.log_licensing_info:
license_info = manager.get_licensing_info()
LOG.info('Microsoft Windows license info:\n%s' % license_info) def execute(self, service, shared_data):
osutils = osutils_factory.get_os_utils() if osutils.is_nano_server():
LOG.info("Licensing info and activation are not available on "
"Nano Server")
else:
manager = licensing.get_licensing_manager() eval_end_date = manager.is_eval()
if eval_end_date:
LOG.info("Evaluation license, skipping activation. "
"Evaluation end date: %s", eval_end_date)
else:
self._set_product_key(service, manager)
self._set_kms_host(service, manager)
self._activate_windows(service, manager)
manager.refresh_status() self._log_licensing_info(manager) return base.PLUGIN_EXECUTION_DONE, False
cloudbase-init-master.cloudbaseinit.plugins.windows.licensing.py
cloud-init配置文件,需要开启cloudbaseinit.plugins.windows.licensing.WindowsLicensingPlugin插件,activate_windows=true,check_latest_version=false
参考:http://cloudbase-init.readthedocs.io/en/latest/plugins.html#winrm-listener-main

windows auto activate的更多相关文章
- 12c windows auto installl
--config for oralce_envset ORACLE_HOME=c:\app\oracle\product\12.1.0\dbhome_1set ORACLE_SID=testuatse ...
- 微软移除WIN10密码过期政策Microsoft Removes Password-Expiration Policy in Windows 10
Microsoft this week announced a series of changes to the security baseline in Windows 10, including ...
- 在windows里安装系统7、8、10或Offcie或Visio等推荐的激活工具
不多说,直接上干货! (1)激活Windows或者Office前,你务必先进去KMSAuto Net的System界面,安装KMS-host Service; (2)然后回到Main主界面,选择Act ...
- windows下安装anaconda和tensorflow
anaconda确实很好用,省去了很多麻烦,现在我个人推荐直接使用anaconda. anaconda的特点:可以存在多个python环境,要使用某一个环境的话,就需要切换到这个环境,安装.卸载包都是 ...
- dhcp、tftp及pxe简介
DHCP: 全称:Dynamic Host Configuration Protocol 动态主机配置协议 DHCP配置内容: IP/Netmask Gateway DNS Server bootp ...
- eclipse keys
Navigate Open Declaration F3 Editing Script Source Source Mark Occurrences Alt+Shift+O Editing PHP s ...
- Linux系统学习之 一:新手必须掌握的Linux命令1
2018-10-03 16:04:12 一.常用系统工作命令 1.wget 命令 作用:用于在终端中下载网络文件. 格式:wget [参数] 下载地址 参数及作用: -b : 后台下载模式 -d:显示 ...
- PXE批量部署安装Linux系统
PXE介绍 1)Preboot Excution Environment 预启动执行环境 2)Intel公司研发 3)基于Client/Server的网络模式,支持远程主机通过网络从远端服务器下载映 ...
- python使用总结
近来公司的测试部门要我们开发,按他们给我测试案例,写vba脚本,方便他们做自动化测试,老大把这事交给了我做.之前没写过vba,很多API都不会用,边写边谷歌,写得很慢. 我记得测试第一次做的是打开关闭 ...
随机推荐
- Java 截屏工具类
PrintScreenUtils.java package javax.utils; import java.awt.AWTException; import java.awt.Dimension; ...
- 【JS-Java-EL】JavaScript和Java(EL表达式)引发的 Uncaught SyntaxError: Unexpected token ILLEGAL
2018.10.14 BUG原因: 在较早期的代码中,容易出现 JS 拼接 HTML 代码字符串的情况.如 // 页面 test.jsp 内部的 JS 代码 // ${} JSP中EL语法,内部为Ja ...
- 阿里数据库连接池druid
官方wiki: https://github.com/alibaba/druid/wiki 实用方法介绍的想当详细,包含监控.扩展.大力推荐!
- 6、SpringBoot+Mybatis整合------参数传递
开发工具:STS 代码下载链接:https://github.com/theIndoorTrain/SpringBoot_Mybatis/tree/7892801d804d2060774f3720f8 ...
- jquery 操作ajax 相关方法
jQuery.get() 使用一个HTTP GET 请求从服务器加载数据. jQuery.get(url [,data] [,success(data,textStatus,jqXHR)] [dtaT ...
- github上更新fork项目
转载:https://blog.csdn.net/qq1332479771/article/details/56087333 ps:需要用GitHub所指定的chrome或者firefox浏览器,其它 ...
- 3.2.5 Magic Squares 魔板
3.2.5 Magic Squares 魔板 成功地发明了魔方之后,鲁比克先生发明了它的二维版本,称作魔板.这是一张有8个大小相同的格子的魔板: 1 2 3 4 8 7 6 5 我们知道魔板的每一个方 ...
- Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; 没有sessionFactory
maven子项目spring配置文件创建bean 没有找到另一个子项目中的bean. 需要引入另一个子项目的配置文件,仅提供测试用 如下: <!-- 仅供测试用 --> <impor ...
- ubuntu18.04.1LTS系统远程工具secureCRT
ubuntu18.04.1LTS类windows的系统下安装远程管理工具 本地电脑之前安装的是win10,疲于win10频繁的更新和各种兼容问题,果断放弃win10系统,安装了Ubuntu 18.04 ...
- sql语句(Oracle和sqlserver)
查询表的首句:(Oracle) select * from (select a.*, rownum as rn from tab_name a order by col )where rn = 1 o ...