diff options
Diffstat (limited to 'sdc-distribution-ci/src/main/java')
7 files changed, 830 insertions, 0 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java new file mode 100644 index 0000000..8b2b129 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.utils.DistributionActionResultEnum; + +public class AdvanceCallBack extends SimpleCallback{ + + + + public AdvanceCallBack(IDistributionClient client) { + super(client); + // TODO Auto-generated constructor stub + } + + @Override + protected void postDownloadLogic( IDistributionClientDownloadResult downloadResult) { + if( downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + saveArtifactPayloadToDisk(downloadResult); + } + + } + + protected void saveFile(byte[] bs, String fileName) { + try { + String downloadPath = SimpleConfiguration.downloadPath(); + FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName); + fileOuputStream.write(bs); + fileOuputStream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) { + System.out.println("################ Downloaded Artifact Payload Start ################"); + String fileName = downloadResult.getArtifactName().replaceAll("attachment; filename=",""); + saveFile(downloadResult.getArtifactPayload(), fileName.replaceAll("\"", "")); + System.out.println("################ Downloaded Artifact Payload End ################"); + } + + + + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java new file mode 100644 index 0000000..7d79571 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Enum That Represents possible Artifacts Types. + * + */ +public enum ArtifactTypeEnum { + CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), ICON("ICON"), UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), + HEAT_ENV("HEAT_ENV"), YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"), NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), + TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), VENDOR_LICENSE("VENDOR_LICENSE"), + MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), + HEAT_ARTIFACT("HEAT_ARTIFACT"), VF_MODULES_METADATA("VF_MODULES_METADATA"), + // DCAE Artifacts + DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), + DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), + DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), + // AAI Artifacts + AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), + // MIB artifacts + SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE") + ; + + ArtifactTypeEnum(String type) { + this.type = type; + } + + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static ArtifactTypeEnum findType(final String type) { + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + // According to Pavel/Ella + if (ate.getType().equalsIgnoreCase(type)) { + return ate; + } + } + return null; + } + + public static List<String> getAllTypes() { + List<String> types = new ArrayList<String>(); + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + types.add(ate.getType()); + } + return types; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java new file mode 100644 index 0000000..519684b --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.IOException; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.tosca.parser.impl.SdcCsarHelperImpl; +import org.openecomp.sdc.toscaparser.ToscaParser; +import org.openecomp.sdc.toscaparser.ToscaParserFactory; +import org.openecomp.sdc.toscaparser.api.ToscaTemplate; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.LoggerContext; + +public class ClientTest { + public static void main(String[] args) throws Exception { + /* ToscaParserFactory toscaParserFactory = null; + try { + toscaParserFactory = new ToscaParserFactory(); + ToscaParser parser = toscaParserFactory.create(); + ToscaTemplate toscaTemplate = parser.parse("test.csar"); + SdcCsarHelperImpl csarHelper = new SdcCsarHelperImpl(toscaTemplate); + String serviceSubstitutionMappingsTypeName = csarHelper.getServiceSubstitutionMappingsTypeName(); + System.out.println("serviceSubstitutionMappingsTypeName is "+serviceSubstitutionMappingsTypeName); + } + catch (Exception e){ + System.out.println(e); + } + finally{ + if (toscaParserFactory != null){ + toscaParserFactory.close(); + } + }*/ + + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.getLogger("org.apache.http").setLevel(Level.INFO); + + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + INotificationCallback callback; + Boolean download = SimpleConfiguration.toDownload(); + if( download ){ + callback = new AdvanceCallBack(client); + } + else{ + callback = new SimpleCallback(client); + } + IDistributionClientResult result = client.init(new SimpleConfiguration(), callback); + + System.out.println(result.getDistributionMessageResult()); + + System.out.println("Starting client..."); + IDistributionClientResult startResult = client.start(); + + // Thread.sleep(10000); + // client.stop(); + + System.out.println(startResult.getDistributionMessageResult()); + + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java new file mode 100644 index 0000000..c7345f2 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +public class Decoder { + + public static String encode(byte[] byteArrayToEncode) { + + byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode); + String strEncoded = new String(bytesEncoded); + return strEncoded; + } + + public static String decode(String strEncoded) throws IOException { + + byte[] byteDecoded = Base64.decodeBase64(strEncoded); + String decoded = new String(byteDecoded); + + return decoded; + + } + + public static String readFileToString(String file) throws IOException { + + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line = null; + StringBuilder stringBuilder = new StringBuilder(); + String ls = System.getProperty("line.separator"); + + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + stringBuilder.append(ls); + } + reader.close(); + return stringBuilder.toString(); + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java new file mode 100644 index 0000000..3b2d772 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.notification.INotificationData; + +public class NotificationCallback extends SimpleCallback{ + INotificationData latestCallbackData; + public INotificationData getData() { + return latestCallbackData; + } + public NotificationCallback(IDistributionClient client) { + super(client); + } + + public void activateCallback(INotificationData data) { + this.latestCallbackData = data; + super.activateCallback(data); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java new file mode 100644 index 0000000..1166109 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java @@ -0,0 +1,309 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.utils.ArtifactTypeEnum; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; + + +public class SimpleCallback implements INotificationCallback { + protected IDistributionClient client; + public List<IArtifactInfo> iArtifactInfo; + + public final Map<String, IDistributionClientResult> simpleCallbackResults = new HashMap<String, IDistributionClientResult>(); + + public Map<String, IDistributionClientResult> getSimpleCallbackResults() { + return simpleCallbackResults; + } + + public List<IArtifactInfo> getIArtifactInfo(){ + return iArtifactInfo; + } + public SimpleCallback(IDistributionClient client) { + this.client = client; + } + + + + + + public void activateCallback(INotificationData data) { + + List<IArtifactInfo> artifacts = getArtifacts(data); + + + for (IArtifactInfo iArtifactInfo : artifacts) { + + IArtifactInfo artifactMetadataByUUID = data.getArtifactMetadataByUUID(iArtifactInfo.getArtifactUUID()); + assertEquals("check artifact checksum", iArtifactInfo.getArtifactChecksum(), artifactMetadataByUUID.getArtifactChecksum()); + System.out.println(artifactMetadataByUUID.getArtifactURL()); + if (artifactMetadataByUUID.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){ + IDistributionClientDownloadResult download = client.download(iArtifactInfo); + if (download.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + List<IVfModuleMetadata> decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload()); +// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2); + if (!decodeVfModuleArtifact.isEmpty()){ + for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) { + List<String> moduleArtifacts = moduleMetadata.getArtifacts(); + if (moduleArtifacts != null) { + + for (String artifactId : moduleArtifacts) { + + IArtifactInfo artifactInfo = data.getArtifactMetadataByUUID(artifactId); + IDistributionClientDownloadResult downloadArt = client.download(artifactInfo); + assertEquals(downloadArt.getDistributionActionResult(), DistributionActionResultEnum.SUCCESS); + + } + + } + } + } + } + } + } + + + for (IArtifactInfo relevantArtifact : artifacts){ + // Download Artifact + IDistributionClientDownloadResult downloadResult = client.download(relevantArtifact); + + postDownloadLogic(downloadResult); + + + + simpleCallbackResults.put("downloadResult", downloadResult); + System.out.println("downloadResult: " + downloadResult.toString()); + System.out.println("<<<<<<<<<<< Artifact content >>>>>>>>>>"); + System.out.println(Decoder.encode(downloadResult.getArtifactPayload())); + + /////Print artifact content to console/////// + +// byte[] contentInBytes = BaseEncoding.base64().decode(Decoder.encode(downloadResult.getArtifactPayload())); +// try { +// System.out.println("Source content: " + new String(contentInBytes, "UTF-8")); +// } catch (UnsupportedEncodingException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + System.out.println("ArtInfo_timeout: "+ relevantArtifact.getArtifactTimeout()); + System.out.println("ArtInfo_Art_description: "+ relevantArtifact.getArtifactDescription()); + System.out.println("ArtInfo_Art_CheckSum: "+ relevantArtifact.getArtifactChecksum()); + System.out.println("ArtInfo_Art_Url: "+ relevantArtifact.getArtifactURL()); + System.out.println("ArtInfo_Art_Type: "+ relevantArtifact.getArtifactType()); + System.out.println("ArtInfo_Art_Name: "+ relevantArtifact.getArtifactName()); + System.out.println("ArtInfo_UUID: " + relevantArtifact.getArtifactUUID()); + System.out.println("ArtInfo_Version: " + relevantArtifact.getArtifactVersion()); + System.out.println("ArtInfo_RelatedArtifacts: "+ relevantArtifact.getRelatedArtifacts()); + + System.out.println("ArtInfo_Serv_description: " + data.getServiceDescription()); + System.out.println("ArtInfo_Serv_Name: " + data.getServiceName()); + System.out.println("Get_serviceVersion: " + data.getServiceVersion()); + System.out.println("Get_Service_UUID: " + data.getServiceUUID()); + System.out.println("ArtInfo_DistributionId: " + data.getDistributionID()); + System.out.println("ArtInfo_ServiceInvariantUUID: " + data.getServiceInvariantUUID()); + + + // assertTrue("response code is not 200, returned :" + downloadResult.getDistributionActionResult(), downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + try { + String payload = new String(downloadResult.getArtifactPayload()); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); +// System.out.println(payload); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); + + } catch (Exception e) { + System.out.println("catch"); +// break; + // TODO: handle exception + } + + + + + if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { + handleSuccessfullDownload(data, relevantArtifact); + } else { + handleFailedDownload(data, relevantArtifact); + } + } +// if (data != null){ +// iArtifactInfo.addAll(artifacts); +// } + + } + + private List<IArtifactInfo> getArtifacts(INotificationData data) { + List<IArtifactInfo> ret = new ArrayList<IArtifactInfo>(); + List<IResourceInstance> resources = data.getResources(); +// data.getArtifactMetadataByUUID(arg0) + List<String> relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes(); + + List<IArtifactInfo> collect = resources.stream().flatMap( e -> e.getArtifacts().stream()).filter(p -> relevantArtifactTypes.contains(p.getArtifactType() )).collect(Collectors.toList()); +// if( resources != null ){ +// for( IResourceInstance resourceInstance : resources){ +// if( resourceInstance.getArtifacts() != null ){ +// +// +// +// ret.addAll(resourceInstance.getArtifacts()); +// +// +// } +// } +// } + ret.addAll(collect); + + List<IArtifactInfo> servicesArt = data.getServiceArtifacts(); + if( servicesArt != null ){ + ret.addAll(servicesArt); + } + + System.out.println("I am here: " + ret.toString()); + return ret; + } + + + + private void handleFailedDownload(INotificationData data, + IArtifactInfo relevantArtifact) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR)); + postDownloadStatusSendLogic(sendDownloadStatus); + } + + private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK)); + + simpleCallbackResults.put("sendDownloadStatus", sendDownloadStatus); +// assertTrue("response code is not 200, returned :" + sendDownloadStatus.getDistributionActionResult(), sendDownloadStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + // Doing deployment ... + postDownloadStatusSendLogic(sendDownloadStatus); + boolean isDeployedSuccessfully = handleDeployment(); + IDistributionClientResult deploymentStatus; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (isDeployedSuccessfully) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_OK)); + + simpleCallbackResults.put("sendDeploymentStatus", deploymentStatus); +// assertTrue("response code is not 200, returned :" + deploymentStatus.getDistributionActionResult(), deploymentStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + } else { + deploymentStatus = handleFailedDeployment(data, relevantArtifact); + } + + postDeploymentStatusSendLogic(deploymentStatus); + } + + private IDistributionClientResult handleFailedDeployment(INotificationData data, IArtifactInfo relevantArtifact) { + IDistributionClientResult deploymentStatus; + boolean isAlreadyDeployed = checkIsDeployed(); + if (isAlreadyDeployed) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.ALREADY_DEPLOYED)); + } else { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_ERROR)); + } + return deploymentStatus; + } + + protected void postDownloadLogic(IDistributionClientDownloadResult downloadResult) { + // TODO Auto-generated method stub + + } + + private void postDownloadStatusSendLogic( + IDistributionClientResult sendDownloadStatus) { + // TODO Auto-generated method stub + + } + + private void postDeploymentStatusSendLogic( + IDistributionClientResult deploymentStatus) { + // TODO Auto-generated method stub + + } + + private boolean checkIsDeployed() { + return false; + } + + private boolean handleDeployment() { + return true; +// to return deploy_error use return false +// return false; + } + + public static IDistributionStatusMessage buildStatusMessage( + final IDistributionClient client, final INotificationData data, + final IArtifactInfo relevantArtifact, + final DistributionStatusEnum status) { + IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() { + + public long getTimestamp() { + long currentTimeMillis = System.currentTimeMillis(); + return currentTimeMillis; + } + + public DistributionStatusEnum getStatus() { + return status; + } + + public String getDistributionID() { + return data.getDistributionID(); + } + + public String getConsumerID() { + return client.getConfiguration().getConsumerID(); + } + + public String getArtifactURL() { + return relevantArtifact.getArtifactURL(); + } + }; + return statusMessage; + } + + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java new file mode 100644 index 0000000..9c07c12 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.util.List; + +import org.openecomp.sdc.api.consumer.IConfiguration; + +public class SimpleConfiguration implements IConfiguration{ + + /*public String getUser() + { + return System.getProperty("user"); + } + + public List<String> getRelevantArtifactTypes() { + return ArtifactTypeEnum.getAllTypes(); + } + + public int getPollingTimeout() + { + return 20; + } + + public int getPollingInterval() + { + return 20; + } + + public String getPassword() + { + return System.getProperty("password"); + } + + public String getEnvironmentName() + { + return System.getProperty("env"); + } + + public String getConsumerID() + { + return System.getProperty("consumerID"); + } + + public String getConsumerGroup() + { + return System.getProperty("groupID"); + } + + public String getAsdcAddress() + { + return System.getProperty("beAddress"); + } + + public String getKeyStorePath() + { + return ""; + } + + public String getKeyStorePassword() + { + return "Aa123456"; + } + + public boolean activateServerTLSAuth() + { + return Boolean.parseBoolean(System.getProperty("auth")); +// res.add(ArtifactTypeEnum.HEAT_ARTIFACT); +// res.add(ArtifactTypeEnum.HEAT_ENV); +// res.add(ArtifactTypeEnum.MURANO_PKG); +// res.add(ArtifactTypeEnum.VF_LICENSE); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE); +// res.add(ArtifactTypeEnum.VNF_CATALOG); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.VF_MODULES_METADATA); +// return "PROD-Tedy-Only"; +// return "A-AI"; +// return "A-AI"; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public static Boolean toDownload() { + return false; + }*/ + + public String getUser() { + return "ci"; + } + + public List<String> getRelevantArtifactTypes() { + +// List<String> res = new ArrayList<String>(); +// for (ArtifactTypeEnum type : AssetTypeEnum.values()){ +// res.add(type.name()); +// } + return ArtifactTypeEnum.getAllTypes(); + } + + + public int getPollingTimeout() { + return 20; + } + + public int getPollingInterval() { + return 20; + } + + public String getPassword() { + return "123456"; + } + + public String getEnvironmentName() { + return "PROD"; + } + + public String getConsumerID() { + return "consumerVasya"; + } + + public String getConsumerGroup() { + return "groupVasya"; + + } + + public static Boolean toDownload() { + return false; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public String getAsdcAddress() { + return "127.0.0.1:8443"; + } + + @Override + public String getKeyStorePath() { + //return ""; + return "etc/asdc-client.jks"; + } + + @Override + public String getKeyStorePassword() { + + return "Aa123456"; + } + + @Override + public boolean activateServerTLSAuth() { + + return false; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + +} |