DatacenterManager datacenterManager = host.getDatacenterManager();
if (!(datacenterManager instanceof Ec2DatacenterManager)) {
throw new IllegalStateException("Expected EC2 datacenter manager, found: " + datacenterManager);
}
Ec2DatacenterManager manager = (Ec2DatacenterManager) datacenterManager;
AmazonEC2Client ec2 = manager.getEc2Client(host);
String ec2InstanceId = manager.findHost(host);
if (ec2InstanceId == null) {
throw new IllegalStateException("Unable to find EC2 instance for host: " + host);
}
Instance ec2Instance = describeInstance(ec2, ec2InstanceId);