salt-states/_states/auto_activate.py

23 lines
699 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, print_function
def auto_activate(name):
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
if __salt__['license.licensed']():
ret['comment'] = 'Windows is already activated'
return ret
licensing = __salt__['cmd.powershell']("Get-WmiObject SoftwareLicensingService")
if licensing is not None:
OEM_key = licensing.get('OA3xOriginalProductKey', '')
if OEM_key != "":
return __states__['license.activate'](OEM_key)
ret['comment'] = 'No Windows Key found in BIOS'
ret['result'] = False
return ret