Refactor shell handler to use transports
This commit is contained in:
parent
19366f66c9
commit
39c5a34a3f
@ -13,7 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from fabric import api as fabric_api
|
||||
from solar.core.log import log
|
||||
from solar import errors
|
||||
|
||||
from solar.core.handlers.base import TempFileHandler
|
||||
|
||||
@ -21,4 +22,19 @@ from solar.core.handlers.base import TempFileHandler
|
||||
class Shell(TempFileHandler):
|
||||
def action(self, resource, action_name):
|
||||
action_file = self._compile_action_file(resource, action_name)
|
||||
fabric_api.local('bash {}'.format(action_file))
|
||||
log.debug('action_file: %s', action_file)
|
||||
|
||||
self.transport_sync.copy(resource, action_file, '/tmp/action.sh')
|
||||
self.transport_sync.sync_all()
|
||||
cmd = self.transport_run.run(
|
||||
resource,
|
||||
'bash', '/tmp/action.sh',
|
||||
use_sudo=True,
|
||||
warn_only=True
|
||||
)
|
||||
|
||||
if cmd.return_code:
|
||||
raise errors.SolarError(
|
||||
'Bash execution for {} failed with {}'.format(
|
||||
resource.name, cmd.return_code))
|
||||
return cmd
|
||||
|
Loading…
x
Reference in New Issue
Block a user