use of com.microsoft.azure.management.samples.SSHShell in project azure-sdk-for-java by Azure.
the class CreateVirtualMachineUsingCustomImageFromVHD method deprovisionAgentInLinuxVM.
/**
* De-provision an Azure linux virtual machine.
*
* @param host the public host name
* @param port the ssh port
* @param userName the ssh user name
* @param password the ssh user password
*/
protected static void deprovisionAgentInLinuxVM(String host, int port, String userName, String password) {
SSHShell shell = null;
try {
System.out.println("Trying to de-provision: " + host);
shell = SSHShell.open(host, port, userName, password);
List<String> deprovisionCommand = new ArrayList<>();
deprovisionCommand.add("sudo waagent -deprovision+user --force");
String output = shell.runCommands(deprovisionCommand);
System.out.println(output);
} catch (JSchException jSchException) {
System.out.println(jSchException.getMessage());
} catch (IOException ioException) {
System.out.println(ioException.getMessage());
} catch (Exception exception) {
System.out.println(exception.getMessage());
} finally {
if (shell != null) {
shell.close();
}
}
}
use of com.microsoft.azure.management.samples.SSHShell in project azure-sdk-for-java by Azure.
the class CreateVirtualMachinesUsingCustomImageOrSpecializedVHD method deprovisionAgentInLinuxVM.
/**
* De-provision an Azure linux virtual machine.
*
* @param host the public host name
* @param port the ssh port
* @param userName the ssh user name
* @param password the ssh user password
*/
protected static void deprovisionAgentInLinuxVM(String host, int port, String userName, String password) {
SSHShell shell = null;
try {
System.out.println("Trying to de-provision: " + host);
shell = SSHShell.open(host, port, userName, password);
List<String> deprovisionCommand = new ArrayList<>();
deprovisionCommand.add("sudo waagent -deprovision+user --force");
String output = shell.runCommands(deprovisionCommand);
System.out.println(output);
} catch (JSchException jSchException) {
System.out.println(jSchException.getMessage());
} catch (IOException ioException) {
System.out.println(ioException.getMessage());
} catch (Exception exception) {
System.out.println(exception.getMessage());
} finally {
if (shell != null) {
shell.close();
}
}
}
use of com.microsoft.azure.management.samples.SSHShell in project azure-sdk-for-java by Azure.
the class CreateVirtualMachineUsingCustomImageFromVM method deprovisionAgentInLinuxVM.
/**
* De-provision an Azure linux virtual machine.
*
* @param host the public host name
* @param port the ssh port
* @param userName the ssh user name
* @param password the ssh user password
*/
protected static void deprovisionAgentInLinuxVM(String host, int port, String userName, String password) {
SSHShell shell = null;
try {
System.out.println("Trying to de-provision: " + host);
shell = SSHShell.open(host, port, userName, password);
List<String> deprovisionCommand = new ArrayList<>();
deprovisionCommand.add("sudo waagent -deprovision+user --force");
String output = shell.runCommands(deprovisionCommand);
System.out.println(output);
} catch (JSchException jSchException) {
System.out.println(jSchException.getMessage());
} catch (IOException ioException) {
System.out.println(ioException.getMessage());
} catch (Exception exception) {
System.out.println(exception.getMessage());
} finally {
if (shell != null) {
shell.close();
}
}
}
use of com.microsoft.azure.management.samples.SSHShell in project azure-sdk-for-java by Azure.
the class ManageManagedDisks method deprovisionAgentInLinuxVM.
private static void deprovisionAgentInLinuxVM(String host, int port, String userName, String password) {
SSHShell shell = null;
try {
System.out.println("Trying to de-provision: " + host);
shell = SSHShell.open(host, port, userName, password);
List<String> deprovisionCommand = new ArrayList<>();
deprovisionCommand.add("sudo waagent -deprovision+user --force");
String output = shell.runCommands(deprovisionCommand);
System.out.println(output);
} catch (JSchException jSchException) {
System.out.println(jSchException.getMessage());
} catch (IOException ioException) {
System.out.println(ioException.getMessage());
} catch (Exception exception) {
System.out.println(exception.getMessage());
} finally {
if (shell != null) {
shell.close();
}
}
}
Aggregations