This is an automated email from the ASF dual-hosted git repository.

ofuks pushed a commit to branch DLAB-1467
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-1467 by this push:
     new 3d65876  Added azure auth file config
3d65876 is described below

commit 3d65876544da38ef007b1a112119d268b46dd741
Author: Oleh Fuks <[email protected]>
AuthorDate: Wed Feb 5 16:16:47 2020 +0200

    Added azure auth file config
---
 .../epam/dlab/backendapi/CloudConfiguration.java   |  1 +
 .../backendapi/core/commands/RunDockerCommand.java |  5 +++
 .../resources/GitExploratoryResource.java          |  7 ++++
 .../dlab/backendapi/resources/ImageResource.java   | 11 +++++-
 .../dlab/backendapi/resources/LibraryResource.java | 11 +++++-
 .../backendapi/resources/base/EdgeService.java     |  8 ++++
 .../resources/base/ExploratoryService.java         |  8 ++++
 .../resources/base/InfrastructureService.java      | 43 ++++++++++++----------
 .../service/impl/CheckInactivityServiceImpl.java   | 23 ++++++++++--
 .../service/impl/ProjectServiceImpl.java           | 13 ++++++-
 .../service/impl/SparkClusterService.java          | 27 +++++++++++---
 11 files changed, 126 insertions(+), 31 deletions(-)

diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/CloudConfiguration.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/CloudConfiguration.java
index 94ed162..9d61210 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/CloudConfiguration.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/CloudConfiguration.java
@@ -42,6 +42,7 @@ public class CloudConfiguration {
        private final String ssnStorageAccountTagName;
        private final String sharedStorageAccountTagName;
        private final String datalakeTagName;
+       private final String azureAuthFile;
        private final String azureClientId;
        private final String peeringId;
        private final String gcpProjectId;
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/core/commands/RunDockerCommand.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/core/commands/RunDockerCommand.java
index 9cab93a..4c466dc 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/core/commands/RunDockerCommand.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/core/commands/RunDockerCommand.java
@@ -33,6 +33,7 @@ public class RunDockerCommand implements CmdCommand {
     private static final String ROOT_KEYS_PATH = "/root/keys";
     private static final String RESPONSE_PATH = "/response";
     private static final String LOG_PATH = "/logs";
+    private static final String AZURE_AUTH_FILE = "/root/azure_auth.json";
 
     public RunDockerCommand withVolume(String hostSrcPath, String bindPath) {
         options.add(String.format("-v %s:%s", hostSrcPath, bindPath));
@@ -47,6 +48,10 @@ public class RunDockerCommand implements CmdCommand {
         return withVolume(hostSrcPath, RESPONSE_PATH);
     }
 
+    public RunDockerCommand withVolumeFoAzureAuthFile(String hostSrcPath) {
+        return withVolume(hostSrcPath, AZURE_AUTH_FILE);
+    }
+
     public RunDockerCommand withVolumeForLog(String hostSrcPath, String 
logDirectory) {
         return withVolume(Paths.get(hostSrcPath, logDirectory).toString(),
                 Paths.get(LOG_PATH, logDirectory).toString());
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/GitExploratoryResource.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/GitExploratoryResource.java
index 80a3d5b..e6f6476 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/GitExploratoryResource.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/GitExploratoryResource.java
@@ -27,6 +27,7 @@ import com.epam.dlab.backendapi.core.commands.DockerCommands;
 import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.ExploratoryGitCredsCallbackHandler;
 import com.epam.dlab.backendapi.service.impl.DockerService;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.exploratory.ExploratoryBaseDTO;
 import com.epam.dlab.dto.exploratory.ExploratoryGitCredsUpdateDTO;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -38,6 +39,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import java.util.Objects;
 
 @Path("/exploratory")
 @Consumes(MediaType.APPLICATION_JSON)
@@ -69,6 +71,11 @@ public class GitExploratoryResource extends DockerService 
implements DockerComma
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(dto.getNotebookImage())
                                .withAction(action);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
 
                commandExecutor.executeAsync(username, uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
                return uuid;
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ImageResource.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ImageResource.java
index b57f5b2..2d6d9e3 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ImageResource.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ImageResource.java
@@ -26,6 +26,7 @@ import com.epam.dlab.backendapi.core.commands.DockerCommands;
 import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.ImageCreateCallbackHandler;
 import com.epam.dlab.backendapi.service.impl.DockerService;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.exploratory.ExploratoryImageDTO;
 import com.epam.dlab.rest.contracts.ExploratoryAPI;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -38,6 +39,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import java.util.Objects;
 
 @Path(ExploratoryAPI.EXPLORATORY_IMAGE)
 @Consumes(MediaType.APPLICATION_JSON)
@@ -64,7 +66,7 @@ public class ImageResource extends DockerService implements 
DockerCommands {
        }
 
        private RunDockerCommand getDockerCommand(DockerAction action, String 
uuid, ExploratoryImageDTO image) {
-               return new RunDockerCommand()
+               RunDockerCommand runDockerCommand = new RunDockerCommand()
                                .withInteractive()
                                
.withVolumeForRootKeys(configuration.getKeyDirectory())
                                
.withVolumeForResponse(configuration.getImagesDirectory())
@@ -75,5 +77,12 @@ public class ImageResource extends DockerService implements 
DockerCommands {
                                .withResource(getResourceType())
                                .withImage(image.getNotebookImage())
                                
.withName(nameContainer(image.getEdgeUserName(), action.toString(), 
image.getImageName()));
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
+
+               return runDockerCommand;
        }
 }
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/LibraryResource.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/LibraryResource.java
index 0e07d69..a6ae018 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/LibraryResource.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/LibraryResource.java
@@ -28,6 +28,7 @@ import 
com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.LibInstallCallbackHandler;
 import com.epam.dlab.backendapi.core.response.handlers.LibListCallbackHandler;
 import com.epam.dlab.backendapi.service.impl.DockerService;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.LibListComputationalDTO;
 import com.epam.dlab.dto.base.DataEngineType;
 import com.epam.dlab.dto.exploratory.ExploratoryActionDTO;
@@ -44,6 +45,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import java.util.Objects;
 
 @Path("/library")
 @Consumes(MediaType.APPLICATION_JSON)
@@ -139,13 +141,20 @@ public class LibraryResource extends DockerService 
implements DockerCommands {
        }
 
        private RunDockerCommand getDockerCommand(DockerAction action, String 
uuid) {
-               return new RunDockerCommand()
+               RunDockerCommand runDockerCommand = new RunDockerCommand()
                                .withInteractive()
                                
.withVolumeForRootKeys(configuration.getKeyDirectory())
                                
.withVolumeForResponse(configuration.getImagesDirectory())
                                .withRequestId(uuid)
                                .withConfKeyName(configuration.getAdminKey())
                                .withAction(action);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
+
+               return runDockerCommand;
        }
 
        private FileHandlerCallback 
getFileHandlerCallbackExploratory(DockerAction action, String uuid,
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/EdgeService.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/EdgeService.java
index a5ed3dc..92cb6e8 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/EdgeService.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/EdgeService.java
@@ -24,6 +24,7 @@ import com.epam.dlab.backendapi.core.Directories;
 import com.epam.dlab.backendapi.core.FileHandlerCallback;
 import com.epam.dlab.backendapi.core.commands.*;
 import 
com.epam.dlab.backendapi.core.response.folderlistener.FolderListenerExecutor;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.ResourceSysBaseDTO;
 import com.epam.dlab.rest.client.RESTService;
 import com.epam.dlab.rest.contracts.KeyAPI;
@@ -33,6 +34,8 @@ import com.google.inject.Inject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Objects;
+
 public abstract class EdgeService implements DockerCommands {
 
        private final Logger logger = LoggerFactory.getLogger(getClass());
@@ -73,6 +76,11 @@ public abstract class EdgeService implements DockerCommands {
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(configuration.getEdgeImage())
                                .withAction(action);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
 
                commandExecutor.executeAsync(username, uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
                return uuid;
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/ExploratoryService.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/ExploratoryService.java
index c25f484..e4d9ecf 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/ExploratoryService.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/ExploratoryService.java
@@ -26,10 +26,13 @@ import 
com.epam.dlab.backendapi.core.commands.DockerCommands;
 import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.ExploratoryCallbackHandler;
 import com.epam.dlab.backendapi.service.impl.DockerService;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.exploratory.ExploratoryBaseDTO;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import lombok.extern.slf4j.Slf4j;
 
+import java.util.Objects;
+
 @Slf4j
 public class ExploratoryService extends DockerService implements 
DockerCommands {
 
@@ -51,6 +54,11 @@ public class ExploratoryService extends DockerService 
implements DockerCommands
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(dto.getNotebookImage())
                                .withAction(action);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
 
                commandExecutor.executeAsync(username, uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
                return uuid;
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/InfrastructureService.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/InfrastructureService.java
index 9406afd..699096a 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/InfrastructureService.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/InfrastructureService.java
@@ -23,9 +23,14 @@ package com.epam.dlab.backendapi.resources.base;
 import com.epam.dlab.backendapi.ProvisioningServiceApplicationConfiguration;
 import com.epam.dlab.backendapi.core.Directories;
 import com.epam.dlab.backendapi.core.FileHandlerCallback;
-import com.epam.dlab.backendapi.core.commands.*;
+import com.epam.dlab.backendapi.core.commands.CommandBuilder;
+import com.epam.dlab.backendapi.core.commands.DockerAction;
+import com.epam.dlab.backendapi.core.commands.DockerCommands;
+import com.epam.dlab.backendapi.core.commands.ICommandExecutor;
+import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.folderlistener.FolderListenerExecutor;
 import 
com.epam.dlab.backendapi.core.response.handlers.ResourcesStatusCallbackHandler;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.UserEnvironmentResources;
 import com.epam.dlab.dto.status.EnvResource;
 import com.epam.dlab.exceptions.DlabException;
@@ -37,6 +42,7 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 import static com.epam.dlab.backendapi.core.commands.DockerAction.STATUS;
@@ -69,24 +75,23 @@ public abstract class InfrastructureService implements 
DockerCommands {
 
                        if (!(dto.getResourceList().getHostList().isEmpty() && 
dto.getResourceList().getClusterList().isEmpty())) {
                                log.trace("Request the status of resources for 
user {} after filtering: {}", username, dto);
-                               commandExecutor.executeAsync(
-                                               username,
-                                               uuid,
-                                               commandBuilder.buildCommand(
-                                                               new 
RunDockerCommand()
-                                                                               
.withInteractive()
-                                                                               
.withName(nameContainer(dto.getEdgeUserName(), STATUS, "resources"))
-                                                                               
.withVolumeForRootKeys(configuration.getKeyDirectory())
-                                                                               
.withVolumeForResponse(configuration.getImagesDirectory())
-                                                                               
.withVolumeForLog(configuration.getDockerLogDirectory(), Directories
-                                                                               
                .EDGE_LOG_DIRECTORY)
-                                                                               
.withResource(getResourceType())
-                                                                               
.withRequestId(uuid)
-                                                                               
.withConfKeyName(configuration.getAdminKey())
-                                                                               
.withActionStatus(configuration.getEdgeImage()),
-                                                               dto
-                                               )
-                               );
+                               RunDockerCommand runDockerCommand = new 
RunDockerCommand()
+                                               .withInteractive()
+                                               
.withName(nameContainer(dto.getEdgeUserName(), STATUS, "resources"))
+                                               
.withVolumeForRootKeys(configuration.getKeyDirectory())
+                                               
.withVolumeForResponse(configuration.getImagesDirectory())
+                                               
.withVolumeForLog(configuration.getDockerLogDirectory(), 
Directories.EDGE_LOG_DIRECTORY)
+                                               .withResource(getResourceType())
+                                               .withRequestId(uuid)
+                                               
.withConfKeyName(configuration.getAdminKey())
+                                               
.withActionStatus(configuration.getEdgeImage());
+                               if (configuration.getCloudProvider() == 
CloudProvider.AZURE &&
+                                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+                               }
+
+                               commandExecutor.executeAsync(username, uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
                        } else {
                                log.debug("Skipping calling status command. 
Resource lists are empty");
                        }
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/CheckInactivityServiceImpl.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/CheckInactivityServiceImpl.java
index 7f7eafe..3713589 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/CheckInactivityServiceImpl.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/CheckInactivityServiceImpl.java
@@ -24,6 +24,7 @@ import com.epam.dlab.backendapi.core.commands.DockerCommands;
 import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.CheckInactivityCallbackHandler;
 import com.epam.dlab.backendapi.service.CheckInactivityService;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.ResourceBaseDTO;
 import com.epam.dlab.dto.base.DataEngineType;
 import com.epam.dlab.dto.computational.ComputationalCheckInactivityDTO;
@@ -32,6 +33,8 @@ import com.epam.dlab.rest.contracts.ApiCallbacks;
 import com.google.inject.Singleton;
 import lombok.extern.slf4j.Slf4j;
 
+import java.util.Objects;
+
 @Slf4j
 @Singleton
 public class CheckInactivityServiceImpl extends DockerService implements 
CheckInactivityService, DockerCommands {
@@ -41,7 +44,7 @@ public class CheckInactivityServiceImpl extends DockerService 
implements CheckIn
        public String checkComputationalInactivity(String userName, 
ComputationalCheckInactivityDTO dto) {
                String uuid = DockerCommands.generateUUID();
                startComputationalCallbackListener(userName, dto, uuid);
-               final RunDockerCommand dockerCommand = new RunDockerCommand()
+               final RunDockerCommand runDockerCommand = new RunDockerCommand()
                                .withInteractive()
                                .withRemove()
                                .withName(nameContainer(uuid, 
DockerAction.CHECK_INACTIVITY.toString()))
@@ -55,7 +58,13 @@ public class CheckInactivityServiceImpl extends 
DockerService implements CheckIn
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(dto.getNotebookImage())
                                .withAction(DockerAction.CHECK_INACTIVITY);
-               runDockerCmd(userName, uuid, dockerCommand, dto);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
+
+               runDockerCmd(userName, uuid, runDockerCommand, dto);
                return uuid;
        }
 
@@ -63,7 +72,7 @@ public class CheckInactivityServiceImpl extends DockerService 
implements CheckIn
        public String checkExploratoryInactivity(String userName, 
ExploratoryCheckInactivityAction dto) {
                String uuid = DockerCommands.generateUUID();
                startExploratoryCallbackListener(userName, dto, uuid);
-               final RunDockerCommand dockerCommand = new RunDockerCommand()
+               final RunDockerCommand runDockerCommand = new RunDockerCommand()
                                .withInteractive()
                                .withRemove()
                                .withName(nameContainer(uuid, 
DockerAction.CHECK_INACTIVITY.toString()))
@@ -75,7 +84,13 @@ public class CheckInactivityServiceImpl extends 
DockerService implements CheckIn
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(dto.getNotebookImage())
                                .withAction(DockerAction.CHECK_INACTIVITY);
-               runDockerCmd(userName, uuid, dockerCommand, dto);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
+
+               runDockerCmd(userName, uuid, runDockerCommand, dto);
                return uuid;
        }
 
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/ProjectServiceImpl.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/ProjectServiceImpl.java
index 47c4dee..1daf93f 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/ProjectServiceImpl.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/ProjectServiceImpl.java
@@ -2,7 +2,11 @@ package com.epam.dlab.backendapi.service.impl;
 
 import com.epam.dlab.auth.UserInfo;
 import com.epam.dlab.backendapi.ProvisioningServiceApplicationConfiguration;
-import com.epam.dlab.backendapi.core.commands.*;
+import com.epam.dlab.backendapi.core.commands.CommandBuilder;
+import com.epam.dlab.backendapi.core.commands.DockerAction;
+import com.epam.dlab.backendapi.core.commands.DockerCommands;
+import com.epam.dlab.backendapi.core.commands.ICommandExecutor;
+import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.folderlistener.FolderListenerExecutor;
 import com.epam.dlab.backendapi.core.response.handlers.ProjectCallbackHandler;
 import com.epam.dlab.backendapi.service.ProjectService;
@@ -18,6 +22,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.inject.Inject;
 import lombok.extern.slf4j.Slf4j;
 
+import java.util.Objects;
+
 @Slf4j
 public class ProjectServiceImpl implements ProjectService {
        private static final String PROJECT_IMAGE = "docker.dlab-project";
@@ -77,6 +83,11 @@ public class ProjectServiceImpl implements ProjectService {
                                .withConfKeyName(configuration.getAdminKey())
                                .withImage(image)
                                .withAction(action);
+               if (configuration.getCloudProvider() == CloudProvider.AZURE &&
+                               
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                               
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                       
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+               }
 
                try {
                        commandExecutor.executeAsync(userInfo.getName(), uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
diff --git 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/SparkClusterService.java
 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/SparkClusterService.java
index a773b70..ce73096 100644
--- 
a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/SparkClusterService.java
+++ 
b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/service/impl/SparkClusterService.java
@@ -27,6 +27,7 @@ import com.epam.dlab.backendapi.core.commands.DockerCommands;
 import com.epam.dlab.backendapi.core.commands.RunDockerCommand;
 import 
com.epam.dlab.backendapi.core.response.handlers.ComputationalCallbackHandler;
 import com.epam.dlab.backendapi.core.response.handlers.ComputationalConfigure;
+import com.epam.dlab.cloud.CloudProvider;
 import com.epam.dlab.dto.base.DataEngineType;
 import com.epam.dlab.dto.base.computational.ComputationalBase;
 import com.epam.dlab.dto.computational.ComputationalClusterConfigDTO;
@@ -38,7 +39,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
-import static com.epam.dlab.backendapi.core.commands.DockerAction.*;
+import java.util.Objects;
+
+import static com.epam.dlab.backendapi.core.commands.DockerAction.CREATE;
+import static 
com.epam.dlab.backendapi.core.commands.DockerAction.RECONFIGURE_SPARK;
+import static com.epam.dlab.backendapi.core.commands.DockerAction.START;
+import static com.epam.dlab.backendapi.core.commands.DockerAction.STOP;
+import static com.epam.dlab.backendapi.core.commands.DockerAction.TERMINATE;
 
 @Singleton
 public class SparkClusterService extends DockerService implements 
DockerCommands {
@@ -76,7 +83,7 @@ public class SparkClusterService extends DockerService 
implements DockerCommands
        private void runReconfigureSparkDockerCommand(UserInfo ui, 
ComputationalClusterConfigDTO clusterConfigDTO,
                                                                                
                  String uuid) {
                try {
-                       final RunDockerCommand dockerCommand = new 
RunDockerCommand()
+                       final RunDockerCommand runDockerCommand = new 
RunDockerCommand()
                                        .withInteractive()
                                        
.withName(nameContainer(clusterConfigDTO.getEdgeUserName(), RECONFIGURE_SPARK,
                                                        
clusterConfigDTO.getExploratoryName(),
@@ -89,8 +96,13 @@ public class SparkClusterService extends DockerService 
implements DockerCommands
                                        
.withConfKeyName(configuration.getAdminKey())
                                        
.withImage(DataEngineType.getDockerImageName(SPARK_ENGINE))
                                        .withAction(RECONFIGURE_SPARK);
+                       if (configuration.getCloudProvider() == 
CloudProvider.AZURE &&
+                                       
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                                       
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                               
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+                       }
 
-                       commandExecutor.executeAsync(ui.getName(), uuid, 
commandBuilder.buildCommand(dockerCommand,
+                       commandExecutor.executeAsync(ui.getName(), uuid, 
commandBuilder.buildCommand(runDockerCommand,
                                        clusterConfigDTO));
                } catch (JsonProcessingException e) {
                        throw new DlabException("Could not" + 
RECONFIGURE_SPARK.toString() + "computational resources cluster", e);
@@ -103,7 +115,7 @@ public class SparkClusterService extends DockerService 
implements DockerCommands
                                configuration.getResourceStatusPollTimeout(),
                                getFileHandlerCallback(action, uuid, dto));
                try {
-                       final RunDockerCommand dockerCommand = new 
RunDockerCommand()
+                       final RunDockerCommand runDockerCommand = new 
RunDockerCommand()
                                        .withInteractive()
                                        
.withName(nameContainer(dto.getEdgeUserName(), action, dto.getExploratoryName(),
                                                        
dto.getComputationalName()))
@@ -115,8 +127,13 @@ public class SparkClusterService extends DockerService 
implements DockerCommands
                                        
.withConfKeyName(configuration.getAdminKey())
                                        
.withImage(DataEngineType.getDockerImageName(SPARK_ENGINE))
                                        .withAction(action);
+                       if (configuration.getCloudProvider() == 
CloudProvider.AZURE &&
+                                       
Objects.nonNull(configuration.getCloudConfiguration().getAzureAuthFile()) &&
+                                       
!configuration.getCloudConfiguration().getAzureAuthFile().isEmpty()) {
+                               
runDockerCommand.withVolumeFoAzureAuthFile(configuration.getCloudConfiguration().getAzureAuthFile());
+                       }
 
-                       commandExecutor.executeAsync(ui.getName(), uuid, 
commandBuilder.buildCommand(dockerCommand, dto));
+                       commandExecutor.executeAsync(ui.getName(), uuid, 
commandBuilder.buildCommand(runDockerCommand, dto));
                } catch (JsonProcessingException e) {
                        throw new DlabException("Could not" + action.toString() 
+ "computational resources cluster", e);
                }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to