diff --git a/management/server/core/environment-manager/environment-manager-api/src/main/java/io/subutai/core/environment/api/EnvironmentManager.java b/management/server/core/environment-manager/environment-manager-api/src/main/java/io/subutai/core/environment/api/EnvironmentManager.java index 3f46317cc1b..19c9a020f79 100644 --- a/management/server/core/environment-manager/environment-manager-api/src/main/java/io/subutai/core/environment/api/EnvironmentManager.java +++ b/management/server/core/environment-manager/environment-manager-api/src/main/java/io/subutai/core/environment/api/EnvironmentManager.java @@ -287,16 +287,6 @@ void placeEnvironmentInfoByContainerId( String environmentId, String containerIp Environment getEnvironment( String environmentId ); - /** - * Places JWT token to container - * - * @param environmentId environment ID - * @param containerIp container IP - * @param token JWT token - */ - void placeTokenToContainer( String environmentId, String containerIp, String token ) - throws EnvironmentNotFoundException, ContainerHostNotFoundException, CommandException; - /** * Creates template on Hub ( Global Kurjun ) out of a specified environment container * diff --git a/management/server/core/environment-manager/environment-manager-impl/src/main/java/io/subutai/core/environment/impl/EnvironmentManagerImpl.java b/management/server/core/environment-manager/environment-manager-impl/src/main/java/io/subutai/core/environment/impl/EnvironmentManagerImpl.java index dc3b36be21f..013d3cf4555 100644 --- a/management/server/core/environment-manager/environment-manager-impl/src/main/java/io/subutai/core/environment/impl/EnvironmentManagerImpl.java +++ b/management/server/core/environment-manager/environment-manager-impl/src/main/java/io/subutai/core/environment/impl/EnvironmentManagerImpl.java @@ -2763,25 +2763,6 @@ public Environment getEnvironment( String environmentId ) } - @Override - public void placeTokenToContainer( String environmentId, String containerIp, String token ) - throws EnvironmentNotFoundException, ContainerHostNotFoundException, CommandException - { - final LocalEnvironment environment = environmentService.find( environmentId ); - - if ( environment == null ) - { - throw new EnvironmentNotFoundException(); - } - - EnvironmentContainerImpl containerHost = - ( EnvironmentContainerImpl ) environment.getContainerHostByIp( containerIp ); - setTransientFields( Sets.newHashSet( environment ) ); - - placeTokenIntoContainer( containerHost, token ); - } - - //called by remote peer @Override public void placeEnvironmentInfoByContainerId( final String environmentId, final String containerId ) @@ -2827,22 +2808,6 @@ private void placeInfoIntoContainer( EnvironmentDto environmentDto, ContainerHos } - private void placeTokenIntoContainer( ContainerHost containerHost, String token ) throws CommandException - { - if ( containerHost instanceof EnvironmentContainerImpl ) - { - // workaround to disable security checks for this call - ( ( EnvironmentContainerImpl ) containerHost ).executeUnsafe( new RequestBuilder( - String.format( "mkdir -p /etc/subutai/ ; echo '%s' > /etc/subutai/jwttoken", token ) ) ); - } - else - { - containerHost.execute( new RequestBuilder( - String.format( "mkdir -p /etc/subutai/ ; echo '%s' > /etc/subutai/jwttoken", token ) ) ); - } - } - - public void cleanupEnvironment( EnvironmentId environmentId ) { try diff --git a/management/server/core/environment-metadata-manager/environment-metadata-manager-impl/src/main/java/io/subutai/core/environment/metadata/impl/EnvironmentMetadataManagerImpl.java b/management/server/core/environment-metadata-manager/environment-metadata-manager-impl/src/main/java/io/subutai/core/environment/metadata/impl/EnvironmentMetadataManagerImpl.java index d5306437268..f5adc129eaa 100644 --- a/management/server/core/environment-metadata-manager/environment-metadata-manager-impl/src/main/java/io/subutai/core/environment/metadata/impl/EnvironmentMetadataManagerImpl.java +++ b/management/server/core/environment-metadata-manager/environment-metadata-manager-impl/src/main/java/io/subutai/core/environment/metadata/impl/EnvironmentMetadataManagerImpl.java @@ -7,8 +7,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.subutai.common.command.CommandException; +import io.subutai.common.command.RequestBuilder; import io.subutai.common.environment.Environment; -import io.subutai.common.environment.EnvironmentNotFoundException; import io.subutai.common.peer.ContainerHost; import io.subutai.common.peer.HostNotFoundException; import io.subutai.core.environment.api.EnvironmentManager; @@ -64,9 +64,11 @@ public void issueToken( String containerIp ) throws TokenCreateException String peerId = container.getPeerId(); String origin = String.format( "%s.%s.%s", peerId, containerId, environmentId ); final String token = identityManager.issueJWTToken( origin ); - environmentManager.placeTokenToContainer( environmentId, containerIp, token ); + // environmentManager.placeTokenToContainer( environmentId, containerIp, token ); + + placeTokenIntoContainer( container, token ); } - catch ( HostNotFoundException | EnvironmentNotFoundException | CommandException e ) + catch ( HostNotFoundException | CommandException e ) { throw new TokenCreateException( e.getMessage() ); } @@ -99,5 +101,12 @@ public void pushEvent( final Event event ) } // TODO: send event to consumers } + + + private void placeTokenIntoContainer( ContainerHost containerHost, String token ) throws CommandException + { + containerHost.executeAsync( new RequestBuilder( + String.format( "mkdir -p /etc/subutai/ ; echo '%s' > /etc/subutai/jwttoken", token ) ) ); + } }