Esempio n. 1
0
  @ScriptUsage(
      description = "join security group",
      arguments = {
        @ScriptArgument(
            name = "group name",
            type = "string",
            description = "name of security group"),
        @ScriptArgument(name = "login name", type = "string", description = "account login name")
      })
  public void joinSecurityGroup(String[] args) {
    SecurityGroup group = findSecurityGroupByName(args[0]);
    if (group == null) {
      context.println("security group not found");
      return;
    }

    for (int i = 1; i < args.length; i++) {
      String loginName = args[i];
      Account account = accountService.getAccount(loginName);
      if (account == null) {
        context.println("account [" + loginName + "] not found. skipping.");
        continue;
      }

      group.getAccounts().add(account.getLoginName());
    }

    accountService.updateSecurityGroup(null, group);
    context.println("updated");
  }
Esempio n. 2
0
 public void accounts(String[] args) {
   context.println("Accounts");
   context.println("----------");
   for (String loginName : accountService.getAccountNames()) {
     Account account = accountService.getAccount(loginName);
     String admin = "";
     if (account.isAdmin()) admin = " (admin)";
     context.println(loginName + admin);
   }
 }