Created
March 7, 2016 09:02
-
-
Save rgerganov/6a0512eed39091bd583d to your computer and use it in GitHub Desktop.
Script for setting vpxd options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Script for setting vpxd options | |
# Example: vpxdcfg.py -host vcenter \ | |
# -user root \ | |
# -password vmware \ | |
# -key config.vmacore.http.readTimeoutMs \ | |
# -value 600000 | |
import argparse | |
from oslo_vmware import api | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-host', help='vCenter host', required=True) | |
parser.add_argument('-user', help='vCenter user', required=True) | |
parser.add_argument('-password', help='vCenter password', required=True) | |
parser.add_argument('-key', help='Option key', required=True) | |
parser.add_argument('-value', help='Option value', required=True) | |
args = parser.parse_args() | |
session = api.VMwareAPISession(args.host, args.user, args.password, | |
10, 0.5, insecure=True) | |
client_factory = session.vim.client.factory | |
opt = client_factory.create('ns0:OptionValue') | |
opt.key = args.key | |
opt.value = args.value | |
setting = session.vim.service_content.setting | |
session.invoke_api(session.vim, 'UpdateOptions', setting, changedValue=[opt]) | |
print('Done.') | |
session.logout() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment