use of com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData in project cloudbreak by hortonworks.
the class ComputeApiExtractor method extractMetadata.
@Override
public CloudInstanceMetaData extractMetadata(OSClient<?> client, Server server, String instanceId) {
String hypervisor = hypervisorExtractor.getHypervisor(server);
String privateIp = null;
String floatingIp = null;
Map<String, List<? extends Address>> adrMap = server.getAddresses().getAddresses();
LOGGER.debug("Address map: {} of instance: {}", adrMap, server.getName());
for (Entry<String, List<? extends Address>> entry : adrMap.entrySet()) {
LOGGER.debug("Network resource key: {} of instance: {}", entry.getKey(), server.getName());
for (Address adr : entry.getValue()) {
LOGGER.debug("Network resource key: {} of instance: {}, address: {}", entry.getKey(), server.getName(), adr);
switch(adr.getType()) {
case "fixed":
privateIp = adr.getAddr();
LOGGER.info("PrivateIp of instance: {} is {}", server.getName(), privateIp);
break;
case "floating":
floatingIp = adr.getAddr();
LOGGER.info("FloatingIp of instance: {} is {}", server.getName(), floatingIp);
break;
default:
LOGGER.error("No such network resource type: {}, instance: {}", adr.getType(), server.getName());
}
}
}
return new CloudInstanceMetaData(privateIp, floatingIp, hypervisor);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData in project cloudbreak by hortonworks.
the class MockServer method addInstance.
public void addInstance(int numberOfAddedInstances) {
ServerAddressGenerator serverAddressGenerator = new ServerAddressGenerator(numberOfAddedInstances);
serverAddressGenerator.setFrom(instanceMap.size());
serverAddressGenerator.iterateOver((address, number) -> {
String instanceId = "instance-" + address;
InstanceTemplate instanceTemplate = new InstanceTemplate("medium", "group", Integer.toUnsignedLong(number), new ArrayList<>(), InstanceStatus.CREATED, null, 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance cloudInstanceWithId = new CloudInstance(instanceId, instanceTemplate, instanceAuthentication);
CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(cloudInstanceWithId, InstanceStatus.STARTED);
CloudInstanceMetaData cloudInstanceMetaData = new CloudInstanceMetaData(address, mockServerAddress, sshPort, "MOCK");
CloudVmMetaDataStatus cloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, cloudInstanceMetaData);
instanceMap.put(instanceId, cloudVmMetaDataStatus);
});
}
Aggregations