From: Xiaohua Zhang Date: Mon, 15 Jul 2019 09:40:50 +0000 (+0000) Subject: Merge "Migrate docker job for multivimbroker" X-Git-Tag: 1.4.1~17 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=multicloud%2Fframework.git;a=commitdiff_plain;h=848132168436d54862ebc9ee008cc1a034e6a11d;hp=64457526dc2685a588d6b8560c9a76d01a795a4a Merge "Migrate docker job for multivimbroker" --- diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java index 9bfe264..e5cf487 100644 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java +++ b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java @@ -69,19 +69,19 @@ public class K8sArtifactForwarder implements ArtifactForwarder { private Map artifactMap; private K8sArtifactForwarderParameterGroup configurationParameters = null; - + @Override public void forward(PolicyInput policyInput) { if (policyInput instanceof CloudArtifact) { - System.out.println("get a CloudArtifact !"); + System.out.println("get a CloudArtifact !"); CloudArtifact cloudArtifact = (CloudArtifact) policyInput; artifactMap = cloudArtifact.getArtifactTypeMap(); - System.out.println("the artifactMap = " + artifactMap); + System.out.println("the artifactMap = " + artifactMap); ArrayList vfModuleModels = cloudArtifact.getVfModulePayload(); - System.out.println("the size of vfModule = " + vfModuleModels.size()); - + System.out.println("the size of vfModule = " + vfModuleModels.size()); + for (VfModuleModel vfModule : vfModuleModels) { forwardAndUpload(vfModule); } @@ -92,7 +92,7 @@ public class K8sArtifactForwarder implements ArtifactForwarder { } private void forwardAndUpload(VfModuleModel vfModule) { - + System.out.println("before create type !"); boolean definitionCreated = createDefinition(vfModule); System.out.println(" after create type !"); @@ -130,8 +130,8 @@ public class K8sArtifactForwarder implements ArtifactForwarder { } private boolean uploadArtifact(VfModuleModel vfModule) { - String url = BASE_PATH + "/" + vfModule.getVfModuleModelName() + "/" - + vfModule.getVfModuleModelVersion() + "/content"; + String url = BASE_PATH + "/" + vfModule.getVfModuleModelName() + "/" + + vfModule.getVfModuleModelVersion() + "/content"; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("content-type", "application/x-www-form-urlencoded;charset=utf-8"); @@ -143,7 +143,7 @@ public class K8sArtifactForwarder implements ArtifactForwarder { boolean found = false; for (String artifact: artifacts) { - if ( artifactMap.get(artifact) != null + if ( artifactMap.get(artifact) != null && artifactMap.get(artifact).getArtifactType().equals("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT")) { cloudArtifact = artifactMap.get(artifact); cloudUuid = cloudArtifact.getArtifactUUID(); @@ -151,17 +151,17 @@ public class K8sArtifactForwarder implements ArtifactForwarder { break; } } - + if ( found == false ) { System.out.println(" meets error , no CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT type found "); return false; } - String cloudArtifactPath = "/data/" + vfModule.getVfModuleModelCustomizationUUID() + String cloudArtifactPath = "/data/" + vfModule.getVfModuleModelCustomizationUUID() + "/" + cloudArtifact.getArtifactName(); File file = new File(cloudArtifactPath); FileEntity entity = new FileEntity(file); httpPost.setEntity(entity); - + return invokeHttpPost("uploading", httpPost); } @@ -172,15 +172,15 @@ public class K8sArtifactForwarder implements ArtifactForwarder { } protected static boolean invokeHttpPost(String action, HttpPost httpPost) { - System.out.println("httpPost begin!"); + System.out.println("httpPost URI: " + httpPost); boolean ret = false; String errorMsg; label1: { try ( CloseableHttpClient httpClient = HttpClients.createDefault() ) { - System.out.println("result1") ; + System.out.println("Execute Post Body: " + EntityUtils.toString(httpPost.getEntity())); CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); - System.out.println("result2") ; + System.out.println("result2"); String result = EntityUtils.toString(closeableHttpResponse.getEntity()); System.out.println("result = {}" + result); System.out.println("status = {}" + closeableHttpResponse.getStatusLine().getStatusCode()); @@ -194,9 +194,9 @@ public class K8sArtifactForwarder implements ArtifactForwarder { closeableHttpResponse.close(); break label1; - } catch (IOException var) { - errorMsg = action + ":httpPostWithJSON connect faild"; - System.out.println("exception: POST_CONNECT_FAILD : {}" + errorMsg); + } catch (IOException exp) { + errorMsg = action + " :invokeHttpPost failed with: " + exp.getMessage(); + System.out.println("exception: POST FAILED : {}" + errorMsg); } } diff --git a/artifactbroker/pom.xml b/artifactbroker/pom.xml index 39c9134..ef01d80 100644 --- a/artifactbroker/pom.xml +++ b/artifactbroker/pom.xml @@ -15,9 +15,9 @@ - org.onap.oparent - oparent - 2.0.0 + org.onap.multicloud.framework + multicloud-framework + 1.4.0-SNAPSHOT 4.0.0 org.onap.multicloud.framework