use of com.sequenceiq.common.api.type.InstanceGroupType 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, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L, "default-id", TemporaryStorage.ATTACHED_VOLUMES, 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, "subnet-123", "eu1a");
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, emptyList());
groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), 50, Optional.empty(), createGroupNetwork(), emptyMap()));
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
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(), null);
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class UserDataService method createUserData.
public void createUserData(Long stackId) throws CloudbreakImageNotFoundException {
Stack stack = stackService.getByIdWithLists(stackId);
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
Future<PlatformParameters> platformParametersFuture = intermediateBuilderExecutor.submit(() -> connector.getPlatformParameters(stack, userCrn));
SecurityConfig securityConfig = securityConfigService.generateAndSaveSecurityConfig(stack);
stack.setSecurityConfig(securityConfig);
stackService.save(stack);
SaltSecurityConfig saltSecurityConfig = securityConfig.getSaltSecurityConfig();
String cbPrivKey = saltSecurityConfig.getSaltBootSignPrivateKey();
byte[] cbSshKeyDer = PkiUtil.getPublicKeyDer(new String(Base64.decodeBase64(cbPrivKey)));
String sshUser = stack.getStackAuthentication().getLoginUserName();
String cbCert = securityConfig.getClientCert();
String saltBootPassword = saltSecurityConfig.getSaltBootPassword();
try {
PlatformParameters platformParameters = platformParametersFuture.get();
CcmConnectivityParameters ccmParameters = ccmUserDataService.fetchAndSaveCcmParameters(stack);
Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByEnvironmentCrn(stack.getEnvironmentCrn());
Map<InstanceGroupType, String> userData = userDataBuilder.buildUserData(Platform.platform(stack.getCloudPlatform()), cbSshKeyDer, sshUser, platformParameters, saltBootPassword, cbCert, ccmParameters, proxyConfig.orElse(null));
imageService.decorateImageWithUserDataForStack(stack, userData);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Failed to get Platform parmaters", e);
throw new GetCloudParameterException("Failed to get Platform parmaters", e);
}
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method init.
@Before
public void init() throws CloudbreakImageCatalogException {
MockitoAnnotations.initMocks(this);
Workspace workspace = new Workspace();
clusterRequest = new ClusterV4Request();
stack = new Stack();
stack.setId(STACK_ID);
stack.setName("test-stack");
stack.setWorkspace(workspace);
Blueprint blueprint = new Blueprint();
blueprint.setBlueprintText("{}");
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "userdata");
Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", IMAGE_CATALOG_NAME, "id", Collections.emptyMap());
imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
cluster = new Cluster();
stack.setCluster(cluster);
cluster.setStack(stack);
cluster.setBlueprint(blueprint);
cluster.setWorkspace(workspace);
setupDefaultClouderaManagerEntries();
Map<String, ImageBasedDefaultCDHInfo> defaultCDHInfoMap = Map.of(OLDER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(OLDER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), SOME_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(SOME_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), NEWER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(NEWER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)));
when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), null, IMAGE_CATALOG_NAME)).thenReturn(defaultCDHInfoMap);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
stackMatrixV4Response.setCdh(Collections.singletonMap(OLDER_CDH_VERSION, null));
when(stackMatrixService.getStackMatrix(Mockito.eq(workspace.getId()), Mockito.eq(null), Mockito.anyString())).thenReturn(stackMatrixV4Response);
when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform("AWS"));
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class JsonTest method testMultipleSerialisationWithOtherConstructorOfImage.
@Test
public void testMultipleSerialisationWithOtherConstructorOfImage() throws IOException {
Map<InstanceGroupType, String> userData = new EnumMap<>(InstanceGroupType.class);
userData.put(InstanceGroupType.CORE, "CORE");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
Json json = new Json(image);
String expected = json.getValue();
Image covertedAgain = json.get(Image.class);
json = new Json(covertedAgain);
Assert.assertEquals(expected, json.getValue());
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class SecurityAccessManifester method overrideSecurityAccess.
public void overrideSecurityAccess(InstanceGroupType instanceGroupType, List<InstanceGroupV4Request> instanceGroups, String securityGroupId, String cidrs) {
instanceGroups.stream().filter(ig -> ig.getType() == instanceGroupType).forEach(ig -> {
SecurityGroupV4Request securityGroup = ig.getSecurityGroup();
if (securityGroup == null) {
securityGroup = new SecurityGroupV4Request();
}
if (!internalApiCallCalculator.isInternalApiCall(securityGroup)) {
if (!Strings.isNullOrEmpty(securityGroupId)) {
securityGroup.setSecurityGroupIds(getSecurityGroupIds(securityGroupId));
securityGroup.setSecurityRules(new ArrayList<>());
} else if (!Strings.isNullOrEmpty(cidrs)) {
List<SecurityRuleV4Request> generatedSecurityRules = new ArrayList<>();
List<SecurityRuleV4Request> originalSecurityRules = securityGroup.getSecurityRules();
for (String cidr : CidrUtil.cidrs(cidrs)) {
SecurityRuleUtil.propagateCidr(generatedSecurityRules, originalSecurityRules, cidr);
}
// Because of YCLOUD we should not set this if null
if (originalSecurityRules != null) {
securityGroup.setSecurityRules(generatedSecurityRules);
}
securityGroup.setSecurityGroupIds(new HashSet<>());
} else {
securityGroup.setSecurityGroupIds(new HashSet<>());
securityGroup.setSecurityRules(new ArrayList<>());
}
}
});
}
Aggregations