use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.
the class AzureUtils method validateStorageType.
public void validateStorageType(CloudStack stack) {
for (Group group : stack.getGroups()) {
InstanceTemplate template = group.getReferenceInstanceConfiguration().getTemplate();
String flavor = template.getFlavor();
String volumeType = template.getVolumeType();
AzureDiskType diskType = AzureDiskType.getByValue(volumeType);
validateStorageTypeForGroup(diskType, flavor);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(azureTemplateBuilder, "freemarkerConfiguration", configuration);
ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplatePath", templatePath);
ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplateParametersPath", "templates/parameters.ftl");
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
groups = new ArrayList<>();
stackName = "testStack";
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);
Map<String, Object> params = new HashMap<>();
params.put(CloudInstance.SUBNET_ID, "existingSubnet");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, params);
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
security = new Security(rules, null);
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
cloudContext = new CloudContext(7899L, "thisisaverylongazureresourcenamewhichneedstobeshortened", "dummy1", "dummy2", "test", Location.location(Region.region("EU"), new AvailabilityZone("availabilityZone")));
azureCredentialView = new AzureCredentialView(cloudCredential("siq-haas"));
azureStorageView = new AzureStorageView(azureCredentialView, cloudContext, azureStorage, null);
azureSubnetStrategy = AzureSubnetStrategy.getAzureSubnetStrategy(FILL, Collections.singletonList("existingSubnet"), ImmutableMap.of("existingSubnet", 100));
defaultTags.put(CloudbreakResourceType.DISK.templateVariable(), CloudbreakResourceType.DISK.key());
defaultTags.put(CloudbreakResourceType.INSTANCE.templateVariable(), CloudbreakResourceType.INSTANCE.key());
defaultTags.put(CloudbreakResourceType.IP.templateVariable(), CloudbreakResourceType.IP.key());
defaultTags.put(CloudbreakResourceType.NETWORK.templateVariable(), CloudbreakResourceType.NETWORK.key());
defaultTags.put(CloudbreakResourceType.SECURITY.templateVariable(), CloudbreakResourceType.SECURITY.key());
defaultTags.put(CloudbreakResourceType.STORAGE.templateVariable(), CloudbreakResourceType.STORAGE.key());
defaultTags.put(CloudbreakResourceType.TEMPLATE.templateVariable(), CloudbreakResourceType.TEMPLATE.key());
reset(azureUtils);
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.
the class GcpAttachedDiskResourceBuilder method build.
@Override
public List<CloudResource> build(GcpContext context, long privateId, AuthenticatedContext auth, Group group, Image image, List<CloudResource> buildableResource, Map<String, String> tags) throws Exception {
CloudInstance instance = group.getReferenceInstanceConfiguration();
InstanceTemplate template = instance.getTemplate();
Volume volume = template.getVolumes().get(0);
List<CloudResource> resources = new ArrayList<>();
List<CloudResource> syncedResources = Collections.synchronizedList(resources);
String projectId = context.getProjectId();
Location location = context.getLocation();
Compute compute = context.getCompute();
Collection<Future<Void>> futures = new ArrayList<>();
for (CloudResource cloudResource : buildableResource) {
Disk disk = createDisk(volume, projectId, location.getAvailabilityZone(), cloudResource.getName(), tags);
Future<Void> submit = intermediateBuilderExecutor.submit(() -> {
Insert insDisk = compute.disks().insert(projectId, location.getAvailabilityZone().value(), disk);
try {
Operation operation = insDisk.execute();
syncedResources.add(createOperationAwareCloudResource(cloudResource, operation));
if (operation.getHttpErrorStatusCode() != null) {
throw new GcpResourceException(operation.getHttpErrorMessage(), resourceType(), cloudResource.getName());
}
} catch (GoogleJsonResponseException e) {
throw new GcpResourceException(checkException(e), resourceType(), cloudResource.getName());
}
return null;
});
futures.add(submit);
}
for (Future<Void> future : futures) {
future.get();
}
return resources;
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method newGroupWithParams.
public Group newGroupWithParams(Map<String, Object> params) {
InstanceTemplate instanceTemplate = new InstanceTemplate(flavor, name, privateId, volumes, InstanceStatus.CREATE_REQUESTED, params, 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance cloudInstance = new CloudInstance(instanceId, instanceTemplate, instanceAuthentication);
return new Group(name, InstanceGroupType.CORE, Collections.singletonList(cloudInstance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.
the class OpenStackAttachedDiskResourceBuilder method create.
@Override
public List<CloudResource> create(OpenStackContext context, long privateId, AuthenticatedContext auth, Group group, Image image) {
List<CloudResource> cloudResources = new ArrayList<>();
InstanceTemplate template = getInstanceTemplate(group, privateId);
NovaInstanceView instanceView = new NovaInstanceView(context.getName(), template, group.getType(), group.getLoginUserName());
String groupName = group.getName();
String stackName = getUtils().getStackName(auth);
for (int i = 0; i < instanceView.getVolumes().size(); i++) {
String resourceName = resourceNameService.resourceName(resourceType(), stackName, groupName, privateId, i);
CloudResource resource = createNamedResource(resourceType(), groupName, resourceName);
resource.putParameter(VOLUME_VIEW, instanceView.getVolumes().get(i));
cloudResources.add(resource);
}
return cloudResources;
}
Aggregations