public static OraclePersistentStore mergeOracleBMCSPersistentStore(OraclePersistentStore oracle, OracleBMCSPersistentStore bmcs) { if (oracle.getTenancyId() == null && bmcs.getTenancyId() != null) { return convertFromOracleBMCSPersistentStore(bmcs); } else { return oracle; } }
private static OraclePersistentStore convertFromOracleBMCSPersistentStore(OracleBMCSPersistentStore bmcs) { OraclePersistentStore store = new OraclePersistentStore(); store.setBucketName(bmcs.getBucketName()); store.setNamespace(bmcs.getNamespace()); store.setCompartmentId(bmcs.getCompartmentId()); store.setRegion(bmcs.getRegion()); store.setUserId(bmcs.getUserId()); store.setFingerprint(bmcs.getFingerprint()); store.setSshPrivateKeyFilePath(bmcs.getSshPrivateKeyFilePath()); store.setTenancyId(bmcs.getTenancyId()); return store; } }
public OraclePersistentStore getOracle() { return OraclePersistentStore.mergeOracleBMCSPersistentStore(oracle, oraclebmcs); }
@Override protected OraclePersistentStore editPersistentStore(OraclePersistentStore persistentStore) { persistentStore.setCompartmentId(isSet(compartmentId) ? compartmentId : persistentStore.getCompartmentId()); persistentStore.setUserId(isSet(userId) ? userId : persistentStore.getUserId()); persistentStore.setFingerprint(isSet(fingerprint) ? fingerprint : persistentStore.getFingerprint()); persistentStore.setSshPrivateKeyFilePath(isSet(sshPrivateKeyFilePath) ? sshPrivateKeyFilePath : persistentStore.getSshPrivateKeyFilePath()); persistentStore.setTenancyId(isSet(tenancyId) ? tenancyId : persistentStore.getTenancyId()); persistentStore.setRegion(isSet(region) ? region : persistentStore.getRegion()); persistentStore.setBucketName(isSet(bucketName) ? bucketName : persistentStore.getBucketName()); persistentStore.setNamespace(isSet(namespace) ? namespace : persistentStore.getNamespace()); return persistentStore; } }
@Override protected S3PersistentStore editPersistentStore(S3PersistentStore persistentStore) { if(isSet(bucket) && bucket.startsWith("s3://")){ bucket = bucket.substring(5); //Line to edit out the "s3://" part of the bucket string } persistentStore.setBucket(isSet(bucket) ? bucket : persistentStore.getBucket()); persistentStore.setRootFolder(isSet(rootFolder) ? rootFolder : persistentStore.getRootFolder()); persistentStore.setRegion(isSet(region) ? region : persistentStore.getRegion()); persistentStore.setEndpoint(isSet(endpoint) ? endpoint : persistentStore.getEndpoint()); persistentStore.setAccessKeyId(isSet(accessKeyId) ? accessKeyId : persistentStore.getAccessKeyId()); persistentStore.setSecretAccessKey(isSet(secretAccessKey) ? secretAccessKey : persistentStore.getSecretAccessKey()); if (persistentStore.getBucket() == null) { String bucketName = "spin-" + UUID.randomUUID().toString(); AnsiUi.raw("Generated bucket name: " + bucketName); persistentStore.setBucket(bucketName); } return persistentStore; } }
@Override protected GcsPersistentStore editPersistentStore(GcsPersistentStore persistentStore) { persistentStore.setProject(isSet(project) ? project : persistentStore.getProject()); persistentStore.setJsonPath(isSet(jsonPath) ? jsonPath : persistentStore.getJsonPath()); persistentStore.setBucket(isSet(bucket) ? bucket : persistentStore.getBucket()); persistentStore.setRootFolder(isSet(rootFolder) ? rootFolder : persistentStore.getRootFolder()); persistentStore.setBucketLocation(isSet(bucketLocation) ? bucketLocation : persistentStore.getBucketLocation()); if (persistentStore.getBucket() == null) { String bucketName = "spin-" + UUID.randomUUID().toString(); AnsiUi.raw("Generated bucket name: " + bucketName); persistentStore.setBucket(bucketName); } return persistentStore; } }
@Override public void validate(ConfigProblemSetBuilder psBuilder, OraclePersistentStore oraclePersistentStore) { notNullOrEmpty(oraclePersistentStore.getCompartmentId(), "compartment id", psBuilder); notNullOrEmpty(oraclePersistentStore.getUserId(), "user id", psBuilder); notNullOrEmpty(oraclePersistentStore.getFingerprint(), "fingerprint", psBuilder); notNullOrEmpty(oraclePersistentStore.getSshPrivateKeyFilePath(), "ssh private key file path", psBuilder); notNullOrEmpty(oraclePersistentStore.getTenancyId(), "tenancy id", psBuilder); notNullOrEmpty(oraclePersistentStore.getNamespace(), "namespace", psBuilder); // region and bucketName *can* be null/empty - they then get defaulted in front50 code if (oraclePersistentStore.getBucketName() != null && !oraclePersistentStore.getBucketName().isEmpty()) { boolean bucketNameValid = Pattern.matches(BUCKET_REGEX, oraclePersistentStore.getBucketName()); if (!bucketNameValid) { psBuilder.addProblem(Severity.ERROR, "bucket name is invalid"); } } // TODO (simonlord): Once BMCS SDK is in maven we can access via spinnaker.dependency("clouddriverOracleBmcs") and test ensureBucket (a la GCS) }
@Override public void validate(ConfigProblemSetBuilder ps, GcsPersistentStore n) { String jsonPath = n.getJsonPath(); try { StorageService storageService = new GcsStorageService( n.getBucket(), n.getBucketLocation(), n.getRootFolder(), n.getProject(), jsonPath != null ? jsonPath : "", "halyard", registry); storageService.ensureBucketExists(); } catch (Exception e) { ps.addProblem(Severity.ERROR, "Failed to ensure the required bucket \"" + n.getBucket() + "\" exists: " + e.getMessage()); } } }
@Override protected AzsPersistentStore editPersistentStore(AzsPersistentStore persistentStore) { persistentStore.setStorageAccountName(isSet(storageAccountName) ? storageAccountName : persistentStore.getStorageAccountName()); persistentStore.setStorageAccountKey(isSet(storageAccountKey) ? storageAccountKey : persistentStore.getStorageAccountKey()); persistentStore.setStorageContainerName(isSet(storageContainerName) ? storageContainerName : persistentStore.getStorageContainerName()); return persistentStore; } }
@Override public void validate(ConfigProblemSetBuilder ps, AzsPersistentStore n) { String connectionString = "DefaultEndpointsProtocol=https;AccountName=" + n.getStorageAccountName() + ";AccountKey=" + n.getStorageAccountKey(); try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString); CloudBlobContainer container = storageAccount.createCloudBlobClient().getContainerReference(n.getStorageContainerName()); container.exists(); } catch (Exception e) { ps.addProblem(Problem.Severity.ERROR, "Failed to connect to the Azure storage account \"" + n.getStorageAccountName() + "\": " + e.getMessage()); return; } } }
@Override protected OraclePersistentStore editPersistentStore(OraclePersistentStore persistentStore) { persistentStore.setCompartmentId(isSet(compartmentId) ? compartmentId : persistentStore.getCompartmentId()); persistentStore.setUserId(isSet(userId) ? userId : persistentStore.getUserId()); persistentStore.setFingerprint(isSet(fingerprint) ? fingerprint : persistentStore.getFingerprint()); persistentStore.setSshPrivateKeyFilePath(isSet(sshPrivateKeyFilePath) ? sshPrivateKeyFilePath : persistentStore.getSshPrivateKeyFilePath()); persistentStore.setPrivateKeyPassphrase(isSet(privateKeyPassphrase) ? privateKeyPassphrase : persistentStore.getPrivateKeyPassphrase()); persistentStore.setTenancyId(isSet(tenancyId) ? tenancyId : persistentStore.getTenancyId()); persistentStore.setRegion(isSet(region) ? region : persistentStore.getRegion()); persistentStore.setBucketName(isSet(bucketName) ? bucketName : persistentStore.getBucketName()); persistentStore.setNamespace(isSet(namespace) ? namespace : persistentStore.getNamespace()); return persistentStore; } }
private static OraclePersistentStore convertFromOracleBMCSPersistentStore(OracleBMCSPersistentStore bmcs) { OraclePersistentStore store = new OraclePersistentStore(); store.setBucketName(bmcs.getBucketName()); store.setNamespace(bmcs.getNamespace()); store.setCompartmentId(bmcs.getCompartmentId()); store.setRegion(bmcs.getRegion()); store.setUserId(bmcs.getUserId()); store.setFingerprint(bmcs.getFingerprint()); store.setSshPrivateKeyFilePath(bmcs.getSshPrivateKeyFilePath()); store.setTenancyId(bmcs.getTenancyId()); return store; } }
@Override protected S3PersistentStore editPersistentStore(S3PersistentStore persistentStore) { if(isSet(bucket) && bucket.startsWith("s3://")){ bucket = bucket.substring(5); //Line to edit out the "s3://" part of the bucket string } persistentStore.setBucket(isSet(bucket) ? bucket : persistentStore.getBucket()); persistentStore.setRootFolder(isSet(rootFolder) ? rootFolder : persistentStore.getRootFolder()); persistentStore.setRegion(isSet(region) ? region : persistentStore.getRegion()); persistentStore.setEndpoint(isSet(endpoint) ? endpoint : persistentStore.getEndpoint()); persistentStore.setAccessKeyId(isSet(accessKeyId) ? accessKeyId : persistentStore.getAccessKeyId()); persistentStore.setSecretAccessKey(isSet(secretAccessKey) ? secretAccessKey : persistentStore.getSecretAccessKey()); if (persistentStore.getBucket() == null) { String bucketName = "spin-" + UUID.randomUUID().toString(); AnsiUi.raw("Generated bucket name: " + bucketName); persistentStore.setBucket(bucketName); } return persistentStore; } }
@Override protected GcsPersistentStore editPersistentStore(GcsPersistentStore persistentStore) { persistentStore.setProject(isSet(project) ? project : persistentStore.getProject()); persistentStore.setJsonPath(isSet(jsonPath) ? jsonPath : persistentStore.getJsonPath()); persistentStore.setBucket(isSet(bucket) ? bucket : persistentStore.getBucket()); persistentStore.setRootFolder(isSet(rootFolder) ? rootFolder : persistentStore.getRootFolder()); persistentStore.setBucketLocation(isSet(bucketLocation) ? bucketLocation : persistentStore.getBucketLocation()); if (persistentStore.getBucket() == null) { String bucketName = "spin-" + UUID.randomUUID().toString(); AnsiUi.raw("Generated bucket name: " + bucketName); persistentStore.setBucket(bucketName); } return persistentStore; } }
@Override public void validate(ConfigProblemSetBuilder psBuilder, OraclePersistentStore oraclePersistentStore) { notNullOrEmpty(oraclePersistentStore.getCompartmentId(), "compartment id", psBuilder); notNullOrEmpty(oraclePersistentStore.getUserId(), "user id", psBuilder); notNullOrEmpty(oraclePersistentStore.getFingerprint(), "fingerprint", psBuilder); notNullOrEmpty(oraclePersistentStore.getSshPrivateKeyFilePath(), "ssh private key file path", psBuilder); notNullOrEmpty(oraclePersistentStore.getTenancyId(), "tenancy id", psBuilder); notNullOrEmpty(oraclePersistentStore.getNamespace(), "namespace", psBuilder); // region and bucketName *can* be null/empty - they then get defaulted in front50 code if (oraclePersistentStore.getBucketName() != null && !oraclePersistentStore.getBucketName().isEmpty()) { boolean bucketNameValid = Pattern.matches(BUCKET_REGEX, oraclePersistentStore.getBucketName()); if (!bucketNameValid) { psBuilder.addProblem(Severity.ERROR, "bucket name is invalid"); } } // TODO (simonlord): Once BMCS SDK is in maven we can access via spinnaker.dependency("clouddriverOracleBmcs") and test ensureBucket (a la GCS) }
@Override protected AzsPersistentStore editPersistentStore(AzsPersistentStore persistentStore) { persistentStore.setStorageAccountName(isSet(storageAccountName) ? storageAccountName : persistentStore.getStorageAccountName()); persistentStore.setStorageAccountKey(isSet(storageAccountKey) ? storageAccountKey : persistentStore.getStorageAccountKey()); persistentStore.setStorageContainerName(isSet(storageContainerName) ? storageContainerName : persistentStore.getStorageContainerName()); return persistentStore; } }
@Override public void validate(ConfigProblemSetBuilder ps, AzsPersistentStore n) { String connectionString = "DefaultEndpointsProtocol=https;AccountName=" + n.getStorageAccountName() + ";AccountKey=" + n.getStorageAccountKey(); try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString); CloudBlobContainer container = storageAccount.createCloudBlobClient().getContainerReference(n.getStorageContainerName()); container.exists(); } catch (Exception e) { ps.addProblem(Problem.Severity.ERROR, "Failed to connect to the Azure storage account \"" + n.getStorageAccountName() + "\": " + e.getMessage()); return; } } }
public static OraclePersistentStore mergeOracleBMCSPersistentStore(OraclePersistentStore oracle, OracleBMCSPersistentStore bmcs) { if (oracle.getTenancyId() == null && bmcs.getTenancyId() != null) { return convertFromOracleBMCSPersistentStore(bmcs); } else { return oracle; } }
public OraclePersistentStore getOracle() { return OraclePersistentStore.mergeOracleBMCSPersistentStore(oracle, oraclebmcs); }
@Override public NodeIterator getChildren() { List<Node> nodes = new ArrayList<Node>(); NodeIterator children = NodeIteratorFactory.makeReflectiveIterator(this); Node child = children.getNext(); while (child != null) { if (!child.getNodeName().equals("oracle") && !child.getNodeName().equals("oraclebmcs")) { nodes.add(child); } child = children.getNext(); } nodes.add(OraclePersistentStore.mergeOracleBMCSPersistentStore(oracle, oraclebmcs)); return NodeIteratorFactory.makeListIterator(nodes); }