예제 #1
0
  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);
      }
    }
  }
 @Override
 public int compare(Viewer viewer, Object e1, Object e2) {
   if (e1 instanceof InstanceStatsAndInfo && e1 instanceof InstanceStatsAndInfo) {
     InstanceStats stats1 = ((InstanceStatsAndInfo) e1).getStats();
     InstanceStats stats2 = ((InstanceStatsAndInfo) e2).getStats();
     return stats1.getId().compareTo(stats2.getId());
   }
   if (e1 instanceof CloudService && e2 instanceof CloudService) {
     CloudService service1 = (CloudService) e1;
     CloudService service2 = (CloudService) e2;
     return service1.getName().compareTo(service2.getName());
   }
   if (e1 instanceof IModule && e2 instanceof IModule) {
     IModule m1 = (IModule) e1;
     IModule m2 = (IModule) e2;
     return m1.getName().compareTo(m2.getName());
   }
   return super.compare(viewer, e1, e2);
 }
예제 #3
0
 private CloudService getCloudService(CloudFoundryClient client, String serviceName) {
   if (services == null) {
     services = new HashMap<String, CloudService>();
     List<CloudService> list = client.getServices();
     for (CloudService cs : list) {
       services.put(cs.getName(), cs);
     }
   }
   return services.get(serviceName);
 }
  public List<String> getServiceNames() {

    if (services == null) {
      services = new ArrayList<String>();

      for (CloudService service : cloudServices) {
        services.add(service.getName());
      }
    }

    return services;
  }
  @Test
  public void createServicesWithoutVersionAndTierTest() throws MojoExecutionException {
    List<String> names = new ArrayList<String>();

    for (int i = 0; i < 4; i++) {
      Map<String, Object> servicesAsMap = new HashMap<String, Object>();
      servicesAsMap.put("vendor", "mysql");
      servicesAsMap.put("name", "test" + i);

      CloudService service = new CloudService(servicesAsMap);

      services.add(service);
      names.add(service.getName());
    }
    serviceCreation.setClient(client);
    serviceCreation.setServices(services);

    assertEquals(names, serviceCreation.createServices());
  }
 public void deleteAllServices() {
   List<CloudService> services = getServices();
   for (CloudService service : services) {
     deleteService(service.getName());
   }
 }