-
Notifications
You must be signed in to change notification settings - Fork 27
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
Rebind CLI #1185
Rebind CLI #1185
Changes from all commits
bad8d3d
68e5907
ba4cfd9
c4118c8
f0ff6d6
b6c194d
c7ba27f
bf422d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,9 @@ public TemplatedStringAttributeSensorAndConfigKey(TemplatedStringAttributeSensor | |
super(orig, defaultValue); | ||
} | ||
|
||
@Override | ||
protected String convertConfigToSensor(String value, Entity entity) { | ||
if (value == null) return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) |
||
return TemplateProcessor.processTemplateContents(value, (EntityInternal)entity, ImmutableMap.<String,Object>of()); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,6 @@ | |
*/ | ||
public class Infinispan5SshDriver extends JavaSoftwareProcessSshDriver implements Infinispan5Driver { | ||
|
||
private String expandedInstallDir; | ||
|
||
public Infinispan5SshDriver(Infinispan5Server entity, SshMachineLocation machine) { | ||
super(entity, machine); | ||
} | ||
|
@@ -41,18 +39,13 @@ protected Integer getPort() { | |
return entity.getAttribute(Infinispan5Server.PORT); | ||
} | ||
|
||
private String getExpandedInstallDir() { | ||
if (expandedInstallDir == null) throw new IllegalStateException("expandedInstallDir is null; most likely install was not called"); | ||
return expandedInstallDir; | ||
} | ||
|
||
@Override | ||
public void install() { | ||
DownloadResolver resolver = Entities.newDownloader(this); | ||
List<String> urls = resolver.getTargets(); | ||
String saveAs = resolver.getFilename(); | ||
// FIXME will saveAs be "infinispan-${version}-all.zip"? | ||
expandedInstallDir = getInstallDir(); // unpacks to current directory, rather than sub-directory | ||
setExpandedInstallDir(getInstallDir()); // unpacks to current directory, rather than sub-directory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re earlier comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this one is correct - the zip unpacks to the current directory rather than creating a sub-dir, so the "expanded install dir" is the same as the "install dir". |
||
|
||
List<String> commands = ImmutableList.<String>builder() | ||
.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import static brooklyn.util.GroovyJavaMethods.elvis; | ||
import static brooklyn.util.GroovyJavaMethods.truth; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import java.io.File; | ||
import java.io.StringReader; | ||
|
@@ -51,6 +52,7 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP | |
// we cache these in case the entity becomes unmanaged | ||
private volatile String installDir; | ||
private volatile String runDir; | ||
private volatile String expandedInstallDir; | ||
|
||
/** include this flag in newScript creation to prevent entity-level flags from being included; | ||
* any SSH-specific flags passed to newScript override flags from the entity, | ||
|
@@ -120,6 +122,12 @@ protected String getEntityVersionLabel(String separator) { | |
|
||
public String getInstallDir() { | ||
if (installDir != null) return installDir; | ||
|
||
String existingVal = getEntity().getAttribute(SoftwareProcess.INSTALL_DIR); | ||
if (Strings.isNonBlank(existingVal)) { // e.g. on rebind | ||
installDir = existingVal; | ||
return installDir; | ||
} | ||
|
||
// deprecated in 0.7.0 | ||
Maybe<Object> minstallDir = getEntity().getConfigRaw(SoftwareProcess.INSTALL_DIR, true); | ||
|
@@ -142,6 +150,12 @@ public String getInstallDir() { | |
public String getRunDir() { | ||
if (runDir != null) return runDir; | ||
|
||
String existingVal = getEntity().getAttribute(SoftwareProcess.RUN_DIR); | ||
if (Strings.isNonBlank(existingVal)) { // e.g. on rebind | ||
runDir = existingVal; | ||
return runDir; | ||
} | ||
|
||
// deprecated in 0.7.0 | ||
Maybe<Object> mRunDir = getEntity().getConfigRaw(SoftwareProcess.RUN_DIR, true); | ||
if (!mRunDir.isPresent() || mRunDir.get()==null) { | ||
|
@@ -160,6 +174,29 @@ public String getRunDir() { | |
return runDir; | ||
} | ||
|
||
public void setExpandedInstallDir(String val) { | ||
checkNotNull(val, "expandedInstallDir"); | ||
String oldVal = getEntity().getAttribute(SoftwareProcess.EXPANDED_INSTALL_DIR); | ||
if (Strings.isNonBlank(oldVal) && !oldVal.equals(val)) { | ||
log.info("Resetting expandedInstallDir (to "+val+" from "+oldVal+") for "+getEntity()); | ||
} | ||
|
||
getEntity().setAttribute(SoftwareProcess.EXPANDED_INSTALL_DIR, val); | ||
} | ||
|
||
public String getExpandedInstallDir() { | ||
if (expandedInstallDir != null) return expandedInstallDir; | ||
|
||
String untidiedVal = ConfigToAttributes.apply(getEntity(), SoftwareProcess.EXPANDED_INSTALL_DIR); | ||
if (Strings.isNonBlank(untidiedVal)) { | ||
expandedInstallDir = Os.tidyPath(untidiedVal); | ||
entity.setAttribute(SoftwareProcess.INSTALL_DIR, expandedInstallDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this is just a mistake? see earlier comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well spotted; yes a mistake. |
||
return expandedInstallDir; | ||
} else { | ||
throw new IllegalStateException("expandedInstallDir is null; most likely install was not called for "+getEntity()); | ||
} | ||
} | ||
|
||
public SshMachineLocation getMachine() { return getLocation(); } | ||
public String getHostname() { return entity.getAttribute(Attributes.HOSTNAME); } | ||
public String getAddress() { return entity.getAttribute(Attributes.ADDRESS); } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package brooklyn.entity.database.mysql; | ||
|
||
import static brooklyn.util.GroovyJavaMethods.truth; | ||
import static brooklyn.util.ssh.BashCommands.*; | ||
import static brooklyn.util.ssh.BashCommands.commandsToDownloadUrlsAs; | ||
import static brooklyn.util.ssh.BashCommands.installPackage; | ||
import static brooklyn.util.ssh.BashCommands.ok; | ||
import static java.lang.String.format; | ||
|
||
import java.io.InputStream; | ||
|
@@ -43,8 +45,6 @@ public class MySqlSshDriver extends AbstractSoftwareProcessSshDriver implements | |
|
||
public static final Logger log = LoggerFactory.getLogger(MySqlSshDriver.class); | ||
|
||
private String expandedInstallDir; | ||
|
||
public MySqlSshDriver(MySqlNodeImpl entity, SshMachineLocation machine) { | ||
super(entity, machine); | ||
|
||
|
@@ -92,17 +92,12 @@ public String getInstallFilename() { | |
return String.format("mysql-%s-%s.tar.gz", getVersion(), getOsTag()); | ||
} | ||
|
||
private String getExpandedInstallDir() { | ||
if (expandedInstallDir == null) throw new IllegalStateException("expandedInstallDir is null; most likely install was not called"); | ||
return expandedInstallDir; | ||
} | ||
|
||
@Override | ||
public void install() { | ||
DownloadResolver resolver = Entities.newDownloader(this, ImmutableMap.of("filename", getInstallFilename())); | ||
List<String> urls = resolver.getTargets(); | ||
String saveAs = resolver.getFilename(); | ||
expandedInstallDir = getInstallDir() + "/" + resolver.getUnpackedDirectoryName(format("mysql-%s-%s", getVersion(), getOsTag())); | ||
setExpandedInstallDir(getInstallDir() + "/" + resolver.getUnpackedDirectoryName(format("mysql-%s-%s", getVersion(), getOsTag()))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if EXPANDED_INSTALL_DIR is really a config key shouldn't this be something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, so maybe rename the method |
||
|
||
List<String> commands = new LinkedList<String>(); | ||
commands.add(BashCommands.INSTALL_TAR); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add javadoc with the reason for this, or comments on the confusing lines -- in particular its interplay with
INSTALL_DIR
, eg things likeentity.setAttribute(SoftwareProcess.INSTALL_DIR, expandedInstallDir);
inAbstractSoftwareProcessSshDriver
and calls tosetExpandedInstallDir
to theinstallDir
in some of the entitiesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added:
Thinking about this more, I'm not sure how well this will cope with someone setting the EXPANDED_INSTALL_DIR configuration. We might just overwrite it in the driver's install method, logging a warning! I'll need to look at that more.