Skip to content

Commit

Permalink
Merge ef14e86 into e1c6271
Browse files Browse the repository at this point in the history
  • Loading branch information
dkliban committed Aug 12, 2019
2 parents e1c6271 + ef14e86 commit 89ad67a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pulp_smash/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def __init__(

self._is_root_cache = None
self._machine = None
self._podname = None
logger.debug("New %s", self)

def __str__(self):
Expand All @@ -232,6 +233,11 @@ def machine(self):

if transport == "local":
self._machine = plumbum.machines.local
elif transport == "kubectl":
self._machine = plumbum.machines.local
chain = self._machine["kubectl"]["get", "pods"] | \
self._machine["grep"]["-E", "-o", r"pulp-api-(\w+)-(\w+)"]
self._podname = chain()
else: # transport == 'ssh'
# The SshMachine is a wrapper around the host's "ssh" binary.
# Thus, it uses ~/.ssh/config, ~/.ssh/known_hosts, etc.
Expand Down Expand Up @@ -276,6 +282,9 @@ def run(self, args, sudo=False, **kwargs):
kwargs.setdefault("retcode")
logger.debug("Running %s cmd (sudo:%s) - %s", args, sudo, kwargs)

if self._podname:
args = ("kubectl", "exec", self._podname) + tuple(args) + ("--",)

if sudo and args[0] != "sudo" and not self.is_superuser:
args = ("sudo",) + tuple(args)

Expand Down

0 comments on commit 89ad67a

Please sign in to comment.