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
| package com.example; | |
| import com.wordnik.swagger.annotations.ApiParam; | |
| import javax.ws.rs.GET; | |
| import javax.ws.rs.Path; | |
| import javax.ws.rs.PathParam; | |
| import javax.ws.rs.Produces; | |
| import javax.ws.rs.core.MediaType; | |
| import javax.ws.rs.core.Response; |
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
| # .___.__ | |
| # __| _/|__| ____ ____ | |
| # / __ | | |/ \ / ___\ | |
| # / /_/ | | | | \/ /_/ > | |
| # \____ | |__|___| /\___ / | |
| # \/ \//_____/ | |
| # | |
| # Make a "ding" sound on your Mac! Useful for notifying you when a command | |
| # line script has finished. | |
| # |
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
| package com.neolitec.examples; | |
| import org.apache.commons.codec.binary.Base64; | |
| import org.apache.commons.lang.StringUtils; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import javax.servlet.*; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; |
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
| def test_vm_to_mac(self): | |
| si = connect.SmartConnect(host='vcsa', | |
| user='my_user', | |
| pwd='my_password') | |
| content = si.RetrieveContent() | |
| # where the name of the VM is 'box' | |
| vm = content.searchIndex.FindByInventoryPath("Datacenter0/vm/box") | |
| self.assertEqual(vm.name, 'box') | |
| nics = [dev for dev in vm.config.hardware.device | |
| if isinstance(dev, vim.vm.device.VirtualEthernetCard)] |
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
| from __future__ import print_function | |
| from pyVim import connect | |
| def list_all_networks_and_vms(): | |
| si = connect.SmartConnect(host='vcsa', | |
| user='root', | |
| pwd='my_password') | |
| root_folder = si.content.rootFolder | |
| datacenters = [entity for entity in root_folder.childEntity | |
| if hasattr(entity, 'networkFolder')] |
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
| testvm = # handwaving | |
| spec = host.configManager.autoStartManager.config | |
| auto_power_info = vim.host.AutoStartManager.AutoPowerInfo() | |
| auto_power_info.key = testvm | |
| auto_power_info.startAction = vim.VirtualMachine.PowerState.poweredOn #note use of constant instead of string | |
| auto_power_info.startDelay = 60 | |
| auto_power_info.startOrder = 1 | |
| auto_power_info.stopAction = None # note: the Python constant 'None' not a string | |
| auto_power_info.stopDelay = -1 # note the use of numeric value here. |
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 | |
| from __future__ import print_function | |
| from pyVim import connect | |
| from pyVmomi import vim | |
| si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
| content = si.RetrieveContent() |
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
| si = connect.SmartConnect(host='vcsa', | |
| user='my_user', | |
| pwd='my_password') | |
| content = si.RetrieveContent() | |
| datacenters = [entity for entity in content.rootFolder.childEntity | |
| if hasattr(entity, 'vmFolder')] | |
| dc = None | |
| for datacenter in datacenters: |
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
| si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
| content = si.RetrieveContent() | |
| # the details we will need to make the disk: | |
| disk_path = '[my_storage] my/path/to/my.vmdk' | |
| adapter_type = vim.VirtualDiskManager.VirtualDiskAdapterType.lsiLogic | |
| disk_type = vim.VirtualDiskManager.VirtualDiskType.preallocated | |
| capacity_kb = 16 * 1024 * 1024 # some arbitrary size | |
| # the spec for the disk: |
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
| si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
| content = si.RetrieveContent() | |
| datacenters = [entity for entity in content.rootFolder.childEntity | |
| if hasattr(entity, 'vmFolder')] | |
| dc = None | |
| for datacenter in datacenters: | |
| if datacenter.name == 'my_datacenter': | |
| dc = datacenter |