Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds WinRmTool interface #1045

Merged
merged 2 commits into from
Nov 24, 2015
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
Expand Up @@ -177,6 +177,10 @@ public class BrooklynConfigKeys {
* and have this prefix pre-prended to the config keys in this class. */
public static final String BROOKLYN_SSH_CONFIG_KEY_PREFIX = "brooklyn.ssh.config.";

/** Public-facing global config keys for Brooklyn are defined in ConfigKeys,
* and have this prefix pre-prended to the config keys in this class. */
public static final String BROOKLYN_WINRM_CONFIG_KEY_PREFIX = "brooklyn.winrm.config.";

// some checks (this line, and a few Preconditions below) that the remote values aren't null,
// because they have some funny circular references
static { assert BROOKLYN_SSH_CONFIG_KEY_PREFIX.equals(SshTool.BROOKLYN_CONFIG_KEY_PREFIX) : "static final initializer classload ordering problem"; }
Expand All @@ -186,6 +190,11 @@ public class BrooklynConfigKeys {
"SshTool implementation to use (or null for default)",
null);

public static final ConfigKey<String> WINRM_TOOL_CLASS = newStringConfigKey(
BROOKLYN_WINRM_CONFIG_KEY_PREFIX + "winrmToolClass",
"WinRmTool implementation to use (or null for default)",
null);

/**
* @deprecated since 0.9.0; use {@link #SSH_TOOL_CLASS}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public interface SshTool extends ShellTool {

/** Public-facing global config keys for Brooklyn are defined in ConfigKeys,
* and have this prefix pre-prended to the config keys in this class.
* and have this prefix prepended to the config keys in this class.
* These keys are detected from entity/global config and automatically applied to ssh executions. */
public static final String BROOKLYN_CONFIG_KEY_PREFIX = "brooklyn.ssh.config.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
*/
package org.apache.brooklyn.entity.software.base;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import io.cloudsoft.winrm4j.winrm.WinRmToolResponse;
import static org.apache.brooklyn.util.JavaGroovyEquivalents.elvis;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.mgmt.Task;
import org.apache.brooklyn.api.sensor.AttributeSensor;
Expand All @@ -31,6 +39,8 @@
import org.apache.brooklyn.entity.software.base.lifecycle.NativeWindowsScriptRunner;
import org.apache.brooklyn.entity.software.base.lifecycle.WinRmExecuteHelper;
import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
import org.apache.brooklyn.util.core.internal.winrm.WinRmTool;
import org.apache.brooklyn.util.core.internal.winrm.WinRmToolResponse;
import org.apache.brooklyn.util.core.task.Tasks;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.exceptions.ReferenceWithError;
Expand All @@ -42,16 +52,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import static org.apache.brooklyn.util.JavaGroovyEquivalents.elvis;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public abstract class AbstractSoftwareProcessWinRmDriver extends AbstractSoftwareProcessDriver implements NativeWindowsScriptRunner {
private static final Logger LOG = LoggerFactory.getLogger(AbstractSoftwareProcessWinRmDriver.class);
Expand Down Expand Up @@ -260,7 +263,7 @@ public int execute(List<String> script) {
}

public int executePsScriptNoRetry(List<String> psScript) {
return getLocation().executePsScriptNoRetry(psScript).getStatusCode();
return getLocation().executePsScript(ImmutableMap.of(WinRmTool.PROP_EXEC_TRIES, 1), psScript).getStatusCode();
}

public int executePsScript(List<String> psScript) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
import org.apache.brooklyn.core.test.entity.TestApplication;
import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
import org.apache.brooklyn.util.core.internal.winrm.WinRmToolResponse;
import org.apache.brooklyn.util.text.Identifiers;
import org.apache.brooklyn.util.time.Time;
import org.slf4j.Logger;
Expand All @@ -59,8 +60,6 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;

import io.cloudsoft.winrm4j.winrm.WinRmToolResponse;

/**
* Tests execution of commands (batch and powershell) on Windows over WinRM, and of
* file upload.
Expand All @@ -72,8 +71,8 @@
* Please update the docs if you encountered new situations, or change the behaviuor
* of existing use-cases.
*/
public class WinRmMachineLocationLiveTest {

public class WinRmMachineLocationLiveTest {
private static final int MAX_EXECUTOR_THREADS = 100;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import io.cloudsoft.winrm4j.winrm.WinRmToolResponse;

import java.util.Collection;
import java.util.Iterator;
Expand Down Expand Up @@ -49,6 +48,7 @@
import org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig;
import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
import org.apache.brooklyn.util.core.flags.TypeCoercions;
import org.apache.brooklyn.util.core.internal.winrm.WinRmToolResponse;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.time.Duration;
import org.slf4j.Logger;
Expand Down
Loading