Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.containerinstance;

import com.microsoft.azure.management.apigeneration.Beta;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.containerinstance.implementation.ContainerExecResponseInner;
import com.microsoft.azure.management.resources.fluentcore.model.HasInner;

/**
* Response containing the container exec command.
*/
@Fluent
@Beta(Beta.SinceVersion.V1_11_0)
public interface ContainerExecResponse extends HasInner<ContainerExecResponseInner> {
/**
* Get the webSocketUri value.
*
* @return the webSocketUri value
*/
String webSocketUri();

/**
* Get the password value.
*
* @return the password value
*/
String password();
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,35 @@ public interface ContainerGroup extends
*/
Observable<String> getLogContentAsync(String containerName, int tailLineCount);

/**
* Starts the exec command for a specific container instance.
*
* @param containerName the container instance name
* @param command the command to be executed
* @param row the row size of the terminal
* @param column the column size of the terminal
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the log lines from the end, up to the number specified
*/
@Beta(Beta.SinceVersion.V1_11_0)
ContainerExecResponse executeCommand(String containerName, String command, int row, int column);

/**
* Starts the exec command for a specific container instance within the container group.
*
* @param containerName the container instance name
* @param command the command to be executed
* @param row the row size of the terminal
* @param column the column size of the terminal
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return a representation of the future computation of this call
*/
@Beta(Beta.SinceVersion.V1_11_0)
Observable<ContainerExecResponse> executeCommandAsync(String containerName, String command, int row, int column);


/**
* The entirety of the Azure Container Instance service container group definition.
* Starts the exec command for a specific container instance within the current group asynchronously.
*/
interface Definition extends
DefinitionStages.Blank,
Expand Down Expand Up @@ -720,18 +746,20 @@ interface WithStartingCommandLine<ParentT> {
/**
* Specifies the starting command lines.
*
* @param commandLines the starting command lines the container will execute after it gets initialized
* @param executable the executable which it will call after initializing the container
* @param parameters the parameter list for the executable to be called
* @return the next stage of the definition
*/
WithContainerInstanceAttach<ParentT> withStartingCommandLines(String... commandLines);
@Beta(Beta.SinceVersion.V1_11_0)
WithContainerInstanceAttach<ParentT> withStartingCommandLine(String executable, String... parameters);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to change the other one parameter name from "commandLine" to "executable" or "pathToExecutable"? command line might be confusing.

withStartingCommandLine(String commandLine);
=>
withStartingCommandLine(String executable);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangl900 Can the user pass the whole command, executable and arguments to it, as one string value? Or is the ACI service always expecting the first string to be an executable or path-to-executable?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACI always expect the first string to be a path to the executable. It's basically start a process in your container. You can start shell (/bin/bash), or other executable, like node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change; thanks for the confirmation, the documentation as it comes via the Swagger spec was not very clear about that :-)


/**
* Specifies the starting command line.
*
* @param commandLine the starting command line the container will execute after it gets initialized
* @param executable the executable or path to the executable that will be called after initializing the container
* @return the next stage of the definition
*/
WithContainerInstanceAttach<ParentT> withStartingCommandLine(String commandLine);
WithContainerInstanceAttach<ParentT> withStartingCommandLine(String executable);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.containerinstance.implementation;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.containerinstance.ContainerExecResponse;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.WrapperImpl;

/**
* Implementation for RegistryCredentials.
*/
@LangDefinition
public class ContainerExecResponseImpl extends WrapperImpl<ContainerExecResponseInner>
implements ContainerExecResponse {
protected ContainerExecResponseImpl(ContainerExecResponseInner innerObject) {
super(innerObject);
}

@Override
public String webSocketUri() {
return this.inner().webSocketUri();
}

@Override
public String password() {
return this.inner().password();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.microsoft.azure.Resource;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.containerinstance.Container;
import com.microsoft.azure.management.containerinstance.ContainerExecRequestTerminalSize;
import com.microsoft.azure.management.containerinstance.ContainerExecResponse;
import com.microsoft.azure.management.containerinstance.ContainerGroup;
import com.microsoft.azure.management.containerinstance.ContainerGroupNetworkProtocol;
import com.microsoft.azure.management.containerinstance.ContainerGroupRestartPolicy;
Expand Down Expand Up @@ -488,4 +490,32 @@ public Observable<String> getLogContentAsync(String containerName) {
public Observable<String> getLogContentAsync(String containerName, int tailLineCount) {
return this.manager().containerGroups().getLogContentAsync(this.resourceGroupName(), this.name(), containerName, tailLineCount);
}

@Override
public ContainerExecResponse executeCommand(String containerName, String command, int row, int column) {
return new ContainerExecResponseImpl(this.manager().inner().startContainers()
.launchExec(this.resourceGroupName(), this.name(), containerName,
new ContainerExecRequestInner()
.withCommand(command)
.withTerminalSize(new ContainerExecRequestTerminalSize()
.withRow(row)
.withColumn(column))));
}

@Override
public Observable<ContainerExecResponse> executeCommandAsync(String containerName, String command, int row, int column) {
return this.manager().inner().startContainers()
.launchExecAsync(this.resourceGroupName(), this.name(), containerName,
new ContainerExecRequestInner()
.withCommand(command)
.withTerminalSize(new ContainerExecRequestTerminalSize()
.withRow(row)
.withColumn(column)))
.map(new Func1<ContainerExecResponseInner, ContainerExecResponse>() {
@Override
public ContainerExecResponse call(ContainerExecResponseInner containerExecResponseInner) {
return new ContainerExecResponseImpl(containerExecResponseInner);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ public ContainerImpl withMemorySizeInGB(double memorySize) {
}

@Override
public ContainerImpl withStartingCommandLines(String... commandLines) {
for (String command : commandLines) {
this.withStartingCommandLine(command);
public ContainerImpl withStartingCommandLine(String executable, String... parameters) {
this.withStartingCommandLine(executable);
if (parameters != null) {
for (String parameter : parameters) {
this.withStartingCommandLine(parameter);
}
}

return this;
Expand Down