use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class OpenStackFlavorVerifierTest method openStackNullFlavor.
@Test(expected = CloudConnectorException.class)
public void openStackNullFlavor() {
try {
Group g1 = new Group("name", InstanceGroupType.GATEWAY, new ArrayList<>(), null, null, null, "loginUserName", "publicKey");
List<Group> instanceGroups = ImmutableList.of(g1);
when(flavorService.list()).thenReturn(null);
underTest.flavorsExist(osClient, instanceGroups);
} catch (Exception e) {
Assert.assertEquals("No flavor found on OpenStack", e.getMessage());
throw e;
}
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class HeatTemplateBuilderTest method buildTestWithExistingNetworkAndExistingSubnetAndAssignFloatingIpWithExistingSecurityGroups.
@Test
public void buildTestWithExistingNetworkAndExistingSubnetAndAssignFloatingIpWithExistingSecurityGroups() throws Exception {
assumeTrue("Template doesn't support this feature, required version is '2.x' at least", isTemplateMajorVersionGreaterOrEqualThan(2));
// GIVEN
boolean existingNetwork = true;
boolean existingSubnet = true;
NeutronNetworkView neutronNetworkView = createNeutronNetworkView("floating_pool_id");
Group group = groups.get(0);
groups.clear();
String cloudSecurityId = "sec-group-id";
Security security = new Security(Collections.emptyList(), cloudSecurityId);
Group groupWithSecGroup = new Group(group.getName(), InstanceGroupType.CORE, group.getInstances(), security, null, group.getInstanceAuthentication(), group.getInstanceAuthentication().getLoginUserName(), group.getInstanceAuthentication().getPublicKey());
groups.add(groupWithSecGroup);
// WHEN
when(openStackUtil.adjustStackNameLength(Mockito.anyString())).thenReturn("t");
ModelContext modelContext = new ModelContext();
modelContext.withExistingNetwork(existingNetwork);
modelContext.withExistingSubnet(existingSubnet);
modelContext.withGroups(groups);
modelContext.withInstanceUserData(image);
modelContext.withLocation(location());
modelContext.withStackName(stackName);
modelContext.withNeutronNetworkView(neutronNetworkView);
modelContext.withTemplateString(heatTemplateBuilder.getTemplate());
String templateString = heatTemplateBuilder.build(modelContext);
// THEN
assertThat(templateString, not(containsString("cb-sec-group_" + 't')));
assertThat(templateString, not(containsString("type: OS::Neutron::SecurityGroup")));
assertThat(templateString, containsString(cloudSecurityId));
assertThat(templateString, containsString("app_net_id"));
assertThat(templateString, not(containsString("app_network")));
assertThat(templateString, containsString("subnet_id"));
assertThat(templateString, not(containsString("app_subnet")));
assertThat(templateString, containsString("network_id"));
assertThat(templateString, containsString("public_net_id"));
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class MockResourceConnector method launch.
@Override
public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) {
List<CloudResourceStatus> cloudResourceStatuses = new ArrayList<>();
for (Group group : stack.getGroups()) {
for (int i = 0; i < group.getInstancesSize(); i++) {
CloudResource cloudResource = new Builder().type(ResourceType.MOCK_INSTANCE).status(CommonStatus.CREATED).name("cloudinstance" + cloudResourceStatuses.size()).reference("").persistent(true).build();
cloudResourceStatuses.add(new CloudResourceStatus(cloudResource, CREATED));
}
}
return cloudResourceStatuses;
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class GroupResourceService method buildResources.
public List<CloudResourceStatus> buildResources(ResourceBuilderContext context, AuthenticatedContext auth, Iterable<Group> groups, Network network, Security security) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
List<CloudResourceStatus> results = new ArrayList<>();
for (GroupResourceBuilder builder : resourceBuilders.group(cloudContext.getPlatform())) {
PollGroup pollGroup = InMemoryStateStore.getStack(auth.getCloudContext().getId());
if (pollGroup != null && CANCELLED.equals(pollGroup)) {
break;
}
for (Group group : getOrderedCopy(groups)) {
try {
CloudResource buildableResource = builder.create(context, auth, group, network);
createResource(auth, buildableResource);
CloudResource resource = builder.build(context, auth, group, network, group.getSecurity(), buildableResource);
updateResource(auth, resource);
PollTask<List<CloudResourceStatus>> task = statusCheckFactory.newPollResourceTask(builder, auth, Collections.singletonList(resource), context, true);
List<CloudResourceStatus> pollerResult = syncPollingScheduler.schedule(task);
context.addGroupResources(group.getName(), Collections.singletonList(resource));
results.addAll(pollerResult);
} catch (ResourceNotNeededException e) {
LOGGER.warn("Skipping resource creation: {}", e.getMessage());
}
}
}
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class ParameterGenerator method createCloudStack.
public CloudStack createCloudStack() {
List<Group> groups = new ArrayList<>();
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");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
Subnet subnet = new Subnet("10.0.0.0/24");
Network network = new Network(subnet);
network.putParameter("publicNetId", "028ffc0c-63c5-4ca0-802a-3ac753eaf76c");
return new CloudStack(groups, network, image, new HashMap<>(), new HashMap<>(), null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
Aggregations