private void genServiceNode( AppModel model, CloudFoundryClient cfClient, List<CloudApplication> apps) { for (CloudApplication app : apps) { List<String> services = app.getServices(); for (String service : services) { // return from cloud foundry client getService() does not include label info // workaround it with method getCloudService CloudService cloudService = getCloudService(cfClient, service); String label = cloudService.getLabel(); // FIXME: to support more services if (!label.contains("mongodb")) { System.out.println("unsupported service " + label + " for app " + app.getName()); continue; } ServiceNode serviceNode = new ServiceNode(model); serviceNode.setName(cloudService.getName()); serviceNode.setServiceType(ServiceType.mongo); serviceNode.setProperty("dbName", "mydb"); model.addNode(serviceNode); Relationship relation = new Relationship(); relation.setSourceNode(app.getName()); relation.setTargetNode(cloudService.getName()); relation.setType(RelationshipType.connectTo); model.addRelationship(relation); } } }
private void genContainerAndRelation( AppModel model, CloudFoundryClient cfClient, List<CloudApplication> apps) { for (CloudApplication app : apps) { // Currently only when pushing an application with an assigned buildpack url, can get the // runtime type app hosted on String staging_info = cfClient.getFile(app.getName(), 0, "staging_info.yml"); // System.out.println("staging info is: " + staging_info); // String buildpack = app.getStaging().getBuildpackUrl(); // FIXME: to support more buildpacks // here only supports "node", if the staging info contains "node", it tips the buildpack is // nodejs if (staging_info.toLowerCase().contains("node")) { // System.out.println("unsupported build pack "); AppContainerNode containerNode = new AppContainerNode(model); containerNode.setName(BuildPack.NodeJS.toString()); containerNode.seteBuildPack(BuildPack.NodeJS); model.addNode(containerNode); Relationship relation = new Relationship(); relation.setSourceNode(app.getName()); relation.setTargetNode(containerNode.getName()); relation.setType(Relationship.RelationshipType.hostedOn); model.addRelationship(relation); // continue; } // if(!buildpack.toLowerCase().contains("node")){ // System.out.println("unsupported build pack " + buildpack); // continue; // } } }
private void genAppDepRelation(AppModel model, Map<String, List<Dependency>> deps) { for (List<Dependency> list : deps.values()) { for (Dependency dep : list) { Relationship r = new Relationship(); r.setSourceNode(dep.getSource().getName()); r.setTargetNode(dep.getTarget().getName()); r.setType(RelationshipType.dependsOn); model.addRelationship(r); } } }
private void genRelationFromEnv(AppModel model, CloudApplication app, List<Env> envs) { for (Env env : envs) { if (env.getType().equals(EnvType.service_url)) { Relationship relation = new Relationship(); relation.setSourceNode(app.getName()); relation.setTargetNode(parseEnvRefTarget(env.getValue())); relation.setType(RelationshipType.connectTo); model.addRelationship(relation); } else if (env.getType().equals(EnvType.webapp_url)) { Relationship relation = new Relationship(); relation.setSourceNode(app.getName()); relation.setTargetNode(parseEnvRefTarget(env.getValue())); relation.setType(RelationshipType.dependsOn); model.addRelationship(relation); } } }