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

Changes to the plugin.py file to include the plugin remove_jar feature #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions prestoadmin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
from prestoadmin.util.base_config import requires_config
from prestoadmin.util.constants import REMOTE_PLUGIN_DIR

__all__ = ['add_jar']
__all__ = ['add_jar', 'remove_jar']
_LOGGER = logging.getLogger(__name__)


def write(local_path, remote_dir):
sudo("mkdir -p " + remote_dir)
put(local_path, remote_dir, use_sudo=True)


@task
@requires_config(StandaloneConfig)
def add_jar(local_path, plugin_name, plugin_dir=REMOTE_PLUGIN_DIR):
Expand All @@ -47,3 +46,15 @@ def add_jar(local_path, plugin_name, plugin_dir=REMOTE_PLUGIN_DIR):
"""
_LOGGER.info('deploying jars on %s' % env.host)
write(local_path, os.path.join(plugin_dir, plugin_name))

def remove_jar(local_path, plugin_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For remove jar, there is no local path. The command should take the plugin name to remove and optionally the remote path to the plugin directory to allow for non-default configurations.

def remove_jar(plugin_name, plugin_dir=REMOTE_PLUGIN_DIR)

"""
Remove jar for the specified plugin to the plugin directory.

Parameters:
local_path - Local path to the jar to be removed
plugin_name - Name of the plugin subdirectory to deploy jars to

"""
_LOGGER.info('removing jar on %s' % env.host)
os.remove(os.path.join(local_path, plugin_name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only remove the jar from the local system the presto-admin is running on. To remove it from all of the presto nodes you should use a fabric command something like.

path = os.path.join(plugin_dir, plugin_name)
sudo('rm %s' % path)