Package com.vmware.bdd.apitypes

Examples of com.vmware.bdd.apitypes.AppManagerAdd


            logger.error("One of the appliation manager cannot be loaded: " + appManager.getName(), e);
         }
      }

      if(!defaultMgrExists) {
         AppManagerAdd appManagerAdd = new AppManagerAdd();
         appManagerAdd.setName(Constants.IRONFAN);
         appManagerAdd.setDescription(Constants.IRONFAN_DESCRIPTION);
         appManagerAdd.setType(Constants.IRONFAN);
         appManagerAdd.setUrl("");
         appManagerAdd.setUsername("");
         appManagerAdd.setPassword("");
         appManagerAdd.setSslCertificate("");

         appManagerService.addAppManager(appManagerAdd);

         try {
            loadSoftwareManager(new AppManagerEntity(appManagerAdd));
         } catch (Exception e) {
            logger.error("One of the appliation manager cannot be loaded: " + appManagerAdd.getName(), e);
         }
      }
   }
View Full Code Here


   /**
    * @param appManager
    * @return
    */
   public static AppManagerAdd toAppManagerAdd(AppManagerEntity appManager) {
      AppManagerAdd appManagerAdd = new AppManagerAdd();
      appManagerAdd.setName(appManager.getName());
      appManagerAdd.setDescription(appManager.getDescription());
      appManagerAdd.setType(appManager.getType());
      appManagerAdd.setUrl(appManager.getUrl());
      appManagerAdd.setUsername(appManager.getUsername());
      appManagerAdd.setPassword(appManager.getPassword());
      appManagerAdd.setSslCertificate(appManager.getSslCertificate());
      return appManagerAdd;
   }
View Full Code Here

         @CliOption(key = { "name" }, mandatory = true, help = "The instance name") final String name,
         @CliOption(key = { "description" }, mandatory = false, help = "The instance description") final String description,
         @CliOption(key = { "type" }, mandatory = true, help = "The provider type, ClouderaManager or Ambari") final String type,
         @CliOption(key = { "url" }, mandatory = true, help = "The instance URL, e.g. http://hostname:port") final String url) {

      AppManagerAdd appManagerAdd = new AppManagerAdd();
      appManagerAdd.setName(name);
      appManagerAdd.setDescription(description);

      //validate appmanager type
      String[] types = restClient.getTypes();
      boolean found = false;
      for (String t : types) {
         if (type.equals(t)) {
            found = true;
            break;
         }
      }
      if (found) {
         appManagerAdd.setType(type);
      } else {
         CommandsUtils.printCmdFailure(
               Constants.OUTPUT_OBJECT_APPMANAGER,
               name,
               Constants.OUTPUT_OP_ADD,
               Constants.OUTPUT_OP_RESULT_FAIL,
               "Invalid type " + type + ". Valid types are "
                     + Arrays.asList(types) + ".");
         return;
      }

      //validate url in appManagerAdd
      List<String> errorMsgs = new ArrayList<String>();
      if (!CommonUtil.validateUrl(url, errorMsgs)) {
         CommandsUtils.printCmdFailure(
               Constants.OUTPUT_OBJECT_APPMANAGER,
               name,
               Constants.OUTPUT_OP_ADD,
               Constants.OUTPUT_OP_RESULT_FAIL,
               "Invalid URL: " + CommonUtil.mergeErrorMsgList(errorMsgs) + ".");
         return;
      }
      appManagerAdd.setUrl(url);

      Map<String, String> loginInfo = getAccount();
      if (null == loginInfo) {
         return;
      }
      appManagerAdd.setUsername(loginInfo.get(Constants.LOGIN_USERNAME));
      appManagerAdd.setPassword(loginInfo.get(Constants.LOGIN_PASSWORD));

      if (url.toLowerCase().startsWith("https")) {
         String sslCertificate = getSslCertificate();
         if (null != sslCertificate) {
            appManagerAdd.setSslCertificate(sslCertificate);
         } else {
            CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_APPMANAGER,
                  name, Constants.OUTPUT_OP_ADD, Constants.OUTPUT_OP_RESULT_FAIL,
                  "Failed to read ssl certificate file.");
            return;
View Full Code Here

                  Constants.OUTPUT_OP_MODIFY, warningMsgList, false)) {
               return;
            }
         }

         AppManagerAdd appManagerAdd = new AppManagerAdd();
         appManagerAdd.setName(name);
         //appManagerAdd.setDescription(description);
         appManagerAdd.setDescription(appManagerRead.getDescription());
         //appManagerAdd.setType(type);
         appManagerAdd.setType(appManagerRead.getType());
         if (url == null) {
            appManagerAdd.setUrl(appManagerRead.getUrl());
         } else {
            //validate url in appManagerAdd
            List<String> errorMsgs = new ArrayList<String>();
            if (!CommonUtil.validateUrl(url, errorMsgs)) {
               CommandsUtils.printCmdFailure(
                     Constants.OUTPUT_OBJECT_APPMANAGER,
                     name,
                     Constants.OUTPUT_OP_ADD,
                     Constants.OUTPUT_OP_RESULT_FAIL,
                     "Invalid URL: " + CommonUtil.mergeErrorMsgList(errorMsgs) + ".");
               return;
            }
            appManagerAdd.setUrl(url);
         }

         if (changeAccount) {
            Map<String, String> loginInfo = getAccount();
            if (null == loginInfo) {
               return;
            }
            appManagerAdd.setUsername(loginInfo.get(Constants.LOGIN_USERNAME));
            appManagerAdd.setPassword(loginInfo.get(Constants.LOGIN_PASSWORD));
         } else {
            appManagerAdd.setUsername(appManagerRead.getUsername());
            appManagerAdd.setPassword(appManagerRead.getPassword());
         }

         if ((url != null && url.toLowerCase().startsWith("https"))
               || (url == null && changeCertificate && appManagerAdd
                     .getUrl().toLowerCase().startsWith("https"))) {
            // new URL starts with https or
            // changeCertificate for old URL starts with https (no new URL)
            String sslCertificate = getSslCertificate();
            if (null == sslCertificate) {
               CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_APPMANAGER,
                     name, Constants.OUTPUT_OP_MODIFY, Constants.OUTPUT_OP_RESULT_FAIL,
                     "Fail to get ssl certificate.");
               return;
            }
            appManagerAdd.setSslCertificate(sslCertificate);
         } else if (url == null && changeCertificate
               && !appManagerAdd.getUrl().toLowerCase().startsWith("https")) {
            // changeCertificate for old URL does not start with https (no new URL)
            CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_APPMANAGER,
                  name, Constants.OUTPUT_OP_MODIFY, Constants.OUTPUT_OP_RESULT_FAIL,
                  "Cannot set ssl certificate for http service.");
            return;
         } else if (url != null && !url.toLowerCase().startsWith("https")) {
            // new url does not start with https
            appManagerAdd.setSslCertificate(null);
         } else {
            // no new url or changeCertificate
            appManagerAdd.setSslCertificate(appManagerRead.getSslCertificate());
         }

         restClient.modify(appManagerAdd);
         CommandsUtils.printCmdSuccess(Constants.OUTPUT_OBJECT_APPMANAGER,
               name, Constants.OUTPUT_OP_RESULT_MODIFY);
View Full Code Here

      Configuration.setString(SoftwareManagerCollector.configurationPrefix + appManagerEntityFoo.getType(), "com.vmware.bdd.manager.mocks.FooSWMgrFactory");
      softwareManagerCollector.setPrivateKey("mock-key");

      softwareManagerCollector.loadSoftwareManagers();

      AppManagerAdd appManagerAdd = SoftwareManagerCollector.toAppManagerAdd(appManagerEntityFoo);
      appManagerAdd.setName("newUserName");
      appManagerAdd.setPassword("newPassword");
      appManagerAdd.setUrl("http://newUrl");


      softwareManagerCollector.modifySoftwareManager(appManagerAdd);
   }
View Full Code Here

   @Test(groups = { "res-mgmt" })
   public void testAddAppManager() {
      appMgrSvc.setAppManagerDAO(appManagerDAO);

      AppManagerAdd appMgr = new AppManagerAdd();
      appMgr.setType(Constants.AMBARI_PLUGIN_TYPE);
      appMgr.setUrl("http://10.141.73.200:7180");
      appMgrSvc.addAppManager(appMgr);

      new Verifications() {
         {
            AppManagerEntity entity = new AppManagerEntity();
View Full Code Here

         }
      };

      appMgrSvc.setAppManagerDAO(appManagerDAO);

      AppManagerAdd appMgr = new AppManagerAdd();
      appMgr.setType(Constants.AMBARI_PLUGIN_TYPE);
      appMgr.setUrl("http://10.141.73.200:7180");
      appMgrSvc.modifyAppManager(appMgr);

      new Verifications() {
         {
            appManagerDAO.update(withAny(appMgrEntity));
View Full Code Here

   }

   @Test(expectedExceptions = SoftwareManagerCollectorException.class,
   expectedExceptionsMessageRegExp = "Invalid URL: URL should starts with http or https.")
   public void testCreateAppManager_InvalidURL() {
      AppManagerAdd appManagerAddDefault1 = new AppManagerAdd();
      appManagerAddDefault1.setName(Constants.IRONFAN);
      appManagerAddDefault1.setDescription(Constants.IRONFAN_DESCRIPTION);
      appManagerAddDefault1.setType(Constants.IRONFAN);
      appManagerAddDefault1.setUrl("ftp://address");
      appManagerAddDefault1.setUsername("");
      appManagerAddDefault1.setPassword("");
      appManagerAddDefault1.setSslCertificate("");

      softwareManagerCollector.createSoftwareManager(appManagerAddDefault1);
   }
View Full Code Here

      SoftwareManagerCollector.loadPrivateKey("key-file");
   }

   @Test
   public void testToAppManagerAdd() {
      AppManagerAdd appManagerAddDefault1 = new AppManagerAdd();
      appManagerAddDefault1.setName(Constants.IRONFAN);
      appManagerAddDefault1.setDescription(Constants.IRONFAN_DESCRIPTION);
      appManagerAddDefault1.setType(Constants.IRONFAN);
      appManagerAddDefault1.setUrl("ftp://address");
      appManagerAddDefault1.setUsername("");
      appManagerAddDefault1.setPassword("");
      appManagerAddDefault1.setSslCertificate("");

      AppManagerAdd appManagerAdd = SoftwareManagerCollector.toAppManagerAdd(new AppManagerEntity(appManagerAddDefault1));
      Assert.assertEquals(appManagerAddDefault1, appManagerAdd);
      Assert.assertEquals(appManagerAddDefault1.hashCode(), appManagerAdd.hashCode());
   }
View Full Code Here

TOP

Related Classes of com.vmware.bdd.apitypes.AppManagerAdd

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.