Github user aledsage commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/1030#issuecomment-156714424
Taking a step back from the minor comments I've been making so far... This
feels like a lot of code we have to write for the SimpleCommand entity. I
wonder if there is another way of doing it that does not involve copying the
pattern used in the `SoftwareProcess` entity.
The "driver pattern" was really introduced to have different
implementations depending on whether it was ssh or something else - and it's
never used for anything but ssh. The "LifecycleEffectorTasks pattern" is mostly
for ensuring that all the different parts of the entity deployment/actions are
executed correctly as tasks that are tracked in the activity view. It includes
support for many tasks being executed (e.g. for pre-install, install,
post-install, customize, etc). We don't need all that complexity for
`SimpleCommand`.
All we really need is to get hold of the right SshMachineLocation and to
execute a command on it using `sshMachine.execScript()`.
For the download-url case, we could download it on Brooklyn, and just pass
the string contents to `sshMachine.execScript`, or if it might be binary then
we could use `machine.copyTo(...); machine.execScript(...)`.
To ensure the command's stdout/stderr etc appears in the activites view
correctly, we can go through the `SshEffectorTasks` stuff rather than calling
methods on machine directly.
My gut feel is that we could put that code directly in the start() method
of the `SimpleCommandImpl` (or more accurately in a method that it delegates
to).
Does that sound like it would work, and does it sound like it would reduce
massively the amount of code required?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---