diff options
Diffstat (limited to 'ncomp-openstack-controller/src/main')
28 files changed, 4955 insertions, 0 deletions
diff --git a/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/Generator.java b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/Generator.java new file mode 100644 index 0000000..397b827 --- /dev/null +++ b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/Generator.java @@ -0,0 +1,76 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.openstack.controller.tools;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.openecomp.utils.YamlToJava;
+import org.openecomp.ncomp.openstack.OpenstackFactory;
+import org.openecomp.ncomp.openstack.location.LocationFactory;
+import org.openecomp.ncomp.sirius.manager.controllermodel.ControllerModel;
+import org.openecomp.ncomp.sirius.manager.controllermodel.ControllermodelFactory;
+import org.openecomp.ncomp.sirius.manager.generator.ControllerGenerator;
+//import org.openecomp.ncomp.sirius.manager.gui.GuiFactory;
+import org.openecomp.ncomp.sirius.manager.server.ServerPackage;
+
+
+public class Generator {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ @SuppressWarnings("unused")
+ ServerPackage f = ServerPackage.eINSTANCE;
+ EObject o = OpenstackFactory.eINSTANCE.createOpenStackController();
+ EPackage p = o.eClass().getEPackage();
+ String dir = p.getNsURI().replace(p.getNsPrefix(),"") + "servers." + p.getNsPrefix();
+ dir= "src/main/sirius-gen/" + dir.replace('.', '/');
+ ControllerModel m = ControllermodelFactory.eINSTANCE.createControllerModel();
+ m.setTemplateDirectory("../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
+ m.setPrefix("Os");
+ m.setPluginName(p.getNsURI());
+ m.setName("OpenStackController");
+ m.setTitle("OpenStack Controller");
+ ControllerGenerator g = new ControllerGenerator(o,m);
+ EObject loc =LocationFactory.eINSTANCE.createOpenStackLocation();
+ g.addObject("loc",loc,m);
+ g.setEnableIRequestHandler(false);
+ //EObject gui = GuiFactory.eINSTANCE.createGuiClientApi();
+ //g.addObject("gui",gui,m);
+ //EObject e = OpenstackFactory.eINSTANCE.createVpnEnterprise();
+ //g.addApi("e",e,m);
+ //g.addFactory("org.openecomp.ncomp.sirius.servers.openstack.OsOpenstackFactory");
+ g.generate(dir);
+ g.generateAnt("./ant.xml",true,true);
+ g.generateScripts("src/main/server-gen/bin","openstack-controller");
+ String pName = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix() +".logging";
+ YamlToJava.convert("src/main/resources/OpenStackAdaptor.yaml", dir + "/logging", pName);
+ YamlToJava.convert("src/main/sirius-gen/OpenStackController.yaml", dir + "/logging", pName);
+ String pName1 = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix() +".loc.logging";
+ YamlToJava.convert("src/main/sirius-gen/OpenStackLocation.yaml", dir + "/loc/logging", pName1);
+
+ }
+
+
+}
diff --git a/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/OpenStackUtil.groovy b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/OpenStackUtil.groovy new file mode 100644 index 0000000..55155fc --- /dev/null +++ b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/openstack/controller/tools/OpenStackUtil.groovy @@ -0,0 +1,1028 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.openstack.controller.tools + +import org.openecomp.ncomp.sirius.manager.JavaHttpClient; +import org.openecomp.ncomp.sirius.manager.Jetty8Client; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.Subject; +import org.openecomp.ncomp.sirius.manager.server.Response +import org.openecomp.ncomp.core.NamedEntity +import org.openecomp.ncomp.core.User +import org.openecomp.ncomp.openstack.* +import org.openecomp.ncomp.openstack.core.* +import org.openecomp.ncomp.openstack.location.* +import org.openecomp.ncomp.openstack.compute.* +import org.openecomp.ncomp.openstack.location.OpenStackLocation +import org.openecomp.ncomp.openstack.location.OpenStackProject +import org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest; +import org.openecomp.ncomp.openstack.neutron.NeutronFactory; +import org.openecomp.ncomp.openstack.neutron.NeutronObject; +import org.openecomp.ncomp.openstack.neutron.NeutronPackage; +import org.openecomp.ncomp.openstack.neutron.NeutronRequest +import org.openecomp.ncomp.webservice.utils.FileUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage +import org.eclipse.emf.ecore.EReference +import org.eclipse.emf.ecore.util.EcoreUtil +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpExchange; +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.io.BufferUtil; +import org.eclipse.jetty.io.ByteArrayBuffer +import org.json.JSONObject +import org.json.JSONArray + +import static org.openecomp.ncomp.utils.PropertyUtil.getPropertiesFromClasspath + + +class OpenStackUtil { + public static final Logger logger = Logger.getLogger(OpenStackUtil.class); + public static final Logger plogger = Logger.getLogger("org.openecomp.ncomp.openstack.OpenStackUtil.polling"); + Properties props + List<OpenStackControllerProject> projects = [] + ManagementServer server + OpenStackLocation loc // used for polling + OpenStackLocation realLocation // location in controller state. + boolean debug = false + int serverCreationTimeout + public long pollingFrequency = 300000 + + public OpenStackUtil(OpenStackLocation loc1, ManagementServer server1, String file = "openstack.properties") { + props = getPropertiesFromClasspath(file); + EPackage p1 = LocationPackage.eINSTANCE; + debug = Boolean.parseBoolean(props.getProperty("server.debug","false")); + serverCreationTimeout = Integer.parseInt(props.get("serverCreationTimeout","120")) + pollingFrequency = Integer.parseInt(props.get("pollingFrequency","300000")) + server = server1 + realLocation = loc1 + loc = EcoreUtil.copy(loc1) + loc.projects.each { p -> + projects += new OpenStackControllerProject(p) + } + System.err.println "OPENSTACK: debug=$debug pollingFrequency=$pollingFrequency" + logger.info("Found ${projects.size()} projects".toString()) + if (!projects.find { it.tenantName == "admin"}) { + logger.warn("Missing Admin Openstack project") + } + } + static main(args) { + // BROKEN WITH THE NEW SETUP. Need to create Location object + // ALWAYS USE GMT. + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + OpenStackUtil openstack = new OpenStackUtil() + switch ("T") { + case "T": + CreateNetworkRequest r = NeutronFactory.eINSTANCE.createCreateNetworkRequest() + r.name = "someone-test" + r.tenant_id = openstack.projects[0].tenantId + openstack.projects[0].create(r) + break + case "P": + openstack.poll() + println openstack.server.ecore2json(openstack.loc, 100, null, false).toString(2) + break + case "S": openstack.projects[0].createServer(); break + } + + } + public OpenStackLocation poll() { + if (loc.keystoneUrl == null) { + logger.warn("No keystoneUrl for $loc.name") + return + } + plogger.info "Starting Logging" + if (props.get("noPoll","no") == "yes") return null + loc.images.clear() + def oldFlavors = [] + loc.flavors.each { f -> oldFlavors += f } + loc.flavors.clear() + + if (projects.size() == 0) { + logger.warn("No project to poll") + return + } + + projects[0].updateGeneric(loc,"image") + try { + projects[0].updateGeneric(loc,"flavor") + } + catch (e) { + } + if (loc.flavors.size() == 0) { + logger.warn("Empty Flavor list, using old") + System.err.println("Empty Flavor list, using old") + oldFlavors.each { f -> loc.flavors.add(f) } + } + projects.each {OpenStackControllerProject p -> + p.poll() + } + realLocation.mergeLocation(loc) + server.save() +// plogger.debug("${server.ecore2json(loc, 100, null, false).toString(2)}".toString()) + plogger.info "Done Logging" + + return loc + } + static def object2json(o,boolean fix = false) { + switch (o) { + case JSONObject: return o + case EObject: return ManagementServer.ecore2json(o, 100, null, false) + case List: + def j = [] as JSONArray + o.each { j.put(object2json(it,fix)) } + return j + case Map: + def j = [:] as JSONObject + o.each { String k,v -> + if (v == null) return + if (!fix) {j.put(k,object2json(v)); return} + switch (k) { + case "addresses": + def a = [] as JSONArray + j.put(k,a) + v.each { k1, v1 -> + a.put(object2json([ name : k1, ips : v1],fix)) + } + break + case "metadata": + def a = [] as JSONArray + j.put(k,a) + v.each { k1, v1 -> + a.put(object2json([ key : k1, value :v1],fix)) + } + break + case ~/.*:.*/: + // eg OS-EXT-STS:vm_state + j.put(k.replace("-", "_").replace(":", "_"),object2json(v,fix)) +// String[] a = k.split(":") +// String nn = a[1] +// def j1 = [:] as JSONObject +// j1.put(nn,object2json(v,fix)) +// j.put(a[0].replace("-", "_").toLowerCase(),j1) + break + default: j.put(k,object2json(v,fix)) + } + } + return j + case boolean: case Boolean: + case int: case Integer: + case long: case Long: + case double: case Double: + case JSONObject.Null: + case null: + case String: return o; break + case GString: return o.toString(); break + default: logger.warn "Unable to convert: $o".toString() + } + } + def json2object (o) { + switch (o) { + case JSONObject: + def m = [:] + o.map.each { n,v -> m[n] = json2object(v) } + return m + case JSONArray: + def a = [] + o.myArrayList.each { a += json2object(it) } + return a + case boolean: case Boolean: + case int: case Integer: + case long: case Long: + case double: case Double: + case null: + case JSONObject.NULL: + case String: return o; break + case GString: return o.toString(); break + default: logger.warn "Unable to convert to object: $o ${o.getClass().name}".toString() + } + } + //{"flavor": {"vcpus": 1, "disk": 10, "name": "someone.test", "os-flavor-access:is_public": true, "rxtx_factor": 1, "OS-FLV-EXT-DATA:ephemeral": 33, "ram": 200, "id": 10001, "swap": 0}} + def x = [:] + def createFlavor(String projectName, VirtualMachineType vmType) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == projectName} + if (p == null) return "No project with name $projectName" + def fName = vmType.name + def i = null + switch (loc.version) { + case OpenStackVersion.FOLSOM: // old BSA version + def flavors = p.httpJsonTransaction([url : "${p.urls['nova']}/flavors"],false) + x.flavors = flavors + def existingId = null + synchronized (loc) { + i = loc.flavorId + 1 + flavors.flavors.each { ff -> + def j = Integer.parseInt(ff.id) + // if (debug) System.err.println "Existing Flavors: id=$ff.id name=$ff.name" + if (i <= j) i = j + 1 + if (fName == ff.name) existingId = ff.id + } + loc.flavorId = i + server.save() + } + break; + } + def req = [ + url : "${p.urls['nova']}/flavors", + method : "POST", + body : [ flavor : [ + vcpus: vmType.numberOfCores, + disk: vmType.rootDiskSizeGB, + name: fName, + "os-flavor-access:is_public": true, + rxtx_factor: 1, + "OS-FLV-EXT-DATA:ephemeral": vmType.diskSizeGB, + ram: vmType.memorySizeMB, + swap: 0] + ] + ] + if (i != null) req.body.flavor.identity = i + x.req = req + def res = p.httpJsonTransaction(req,false) + x.res = res + } + def createSecurityGroup(String projectName, VirtualMachineType vmType) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == projectName} + if (p == null) return "No project with name $projectName" + def gName = vmType.name + def req = [ + url : "${p.urls['nova']}/os-security-groups", + method : "POST", + body : [ security_group : [ name: gName, description : "Automatically created" ] ] + ] + x.req = req + def res = p.httpJsonTransaction(req,false) + // {"security_group_rule": {"from_port": 22, "ip_protocol": "tcp", "to_port": 22, "parent_group_id": 12, "cidr": "0.0.0.0/0", "group_id": null}} + vmType.incomingSecurityRules.each { SecurityRule r -> + def id = res.security_group.id + def req2 = [ + url : "${p.urls['nova']}/os-security-group-rules", + method : "POST", + body : [ security_group_rule : [ + from_port: r.portRangeStart, + to_port: r.portRangeEnd, + ip_protocol: r.ipProtocol.toString(), + cidr: r.prefix, + parent_group_id: id, + ] ] + ] + def res2 = p.httpJsonTransaction(req2,false) + } + x.res = res + } + def delete(String projectName, String type, String name) { + if (debug) System.err.println "DELETING $projectName $type $name" + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == projectName} + if (p == null) return "No project with name $projectName" + def types = "${type}s" + def idName = "id" + def oName = "name" + def api = "nova" + def dtypes = types + def nameAttr = loc.version == OpenStackVersion.FOLSOM ? "display_name" : "name" + switch (type) { + case "volume": oName = nameAttr; api = "cinder"; break + case "flavor": types = "$types/detail"; break + case "security_group": types = "os-security-groups"; dtypes = types; break + case "keypair": + p.httpJsonTransaction([url : "${p.urls[api]}/os-$types/$name", method:"DELETE"],false,true,true,false) + if (debug) System.err.println "$type name=$name deleted" + return + } + def l = p.httpJsonTransaction([url : "${p.urls[api]}/$types"],false) + if (debug) System.err.println "l=$l" + if (debug) System.err.println "DELETE LIST:" + l["${type}s"].each { if (debug) System.err.println it } + if (debug) System.err.println "type=$type types=$types oName=$oName name=$name idName=$idName" + def fl = l["${type}s"].findAll { it[oName] == name } + if (debug) System.err.println "DELETEING LIST: $fl" + if (fl.size() == null) return "No $type with name $name" + fl.each { f -> + p.httpJsonTransaction([url : "${p.urls[api]}/$dtypes/${f[idName]}", method:"DELETE"],false,true,true,false) + if (debug) System.err.println "$type name=$name id=${f[idName]} deleted" + } + } + + // {"volume": {"status": "creating", "availability_zone": "nova:lab2-bsa-02-bay04", + // "display_description": null, "snapshot_id": null, "user_id": null, "size": 2, + // "display_name": "someone.test", "imageRef": null, "attach_status": "detached", + // "volume_type": null, "project_id": null, "metadata": {}}} + def createVolume (OpenstackRequestNewServer req) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == req.projectName} + if (p == null) return "No project with name $projectName" + def reqV = [url : "${p.urls['cinder']}/volumes/detail"] + def resV = p.httpJsonTransaction(reqV,false) +// System.out.println("VVVVVVVVVVVVVVVVVV: ${reqV}") +// System.out.println("VVVVVVVVVVVVVVVVVV: ${resV}") + def nameAttr = loc.version == OpenStackVersion.FOLSOM ? "display_name" : "name" + def existingVol = resV.volumes.find { vol -> + ( vol["display_name"] ?: vol["name"] ) == req.name + } + if (existingVol != null) { + if (debug) System.err.println "EXISTING VOLUME: ${existingVol}" + switch (loc.version) { + case OpenStackVersion.FOLSOM: + if (existingVol.availability_zone != "nova:$req.hypervisor") + return [status:"error",message:"existing volume on wrong hypervisor: $existingVol.availability_zone"] + } + if ("$existingVol.size" != "$req.vmType.volumeSizeGB") + return [status:"error",message:"existing volume has wrong size: $existingVol.size"] + if (existingVol.status != "available") + return [status:"error",message:"existing volume is not available: $existingVol.status"] + return [status: "ok", volume: existingVol] + } + def req1 = [ + url : "${p.urls['cinder']}/volumes", + method : "POST", + body : [ volume : [ + display_name: req.name, + size: req.vmType.volumeSizeGB] + ] + ] + if (req.hypervisor != null) { + req1.body.volume.availability_zone = "nova:$req.hypervisor" + } + def res1 = p.httpJsonTransaction(req1,false,false) +// System.out.println("VVVVVVVVVVVVVVVVVV req1: ${req1}") +// System.out.println("VVVVVVVVVVVVVVVVVV res1: ${res1}") + def volume = res1.volume ?: null + // wait for the new volume to be available. Wait at most 10 seconds. + (1..10).each { + if (volume == null || volume.status == "available") return + sleep 1000 + res1 = p.httpJsonTransaction([url : "${p.urls['cinder']}/volumes/$volume.id"],false,false) +// System.out.println("VVVVVVVVVVVVVVVVVV res1 LOOP: ${res1}") + volume = res1.volume ?: null + } + if (volume == null) return [status:"error",message:res1] + if (volume.status != "available") return [status:"error",message:"new volume did not become available"] + return [status: "ok", volume: volume] + } + // {"server": {"name": "someone.test", "imageRef": "9a460998-6501-4008-9eed-a510cf9a13bc", + // "availability_zone": "nova:lab3-bsa-03-bay03", "key_name": "someone", "flavorRef": "2", + // "max_count": 1, "min_count": 1, "networks": [], + // "security_groups": [{"name": "default"}, {"name": "ssh"}]}} + def createServer (OpenstackRequestNewServer req) { + OpenStackControllerProject p + def loc = realLocation + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == req.projectName} + if (p == null) throw new RuntimeException( "No project with name $req.projectName" ) + if (req.vmType == null) throw new RuntimeException("Null VmType") + String flavorName = req.vmType.flavorName ?: req.vmType.name + def flavor = loc.flavors.find { it.name == flavorName } + if (flavor == null) { + System.err.println "flavors $loc.name: ${loc.flavors.collect {it.name}}" + throw new RuntimeException("No flavor with name '$flavorName'") + } + if (req.vmType.imageName == null) req.vmType.imageName = req.vmType.name + def image = loc.images.find { it.name == req.vmType.imageName } + if (image == null) throw new RuntimeException( "No image with name $req.vmType.imageName") + def keypair = p.project.keypairs.find { it.name == req.user } + if (req.user != null && keypair == null) throw new RuntimeException( "No key pair with name $req.user") + def req1 = [ + url : "${p.urls['nova']}/servers", + method : "POST", + body : [ server : [ + name: req.name, + imageRef: image.id, + key_name: req.user, + flavorRef: flavor.id, + max_count: 1, min_count: 1, networks: [], + security_groups: [[name: "default"]], + config_drive: true, + ], + ] + ] + if (! loc.supportsSecurityGroups) req1.body.server.remove('security_groups') + req.networks.each {network -> req1.body.server.networks += [uuid:network]} + req.ports.each {port -> req1.body.server.networks += [port:port]} + if (req.hypervisor != null) { + req1.body.server.availability_zone = "nova:$req.hypervisor" + } + if (req.user_data != null) { + req1.body.server.user_data = req.user_data + } + x["req"] = req1 + logger.info "create server request: ${object2json(req1).toString(2)}" + def server = p.httpJsonTransaction(req1,false) + logger.info "create server return: ${object2json(server).toString(2)}" + if (! server.server) { + throw new RuntimeException("create server failed: ${object2json(server).toString(2)}") + } + def vol + if (req.vmType.volumeSizeGB > 0) { + vol = createVolume(req) +// System.err.println "VOLUME= $req $vol " + if (vol.status != "ok") { + throw new RuntimeException("create volume failed: $vol.message") + } + } + String sid = server.server.id + // wait upto 2 minutes for status to become ACTIVE + def status = "??" + (1..serverCreationTimeout/5).each { + if (status == "ACTIVE") return + sleep 5000 + def x = p.httpJsonTransaction([url : "${p.urls['nova']}/servers/$sid"]) +// if (debug) System.err.println "Waiting status=$x.server.status" + status = x.server.status + } + logger.info "Done waiting status=$status" + if (status != "ACTIVE") { + throw new RuntimeException("create server failed to get ACTIVE: ${object2json(server).toString(2)}") + } +// if (debug) System.err.println object2json(server).toString(2) + if (req.vmType.volumeSizeGB > 0) { +// if (debug) System.err.println object2json(vol.volume).toString(2) + def attach = [ + url : "${p.urls['nova']}/servers/$sid/os-volume_attachments", + method : "POST", + body : [ volumeAttachment: [volumeId: vol.volume.id, device: "/dev/vdc"]] + ] + server["volume"] = vol +// if (debug) System.err.println "attach request: ${object2json(attach).toString(2)}" + def a = p.httpJsonTransaction(attach,false) +// if (debug) System.err.println object2json(a).toString(2) + server["volume_attach"] = a + } + if (req.vmType.incomingSecurityRules.size() > 0 && loc.supportsSecurityGroups) { + def addSecurityGroup = [ + url : "${p.urls['nova']}/servers/$sid/action", + method : "POST", + body : [ addSecurityGroup: [name: "$req.vmType.name"]] + ] + def res4 = p.httpJsonTransaction(addSecurityGroup,false,true,true,false) + } + if (req.vmType.needPublicIp) { + sleep 10000 + server["ip"] = addFloatingIp(req.projectName, sid, req.floatingIp) + } + x["res"] = server +// if (debug) System.err.println object2json(server).toString(2) + return server + } + def createKeypair (String projectName, User user) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == projectName} + if (p == null) return "No project with name $projectName" + def req1 = [ + url : "${p.urls['nova']}/os-keypairs", + method : "POST", + body : [ keypair : [ + name: user.name, + public_key: user.publicKey] + ] + ] + def k = p.httpJsonTransaction(req1,false) +// if (debug) System.err.println k + return k + } + def addFloatingIp(String projectName,sid,requestIp) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == projectName} + if (p == null) return "No project with name $projectName" + def res = p.httpJsonTransaction([url : "${p.urls['nova']}/os-floating-ips"],false) + def ip = null +// if (debug) System.err.println object2json(res).toString(2) + res.floating_ips.each { x -> + if (debug) System.err.println "AAAAAAAAAA ${object2json(x).toString(2)} ${x['instance_id']}" + if (requestIp != null && requestIp != "$x.ip") return + if ("${x['instance_id']}" == "null") ip = x.ip + } + if (requestIp != null && ip == null) { + throw new RuntimeException("Unable to find requested floating IP: $requestIp") + } + if (ip == null) { + res = p.httpJsonTransaction([method:"POST", url : "${p.urls['nova']}/os-floating-ips"],false) +// if (debug) System.err.println object2json(res).toString(2) + ip = res.floating_ip.ip + if (debug) System.err.println "Using new ip: $ip" + } else { + if (debug) System.err.println "Using old ip: $ip" + } + def req = [ + url : "${p.urls['nova']}/servers/$sid/action", + method : "POST", + body : [ addFloatingIp: [address: ip]] + ] +// if (debug) System.err.println object2json(req).toString(2) + p.httpJsonTransaction(req,false,true,true,false) + return ip + } + def action(req) { + switch (req) { + case OpenstackRequestDelete: delete(req.projectName,req.objectType, req.objectName); break + case OpenstackRequestKeyPair: createKeypair(req.projectName,req.user); break + case OpenstackRequestFlavor: createFlavor(req.projectName,req.vmType); break + case OpenstackRequestSecurityGroup: createSecurityGroup(req.projectName,req.vmType); break + case OpenstackRequestNewServer: + def r = createServer(req) + logger.info "createServer returns: $r" + break; + } + } + Response serverAction(OpenstackRequestServerAction req) { + OpenStackControllerProject p + p = projects.find {OpenStackControllerProject p1 -> p1.tenantName == req.projectName} + if (p == null) { + logger.warn "serverAction with null $req.projectName" + throw new RuntimeException("no Openstack project $req.projectName") + } + Server s = p.project.servers.find { it.name == req.name } + if (s == null) { + logger.warn "serverAction unable to find VM with name $req.name in $req.projectName" + throw new RuntimeException("unable to find VM with name $req.name in $req.projectName") + } + def url = "${p.urls['nova']}/servers/$s.ID/action" + def res + switch (req.action) { + case "stop": + case "start": + res = p.httpJsonTransaction([url:url,method:"POST",body:["os-$req.action":"null"]],false,true,true,false) + break; + case "pause": + case "unpause": + case "suspend": + case "resume": + case "lock": + case "unlock": + res = p.httpJsonTransaction([url:url,method:"POST",body:["$req.action":"null"]],false,true,true,false) + break; + case "reboot": + res = p.httpJsonTransaction([url:url,method:"POST",body:[reboot:[type:"SOFT"]]],false,true,true,false) + break; + case "hardReboot": + res = p.httpJsonTransaction([url:url,method:"POST",body:[reboot:[type:"HARD"]]],false,true,true,false) + break; + case "reset-state": + res = p.httpJsonTransaction([url:url,method:"POST",body:['os-resetState':[state:"error"]]],false,true,true,false) + break; + case "reset-state-active": + res = p.httpJsonTransaction([url:url,method:"POST",body:['os-resetState':[state:"active"]]],false,true,true,false) + break; + default: + logger.error "unknown nova command $req.action"; + return + } + if (res == null) { + logger.warn "ran nova command $req.action on $req.name succesfully" + return + } + logger.error "ran nova command $req.action on $req.name: $res" + } + + OpenStackControllerProject findProject(String name) { + return projects.find {OpenStackControllerProject p1 -> p1.tenantName == name} + } + + +class OpenStackControllerProject { + HttpClient httpClient + def tokens = null + String password + String username + String tenantName + String tenantId + String keystoneUrl + OpenStackProject project + def urls = [:] + public OpenStackControllerProject(OpenStackProject project1) { + project = project1 + tenantName = project.name + username = project.adminUser + password = props.get("${loc.name}.password.$username".toString()) + if (password == null) { + // BSA setup + password = props.get("project.${project.name}.password".toString()) + } + if (password == null) { + logger.warn("No password for $loc.name $project.name") + System.err.println "No password for $loc.name $project.name $username" + } + password = JavaHttpClient.decryptPassword(password) + tenantId = project.tenantId + keystoneUrl = loc.keystoneUrl +// if (debug) System.err.println "u=$username pw=$password tenantId=$tenantId" + // Remove the refs are supported. +// logger.info "${server.ecore2json(loc, 100, null, false).toString(2)}".toString() +// if (debug) System.err.println "${server.ecore2json(project, 100, null, false).toString(2)}" + httpClient = new HttpClient() + httpClient.start(); + updateTokens() + } + public void poll() { +// updateImages() +// updateGeneric(loc,"image") +// updateGeneric(loc,"flavor") + updateServers() + updateHypervisor() + try { updateSecurityGroups() } catch (e) { println "updateSecurityGroups failed: $e" } + updateVolumes() + updateKeypairs() + if (urls['neutron'] != null) { + updateGenericNeutron(project, "network") + updateGenericNeutron(project, "subnet") + updateGenericNeutron(project, "router") + updateGenericNeutron(project, "port") + updateGenericNeutron(project, "security_group") + updateGenericNeutron(project, "floatingip") + } + server.save() + } + /** + * Polls the Openstack Nova API for all the nova state (e.g, servers, images,..) + * for a project. + */ + def synchronized void updateTokens() { + if (keystoneUrl == null) { + logger.warn("No keystoneUrl for $loc.name") + return + } + if (password == null) { + logger.warn("No password for $loc.name") + return + } + def req = [ url : "$keystoneUrl/tokens", method : "POST", + body :[ auth : [passwordCredentials : [username: username, password: password], tenantId: tenantId]] + ] + + // RACKSPACE + if (project.apiKey != null) { + req.body.auth = ["RAX-KSKEY:apiKeyCredentials" : [username: username, apiKey: JavaHttpClient.decryptPassword(project.apiKey)]] + } + // {"auth": {"RAX-KSKEY:apiKeyCredentials": {"username": "ft123456", "apiKey": "dae41ba7484d4f8482"}}} + + tokens = httpJsonTransaction(req,,false,false,false) + if (debug) System.err.println object2json(tokens).toString(2) + if (! tokens.access) { + if (debug) System.err.println "Unabled to access tenant: $tenantName : ${object2json(tokens).toString(2)}" + logger.fatal "Unabled to access tenant: $tenantName : ${object2json(tokens).toString(2)}" + return; + } + tokens.access.serviceCatalog.each { it -> + def u = it.endpoints.get(0).publicURL + it.endpoints.each { x -> + if (x['region'] == project.region) + u = x.publicURL + } + urls[it.name] = u + if (debug) System.err.println "serviceCatalog $it.name -> ${urls[it.name]}" + } + // RACKSPACE + [ images :"cloudImages", + nova:"cloudServersOpenStack", + neutron: "cloudNetworks", + cinder: "cloudBlockStorage"]. each { n, v -> + if (urls[n] == null && urls[v] != null) { + System.err.println "Using $v service for $n" + if (n == "neutron" && urls[v].endsWith("/v2.0")) + urls[v] = urls[v].replace("/v2.0","") + urls[n] = urls[v] + } + if (urls[n] != null) { + System.err.println "No $n service" + } + } + } + def void updateImages() { + def req1 = [url : "${urls['nova']}/images"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) + loc.images.clear() + res1.images.each { s -> + def req2 = [url : s.links[0].href] + def res2 = httpJsonTransaction(req2) + logger.debug(object2json(res2).toString(2)) + createFromJson(server, new Subject(loc, "images"),object2json(res2.image,true)) ; + } + } + def void updateKeypairs() { + def req1 = [url : "${urls['nova']}/os-keypairs"] + def res1 = httpJsonTransaction(req1) + project.keypairs.clear() + res1.keypairs.each { s -> + createFromJson(server, new Subject(project, "keypairs"),object2json(s.keypair,true)) ; + } + } + def void updateGeneric(o,name) { + def req1 = [url : "${urls['nova']}/${name}s"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) + o["${name}s"].clear() + res1["${name}s"].each { s -> +// logger.info("getting ${s.links[0].href}") + def req2 = [url : s.links[0].href] + def res2 = httpJsonTransaction(req2) +// logger.debug( object2json(res2).toString(2)) +// if (debug) System.err.println "o=$o name=$name" + createFromJson(server, new Subject(o, "${name}s"),object2json(res2[name],true)) ; + } + } + def void updateGenericNeutron(o,name) { + def req1 = [url : "${urls['neutron']}/v2.0/${name.replace('_','-')}s"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) + o["${name}s"].clear() + res1["${name}s"].each { s -> + if (s.tenant_id != null && s.tenant_id != tenantId) return + JSONObject json = OpenStackUtil.object2json(s,true) +// if (debug) System.err.println json.toString(2) +// if (debug) System.err.println "o=$o id=$s.id" + if (s.name == null || s.name == "" || name == "security_group") json.put("name", s.id) + createFromJson(server, new Subject(o, "${name}s"),json) ; + } + } + def createFromJson(ManagementServer server,subject,JSONObject json) { + server.create(subject,json,false) + } + + def void updateHypervisor() { + if (tenantName != "admin") return + def req1 = [url : "${urls['nova']}/os-hypervisors/detail"] + def res1 = null; + try { res1 = httpJsonTransaction(req1) } catch (e) { + logger.error "Unable to get Hypervisor information: $e" + return + } +// if (debug) System.err.println object2json(res1).toString(2) + loc.hypervisors.clear() + res1.hypervisors.each { s -> + def json = new JSONObject(s.cpu_info) + s.cpu_info = json2object(json) +// if (debug) System.err.println s +// if (debug) System.err.println object2json(s,true) +// logger.info(object2json(s).toString(2)) + createFromJson(server, new Subject(loc, "hypervisors"),object2json(s,true)) + } + loc.hypervisors.each { it.name = it.service.host } + } + + def void updateSecurityGroups() { + def req1 = [url : "${urls['nova']}/os-security-groups"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) + project.groups.clear() + res1.security_groups.each { s -> +// logger.info(object2json(s).toString(2)) + createFromJson(server, new Subject(project, "groups"),object2json(s,true)) + } + } + + def void updateVolumes() { + if (urls['cinder'] == null) return + def req1 = [url : "${urls['cinder']}/volumes/detail"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) +// System.out.println("VVVVVVVVVVVVVVVVVV poll res1: ${res1}") + project.volumes.clear() + res1.volumes.each { s -> +// logger.info(object2json(s).toString(2)) + createFromJson(server, new Subject(project, "volumes"),object2json(s,true)) + } + if (loc.version == OpenStackVersion.FOLSOM ) + project.volumes.each { it.name = it.display_name } + project.volumes.each { + if (it.name == null) it.name = it.display_name + } + } + + def void updateFloatingIps() { + def req1 = [url : "${urls['nova']}/os-floating-ips"] + def res1 = httpJsonTransaction(req1) +// if (debug) System.err.println object2json(res1).toString(2) + project.ips.clear() + res1.floating_ips.each { s -> +// logger.info(object2json(s).toString(2)) + createFromJson(server, new Subject(project, "ips"),object2json(s,true)) + } + } + def void updateServers() { + def req1 = [url : "${urls['nova']}/servers" ] + def res1 = httpJsonTransaction(req1) + project.servers.clear() +// if (debug) System.err.println OpenStackUtil.object2json(res1).toString(2) + res1.servers.each { s -> + def req2 = [url : s.links[0].href ] + def res2 = httpJsonTransaction(req2) +// if (debug) System.err.println OpenStackUtil.object2json(res2).toString(2) +// return +// logger.debug(object2json(res2).toString(2)) + if (res2.server.image == "") res2.server.image = null + createFromJson(server, new Subject(project, "servers"),object2json(res2.server,true)) +// def req3 = [url : res2.server.image.links[0].href] +// def res3 = httpJsonTransaction(req3) +// logger.debug( object2json(res3).toString(2)) +// def req4 = [url : res3.choices[0].links[0].href] +// def res4 = httpJsonTransaction(req4) +// logger.debug( object2json(res4).toString(2)) + } + } + def NeutronObject create(NeutronRequest req) { + def ename = req.eClass().name + def cname = ename.substring(6,ename.length()-7) + def name = cname.toLowerCase() + switch (req) { + case CreateNetworkRequest: name = "network"; cname = "Network"; break + } + JSONObject j = new JSONObject() + // TODO look at annotations in ecore2json + JSONObject jj = ManagementServer.ecore2json(req, 100, null, false) + jj.remove('$class') + jj.remove('projectName') + req.eClass().EAllAttributes.each { EAttribute attr -> + EAnnotation anno = attr.getEAnnotation("http://openecomp.org/sirius/openstack"); + if (anno == null) return + String name1 = anno.details.get("name") + if (name1 != null && jj.has(attr.name)) { + def v = jj.get(attr.name) + jj.remove(attr.name) + jj.put(name1, v) + } + name1 = anno.details.get("removeEmptyList") + if (name1 == "true" && jj.has(attr.name)) { + def v = jj.get(attr.name) + switch (v) { + case JSONArray: + if (v.length() == 0) jj.remove(attr.name) + } + } + } + req.eClass().EAllReferences.each { EReference ref -> + EAnnotation anno = ref.getEAnnotation("http://openecomp.org/sirius/openstack"); + if (anno == null) return + String name1 = anno.details.get("name") + if (name1 != null && jj.has(ref.name)) { + def v = jj.get(ref.name) + jj.remove(ref.name) + jj.put(name1, v) + } + name1 = anno.details.get("removeEmptyList") + if (name1 == "true" && jj.has(ref.name)) { + def v = jj.get(ref.name) + switch (v) { + case JSONArray: + if (v.length() == 0) jj.remove(ref.name) + } + } + } + j.put(name, jj) + if (debug) System.err.println jj.toString(2) + def req1 = [url : "${urls['neutron']}/v2.0/${name.replace('_','-')}s", method:"POST", body:j] + if (debug) System.err.println req1 + def res1 = httpJsonTransaction(req1) + if (debug) System.err.println res1 + j = OpenStackUtil.object2json(res1[name],true) + if (debug) System.err.println j == null ? "NULL" : j.toString(2) + return server.json2ecore(NeutronPackage.eINSTANCE.getEClassifier(cname),j, false) + } + def void deleteNeutron(String type, String name) { + project["${type}s"].each { o -> + if (o.name != name) return + logger.warn "deleting $type $name $o.id" + def req1 = [url : "${urls['neutron']}/v2.0/${type.replace('_','-')}s/$o.id", method:"DELETE"] + if (debug) System.err.println req1 + def res1 = httpJsonTransaction(req1,false,true,true,false) + if (debug) System.err.println res1 + } + } + def httpJsonTransaction(m, boolean polling = true, boolean throwError = true, boolean addAuth = true, boolean expectResponse = true) { + def exchange = new Exchange() + if (debug) System.err.println "m=$m" + def url = m.url ?: "${urls[m.api]}/$m.uri" + if (loc.bypassIp) { + url = url.replaceFirst("http://.*:", "http://$loc.bypassIp:") + } + exchange.setURL(url); + if (debug) System.err.println "URL=$url" + exchange.setMethod(m.method ?: "GET"); + def headers = m.headers ?: [:] + headers['Content-type'] = 'application/json' + if (addAuth) { + headers['X-Auth-Token'] = tokens.access.token.id + headers['X-Auth-Project-Id'] = project.tenantId + } + headers.each { n,v -> + exchange.addRequestHeader(n, v); + if (debug) System.err.println "Header: $n: $v" + } + if (m.body) { + String json = object2json(m.body).toString() +// logger.info("REQUEST: ${object2json(m.body).toString(2)}") + if (debug) System.err.println "REQUEST BODY: $json" +// exchange.setRequestContentSource(new ByteArrayInputStream(json.bytes)) + exchange.setRequestContent(new ByteArrayBuffer(json.bytes)); + } +// if (debug) System.err.println "Sending request" + Date start = new Date() + httpClient.send(exchange) +// if (debug) System.err.println "Exchange sent" + int exchangeState = exchange.waitForDone(); + if (debug) System.err.println "Exchange done: $exchangeState" + if (debug) System.err.println "code=$exchange.code content=$exchange.content" + if (polling) plogger.info "content=$exchange.content" + else logger.info "content=$exchange.content" + def res = exchange.content.toString() + if (res == "" && ! expectResponse) return null + if (res == "") { + def duration = new Date().time - start.time + throw new RuntimeException("Openstack API returned NULL: $url duration=$duration") + } + if (res.startsWith("401 Unauthorize") || res.startsWith("Authentication required")) { + // keystone auth expired + logger.info("keystone auth expired, updating tokens and resending request") + updateTokens(); + return httpJsonTransaction(m, polling, throwError, addAuth) + } + if (res.startsWith("404 Not Found")) { + if (throwError) + throw new RuntimeException("Openstack API: 404 Not Found") + return null + } + JSONObject json = new JSONObject(res) + if (exchange.code < 200 || exchange.code >= 300) { + if (throwError && json.has("expection")) { + throw new RuntimeException("Openstack API: expection $json") + } + if (throwError && json.has("badRequest")) { + throw new RuntimeException("Openstack API: badRequest $json") + } + if (throwError && json.has("itemNotFound")) { + throw new RuntimeException("Openstack API: itemNotFound $json") + } + if (throwError && json.has("NeutronError")) { + throw new RuntimeException("Openstack API: NeutronError $json") + } + if (throwError) { + throw new RuntimeException("Openstack API: Error $json") + } + } + + if (debug) System.err.println json.toString(2) +// logger.info("RETURNED: ${json.toString(2)}") + return json2object(json) + } + public void associateFloatingIp(String ipId, String portId) { + def req1 = [url : "${urls['neutron']}/v2.0/floatingips/$ipId", method:"PUT", body:[floatingip:[port_id:portId]]] + if (debug) System.err.println req1 + def res1 = httpJsonTransaction(req1,false,true,true,false) + if (debug) System.err.println res1 +// return server.json2ecore(NeutronPackage.eINSTANCE.getEClassifier(cname),j, false) + } + + +} + +private class Exchange extends HttpExchange { + String version2; + int code; + String message; + String location; + StringBuffer content = new StringBuffer(); + + protected void onResponseHeader(Buffer name, Buffer value) { +// System.out.println("HEADER: " + name + " " + value); + if (name.toString().equals("Location")) + location = value.toString(); + } + + protected void onResponseStatus(Buffer httpVersion, int statusCode, Buffer statusMessage) { +// if (debug) System.err.println "v=$httpVersion code=$statusCode m=$statusMessage" + version2 = httpVersion.toString(); + code = statusCode; + message = statusMessage.toString(); + } + protected void onResponseContent(Buffer content) { + this.content.append(content.toString()); + } + +} +} + diff --git a/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProvider.java b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProvider.java new file mode 100644 index 0000000..07941a9 --- /dev/null +++ b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProvider.java @@ -0,0 +1,161 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack; + +import java.util.Date; +import java.util.HashMap; + +import org.apache.log4j.Logger; +import org.json.JSONObject; + +import org.openecomp.logger.EcompLogger; +import org.openecomp.ncomp.openstack.OpenStackController; +import org.openecomp.ncomp.openstack.controller.tools.OpenStackUtil; +import org.openecomp.ncomp.openstack.location.OpenStackLocation; +import org.openecomp.ncomp.servers.openstack.logging.OpenStackAdaptorMessageEnum; +import org.openecomp.ncomp.servers.openstack.logging.OpenStackAdaptorOperationEnum; +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; +import org.openecomp.ncomp.sirius.manager.ManagementServerUtils; +import org.openecomp.ncomp.sirius.manager.server.ServerPackage; + +public class OsOpenStackControllerProvider extends BasicAdaptorProvider { + public static final Logger logger = Logger.getLogger(OsOpenStackControllerProvider.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + private HashMap<String, OpenStackUtil> utils = new HashMap<String, OpenStackUtil>(); + private HashMap<String, Thread> pollers = new HashMap<String, Thread>(); + private HashMap<String, Date> lastPoll = new HashMap<String, Date>(); + private OpenStackController o; + private OsOpenStackControllerClient parent = null; + protected long pollingFrequency; + + public OsOpenStackControllerProvider(ISiriusServer controller, OpenStackController o) { + super(controller, o); + this.o = o; + for (OpenStackLocation l : o.getLocations()) { + if (!l.isRemoteLocation()) { + startOpenstackPolling(l); + } + } + if (controller.getServer().getProps().containsKey("openstackParent.endpoint")) { + parent = new OsOpenStackControllerClient("location.properties", "openstackParent"); + } + } + + private synchronized void startOpenstackPolling(final OpenStackLocation l) { + Thread t = pollers.get(l.getName()); + if (t != null && t.isAlive()) { + return; + } + t = new Thread("openstackPoller " + l.getName()) { + @Override + public void run() { + ecomplogger.setOperation(OpenStackAdaptorOperationEnum.POLLING); + while (true) { + Date lastPoll2 = lastPoll.get(l.getName()); + if (lastPoll2 == null || lastPoll2.getTime() + pollingFrequency < new Date().getTime()) { + try { + ecomplogger.newRequestId(); + ecomplogger.recordAuditEventStart(); + openstackPolling(l); + } catch (Exception e) { + ecomplogger.warn(OpenStackAdaptorMessageEnum.POLLING_FAILED, ManagementServer.object2ref(l)); + ManagementServerUtils.printStackTrace(e); + } + finally { + ecomplogger.recordAuditEventEnd(); + } + } + try { + Thread.sleep(30000); + } catch (InterruptedException e1) { + } + } + }; + }; + t.setDaemon(true); + t.start(); + pollers.put(l.getName(), t); + } + + protected void openstackPolling(OpenStackLocation l) { + if (! l.getKeystoneUrl().startsWith("http")) { + logger.warn("openstackPolling ignored no valid keystone url: " + l.getName() + " " + l.getKeystoneUrl()); + return; + } + logger.info("openstackPolling: " + l.getName()); + OpenStackUtil util = getUtil(l.getName()); + lastPoll.put(l.getName(), new Date()); + OpenStackLocation poll = util.poll(); + poll.setName(l.getName()); + poll.setRemoteLocationName(l.getName()); + logger.info("polling done: " + poll); + if (poll != null) { + try { + uploadOpenstackConfiguration(null, poll); + } catch (ManagementServerError e) { + logger.warn("uploadOpenstackConfiguration: " + e.getJson().toString(2)); + } + } + + } + + public static void ecoreSetup() { + ServerPackage.eINSTANCE.getClass(); + } + + public void uploadOpenstackConfiguration(JSONObject cx, OpenStackLocation loc) { + if (parent != null) { + parent.uploadOpenstackConfiguration(cx, loc); + } + } + + public void start() { + for (OpenStackLocation l : o.getLocations()) { + if (!l.isRemoteLocation()) { + startOpenstackPolling(l); + } + } + } + + public synchronized OpenStackUtil getUtil(String name) { + OpenStackUtil util = utils.get(name); + if (util == null) { + for (OpenStackLocation l : o.getLocations()) { + if (l.isRemoteLocation()) { + break; + } + if (!l.getName().equals(name)) + continue; + util = new OpenStackUtil(l, controller.getServer(), controller.getServer().getProps() + .getProperty("openstack.propertyfile", "openstack.properties")); + utils.put(name, util); + pollingFrequency = util.pollingFrequency; + return (util); + } + } + return (util); + } + +} diff --git a/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProvider.java b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProvider.java new file mode 100644 index 0000000..3652555 --- /dev/null +++ b/ncomp-openstack-controller/src/main/java/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProvider.java @@ -0,0 +1,291 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.loc; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import org.openecomp.ncomp.core.User; +import org.openecomp.ncomp.openstack.OpenStackController; +import org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm; +import org.openecomp.ncomp.openstack.ceilometer.CeilometerSample; +import org.openecomp.ncomp.openstack.ceilometer.CreateAlarmRequest; +import org.openecomp.ncomp.openstack.ceilometer.SampleRequest; +import org.openecomp.ncomp.openstack.compute.ComputeFactory; +import org.openecomp.ncomp.openstack.compute.OpenstackRequestFlavor; +import org.openecomp.ncomp.openstack.compute.OpenstackRequestKeyPair; +import org.openecomp.ncomp.openstack.compute.OpenstackRequestNewServer; +import org.openecomp.ncomp.openstack.compute.OpenstackRequestSecurityGroup; +import org.openecomp.ncomp.openstack.compute.OpenstackRequestServerAction; +import org.openecomp.ncomp.openstack.controller.tools.OpenStackUtil; +import org.openecomp.ncomp.openstack.controller.tools.OpenStackUtil.OpenStackControllerProject; +import org.openecomp.ncomp.openstack.core.CoreFactory; +import org.openecomp.ncomp.openstack.core.OpenstackRequestDelete; +import org.openecomp.ncomp.openstack.core.VirtualMachineType; +import org.openecomp.ncomp.openstack.location.OpenStackLocation; +import org.openecomp.ncomp.openstack.neutron.CreateRouterRequest; +import org.openecomp.ncomp.openstack.neutron.CreateSubnetRequest; +import org.openecomp.ncomp.openstack.neutron.CreatePortRequest; +import org.openecomp.ncomp.openstack.neutron.Network; +import org.openecomp.ncomp.openstack.neutron.NeutronObject; +import org.openecomp.ncomp.openstack.neutron.NeutronRequest; +import org.openecomp.ncomp.openstack.neutron.Router; +import org.openecomp.ncomp.openstack.neutron.Subnet; +import org.openecomp.ncomp.openstack.neutron.Port; +import org.openecomp.ncomp.servers.openstack.OsOpenStackController; +import org.openecomp.ncomp.servers.openstack.OsOpenStackControllerProvider; +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.Subject; +import org.openecomp.ncomp.sirius.manager.server.Response; +import org.openecomp.ncomp.sirius.manager.server.ServerPackage; + +public class OsOpenStackLocationProvider extends BasicAdaptorProvider implements ISiriusPlugin { + public static final Logger logger = Logger.getLogger(OsOpenStackLocationProvider.class); + OpenStackUtil util; + private OpenStackLocation o; + + public OsOpenStackLocationProvider(ISiriusServer controller, OpenStackLocation o) { + super(controller, o); + this.o = o; + } + + public Network createNetwork(org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest request) { + return (Network) handleNeutronRequest(request); + } + + public void createServer(OpenstackRequestNewServer request) { + initUtil(); + util.createServer(request); + } + + public Subnet createSubnet(CreateSubnetRequest request) { + initUtil(); + return (Subnet) handleNeutronRequest(request); + } + + public Port createPort(CreatePortRequest request) { + initUtil(); + return (Port) handleNeutronRequest(request); + } + + public void poll() { + initUtil(); + // TODO implement poll + // o.poll(); + } + + @Override + public void start() { + // TODO Auto-generated method stub + + } + + private void initUtil() { + if (util == null) { + OsOpenStackController c = (OsOpenStackController) o.eContainer(); + util = c.controller.getUtil(o.getName()); + } + if (util == null) { + throw new RuntimeException("Unable to create Openstack Util"); + } + } + + private NeutronObject handleNeutronRequest(NeutronRequest request) { + initUtil(); + OpenStackControllerProject p = util.findProject(request.getProjectName()); + if (p == null) { + throw new RuntimeException("unable to find project: " + request.getProjectName()); + } + return p.create(request); + } + + public void deleteNetwork(String projectName, String name) { + initUtil(); + OpenStackControllerProject p = util.findProject(projectName); + if (p == null) { + logger.warn("unable to find project: " + projectName + " " + name); + return; + } + p.deleteNeutron("network", name); + } + + public void deleteSubnet(String projectName, String name) { + initUtil(); + OpenStackControllerProject p = util.findProject(projectName); + if (p == null) { + logger.warn("unable to find project: " + projectName); + return; + } + p.deleteNeutron("subnet", name); + } + + public void deleteServer(String projectName, String name) { + initUtil(); + util.delete(projectName, "server", name); + } + + public void associateFloatingIp(String projectName, String ipId, String portId) { + initUtil(); + OpenStackControllerProject p = util.findProject(projectName); + if (p == null) { + logger.warn("unable to find project: " + projectName); + return; + } + p.associateFloatingIp(ipId, portId); + } + + public CeilometerAlarm createAlarm(CreateAlarmRequest request) { + throw new UnsupportedOperationException(); + } + + public void deleteAlarm(String projectName, String name) { + throw new UnsupportedOperationException(); + } + + public EList<CeilometerSample> createAlarm(SampleRequest request) { + throw new UnsupportedOperationException(); + } + + public static void ecoreSetup() { + ServerPackage.eINSTANCE.getClass(); + } + + public void createKeyPair(OpenstackRequestKeyPair request) { + initUtil(); + util.createKeypair(request.getProjectName(), request.getUser()); + } + + public void delete(OpenstackRequestDelete request) { + initUtil(); + util.delete(request.getProjectName(), request.getObjectType(), request.getObjectName()); + } + + public void createFlavor(OpenstackRequestFlavor request) { + initUtil(); + util.createFlavor(request.getProjectName(), request.getVmType()); + } + + public void createSecurityGroup(OpenstackRequestSecurityGroup request) { + initUtil(); + util.createSecurityGroup(request.getProjectName(), request.getVmType()); + } + + public void serverAction(OpenstackRequestServerAction request) { + initUtil(); + util.serverAction(request); + } + + public void deployVmType(String vmTypeName, String projectName) { + OpenstackRequestSecurityGroup req2 = ComputeFactory.eINSTANCE.createOpenstackRequestSecurityGroup(); + req2.setProjectName(projectName); + req2.setVmType(EcoreUtil.copy(findVmType(vmTypeName))); + o.createSecurityGroup(req2); + if (o.isAllowCreateFlavor()) { + OpenstackRequestFlavor req = ComputeFactory.eINSTANCE.createOpenstackRequestFlavor(); + req.setProjectName(projectName); + req.setVmType(EcoreUtil.copy(findVmType(vmTypeName))); + o.createFlavor(req); + } + } + + private VirtualMachineType findVmType(String name) { + OpenStackController c = (OpenStackController) o.eContainer(); + for (VirtualMachineType v : c.getVmTypes()) { + if (v.getName().equals(name)) return v; + } + throw new RuntimeException("Not VmType with name: " + name); + } + + public void undeployVmType(String vmTypeName, String projectName) { + OpenstackRequestDelete req1 = CoreFactory.eINSTANCE.createOpenstackRequestDelete(); + req1.setProjectName(projectName); + req1.setObjectType("flavor"); + req1.setObjectName(vmTypeName); + o.delete(req1); + req1.setObjectType("security_group"); + o.delete(req1); + } + + public void deployUser(User user, String projectName) { + OpenstackRequestKeyPair req = ComputeFactory.eINSTANCE.createOpenstackRequestKeyPair(); + if (user == null) + throw new RuntimeException("Null user"); + req.setProjectName(projectName); + req.setUser(EcoreUtil.copy(user)); + o.createKeyPair(req); + } + + public void undeployUser(User user, String projectName) { + OpenstackRequestDelete req1 = CoreFactory.eINSTANCE.createOpenstackRequestDelete(); + if (user == null) + throw new RuntimeException("Null user"); + req1.setProjectName(projectName); + req1.setObjectType("keypair"); + req1.setObjectName(user.getName()); + o.delete(req1); + } + + @SuppressWarnings("unused") + private User findUser(String userPath) { + Subject s = controller.getServer().find(userPath); + if (s == null || s.o == null || ! (s instanceof User)) + throw new RuntimeException("Unable to find user: " + userPath); + return (User) s.o; + } + + public void mergeLocation(OpenStackLocation loc) { + ManagementServer.merge(o, loc, null, true, null); + } + + public void deletePort(String projectName, String name) { + initUtil(); + OpenStackControllerProject p = util.findProject(projectName); + if (p == null) { + logger.warn("unable to find project: " + projectName + " " + name); + return; + } + p.deleteNeutron("port", name); + + } + + public Router createRouter(CreateRouterRequest request) { + initUtil(); + return (Router) handleNeutronRequest(request); + } + + public void deleteRouter(String projectName, String name) { + initUtil(); + OpenStackControllerProject p = util.findProject(projectName); + if (p == null) { + logger.warn("unable to find project: " + projectName + " " + name); + return; + } + p.deleteNeutron("router", name); + + + } +} diff --git a/ncomp-openstack-controller/src/main/resources/OpenStackAdaptor.yaml b/ncomp-openstack-controller/src/main/resources/OpenStackAdaptor.yaml new file mode 100644 index 0000000..2e671a2 --- /dev/null +++ b/ncomp-openstack-controller/src/main/resources/OpenStackAdaptor.yaml @@ -0,0 +1,12 @@ +operations: + POLLING: + description: Openstack polling. +messages: + POLLING_FAILED: + errorCode: NCOMP-OPENSTACK-POLLING-FAILED-5001W + messageFormat: '{0}' + parameters: + service-name: + description: Resource path of Openstack Location. + resolution: Verify Openstack setup. + description: Openstack Polling fails. diff --git a/ncomp-openstack-controller/src/main/server-gen/bin/openstack-controller-controller b/ncomp-openstack-controller/src/main/server-gen/bin/openstack-controller-controller new file mode 100644 index 0000000..0c67d4c --- /dev/null +++ b/ncomp-openstack-controller/src/main/server-gen/bin/openstack-controller-controller @@ -0,0 +1,138 @@ +#!/bin/bash + +# setup env if needed. java 6 required +## JAVA_HOME= + +############################## DO NOT EDIT BELOW ########################## + +SNAME="Os Controller" +PNAME=openstack-controller-controller +CLASS=org.openecomp.ncomp.servers.openstack.OsOpenStackControllerServer + +############################## COMMON BELOW ########################## + +check_status () +{ + if [ -f "${_PIDFILE}" ]; then + _PID=`cat "${_PIDFILE}"` + check_status_of_pid $_PID + else + _STATUS="$SNAME (no pidfile) is NOT running" + _RUNNING=0 + fi +} + + +check_status_of_pid () +{ + if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then + _STATUS="$SNAME (pid $1) is running" + _RUNNING=1 + else + _STATUS="$SNAME (pid $1) is NOT running" + _RUNNING=0 + fi +} + + +check_status_of_pid () +{ + if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then + _STATUS="$SNAME (pid $1) is running" + _RUNNING=1 + else + _STATUS="$SNAME (pid $1) is NOT running" + _RUNNING=0 + fi +} + +remove_pid_file () +{ + if [ -f "${_PIDFILE}" ]; then + rm "${_PIDFILE}" + fi +} + + +_DIR=`dirname "$0"` +_DIR=`dirname "$_DIR"` + +_PIDFILE=$_DIR/PID + +CMD=$1 +shift + +check_status + +CP=$(find $_DIR/lib/*/* -name \*.jar 2>/dev/null | xargs -I X printf ":%s" X) + +JVMARGS=$(grep 'server.jvmargs' $_DIR/config/openstack.properties | sed -e 's/.*=//') + +case $CMD in + status) + echo $_STATUS + exit 0 + ;; + console) + $GROOVY_HOME/bin/groovysh -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP + ;; + run) + $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" + ;; + groovy) + $GROOVY_HOME/bin/groovy -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" + ;; + start) + if [ "$_RUNNING" = "1" ]; then + echo $_STATUS + exit 0 + fi + mkdir -p $_DIR/logs + if [ -e $_DIR/logs/$PNAME.out.1 ]; then mv $_DIR/logs/$PNAME.out.1 $_DIR/logs/$PNAME.out.2; fi + if [ -e $_DIR/logs/$PNAME.err.1 ]; then mv $_DIR/logs/$PNAME.err.1 $_DIR/logs/$PNAME.err.2; fi + if [ -e $_DIR/logs/$PNAME.out ]; then mv $_DIR/logs/$PNAME.out $_DIR/logs/$PNAME.out.1; fi + if [ -e $_DIR/logs/$PNAME.err ]; then mv $_DIR/logs/$PNAME.err $_DIR/logs/$PNAME.err.1; fi + + nohup $JAVA_HOME/bin/java $JVMARGS -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" $CLASS >> $_DIR/logs/$PNAME.out 2>> $_DIR/logs/$PNAME.err & + + _PID=$! + echo $_PID > $_PIDFILE + sleep 5 + check_status + echo $_STATUS + if [ "$_RUNNING" = "1" ]; then + exit 0 + else + echo "Failed to start - make sure the $SNAME is fully configured properly" + exit 1 + fi + ;; + stop) + if [ "$_RUNNING" = "0" ]; then + echo $_STATUS + remove_pid_file + exit 0 + fi + echo "Stopping $SNAME..." + _PID_TO_KILL=$_PID; + echo "$SNAME (pid=${_PID_TO_KILL}) is stopping..." + kill -TERM $_PID_TO_KILL + sleep 5 + check_status_of_pid $_PID_TO_KILL + if [ "$_RUNNING" = "1" ]; then + kill -TERM $_PID_TO_KILL + fi + while [ "$_RUNNING" = "1" ]; do + sleep 2 + check_status_of_pid $_PID_TO_KILL + done + remove_pid_file + echo "$SNAME has stopped." + exit 0 + ;; + *) + echo "$0 start|stop" + ;; +esac + + diff --git a/ncomp-openstack-controller/src/main/sirius-gen/OpenStackController.yaml b/ncomp-openstack-controller/src/main/sirius-gen/OpenStackController.yaml new file mode 100644 index 0000000..fb697a4 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/OpenStackController.yaml @@ -0,0 +1,14 @@ +operations: + uploadOpenstackConfiguration: {} + REMOTE_uploadOpenstackConfiguration: + decription: Remote call uploadOpenstackConfiguration +messages: + dummy: {} + uploadOpenstackConfiguration: + errorCode: uploadOpenstackConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_uploadOpenstackConfiguration: + errorCode: REMOTE-uploadOpenstackConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception diff --git a/ncomp-openstack-controller/src/main/sirius-gen/OpenStackLocation.yaml b/ncomp-openstack-controller/src/main/sirius-gen/OpenStackLocation.yaml new file mode 100644 index 0000000..3296bdc --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/OpenStackLocation.yaml @@ -0,0 +1,267 @@ +operations: + createNetwork: {} + createSubnet: {} + createPort: {} + createRouter: {} + deleteNetwork: {} + deleteSubnet: {} + deletePort: {} + deleteRouter: {} + associateFloatingIp: {} + createServer: {} + deleteServer: {} + createKeyPair: {} + delete: {} + createFlavor: {} + createSecurityGroup: {} + serverAction: {} + deployVmType: {} + undeployVmType: {} + deployUser: {} + undeployUser: {} + createAlarm: {} + deleteAlarm: {} + poll: {} + mergeLocation: {} + REMOTE_createNetwork: + decription: Remote call createNetwork + REMOTE_createSubnet: + decription: Remote call createSubnet + REMOTE_createPort: + decription: Remote call createPort + REMOTE_createRouter: + decription: Remote call createRouter + REMOTE_deleteNetwork: + decription: Remote call deleteNetwork + REMOTE_deleteSubnet: + decription: Remote call deleteSubnet + REMOTE_deletePort: + decription: Remote call deletePort + REMOTE_deleteRouter: + decription: Remote call deleteRouter + REMOTE_associateFloatingIp: + decription: Remote call associateFloatingIp + REMOTE_createServer: + decription: Remote call createServer + REMOTE_deleteServer: + decription: Remote call deleteServer + REMOTE_createKeyPair: + decription: Remote call createKeyPair + REMOTE_delete: + decription: Remote call delete + REMOTE_createFlavor: + decription: Remote call createFlavor + REMOTE_createSecurityGroup: + decription: Remote call createSecurityGroup + REMOTE_serverAction: + decription: Remote call serverAction + REMOTE_deployVmType: + decription: Remote call deployVmType + REMOTE_undeployVmType: + decription: Remote call undeployVmType + REMOTE_deployUser: + decription: Remote call deployUser + REMOTE_undeployUser: + decription: Remote call undeployUser + REMOTE_createAlarm: + decription: Remote call createAlarm + REMOTE_deleteAlarm: + decription: Remote call deleteAlarm + REMOTE_poll: + decription: Remote call poll + REMOTE_mergeLocation: + decription: Remote call mergeLocation +messages: + dummy: {} + createNetwork: + errorCode: createNetwork-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createSubnet: + errorCode: createSubnet-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createPort: + errorCode: createPort-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createRouter: + errorCode: createRouter-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deleteNetwork: + errorCode: deleteNetwork-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deleteSubnet: + errorCode: deleteSubnet-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deletePort: + errorCode: deletePort-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deleteRouter: + errorCode: deleteRouter-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + associateFloatingIp: + errorCode: associateFloatingIp-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createServer: + errorCode: createServer-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deleteServer: + errorCode: deleteServer-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createKeyPair: + errorCode: createKeyPair-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + delete: + errorCode: delete-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createFlavor: + errorCode: createFlavor-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createSecurityGroup: + errorCode: createSecurityGroup-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + serverAction: + errorCode: serverAction-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deployVmType: + errorCode: deployVmType-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + undeployVmType: + errorCode: undeployVmType-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deployUser: + errorCode: deployUser-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + undeployUser: + errorCode: undeployUser-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + createAlarm: + errorCode: createAlarm-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deleteAlarm: + errorCode: deleteAlarm-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + poll: + errorCode: poll-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + mergeLocation: + errorCode: mergeLocation-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_createNetwork: + errorCode: REMOTE-createNetwork-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createSubnet: + errorCode: REMOTE-createSubnet-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createPort: + errorCode: REMOTE-createPort-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createRouter: + errorCode: REMOTE-createRouter-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deleteNetwork: + errorCode: REMOTE-deleteNetwork-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deleteSubnet: + errorCode: REMOTE-deleteSubnet-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deletePort: + errorCode: REMOTE-deletePort-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deleteRouter: + errorCode: REMOTE-deleteRouter-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_associateFloatingIp: + errorCode: REMOTE-associateFloatingIp-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createServer: + errorCode: REMOTE-createServer-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deleteServer: + errorCode: REMOTE-deleteServer-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createKeyPair: + errorCode: REMOTE-createKeyPair-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_delete: + errorCode: REMOTE-delete-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createFlavor: + errorCode: REMOTE-createFlavor-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createSecurityGroup: + errorCode: REMOTE-createSecurityGroup-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_serverAction: + errorCode: REMOTE-serverAction-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deployVmType: + errorCode: REMOTE-deployVmType-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_undeployVmType: + errorCode: REMOTE-undeployVmType-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deployUser: + errorCode: REMOTE-deployUser-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_undeployUser: + errorCode: REMOTE-undeployUser-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_createAlarm: + errorCode: REMOTE-createAlarm-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deleteAlarm: + errorCode: REMOTE-deleteAlarm-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_poll: + errorCode: REMOTE-poll-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_mergeLocation: + errorCode: REMOTE-mergeLocation-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackController.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackController.java new file mode 100644 index 0000000..f6db33f --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackController.java @@ -0,0 +1,111 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack; + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; +import org.openecomp.ncomp.component.ApiRequestStatus; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + +import java.util.Date; + +import org.openecomp.ncomp.servers.openstack.logging.OpenStackControllerOperationEnum; +import org.openecomp.ncomp.servers.openstack.logging.OpenStackControllerMessageEnum; + + + + +import org.openecomp.ncomp.openstack.impl.OpenStackControllerImpl; + + + +public class OsOpenStackController extends OpenStackControllerImpl implements ISiriusPlugin { + public static final Logger logger = Logger.getLogger(OsOpenStackController.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public OsOpenStackControllerProvider controller; + ISiriusServer server; + + public OsOpenStackController(ISiriusServer server) { + this.server = server; + this.controller = new OsOpenStackControllerProvider(server,this); + } + + public void uploadOpenstackConfiguration(org.json.JSONObject cx, org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "uploadOpenstackConfiguration", ApiRequestStatus.START, duration_,cx,loc); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackControllerOperationEnum.uploadOpenstackConfiguration); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.uploadOpenstackConfiguration(cx,loc); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "uploadOpenstackConfiguration", ApiRequestStatus.ERROR, duration_,cx,loc); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackControllerMessageEnum.uploadOpenstackConfiguration, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "uploadOpenstackConfiguration", ApiRequestStatus.OKAY, duration_,cx,loc); + + } + + + + + + + @Override + public void start() { + controller.start(); + } + + public static void ecoreSetup() { + OsOpenStackControllerProvider.ecoreSetup(); + } + public OsOpenStackControllerProvider getSomfProvider() { + return controller; + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerClient.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerClient.java new file mode 100644 index 0000000..855faf9 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerClient.java @@ -0,0 +1,89 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.ncomp.openstack.impl.OpenStackControllerImpl; +import org.openecomp.ncomp.openstack.OpenstackPackage; +import org.openecomp.ncomp.servers.openstack.logging.OpenStackControllerOperationEnum; +import org.openecomp.ncomp.servers.openstack.logging.OpenStackControllerMessageEnum; + + + + + + +@SuppressWarnings("unchecked") +public class OsOpenStackControllerClient extends OpenStackControllerImpl { + public static final Logger logger = Logger.getLogger(OsOpenStackControllerClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public OsOpenStackControllerClient(String file, String name) { + OsOpenStackController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/resources", this); + } + + public OsOpenStackControllerClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/resources", this); + } + + public OsOpenStackControllerClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + @Override + public void uploadOpenstackConfiguration(org.json.JSONObject cx, org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + EClass c = OpenstackPackage.eINSTANCE.getOpenStackController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackControllerOperationEnum.REMOTE_uploadOpenstackConfiguration); + + try { + client.operationPath("/resources", c, "uploadOpenstackConfiguration", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,loc); + } + catch (Exception e) { + ecomplogger.warn(OpenStackControllerMessageEnum.REMOTE_uploadOpenstackConfiguration, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@uploadOpenstackConfiguration: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerConsole.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerConsole.java new file mode 100644 index 0000000..111d317 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerConsole.java @@ -0,0 +1,72 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.ncomp.servers.openstack; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + +import org.openecomp.ncomp.servers.openstack.loc.OsOpenStackLocationConsole; + + +public class OsOpenStackControllerConsole extends Console { + public static final Logger logger = Logger.getLogger(OsOpenStackControllerConsole.class); + protected OsOpenStackControllerClient controller; + + + OsOpenStackLocationConsole loc; + + + public OsOpenStackControllerConsole(String filename, String name) { + super(filename, name); + controller = new OsOpenStackControllerClient(filename,name); + client = controller.client; + + loc = new OsOpenStackLocationConsole(filename,name); + } + + public OsOpenStackControllerConsole(AbstractClient c) { + controller = new OsOpenStackControllerClient(c); + client = controller.client; + } + + + public void uploadOpenstackConfiguration(org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + try { + controller.uploadOpenstackConfiguration(null,loc); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProviderTemplate.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProviderTemplate.java new file mode 100644 index 0000000..0bd01d2 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerProviderTemplate.java @@ -0,0 +1,71 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack; + + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; + + +import org.openecomp.ncomp.openstack.impl.OpenStackControllerImpl; +import org.openecomp.ncomp.openstack.OpenStackController; + + +public class OsOpenStackControllerProviderTemplate extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(OsOpenStackControllerProviderTemplate.class); + OpenStackController o; + + public OsOpenStackControllerProviderTemplate(ISiriusServer controller, OpenStackController o) { + super(controller, o); + this.o = o; + } + + public void uploadOpenstackConfiguration(org.json.JSONObject cx, org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + + + + + + + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerServer.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerServer.java new file mode 100644 index 0000000..4249dc3 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenStackControllerServer.java @@ -0,0 +1,109 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.ncomp.servers.openstack; + +import static org.openecomp.ncomp.utils.PropertyUtil.getPropertiesFromClasspath; + +import java.io.IOException; +import java.util.Properties; +import java.util.TimeZone; + +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EFactory; + +import org.openecomp.entity.EcompComponent; +import org.openecomp.entity.EcompSubComponent; +import org.openecomp.entity.EcompSubComponentInstance; +import org.openecomp.ncomp.sirius.manager.Jetty8Server; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.openstack.OpenStackController; + + +import org.openecomp.ncomp.servers.openstack.loc.OsLocationFactory; + + + + + +public class OsOpenStackControllerServer implements ISiriusServer { + public static final Logger logger = Logger.getLogger(OsOpenStackControllerServer.class); + String serverPath; + ManagementServer server; + OsOpenStackController controller; + String directory = "data"; +// LocationControllerApi api ; + Jetty8Server webServer; + OsOpenstackFactory f = new OsOpenstackFactory(this); + + + String locPath; + ManagementServer locServer; + + + public OsOpenStackControllerServer(String filename) throws IOException { + logger.warn("controller restarting"); + OsOpenStackController.ecoreSetup(); + props = getPropertiesFromClasspath(filename); + serverPath = (String) props.get("server.dir"); + server = new ManagementServer(f, "OpenStackController", serverPath, filename); + server.addFactory(f); + + server.addRuntimeFactories(this); + server.start(); + } + public void runWebserver() throws IOException { + controller = (OsOpenStackController) server.find("/").o; + webServer = new Jetty8Server("openstack.properties"); + webServer.add("/resources",server); + + + + EFactory locFactory = new OsLocationFactory(this); + locPath = serverPath + "/loc"; + locServer = new ManagementServer(locFactory, "OpenStackLocation", locPath, "loc.properties"); + locServer.start(); + webServer.add("/loc",locServer); + + + + logger.info("Joining webserver"); + webServer.join(); + } + static Properties props = null; + public static void main(String []args) throws IOException { + // ALWAYS USE GMT. + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + + OsOpenStackControllerServer s = new OsOpenStackControllerServer("openstack.properties"); + s.runWebserver(); + } + public OpenStackController getController() { + return controller; + } + public ManagementServer getServer() { + return server; + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenstackFactory.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenstackFactory.java new file mode 100644 index 0000000..bf5563e --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/OsOpenstackFactory.java @@ -0,0 +1,54 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack; + +import org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.openstack.OpenStackController; +import org.openecomp.ncomp.openstack.OpenstackPackage; +import org.openecomp.ncomp.openstack.impl.OpenstackFactoryImpl; + + + + + +public class OsOpenstackFactory extends OpenstackFactoryImpl { + public static final Logger logger = Logger.getLogger(OsOpenstackFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return OpenstackPackage.eINSTANCE; } + public OsOpenstackFactory(ISiriusServer server) { + this.server = server; + } + @Override + public OpenStackController createOpenStackController() { + return new OsOpenStackController(server); + } + + + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsLocationFactory.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsLocationFactory.java new file mode 100644 index 0000000..62e0e4b --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsLocationFactory.java @@ -0,0 +1,54 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack.loc; + +import org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.openstack.location.OpenStackLocation; +import org.openecomp.ncomp.openstack.location.LocationPackage; +import org.openecomp.ncomp.openstack.location.impl.LocationFactoryImpl; + +import org.openecomp.ncomp.servers.openstack.OsOpenStackControllerServer; + + + +public class OsLocationFactory extends LocationFactoryImpl { + public static final Logger logger = Logger.getLogger(OsLocationFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return LocationPackage.eINSTANCE; } + public OsLocationFactory(ISiriusServer server) { + this.server = server; + } + @Override + public OpenStackLocation createOpenStackLocation() { + return new OsOpenStackLocation(server); + } + + + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocation.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocation.java new file mode 100644 index 0000000..120135c --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocation.java @@ -0,0 +1,754 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack.loc; + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; +import org.openecomp.ncomp.component.ApiRequestStatus; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + +import java.util.Date; + +import org.openecomp.ncomp.servers.openstack.loc.logging.OpenStackLocationOperationEnum; +import org.openecomp.ncomp.servers.openstack.loc.logging.OpenStackLocationMessageEnum; + + + + +import org.openecomp.ncomp.openstack.location.impl.OpenStackLocationImpl; + + + +public class OsOpenStackLocation extends OpenStackLocationImpl { + public static final Logger logger = Logger.getLogger(OsOpenStackLocation.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public OsOpenStackLocationProvider controller; + ISiriusServer server; + + public OsOpenStackLocation(ISiriusServer server) { + this.server = server; + this.controller = new OsOpenStackLocationProvider(server,this); + } + + public void poll() { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "poll", ApiRequestStatus.START, duration_); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.poll); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.poll(); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "poll", ApiRequestStatus.ERROR, duration_); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.poll, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "poll", ApiRequestStatus.OKAY, duration_); + + } + + public void mergeLocation(org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "mergeLocation", ApiRequestStatus.START, duration_,loc); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.mergeLocation); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.mergeLocation(loc); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "mergeLocation", ApiRequestStatus.ERROR, duration_,loc); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.mergeLocation, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "mergeLocation", ApiRequestStatus.OKAY, duration_,loc); + + } + + public org.openecomp.ncomp.openstack.neutron.Network createNetwork(org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest request) { + org.openecomp.ncomp.openstack.neutron.Network res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createNetwork", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createNetwork); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createNetwork(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createNetwork", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createNetwork, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createNetwork", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Subnet createSubnet(org.openecomp.ncomp.openstack.neutron.CreateSubnetRequest request) { + org.openecomp.ncomp.openstack.neutron.Subnet res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createSubnet", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createSubnet); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createSubnet(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createSubnet", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createSubnet, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createSubnet", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Port createPort(org.openecomp.ncomp.openstack.neutron.CreatePortRequest request) { + org.openecomp.ncomp.openstack.neutron.Port res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createPort", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createPort); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createPort(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createPort", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createPort, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createPort", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Router createRouter(org.openecomp.ncomp.openstack.neutron.CreateRouterRequest request) { + org.openecomp.ncomp.openstack.neutron.Router res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createRouter", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createRouter); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createRouter(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createRouter", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createRouter, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createRouter", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + public void deleteNetwork(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deleteNetwork", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deleteNetwork); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deleteNetwork(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteNetwork", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deleteNetwork, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteNetwork", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public void deleteSubnet(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deleteSubnet", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deleteSubnet); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deleteSubnet(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteSubnet", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deleteSubnet, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteSubnet", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public void deletePort(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deletePort", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deletePort); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deletePort(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deletePort", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deletePort, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deletePort", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public void deleteRouter(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deleteRouter", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deleteRouter); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deleteRouter(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteRouter", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deleteRouter, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteRouter", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public void associateFloatingIp(java.lang.String projectName, java.lang.String ipId, java.lang.String portId) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "associateFloatingIp", ApiRequestStatus.START, duration_,projectName,ipId,portId); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.associateFloatingIp); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.associateFloatingIp(projectName,ipId,portId); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "associateFloatingIp", ApiRequestStatus.ERROR, duration_,projectName,ipId,portId); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.associateFloatingIp, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "associateFloatingIp", ApiRequestStatus.OKAY, duration_,projectName,ipId,portId); + + } + + public void createServer(org.openecomp.ncomp.openstack.compute.OpenstackRequestNewServer request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createServer", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createServer); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.createServer(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createServer", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createServer, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createServer", ApiRequestStatus.OKAY, duration_,request); + + } + + public void deleteServer(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deleteServer", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deleteServer); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deleteServer(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteServer", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deleteServer, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteServer", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public void createKeyPair(org.openecomp.ncomp.openstack.compute.OpenstackRequestKeyPair request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createKeyPair", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createKeyPair); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.createKeyPair(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createKeyPair", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createKeyPair, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createKeyPair", ApiRequestStatus.OKAY, duration_,request); + + } + + public void delete(org.openecomp.ncomp.openstack.core.OpenstackRequestDelete request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "delete", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.delete); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.delete(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "delete", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.delete, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "delete", ApiRequestStatus.OKAY, duration_,request); + + } + + public void createFlavor(org.openecomp.ncomp.openstack.compute.OpenstackRequestFlavor request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createFlavor", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createFlavor); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.createFlavor(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createFlavor", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createFlavor, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createFlavor", ApiRequestStatus.OKAY, duration_,request); + + } + + public void createSecurityGroup(org.openecomp.ncomp.openstack.compute.OpenstackRequestSecurityGroup request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createSecurityGroup", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createSecurityGroup); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.createSecurityGroup(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createSecurityGroup", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createSecurityGroup, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createSecurityGroup", ApiRequestStatus.OKAY, duration_,request); + + } + + public void serverAction(org.openecomp.ncomp.openstack.compute.OpenstackRequestServerAction request) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "serverAction", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.serverAction); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.serverAction(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "serverAction", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.serverAction, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "serverAction", ApiRequestStatus.OKAY, duration_,request); + + } + + public void deployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deployVmType", ApiRequestStatus.START, duration_,vmTypeName,projectName); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deployVmType); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deployVmType(vmTypeName,projectName); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployVmType", ApiRequestStatus.ERROR, duration_,vmTypeName,projectName); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deployVmType, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployVmType", ApiRequestStatus.OKAY, duration_,vmTypeName,projectName); + + } + + public void undeployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "undeployVmType", ApiRequestStatus.START, duration_,vmTypeName,projectName); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.undeployVmType); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.undeployVmType(vmTypeName,projectName); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "undeployVmType", ApiRequestStatus.ERROR, duration_,vmTypeName,projectName); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.undeployVmType, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "undeployVmType", ApiRequestStatus.OKAY, duration_,vmTypeName,projectName); + + } + + public void deployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deployUser", ApiRequestStatus.START, duration_,user,projectName); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deployUser); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deployUser(user,projectName); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployUser", ApiRequestStatus.ERROR, duration_,user,projectName); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deployUser, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployUser", ApiRequestStatus.OKAY, duration_,user,projectName); + + } + + public void undeployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "undeployUser", ApiRequestStatus.START, duration_,user,projectName); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.undeployUser); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.undeployUser(user,projectName); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "undeployUser", ApiRequestStatus.ERROR, duration_,user,projectName); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.undeployUser, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "undeployUser", ApiRequestStatus.OKAY, duration_,user,projectName); + + } + + public org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm createAlarm(org.openecomp.ncomp.openstack.ceilometer.CreateAlarmRequest request) { + org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createAlarm); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createAlarm(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createAlarm, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + public void deleteAlarm(java.lang.String projectName, java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deleteAlarm", ApiRequestStatus.START, duration_,projectName,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.deleteAlarm); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deleteAlarm(projectName,name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteAlarm", ApiRequestStatus.ERROR, duration_,projectName,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.deleteAlarm, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deleteAlarm", ApiRequestStatus.OKAY, duration_,projectName,name); + + } + + public EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> createAlarm(org.openecomp.ncomp.openstack.ceilometer.SampleRequest request) { + EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.START, duration_,request); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.createAlarm); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.createAlarm(request); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.ERROR, duration_,request); + System.err.println("ERROR: " + e); + ecomplogger.warn(OpenStackLocationMessageEnum.createAlarm, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "createAlarm", ApiRequestStatus.OKAY, duration_,request); + return res; + } + + + + + + + public static void ecoreSetup() { + OsOpenStackLocationProvider.ecoreSetup(); + } + public OsOpenStackLocationProvider getSomfProvider() { + return controller; + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationClient.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationClient.java new file mode 100644 index 0000000..92bfacc --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationClient.java @@ -0,0 +1,498 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.servers.openstack.loc; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.ncomp.openstack.location.impl.OpenStackLocationImpl; +import org.openecomp.ncomp.openstack.location.LocationPackage; +import org.openecomp.ncomp.servers.openstack.loc.logging.OpenStackLocationOperationEnum; +import org.openecomp.ncomp.servers.openstack.loc.logging.OpenStackLocationMessageEnum; + + +import org.openecomp.ncomp.servers.openstack.OsOpenStackController; + + + + +@SuppressWarnings("unchecked") +public class OsOpenStackLocationClient extends OpenStackLocationImpl { + public static final Logger logger = Logger.getLogger(OsOpenStackLocationClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public OsOpenStackLocationClient(String file, String name) { + OsOpenStackController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/loc", this); + } + + public OsOpenStackLocationClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/loc", this); + } + + public OsOpenStackLocationClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + @Override + public void poll() { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_poll); + + try { + client.operationPath("/loc", c, "poll", null); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_poll, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@poll: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void mergeLocation(org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_mergeLocation); + + try { + client.operationPath("/loc", c, "mergeLocation", null, loc); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_mergeLocation, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@mergeLocation: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public org.openecomp.ncomp.openstack.neutron.Network createNetwork(org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createNetwork); + org.openecomp.ncomp.openstack.neutron.Network res; + try { + res = (org.openecomp.ncomp.openstack.neutron.Network) client.operationPath("/loc", c, "createNetwork", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createNetwork, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createNetwork: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.openstack.neutron.Subnet createSubnet(org.openecomp.ncomp.openstack.neutron.CreateSubnetRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createSubnet); + org.openecomp.ncomp.openstack.neutron.Subnet res; + try { + res = (org.openecomp.ncomp.openstack.neutron.Subnet) client.operationPath("/loc", c, "createSubnet", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createSubnet, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createSubnet: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.openstack.neutron.Port createPort(org.openecomp.ncomp.openstack.neutron.CreatePortRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createPort); + org.openecomp.ncomp.openstack.neutron.Port res; + try { + res = (org.openecomp.ncomp.openstack.neutron.Port) client.operationPath("/loc", c, "createPort", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createPort, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createPort: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.openstack.neutron.Router createRouter(org.openecomp.ncomp.openstack.neutron.CreateRouterRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createRouter); + org.openecomp.ncomp.openstack.neutron.Router res; + try { + res = (org.openecomp.ncomp.openstack.neutron.Router) client.operationPath("/loc", c, "createRouter", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createRouter, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createRouter: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public void deleteNetwork(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deleteNetwork); + + try { + client.operationPath("/loc", c, "deleteNetwork", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deleteNetwork, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deleteNetwork: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deleteSubnet(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deleteSubnet); + + try { + client.operationPath("/loc", c, "deleteSubnet", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deleteSubnet, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deleteSubnet: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deletePort(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deletePort); + + try { + client.operationPath("/loc", c, "deletePort", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deletePort, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deletePort: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deleteRouter(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deleteRouter); + + try { + client.operationPath("/loc", c, "deleteRouter", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deleteRouter, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deleteRouter: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void associateFloatingIp(java.lang.String projectName, java.lang.String ipId, java.lang.String portId) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_associateFloatingIp); + + try { + client.operationPath("/loc", c, "associateFloatingIp", null, projectName,ipId,portId); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_associateFloatingIp, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@associateFloatingIp: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void createServer(org.openecomp.ncomp.openstack.compute.OpenstackRequestNewServer request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createServer); + + try { + client.operationPath("/loc", c, "createServer", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createServer, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createServer: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deleteServer(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deleteServer); + + try { + client.operationPath("/loc", c, "deleteServer", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deleteServer, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deleteServer: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void createKeyPair(org.openecomp.ncomp.openstack.compute.OpenstackRequestKeyPair request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createKeyPair); + + try { + client.operationPath("/loc", c, "createKeyPair", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createKeyPair, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createKeyPair: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void delete(org.openecomp.ncomp.openstack.core.OpenstackRequestDelete request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_delete); + + try { + client.operationPath("/loc", c, "delete", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_delete, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@delete: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void createFlavor(org.openecomp.ncomp.openstack.compute.OpenstackRequestFlavor request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createFlavor); + + try { + client.operationPath("/loc", c, "createFlavor", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createFlavor, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createFlavor: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void createSecurityGroup(org.openecomp.ncomp.openstack.compute.OpenstackRequestSecurityGroup request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createSecurityGroup); + + try { + client.operationPath("/loc", c, "createSecurityGroup", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createSecurityGroup, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createSecurityGroup: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void serverAction(org.openecomp.ncomp.openstack.compute.OpenstackRequestServerAction request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_serverAction); + + try { + client.operationPath("/loc", c, "serverAction", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_serverAction, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@serverAction: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deployVmType); + + try { + client.operationPath("/loc", c, "deployVmType", null, vmTypeName,projectName); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deployVmType, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deployVmType: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void undeployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_undeployVmType); + + try { + client.operationPath("/loc", c, "undeployVmType", null, vmTypeName,projectName); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_undeployVmType, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@undeployVmType: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void deployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deployUser); + + try { + client.operationPath("/loc", c, "deployUser", null, user,projectName); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deployUser, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deployUser: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void undeployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_undeployUser); + + try { + client.operationPath("/loc", c, "undeployUser", null, user,projectName); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_undeployUser, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@undeployUser: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm createAlarm(org.openecomp.ncomp.openstack.ceilometer.CreateAlarmRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createAlarm); + org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm res; + try { + res = (org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm) client.operationPath("/loc", c, "createAlarm", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createAlarm, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createAlarm: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public void deleteAlarm(java.lang.String projectName, java.lang.String name) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_deleteAlarm); + + try { + client.operationPath("/loc", c, "deleteAlarm", null, projectName,name); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_deleteAlarm, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deleteAlarm: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> createAlarm(org.openecomp.ncomp.openstack.ceilometer.SampleRequest request) { + EClass c = LocationPackage.eINSTANCE.getOpenStackLocation(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(OpenStackLocationOperationEnum.REMOTE_createAlarm); + EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> res; + try { + res = (EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample>) client.operationPath("/loc", c, "createAlarm", null, request); + } + catch (Exception e) { + ecomplogger.warn(OpenStackLocationMessageEnum.REMOTE_createAlarm, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@createAlarm: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationConsole.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationConsole.java new file mode 100644 index 0000000..db83255 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationConsole.java @@ -0,0 +1,332 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.ncomp.servers.openstack.loc; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + + +public class OsOpenStackLocationConsole extends Console { + public static final Logger logger = Logger.getLogger(OsOpenStackLocationConsole.class); + protected OsOpenStackLocationClient controller; + + + + + public OsOpenStackLocationConsole(String filename, String name) { + super(filename, name); + controller = new OsOpenStackLocationClient(filename,name); + client = controller.client; + + } + + public OsOpenStackLocationConsole(AbstractClient c) { + controller = new OsOpenStackLocationClient(c); + client = controller.client; + } + + + public void poll() { + + try { + controller.poll(); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void mergeLocation(org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + try { + controller.mergeLocation(loc); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public org.openecomp.ncomp.openstack.neutron.Network createNetwork(org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest request) { + org.openecomp.ncomp.openstack.neutron.Network res = null; + try { + res = controller.createNetwork(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Subnet createSubnet(org.openecomp.ncomp.openstack.neutron.CreateSubnetRequest request) { + org.openecomp.ncomp.openstack.neutron.Subnet res = null; + try { + res = controller.createSubnet(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Port createPort(org.openecomp.ncomp.openstack.neutron.CreatePortRequest request) { + org.openecomp.ncomp.openstack.neutron.Port res = null; + try { + res = controller.createPort(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.openstack.neutron.Router createRouter(org.openecomp.ncomp.openstack.neutron.CreateRouterRequest request) { + org.openecomp.ncomp.openstack.neutron.Router res = null; + try { + res = controller.createRouter(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public void deleteNetwork(java.lang.String projectName, java.lang.String name) { + + try { + controller.deleteNetwork(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deleteSubnet(java.lang.String projectName, java.lang.String name) { + + try { + controller.deleteSubnet(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deletePort(java.lang.String projectName, java.lang.String name) { + + try { + controller.deletePort(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deleteRouter(java.lang.String projectName, java.lang.String name) { + + try { + controller.deleteRouter(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void associateFloatingIp(java.lang.String projectName, java.lang.String ipId, java.lang.String portId) { + + try { + controller.associateFloatingIp(projectName,ipId,portId); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void createServer(org.openecomp.ncomp.openstack.compute.OpenstackRequestNewServer request) { + + try { + controller.createServer(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deleteServer(java.lang.String projectName, java.lang.String name) { + + try { + controller.deleteServer(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void createKeyPair(org.openecomp.ncomp.openstack.compute.OpenstackRequestKeyPair request) { + + try { + controller.createKeyPair(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void delete(org.openecomp.ncomp.openstack.core.OpenstackRequestDelete request) { + + try { + controller.delete(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void createFlavor(org.openecomp.ncomp.openstack.compute.OpenstackRequestFlavor request) { + + try { + controller.createFlavor(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void createSecurityGroup(org.openecomp.ncomp.openstack.compute.OpenstackRequestSecurityGroup request) { + + try { + controller.createSecurityGroup(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void serverAction(org.openecomp.ncomp.openstack.compute.OpenstackRequestServerAction request) { + + try { + controller.serverAction(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + try { + controller.deployVmType(vmTypeName,projectName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void undeployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + try { + controller.undeployVmType(vmTypeName,projectName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void deployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + try { + controller.deployUser(user,projectName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void undeployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + try { + controller.undeployUser(user,projectName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm createAlarm(org.openecomp.ncomp.openstack.ceilometer.CreateAlarmRequest request) { + org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm res = null; + try { + res = controller.createAlarm(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public void deleteAlarm(java.lang.String projectName, java.lang.String name) { + + try { + controller.deleteAlarm(projectName,name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> createAlarm(org.openecomp.ncomp.openstack.ceilometer.SampleRequest request) { + EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> res = null; + try { + res = controller.createAlarm(request); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProviderTemplate.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProviderTemplate.java new file mode 100644 index 0000000..0ac84a3 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/OsOpenStackLocationProviderTemplate.java @@ -0,0 +1,213 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.loc; + + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; + + +import org.openecomp.ncomp.openstack.location.impl.OpenStackLocationImpl; +import org.openecomp.ncomp.openstack.location.OpenStackLocation; + + +public class OsOpenStackLocationProviderTemplate extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(OsOpenStackLocationProviderTemplate.class); + OpenStackLocation o; + + public OsOpenStackLocationProviderTemplate(ISiriusServer controller, OpenStackLocation o) { + super(controller, o); + this.o = o; + } + + public void poll() { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void mergeLocation(org.openecomp.ncomp.openstack.location.OpenStackLocation loc) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.ncomp.openstack.neutron.Network createNetwork(org.openecomp.ncomp.openstack.neutron.CreateNetworkRequest request) { + org.openecomp.ncomp.openstack.neutron.Network res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.ncomp.openstack.neutron.Subnet createSubnet(org.openecomp.ncomp.openstack.neutron.CreateSubnetRequest request) { + org.openecomp.ncomp.openstack.neutron.Subnet res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.ncomp.openstack.neutron.Port createPort(org.openecomp.ncomp.openstack.neutron.CreatePortRequest request) { + org.openecomp.ncomp.openstack.neutron.Port res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.ncomp.openstack.neutron.Router createRouter(org.openecomp.ncomp.openstack.neutron.CreateRouterRequest request) { + org.openecomp.ncomp.openstack.neutron.Router res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deleteNetwork(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deleteSubnet(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deletePort(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deleteRouter(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void associateFloatingIp(java.lang.String projectName, java.lang.String ipId, java.lang.String portId) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void createServer(org.openecomp.ncomp.openstack.compute.OpenstackRequestNewServer request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deleteServer(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void createKeyPair(org.openecomp.ncomp.openstack.compute.OpenstackRequestKeyPair request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void delete(org.openecomp.ncomp.openstack.core.OpenstackRequestDelete request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void createFlavor(org.openecomp.ncomp.openstack.compute.OpenstackRequestFlavor request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void createSecurityGroup(org.openecomp.ncomp.openstack.compute.OpenstackRequestSecurityGroup request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void serverAction(org.openecomp.ncomp.openstack.compute.OpenstackRequestServerAction request) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void undeployVmType(java.lang.String vmTypeName, java.lang.String projectName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void undeployUser(org.openecomp.ncomp.core.User user, java.lang.String projectName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm createAlarm(org.openecomp.ncomp.openstack.ceilometer.CreateAlarmRequest request) { + org.openecomp.ncomp.openstack.ceilometer.CeilometerAlarm res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void deleteAlarm(java.lang.String projectName, java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> createAlarm(org.openecomp.ncomp.openstack.ceilometer.SampleRequest request) { + EList<org.openecomp.ncomp.openstack.ceilometer.CeilometerSample> res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + + + + + +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocation.properties b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocation.properties new file mode 100644 index 0000000..1329d77 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocation.properties @@ -0,0 +1,294 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +createNetwork=\ + createNetwork-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createSubnet=\ + createSubnet-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createPort=\ + createPort-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createRouter=\ + createRouter-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deleteNetwork=\ + deleteNetwork-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deleteSubnet=\ + deleteSubnet-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deletePort=\ + deletePort-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deleteRouter=\ + deleteRouter-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +associateFloatingIp=\ + associateFloatingIp-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createServer=\ + createServer-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deleteServer=\ + deleteServer-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createKeyPair=\ + createKeyPair-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +delete=\ + delete-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createFlavor=\ + createFlavor-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createSecurityGroup=\ + createSecurityGroup-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +serverAction=\ + serverAction-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deployVmType=\ + deployVmType-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +undeployVmType=\ + undeployVmType-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deployUser=\ + deployUser-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +undeployUser=\ + undeployUser-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +createAlarm=\ + createAlarm-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deleteAlarm=\ + deleteAlarm-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +poll=\ + poll-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +mergeLocation=\ + mergeLocation-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_createNetwork=\ + REMOTE-createNetwork-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createSubnet=\ + REMOTE-createSubnet-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createPort=\ + REMOTE-createPort-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createRouter=\ + REMOTE-createRouter-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deleteNetwork=\ + REMOTE-deleteNetwork-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deleteSubnet=\ + REMOTE-deleteSubnet-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deletePort=\ + REMOTE-deletePort-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deleteRouter=\ + REMOTE-deleteRouter-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_associateFloatingIp=\ + REMOTE-associateFloatingIp-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createServer=\ + REMOTE-createServer-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deleteServer=\ + REMOTE-deleteServer-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createKeyPair=\ + REMOTE-createKeyPair-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_delete=\ + REMOTE-delete-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createFlavor=\ + REMOTE-createFlavor-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createSecurityGroup=\ + REMOTE-createSecurityGroup-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_serverAction=\ + REMOTE-serverAction-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deployVmType=\ + REMOTE-deployVmType-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_undeployVmType=\ + REMOTE-undeployVmType-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deployUser=\ + REMOTE-deployUser-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_undeployUser=\ + REMOTE-undeployUser-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_createAlarm=\ + REMOTE-createAlarm-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deleteAlarm=\ + REMOTE-deleteAlarm-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_poll=\ + REMOTE-poll-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_mergeLocation=\ + REMOTE-mergeLocation-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationMessageEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationMessageEnum.java new file mode 100644 index 0000000..b0f7851 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationMessageEnum.java @@ -0,0 +1,83 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.loc.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum OpenStackLocationMessageEnum implements EcompMessageEnum { + + dummy, + createNetwork, + createSubnet, + createPort, + createRouter, + deleteNetwork, + deleteSubnet, + deletePort, + deleteRouter, + associateFloatingIp, + createServer, + deleteServer, + createKeyPair, + delete, + createFlavor, + createSecurityGroup, + serverAction, + deployVmType, + undeployVmType, + deployUser, + undeployUser, + createAlarm, + deleteAlarm, + poll, + mergeLocation, + REMOTE_createNetwork, + REMOTE_createSubnet, + REMOTE_createPort, + REMOTE_createRouter, + REMOTE_deleteNetwork, + REMOTE_deleteSubnet, + REMOTE_deletePort, + REMOTE_deleteRouter, + REMOTE_associateFloatingIp, + REMOTE_createServer, + REMOTE_deleteServer, + REMOTE_createKeyPair, + REMOTE_delete, + REMOTE_createFlavor, + REMOTE_createSecurityGroup, + REMOTE_serverAction, + REMOTE_deployVmType, + REMOTE_undeployVmType, + REMOTE_deployUser, + REMOTE_undeployUser, + REMOTE_createAlarm, + REMOTE_deleteAlarm, + REMOTE_poll, + REMOTE_mergeLocation; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.ncomp.servers.openstack.loc.logging.OpenStackLocation"); + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationOperationEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationOperationEnum.java new file mode 100644 index 0000000..5c37fc3 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/loc/logging/OpenStackLocationOperationEnum.java @@ -0,0 +1,77 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.loc.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum OpenStackLocationOperationEnum implements EcompOperationEnum { + + createNetwork, + createSubnet, + createPort, + createRouter, + deleteNetwork, + deleteSubnet, + deletePort, + deleteRouter, + associateFloatingIp, + createServer, + deleteServer, + createKeyPair, + delete, + createFlavor, + createSecurityGroup, + serverAction, + deployVmType, + undeployVmType, + deployUser, + undeployUser, + createAlarm, + deleteAlarm, + poll, + mergeLocation, + REMOTE_createNetwork, + REMOTE_createSubnet, + REMOTE_createPort, + REMOTE_createRouter, + REMOTE_deleteNetwork, + REMOTE_deleteSubnet, + REMOTE_deletePort, + REMOTE_deleteRouter, + REMOTE_associateFloatingIp, + REMOTE_createServer, + REMOTE_deleteServer, + REMOTE_createKeyPair, + REMOTE_delete, + REMOTE_createFlavor, + REMOTE_createSecurityGroup, + REMOTE_serverAction, + REMOTE_deployVmType, + REMOTE_undeployVmType, + REMOTE_deployUser, + REMOTE_undeployUser, + REMOTE_createAlarm, + REMOTE_deleteAlarm, + REMOTE_poll, + REMOTE_mergeLocation; +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptor.properties b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptor.properties new file mode 100644 index 0000000..47c5487 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptor.properties @@ -0,0 +1,6 @@ + +POLLING_FAILED=\ + NCOMP-OPENSTACK-POLLING-FAILED-5001W|\ + {0}|\ + Verify Openstack setup.|\ + Openstack Polling fails. diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorMessageEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorMessageEnum.java new file mode 100644 index 0000000..e412d6d --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorMessageEnum.java @@ -0,0 +1,35 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum OpenStackAdaptorMessageEnum implements EcompMessageEnum { + + POLLING_FAILED; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.ncomp.servers.openstack.logging.OpenStackAdaptor"); + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorOperationEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorOperationEnum.java new file mode 100644 index 0000000..e83d584 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackAdaptorOperationEnum.java @@ -0,0 +1,30 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum OpenStackAdaptorOperationEnum implements EcompOperationEnum { + + POLLING; +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackController.properties b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackController.properties new file mode 100644 index 0000000..5825f57 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackController.properties @@ -0,0 +1,18 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +uploadOpenstackConfiguration=\ + uploadOpenstackConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_uploadOpenstackConfiguration=\ + REMOTE-uploadOpenstackConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerMessageEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerMessageEnum.java new file mode 100644 index 0000000..ee93bf2 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerMessageEnum.java @@ -0,0 +1,37 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum OpenStackControllerMessageEnum implements EcompMessageEnum { + + dummy, + uploadOpenstackConfiguration, + REMOTE_uploadOpenstackConfiguration; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.ncomp.servers.openstack.logging.OpenStackController"); + } +} diff --git a/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerOperationEnum.java b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerOperationEnum.java new file mode 100644 index 0000000..069aa56 --- /dev/null +++ b/ncomp-openstack-controller/src/main/sirius-gen/org/openecomp/ncomp/servers/openstack/logging/OpenStackControllerOperationEnum.java @@ -0,0 +1,31 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * 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.ncomp.servers.openstack.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum OpenStackControllerOperationEnum implements EcompOperationEnum { + + uploadOpenstackConfiguration, + REMOTE_uploadOpenstackConfiguration; +} |