コード例 #1
0
 @Override
 public Cluster convert(ClusterRequest source) {
   Cluster cluster = new Cluster();
   cluster.setName(source.getName());
   cluster.setStatus(REQUESTED);
   cluster.setDescription(source.getDescription());
   cluster.setEmailNeeded(source.getEmailNeeded());
   cluster.setUserName(source.getUserName());
   cluster.setPassword(source.getPassword());
   Boolean enableSecurity = source.getEnableSecurity();
   cluster.setSecure(enableSecurity == null ? false : enableSecurity);
   KerberosRequest kerberos = source.getKerberos();
   KerberosConfig kerberosConfig = new KerberosConfig();
   if (source.getKerberos() != null) {
     kerberosConfig.setKerberosMasterKey(kerberos.getMasterKey());
     kerberosConfig.setKerberosAdmin(kerberos.getAdmin());
     kerberosConfig.setKerberosPassword(kerberos.getPassword());
     kerberosConfig.setKerberosUrl(kerberos.getUrl());
     kerberosConfig.setKerberosRealm(kerberos.getRealm());
     kerberosConfig.setKerberosTcpAllowed(kerberos.getTcpAllowed());
     kerberosConfig.setKerberosPrincipal(kerberos.getPrincipal());
     kerberosConfig.setKerberosLdapUrl(kerberos.getLdapUrl());
     kerberosConfig.setKerberosContainerDn(kerberos.getContainerDn());
   }
   cluster.setKerberosConfig(kerberosConfig);
   cluster.setLdapRequired(source.getLdapRequired());
   cluster.setConfigStrategy(source.getConfigStrategy());
   cluster.setEnableShipyard(source.getEnableShipyard());
   cluster.setEmailTo(source.getEmailTo());
   FileSystemBase fileSystem = source.getFileSystem();
   cluster.setCloudbreakAmbariPassword(PasswordUtil.generatePassword());
   cluster.setCloudbreakAmbariUser("cloudbreak");
   if (fileSystem != null) {
     cluster.setFileSystem(getConversionService().convert(fileSystem, FileSystem.class));
   }
   try {
     Json json = new Json(convertBlueprintInputJsons(source.getBlueprintInputs()));
     cluster.setBlueprintInputs(
         source.getBlueprintInputs() == null ? new Json(new HashMap<>()) : json);
     if (source.getBlueprintCustomProperties() != null) {
       cluster.setBlueprintCustomProperties(source.getBlueprintCustomProperties());
     } else {
       cluster.setBlueprintCustomProperties(null);
     }
   } catch (JsonProcessingException e) {
     cluster.setBlueprintInputs(null);
   }
   return cluster;
 }
コード例 #2
0
  @Test(expected = BadRequestException.class)
  public void testStopWhenAwsHasEphemeralVolume() {
    cluster =
        TestUtil.cluster(
            TestUtil.blueprint(), TestUtil.stack(Status.AVAILABLE, TestUtil.awsCredential()), 1L);
    stack = TestUtil.setEphemeral(cluster.getStack());
    cluster.setStatus(Status.AVAILABLE);
    cluster.setStack(stack);
    stack.setCluster(cluster);

    when(stackService.get(anyLong())).thenReturn(stack);
    when(stackService.getById(anyLong())).thenReturn(stack);

    underTest.updateStatus(1L, StatusRequest.STOPPED);
  }