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

Require documentation for spire commands #512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions platform/spire/src/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ def short_doc(self):


def wrapop(f):
return functools.update_wrapper(Command(f), f, updated=[])
r = functools.update_wrapper(Command(f), f, updated=[])
if r.short_doc() is None:
raise ValueError('undocumented command {!r}'.format(r))
return r


class Seq(Command):
Expand All @@ -198,7 +201,10 @@ def invoke(self, aargs):
op(dry_run=aargs.dry_run or aargs.dry_run_outer)

def wrapseq(f):
return functools.update_wrapper(Seq(f), f, updated=[])
r = functools.update_wrapper(Seq(f), f, updated=[])
if r.short_doc() is None:
raise ValueError('undocumented command {!r}'.format(r))
return r


class Simple(Command):
Expand All @@ -215,7 +221,10 @@ def invoke(self, aargs):


def wrap(f):
return functools.update_wrapper(Simple(f), f, updated=[])
r = functools.update_wrapper(Simple(f), f, updated=[])
if r.short_doc() is None:
raise ValueError('undocumented command {!r}'.format(r))
return r


# Decorator for delegating a function call to self._context if it exists,
Expand All @@ -235,6 +244,8 @@ def __init__(self):

@_delegate_to_context
def add_operation(self, name: str, callback, command=None):
if not name:
raise ValueError('unlabelled operation {!r}'.format(callback))
self._ops.append((name, callback, command))

def add_command(self, cmd, *args, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions platform/spire/src/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def pull_prometheus_query(query, default_value=None):

@command.wrap
def check_keystatics():
"verify the keyserver's static files"
cluster_conf = query.get_keyurl_data("/static/cluster.conf")
expected_cluster_conf = configuration.get_cluster_conf()

Expand Down
5 changes: 4 additions & 1 deletion platform/spire/src/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,19 +544,21 @@ def qemu_check_nested_virt():

@command.wrapseq
def auto_install_supervisor(ops: command.Operations, tc: TerminationContext, supervisor: configuration.Node, install_iso: str, cdrom_install: bool=False, debug_qemu=False):
'install supervisor node'
vm = VirtualMachine(supervisor, tc, install_iso, cdrom_install=cdrom_install, debug_qemu=debug_qemu)
ops.add_operation("install supervisor node (this may take several minutes)", vm.boot_install_supervisor, supervisor)


@command.wrapseq
def auto_launch_supervisor(ops: command.Operations, tc: TerminationContext, supervisor: configuration.Node, debug_qemu=False):
# TODO: annotations, so that this can be --dry-run'd
'launch supervisor node'
vm = VirtualMachine(supervisor, tc, debug_qemu=debug_qemu)
ops.add_operation("start up supervisor node", lambda: vm.boot_launch(autoadd_fingerprint=True))


@command.wrapseq
def auto_install_nodes(ops: command.Operations, tc: TerminationContext, nodes: list, install_iso: str, cdrom_install: bool=False, debug_qemu=False):
'install non-supervisor nodes'
vms = [VirtualMachine(node, tc, install_iso, cdrom_install=cdrom_install, debug_qemu=debug_qemu) for node in nodes]

def boot_install_and_admit_all():
Expand All @@ -570,6 +572,7 @@ def boot_install_and_admit_all():

@command.wrapseq
def auto_launch_nodes(ops: command.Operations, tc: TerminationContext, nodes: list, debug_qemu=False):
'launch non-supervisor nodes'
for node in nodes:
vm = VirtualMachine(node, tc, debug_qemu=debug_qemu)
ops.add_operation("start up node {}".format(node), vm.boot_launch)
Expand Down