Skip to content

Commit

Permalink
Merge pull request #5 in SS_PLUGINS/generic-plugin from ui to master
Browse files Browse the repository at this point in the history
* commit 'f512ec8fec70a040a6c552d876c86bd27144467d':
  Merged with db
  • Loading branch information
Ermek Abyshev committed Nov 5, 2015
2 parents 5741fc9 + f512ec8 commit 0c299b1
Show file tree
Hide file tree
Showing 22 changed files with 1,759 additions and 1,662 deletions.
10 changes: 5 additions & 5 deletions features.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<features name="generic-plugin" version="4.0.0-RC2">
<feature name="generic-plugin" version="4.0.0-RC2">
<bundle>mvn:io.subutai/generic-plugin-api/4.0.0-RC2</bundle>
<bundle>mvn:io.subutai/generic-plugin-impl/4.0.0-RC2</bundle>
<bundle>mvn:io.subutai/generic-plugin-ui/4.0.0-RC2</bundle>
<features name="generic-plugin" version="4.0.0-RC3">
<feature name="generic-plugin" version="4.0.0-RC3">
<bundle>mvn:io.subutai/generic-plugin-api/4.0.0-RC3</bundle>
<bundle>mvn:io.subutai/generic-plugin-impl/4.0.0-RC3</bundle>
<bundle>mvn:io.subutai/generic-plugin-ui/4.0.0-RC3</bundle>
</feature>
</features>
2 changes: 1 addition & 1 deletion generic-plugin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>generic-plugin</artifactId>
<groupId>io.subutai</groupId>
<version>4.0.0-RC2</version>
<version>4.0.0-RC3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@

import io.subutai.common.peer.ContainerHost;
import io.subutai.plugin.generic.api.model.Operation;
import io.subutai.plugin.generic.api.model.Profile;


public interface GenericPlugin
{
public void saveProfile( String profileName );
void saveProfile (String profileName);

public List<io.subutai.plugin.generic.api.model.Profile> getProfiles();
List <Profile> getProfiles();

public void saveOperation( Long profileId, String operationName, String commandName, String cwd, String timeout,
Boolean daemon );
void saveOperation (Long profileId, String operationName, String commandName, String cwd, String timeout, Boolean daemon);

public List<Operation> getProfileOperations( Long profileId );
List <Operation> getProfileOperations (Long profileId);

public boolean IsOperationRegistered( String operationName );
boolean IsOperationRegistered (String operationName);

public void updateOperation( final Operation operation, final String commandValue, final String cwdValue,
final String timeoutValue, final Boolean daemonValue );
void updateOperation (final Operation operation, final String commandValue, final String cwdValue, final String timeoutValue, final Boolean daemonValue);

public void deleteOperation( Long operationId );
void deleteOperation (Long operationId);

public String executeCommandOnContainer( ContainerHost host, Operation operation );
String executeCommandOnContainer (ContainerHost host, Operation operation);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@

public interface ConfigDataService
{
public void saveProfile( String profileName );
void saveProfile (String profileName);

public List<Profile> getAllProfiles();
List <Profile> getAllProfiles();

public void saveOperation( Long profileId, String operationName, String commandName, String cwd, String timeout,
Boolean daemon );
void saveOperation (Long profileId, String operationName, String commandName, String cwd, String timeout, Boolean daemon);

public List<Operation> getOperations( Long profileId );
List <Operation> getOperations (Long profileId);

public boolean isOperationRegistered( String operationName );
boolean isOperationRegistered (String operationName);

public Operation getOperationByName( String operationName );
Operation getOperationByName (String operationName);

public void updateOperation( Operation operation, String commandValue, String cwdValue, String timeoutValue,
Boolean daemonValue );
void updateOperation (Operation operation, String commandValue, String cwdValue, String timeoutValue, Boolean daemonValue);

public void deleteOperation( Long operationId );
void deleteOperation (Long operationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@

public interface Operation
{
public String getOperationName();
String getOperationName();


public void setOperationName( final String operationName );
void setOperationName (final String operationName);


public String getCommandName();
String getCommandName();


public void setCommandName( final String commandName );
void setCommandName (final String commandName);


public String getCwd();
String getCwd();


public void setCwd( final String cwd );
void setCwd (final String cwd);


public String getTimeout();
String getTimeout();


public void setTimeout( final String timeout );
void setTimeout (final String timeout);


public Boolean getDaemon();
Boolean getDaemon();


public void setDaemon( final Boolean daemon );
void setDaemon (final Boolean daemon);

public Long getProfileId();
Long getProfileId();


public void setProfileId( final Long profileId );
void setProfileId (final Long profileId);


public Long getOperationId();
Long getOperationId();


public void setOperationId( final Long operationId );
void setOperationId (final Long operationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

public interface Profile
{
public Long getId();
Long getId();

public void setId( final Long id );
void setId (final Long id);

public String getName();
String getName();

public void setName( final String name );
void setName (final String name);
}
4 changes: 2 additions & 2 deletions generic-plugin-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>generic-plugin</artifactId>
<groupId>io.subutai</groupId>
<version>4.0.0-RC2</version>
<version>4.0.0-RC3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>generic-plugin-api</artifactId>
<version>4.0.0-RC2</version>
<version>4.0.0-RC3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,88 +21,79 @@

public class ExecutorManager
{
private static final Logger LOG = LoggerFactory.getLogger( ExecutorManager.class.getName() );
private ExecutorService executor = SubutaiExecutors.newCachedThreadPool();
private String output;
private ContainerHost containerHost;
private Operation operation;
private static final Logger LOG = LoggerFactory.getLogger (ExecutorManager.class.getName());
// private ExecutorService executor = SubutaiExecutors.newCachedThreadPool();
private String output;
private ContainerHost containerHost;
private Operation operation;

public ExecutorManager( final ContainerHost host, final Operation operation )
{
this.containerHost = host;
this.operation = operation;
}
public ExecutorManager (final ContainerHost host, final Operation operation)
{
this.containerHost = host;
this.operation = operation;
}


public String execute()
{
final RequestBuilder requestBuilder = new RequestBuilder( operation.getCommandName() );
requestBuilder.withCwd( operation.getCwd() );
// TODO: timeout cannot be float???
requestBuilder.withTimeout( Integer.parseInt( operation.getTimeout() ) );
if ( operation.getDaemon() )
{
requestBuilder.daemon();
}
/* executor.execute (new Runnable()
{
public String execute()
{
final RequestBuilder requestBuilder = new RequestBuilder (operation.getCommandName());
requestBuilder.withCwd (operation.getCwd());
// TODO: timeout cannot be float???
requestBuilder.withTimeout (Integer.parseInt (operation.getTimeout()));
if (operation.getDaemon())
{
requestBuilder.daemon();
}
/* executor.execute (new Runnable()
{
@Override
public void run()
{*/
try
{
containerHost.execute( requestBuilder, new CommandCallback()
{
@Override
public void onResponse( Response response, CommandResult commandResult )
{
StringBuilder out = new StringBuilder();
if ( !Strings.isNullOrEmpty( response.getStdOut() ) )
{
out.append( response.getStdOut() ).append( "\n" );
}
if ( !Strings.isNullOrEmpty( response.getStdErr() ) )
{
out.append( response.getStdErr() ).append( "\n" );
}
if ( commandResult.hasCompleted() || commandResult.hasTimedOut() )
{
if ( response.getType() == ResponseType.EXECUTE_RESPONSE && response.getExitCode() != 0 )
{
out.append( "Exit code: " ).append( response.getExitCode() ).append( "\n\n" );
}
else if ( response.getType() != ResponseType.EXECUTE_RESPONSE )
{
out.append( response.getType() ).append( "\n\n" );
}
}
try
{
containerHost.execute (requestBuilder, new CommandCallback()
{
@Override
public void onResponse (Response response, CommandResult commandResult)
{
StringBuilder out = new StringBuilder();
if (!Strings.isNullOrEmpty (response.getStdOut()))
{
out.append (response.getStdOut()).append ("\n");
}
if (!Strings.isNullOrEmpty (response.getStdErr()))
{
out.append (response.getStdErr()).append ("\n");
}
if (commandResult.hasCompleted() || commandResult.hasTimedOut())
{
if (response.getType() == ResponseType.EXECUTE_RESPONSE && response.getExitCode() != 0)
{
out.append ("Exit code: ").append (response.getExitCode()).append ("\n\n");
}
else if (response.getType() != ResponseType.EXECUTE_RESPONSE)
{
out.append (response.getType()).append ("\n\n");
}
}

if ( out.length() > 0 )
{
LOG.info( "out is:\n" + out );
output =
String.format( "%s [%d]:%n%s", containerHost.getHostname(), response.getPid(), out );
}
}
} );
}
catch ( CommandException e )
{
//LOG.error( "Error in ExecuteCommandTask", e );
output = e.getMessage() + "\n";
}
finally
{
//form.taskCount.decrementAndGet();
//if ( form.taskCount.get() == 0 )
//{
// form.indicator.setVisible( false );
//}
}
if (out.length() > 0)
{
LOG.info ("out is:\n" + out);
output = String.format ("%s [%d]:%n%s", containerHost.getHostname(), response.getPid(), out);
}
}
});
}
catch (CommandException e)
{
LOG.error ("Error in ExecuteCommandTask", e);
output = e.getMessage() + "\n";
}
/* }
});*/

LOG.info( "Output is:\n" + output );
return output;
}
LOG.info ("Output is:\n" + output);
return output;
}
}
Loading

0 comments on commit 0c299b1

Please sign in to comment.