Created
April 29, 2015 14:30
-
-
Save michaelrice/1ed5f2d8c352cf14c996 to your computer and use it in GitHub Desktop.
remove host from vcenter
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
| boolean removeHostFromVCenter() { | |
| try { | |
| // This only works on a HostSystem that is a member of a cluster. | |
| return hostSystem.destroy_Task().waitForMe().equals(Task.SUCCESS) | |
| } | |
| catch (NotSupported ns) { | |
| // If the host parent is a ComputeResource destroy it. | |
| // That means its a stand alone hostsystem. | |
| if (hostSystem.parent.class.equals(ComputeResource.class)) { | |
| log.debug("Stand alone HostSystem found. Destroying ComputeResource to remove from vCenter.") | |
| return hostSystem.parent.destroy_Task().waitForMe().equals(Task.SUCCESS) | |
| } | |
| log.error("Unable to remove HostSystem from Vcenter", ns) | |
| return false | |
| } | |
| catch (Exception e) { | |
| log.error("An unexpected error occurred.", e) | |
| } | |
| return false | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment