Exemplo n.º 1
0
 static boolean shouldInitialize() { // GRZE:WARNING:HACKHACKHACK do not duplicate pls thanks.
   for (final Host h : Hosts.listActiveDatabases()) {
     final String url =
         String.format(
             "jdbc:%s",
             ServiceUris.remote(Database.class, h.getBindAddress(), "eucalyptus_config"));
     try {
       final Connection conn =
           DriverManager.getConnection(url, Databases.getUserName(), Databases.getPassword());
       try {
         final PreparedStatement statement =
             conn.prepareStatement(
                 "select config_component_hostname from config_component_base where config_component_partition='eucalyptus';");
         final ResultSet result = statement.executeQuery();
         while (result.next()) {
           final Object columnValue = result.getObject(1);
           if (Internets.testLocal(columnValue.toString())) {
             return true;
           }
         }
       } finally {
         conn.close();
       }
     } catch (final Exception ex) {
       LOG.error(ex, ex);
     }
   }
   return false;
 }
Exemplo n.º 2
0
 static boolean disable(final String hostName) {
   if (!Bootstrap.isFinished()) {
     return false;
   } else if (Internets.testLocal(hostName)) {
     return true;
   } else {
     try {
       runDbStateChange(DeactivateHostFunction.INSTANCE.apply(hostName));
       return true;
     } catch (Exception ex) {
       Logs.extreme().debug(ex);
       return false;
     }
   }
 }