コード例 #1
0
 public Task<?> expunge(final Entity entity, final boolean release) {
   if (mgmt.getEntitlementManager()
       .isEntitled(
           Entitlements.getEntitlementContext(),
           Entitlements.INVOKE_EFFECTOR,
           Entitlements.EntityAndItem.of(entity, "expunge"))) {
     return mgmt.getExecutionManager()
         .submit(
             MutableMap.of(
                 "displayName",
                 "expunging " + entity,
                 "description",
                 "REST call to expunge entity " + entity.getDisplayName() + " (" + entity + ")"),
             new Runnable() {
               @Override
               public void run() {
                 if (release) Entities.destroyCatching(entity);
                 else mgmt.getEntityManager().unmanage(entity);
               }
             });
   }
   throw WebResourceUtils.unauthorized(
       "User '%s' is not authorized to expunge entity %s",
       Entitlements.getEntitlementContext().user(), entity);
 }
コード例 #2
0
ファイル: EntityProxyTest.java プロジェクト: kraman/brooklyn
  @Test
  public void testEffectorOnProxyIsRecorded() {
    Object result = entity.identityEffector("abc");
    assertEquals(result, "abc");

    Set<Task<?>> tasks =
        managementContext
            .getExecutionManager()
            .getTasksWithAllTags(ImmutableList.of(ManagementContextInternal.EFFECTOR_TAG, entity));
    Task<?> task = Iterables.get(tasks, 0);
    assertEquals(tasks.size(), 1, "tasks=" + tasks);
    assertTrue(task.getDescription().contains("identityEffector"));
  }
コード例 #3
0
  @Test(groups = "Integration")
  public void testSshFetch() throws IOException {
    String fn = Urls.mergePaths(tempDir.getPath(), "f2");
    FileUtils.write(new File(fn), "hello fetched world");

    SshFetchTaskFactory tf = SshTasks.newSshFetchTaskFactory(host, fn);
    SshFetchTaskWrapper t = tf.newTask();
    mgmt.getExecutionManager().submit(t);

    t.block();
    Assert.assertTrue(t.isDone());
    Assert.assertEquals(t.get(), "hello fetched world");
    Assert.assertEquals(t.getBytes(), "hello fetched world".getBytes());
  }
コード例 #4
0
 public Task<?> destroy(final Application application) {
   return mgmt.getExecutionManager()
       .submit(
           MutableMap.of(
               "displayName",
               "destroying " + application,
               "description",
               "REST call to destroy application "
                   + application.getDisplayName()
                   + " ("
                   + application
                   + ")"),
           new Runnable() {
             @Override
             public void run() {
               ((EntityInternal) application).destroy();
               mgmt.getEntityManager().unmanage(application);
             }
           });
 }
コード例 #5
0
 protected <T> ProcessTaskWrapper<T> submit(final ProcessTaskFactory<T> tf) {
   tf.machine(host);
   ProcessTaskWrapper<T> t = tf.newTask();
   mgmt.getExecutionManager().submit(t);
   return t;
 }
コード例 #6
0
 protected SshPutTaskWrapper submit(final SshPutTaskFactory tf) {
   SshPutTaskWrapper t = tf.newTask();
   mgmt.getExecutionManager().submit(t);
   return t;
 }