Search in sources :

Example 11 with CloudInstanceMetaData

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);
}
Also used : CloudInstanceMetaData(com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData) Address(org.openstack4j.model.compute.Address) List(java.util.List)

Example 12 with CloudInstanceMetaData

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);
    });
}
Also used : InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) CloudInstanceMetaData(com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) ServerAddressGenerator(com.sequenceiq.it.util.ServerAddressGenerator) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Aggregations

CloudInstanceMetaData (com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData)12 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)10 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)9 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)9 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)5 ArrayList (java.util.ArrayList)4 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)2 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)2 ServerAddressGenerator (com.sequenceiq.it.util.ServerAddressGenerator)2 Server (org.openstack4j.model.compute.Server)2 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 Instance (com.amazonaws.services.ec2.model.Instance)1 Reservation (com.amazonaws.services.ec2.model.Reservation)1 Compute (com.google.api.services.compute.Compute)1 AccessConfig (com.google.api.services.compute.model.AccessConfig)1 Instance (com.google.api.services.compute.model.Instance)1 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)1 LoadBalancerBackend (com.microsoft.azure.management.network.LoadBalancerBackend)1