preparations to have random password for containers
This commit is contained in:
parent
2eab309cb2
commit
3e2ebac614
@ -171,7 +171,7 @@ public class DockerService {
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
/// First, we create our container and basic functions
|
/// First, we create our container and basic functions
|
||||||
public String createContainer(String name, int port) {
|
public String createContainer(String name, int port, String username, String password) {
|
||||||
ExposedPort tcpSsh = ExposedPort.tcp(2222);
|
ExposedPort tcpSsh = ExposedPort.tcp(2222);
|
||||||
|
|
||||||
Ports portBindings = new Ports();
|
Ports portBindings = new Ports();
|
||||||
@ -199,8 +199,8 @@ public class DockerService {
|
|||||||
.withExposedPorts(tcpSsh)
|
.withExposedPorts(tcpSsh)
|
||||||
.withHostConfig(hostConfig)
|
.withHostConfig(hostConfig)
|
||||||
.withEnv("SUDO_ACCESS=false", "PASSWORD_ACCESS=true",
|
.withEnv("SUDO_ACCESS=false", "PASSWORD_ACCESS=true",
|
||||||
"USER_NAME=test", // TODO : User login
|
"USER_NAME="+username, // TODO : User login
|
||||||
"USER_PASSWORD=test" // TODO : Random passwd
|
"USER_PASSWORD="+password // TODO : Random passwd
|
||||||
)
|
)
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
|
|||||||
@ -62,15 +62,15 @@ public class InstanceService {
|
|||||||
public void createContainer(Long instanceId) {
|
public void createContainer(Long instanceId) {
|
||||||
Instance instance = instanceRepository.findById(instanceId);
|
Instance instance = instanceRepository.findById(instanceId);
|
||||||
if (instance.containerId.equals("Not created"))
|
if (instance.containerId.equals("Not created"))
|
||||||
instance.containerId =
|
instance.containerId = dockerService.createContainer(
|
||||||
dockerService.createContainer(instance.name, instance.port);
|
instance.name, instance.port, "test", "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
public InspectContainerResponse.ContainerState getStatusContainer(Long id) {
|
public InspectContainerResponse.ContainerState getStatusContainer(Long id) {
|
||||||
Instance instance = instanceRepository.findById(id);
|
Instance instance = instanceRepository.findById(id);
|
||||||
return dockerService.getStatusContainer(instance.name);
|
return dockerService.getStatusContainer(instance.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/// Finally, start/stop the containers
|
/// Finally, start/stop the containers
|
||||||
@ -84,7 +84,7 @@ public class InstanceService {
|
|||||||
Instance instance = instanceRepository.findById(instanceId);
|
Instance instance = instanceRepository.findById(instanceId);
|
||||||
dockerService.stop(instance.containerId);
|
dockerService.stop(instance.containerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/// Last but not least, be able do delete every container and instance
|
/// Last but not least, be able do delete every container and instance
|
||||||
@ -95,7 +95,6 @@ public class InstanceService {
|
|||||||
return dockerService.remove(instance.name);
|
return dockerService.remove(instance.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteInstance(Long id) {
|
public void deleteInstance(Long id) {
|
||||||
Instance instance = instanceRepository.findById(id);
|
Instance instance = instanceRepository.findById(id);
|
||||||
@ -105,7 +104,7 @@ public class InstanceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///UTILS FOR PORTS NUMBERS HANDLING
|
/// UTILS FOR PORTS NUMBERS HANDLING
|
||||||
public Set<Integer> getUsedPorts() {
|
public Set<Integer> getUsedPorts() {
|
||||||
Set<Integer> retour = new HashSet<>();
|
Set<Integer> retour = new HashSet<>();
|
||||||
List<Instance> allInstances = getAllInstances();
|
List<Instance> allInstances = getAllInstances();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user