use of com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication in project cloudbreak by hortonworks.
the class MockInstanceUtil method addInstance.
public void addInstance(Map<String, CloudVmMetaDataStatus> instanceMap, 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);
});
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication in project cloudbreak by hortonworks.
the class MockInstanceUtil method terminateInstance.
public void terminateInstance(Map<String, CloudVmMetaDataStatus> instanceMap, String instanceId) {
CloudVmMetaDataStatus vmMetaDataStatus = instanceMap.get(instanceId);
InstanceTemplate oldTemplate = vmMetaDataStatus.getCloudVmInstanceStatus().getCloudInstance().getTemplate();
InstanceTemplate newTemplate = new InstanceTemplate("medium", "group", oldTemplate.getPrivateId(), new ArrayList<>(), InstanceStatus.TERMINATED, null, 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance cloudInstanceWithId = new CloudInstance(instanceId, newTemplate, instanceAuthentication);
CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(cloudInstanceWithId, InstanceStatus.TERMINATED);
CloudVmMetaDataStatus cloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, vmMetaDataStatus.getMetaData());
instanceMap.put(instanceId, cloudVmMetaDataStatus);
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication in project cloudbreak by hortonworks.
the class HeatTemplateBuilderTest method setup.
@Before
public void setup() throws IOException, TemplateException {
initMocks(this);
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(heatTemplateBuilder, "freemarkerConfiguration", configuration);
ReflectionTestUtils.setField(heatTemplateBuilder, "openStackHeatTemplatePath", templatePath);
stackName = "testStack";
groups = new ArrayList<>(1);
String name = "master";
List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1));
InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication);
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
Security security = new Security(rules, null);
groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
Map<String, String> tags = new HashMap<>();
tags.put(CloudbreakResourceType.DISK.templateVariable(), CloudbreakResourceType.DISK.key());
tags.put(CloudbreakResourceType.INSTANCE.templateVariable(), CloudbreakResourceType.INSTANCE.key());
tags.put(CloudbreakResourceType.IP.templateVariable(), CloudbreakResourceType.IP.key());
tags.put(CloudbreakResourceType.NETWORK.templateVariable(), CloudbreakResourceType.NETWORK.key());
tags.put(CloudbreakResourceType.SECURITY.templateVariable(), CloudbreakResourceType.SECURITY.key());
tags.put(CloudbreakResourceType.STORAGE.templateVariable(), CloudbreakResourceType.STORAGE.key());
tags.put(CloudbreakResourceType.TEMPLATE.templateVariable(), CloudbreakResourceType.TEMPLATE.key());
when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(tags);
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "url", "default", null);
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication in project cloudbreak by hortonworks.
the class MockServer method terminateInstance.
public static void terminateInstance(Map<String, CloudVmMetaDataStatus> instanceMap, String instanceId) {
CloudVmMetaDataStatus vmMetaDataStatus = instanceMap.get(instanceId);
InstanceTemplate oldTemplate = vmMetaDataStatus.getCloudVmInstanceStatus().getCloudInstance().getTemplate();
InstanceTemplate newTemplate = new InstanceTemplate("medium", "group", oldTemplate.getPrivateId(), new ArrayList<>(), InstanceStatus.TERMINATED, null, 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance cloudInstanceWithId = new CloudInstance(instanceId, newTemplate, instanceAuthentication);
CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(cloudInstanceWithId, InstanceStatus.TERMINATED);
CloudVmMetaDataStatus cloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, vmMetaDataStatus.getMetaData());
instanceMap.put(instanceId, cloudVmMetaDataStatus);
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication 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