-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rptest: Implement functions for byoc cluster creation
- Loading branch information
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from rptest.clients.rpk import RpkTool | ||
|
||
|
||
class FakePanda: | ||
logger = None | ||
|
||
def __init__(self, context, log): | ||
self._context = context | ||
self.logger = log | ||
|
||
|
||
class CloudClusterUtils: | ||
def __init__(self, context, logger): | ||
# Create fake redpanda class with logger only | ||
self.fake_panda = FakePanda(context, logger) | ||
# Create rpk to use several functions that is isolated | ||
# from actual redpanda service | ||
self.rpk = RpkTool(self.fake_panda) | ||
self.logger = logger | ||
|
||
def _parse_plugin_list(self, plist): | ||
""" | ||
Parses 'rpk plugin list' output | ||
""" | ||
# 'NAME PATH SHADOWS\nbyoc /home/ubuntu/.local/bin/.rpk.ac-byoc \n' | ||
_lines = plist.split('\n') | ||
_headers = [] | ||
_plugins = [] | ||
for _line in _lines: | ||
# cleanup repeated spaces | ||
_l = ' '.join(_line.split()) | ||
# Get nice list | ||
_fields = _l.lower().split() | ||
if not _fields: | ||
continue | ||
elif _fields[0] == 'name': | ||
_headers = _l.lower().split() | ||
elif not _headers: | ||
self.logger.warning(f"Error parsing rpk plugin list: {plist}") | ||
else: | ||
# Create dict | ||
_p = {} | ||
for idx in range(len(_fields)): | ||
_p[_headers[idx]] = _fields[idx] | ||
_plugins.append(_p) | ||
return _plugins | ||
|
||
def rpk_plugin_install(self, plugin_name, reinstall=False): | ||
_plist = self.rpk.plugin_list() | ||
# parse plugin list | ||
_plist = self._parse_plugin_list(_plist) | ||
_installed = [p['name'] == plugin_name for p in _plist] | ||
if any(_installed) and reinstall: | ||
# uninstall if plugin present. Use sudo just in case | ||
self.rpk._execute( | ||
[self.rpk._rpk_binary(), 'plugin', 'uninstall', plugin_name]) | ||
# Install latest plugin | ||
self.rpk._execute( | ||
[self.rpk._rpk_binary(), 'plugin', 'install', plugin_name]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters