Skip to content

Instantly share code, notes, and snippets.

View yfauser's full-sized avatar

Yves Fauser yfauser

View GitHub Profile
@yfauser
yfauser / get_nsxmandetails_vc.py
Created February 7, 2017 08:32
A small script to retrieve the NSX Manager Version and IP from vCenters extension Manager
#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2015-2016 VMware, Inc. All Rights Reserved.
#
# Licensed under the X11 (MIT) (the “License”) set forth below;
#
# you may not use this file except in compliance with the License. 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
@yfauser
yfauser / get_vnic_external_id.py
Created August 15, 2016 09:57
Tool to retrieve the external Id for a vnic using an opaque network
#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2015-2016 VMware, Inc. All Rights Reserved.
#
# Licensed under the X11 (MIT) (the “License”) set forth below;
#
# you may not use this file except in compliance with the License. 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
@yfauser
yfauser / vc_reconnect.py
Created June 11, 2016 08:57
This is an example on how to build a decorator that reauthenticates with vCenter in case the session times out
#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2016 VMware, Inc. All Rights Reserved.
#
# Licensed under the X11 (MIT) (the “License”) set forth below;
#
# you may not use this file except in compliance with the License. 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
@yfauser
yfauser / test_module_owm_curl.py
Created February 21, 2016 10:53
This is another example Ansible Module written in Python with the module.run_command method demonstrating a couple of key concepts for a Meetup presentation
#!/usr/bin/python
import json
def main():
module = AnsibleModule(
argument_spec=dict(
appkey=dict(required=True),
city=dict(default='munich,de'),
treshold=dict(required=True, type='float')
@yfauser
yfauser / test_module_owm.py
Created February 20, 2016 19:33
This is an example Ansible Module written in Python demonstrating a couple of key concepts for a Meetup presentation
#!/usr/bin/python
import requests
import json
def get_temperature(appkey, city, module, units='metric'):
session = requests.Session()
headers = {'Content-Type': 'application/json'}
url = 'http://api.openweathermap.org/data/2.5/weather'
params = {'q': city, 'APPID': appkey, 'units': units}
@yfauser
yfauser / retrieve_vcenter_moids.py
Last active October 26, 2015 00:33
This is an example on how to retrieve several vCenter moids, including the DC, Cluster, RP, DVS, Datastore and Port-Group Objects
#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2015 VMware, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#