Package org.jclouds.openstack.trove.v1.features

Examples of org.jclouds.openstack.trove.v1.features.UserApiLiveTest


            responseWithKeystoneAccess,
            authenticatedGET().endpoint(endpoint).build(),
            HttpResponse.builder().statusCode(404).payload(payloadFromResource("/user_get_withhost.json")).build()
      ).getUserApiForZoneAndInstance("RegionOne", "instanceId-1234-5678");

      User user = api.get("example.user", "192.168.64.64");
      assertNull(user);
   }
View Full Code Here


         Instance second = utils.getWorkingInstance(zone, "second_user_trove_live_testing_" + zone, "1", 1);
         instanceList.add(first);
         instanceList.add(second);
         instancesToDelete.put(zone, instanceList);
         // create users
         User user1 = User.builder()
               .name("user1")
               .password(UUID.randomUUID().toString())
               .databases(ImmutableSet.of(
                     "u1db1",
                     "u1db2")).build();
         User user2 = User.builder()
               .name("user2")
               .password(UUID.randomUUID().toString())
               .databases(ImmutableSet.of(
                     "u2db1",
                     "u2db2")).build();
         User user3 = User.builder()
               .name("user3")
               .password(UUID.randomUUID().toString())
               .host("173.203.44.122")
               .databases(ImmutableSet.of(
                     "u3db1",
View Full Code Here

            UserApi userApi = api.getUserApiForZoneAndInstance(zone, instance.getId());
            if (!instance.getName().contains("user_trove_live_testing"))
               continue;
            assertTrue(userApi.list().size() >= 1);
            for (User user : userApi.list()) {
               User userFromGet = userApi.get(user.getIdentifier());
               assertEquals(userFromGet.getName(), user.getName());
               assertEquals(userFromGet.getHost(), user.getHost());
               assertEquals(userFromGet.getIdentifier(), user.getIdentifier());
               assertEquals(userFromGet.getDatabases(), user.getDatabases());
               assertEquals(userFromGet, user);
            }
         } 
      }
   }
View Full Code Here

      if( postParams.get("name") != null ) {
         Set<String> databases = Sets.newHashSet();
         if(postParams.get("databaseName")!=null)
            databases.add((String) postParams.get("databaseName"));
        
         Builder builder = User.builder();
         builder.name((String) postParams.get("name"))
                .password((String) postParams.get("password"));
        
         builder.host((String) postParams.get("host"));
         builder.databases(databases);
        
         User user = builder.build();
         users.add(user);
      }
      else if( postParams.get("users") != null ) {
         users = (Set<User>) postParams.get("users");
      }
View Full Code Here

    * @param size
    *           Size of the instance.
    * @return Instance object in active state or NULL.
    */
   public Instance getWorkingInstance(String zone, String name, String flavorId, int size) {
      InstanceApi instanceApi = api.getInstanceApiForZone(zone);
      for (int retries = 0; retries < 10; retries++) {
         Instance instance = null;
         try {
            instance = instanceApi.create(flavorId, size, name);
         } catch (Exception e) {

            Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);

            logger.error(e.getStackTrace().toString());
            continue;
         }

         Instance updatedInstance = awaitAvailable(instance, instanceApi);
         if (updatedInstance != null) {
            return updatedInstance;
         }
         instanceApi.delete(instance.getId());
         InstancePredicates.awaitDeleted(instanceApi).apply(instance);
        
      }
      return null;
   }
View Full Code Here

    * @param size
    *           Size of the instance.
    * @return Instance object in active state or NULL.
    */
   public Instance getWorkingInstance(String zone, String name, String flavorId, int size) {
      InstanceApi instanceApi = api.getInstanceApiForZone(zone);
      for (int retries = 0; retries < 10; retries++) {
         Instance instance = null;
         try {
            instance = instanceApi.create(flavorId, size, name);
         } catch (Exception e) {

            Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);

            logger.error(Arrays.toString(e.getStackTrace()));
            continue;
         }

         Instance updatedInstance = awaitAvailable(instance, instanceApi);
         if (updatedInstance != null) {
            return updatedInstance;
         }
         instanceApi.delete(instance.getId());
         InstancePredicates.awaitDeleted(instanceApi).apply(instance);
        
      }
      return null;
   }
View Full Code Here

      /**
       *
       * @return A new Instance object.
       */
      public Instance build() {
         return new Instance(id, name, flavor, new Volume(size), status, links, hostname);
      }
View Full Code Here

   
    @Override   
    public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
       Map<String, Object> databaseInstance = Maps.newHashMap();
       databaseInstance.put("flavorRef", postParams.get("flavorRef"));
       databaseInstance.put("volume", new Volume((Integer) postParams.get("size")));
       if (postParams.get("name") != null)
           databaseInstance.put("name", postParams.get("name"));
       return jsonBinder.bindToRequest(request, ImmutableMap.of("instance", databaseInstance));
    }
View Full Code Here

      /**
       *
       * @return A new Instance object.
       */
      public Instance build() {
         return new Instance(id, name, flavor, new Volume(size), status, links, hostname);
      }
View Full Code Here

   @Override
   @BeforeClass(groups = { "integration", "live" })
   public void setup() {
      super.setup();
      TroveUtils utils= new TroveUtils(api);
      for (String zone : api.getConfiguredZones()) {
         // create instances
         List<Instance> instanceList = Lists.newArrayList();
         Instance first = utils.getWorkingInstance(zone, "first_user_trove_live_testing_" + zone, "1", 1);
         Instance second = utils.getWorkingInstance(zone, "second_user_trove_live_testing_" + zone, "1", 1);
         instanceList.add(first);
         instanceList.add(second);
         instancesToDelete.put(zone, instanceList);
         // create users
         User user1 = User.builder()
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.trove.v1.features.UserApiLiveTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.