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

docs: update maas-anvil documentation #77

Merged
merged 37 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
84f4fa6
Update documentation
dgtlntv Nov 13, 2024
9be1281
Fix markup
dgtlntv Nov 13, 2024
7252837
fixed syntax highlighting
dgtlntv Nov 13, 2024
0a6fc67
Fixed capitalisation
dgtlntv Nov 13, 2024
1352bdd
add internal link
dgtlntv Nov 13, 2024
413dd54
fix flag name
dgtlntv Nov 13, 2024
d9c8d6e
Fix flag reference
dgtlntv Nov 13, 2024
7569f25
Remove newline
dgtlntv Nov 13, 2024
63d6ea9
omit update cluster section for now
dgtlntv Nov 13, 2024
4a72349
add internal link
dgtlntv Nov 13, 2024
ecce3c3
fix several small typos
dgtlntv Nov 13, 2024
5c4584b
fixed code snippet
dgtlntv Nov 13, 2024
c1effed
fixed small typo
dgtlntv Nov 13, 2024
a223ff6
made yaml indentation consistent
dgtlntv Nov 13, 2024
a9f29fa
added links to charms
dgtlntv Nov 13, 2024
5a1b5b7
test cli interface formatting
dgtlntv Nov 13, 2024
2fdc4a5
added newline
dgtlntv Nov 13, 2024
66217be
Update README.md
dgtlntv Nov 13, 2024
109fb70
cli interface formatting
dgtlntv Nov 13, 2024
6fc7806
test other cli header formatting
dgtlntv Nov 13, 2024
8fc8812
change cli interface header formatting
dgtlntv Nov 13, 2024
c630303
small fixes
dgtlntv Nov 13, 2024
3cc1cb7
fix apostrophe
dgtlntv Nov 13, 2024
8045937
added link
dgtlntv Nov 13, 2024
45cad2a
Update README.md
dgtlntv Nov 13, 2024
05e8606
Update README.md
dgtlntv Nov 13, 2024
a9bc86c
Update README.md
dgtlntv Nov 13, 2024
df53f81
fixed indentation
dgtlntv Nov 13, 2024
0271a50
fixed spelling and formatting mistakes
dgtlntv Nov 14, 2024
f47b27a
Update help pages
dgtlntv Nov 19, 2024
b88f407
Fix linting issues
dgtlntv Nov 19, 2024
ebe87f6
Add note regarding tls configuration
dgtlntv Nov 19, 2024
ba072c6
Update example manifest file
dgtlntv Nov 19, 2024
17ba0ce
Add missing parenthesis
dgtlntv Nov 19, 2024
6cc6749
updated root command styling and grouping
dgtlntv Nov 22, 2024
18c9b07
fix mypy
skatsaounis Nov 27, 2024
871b93a
fix linting issues
skatsaounis Nov 27, 2024
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
821 changes: 771 additions & 50 deletions README.md

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions anvil-python/anvil/commands/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@
snap = Snap()


@click.group(invoke_without_command=True)
@click.group(
invoke_without_command=True,
epilog="""
\b
Inspect the MAAS Anvil cluster.
maas-anvil inspect
""",
)
@click.pass_context
def inspect(ctx: click.Context) -> None:
"""Inspect the maas-anvil installation.

This script will inspect your installation. It will report any issue
it finds, and create a tarball of logs and traces which can be
attached to an issue filed against the maas-anvil project.
"""Inspects the cluster and reports any issues it finds. A tarball of
logs and traces is created.
You can attach this tarball to an issue filed in the MAAS Anvil Github
repository. github.com/canonical/maas-anvil
"""
preflight_checks = []
preflight_checks.append(DaemonGroupCheck())
Expand Down
50 changes: 36 additions & 14 deletions anvil-python/anvil/commands/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from anvil.jobs.checks import DaemonGroupCheck, VerifyBootstrappedCheck
from anvil.jobs.manifest import Manifest
from anvil.utils import FormatEpilogCommand

LOG = logging.getLogger(__name__)
console = Console()
Expand Down Expand Up @@ -70,17 +71,24 @@ def generate_software_manifest(manifest: Manifest) -> str:
raise click.ClickException(f"Manifest generation failed: {e!s}")


@click.command()
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
List previously used manifest files.
maas-anvil manifest list
""",
)
@click.option(
"-f",
"--format",
type=click.Choice([FORMAT_TABLE, FORMAT_YAML]),
default=FORMAT_TABLE,
help="Output format.",
help="Output format of the list.",
)
@click.pass_context
def list(ctx: click.Context, format: str) -> None:
"""List manifests"""
"""Lists manifest files that were used in the cluster."""
deployment: Deployment = ctx.obj
client = deployment.get_client()
manifests = []
Expand Down Expand Up @@ -109,13 +117,22 @@ def list(ctx: click.Context, format: str) -> None:
click.echo(yaml.dump(manifests))


@click.command()
@click.option("--id", type=str, prompt=True, help="Manifest ID")
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
Show the contents of the most recently committed manifest file.
maas-anvil manifest show --id=latest
""",
)
@click.option(
"--id", type=str, prompt=True, help="The database id of the manifest file."
)
@click.pass_context
def show(ctx: click.Context, id: str) -> None:
"""Show Manifest data.

Use '--id=latest' to get the last committed manifest.
"""Shows the contents of a manifest file given an id.
Get ids using the 'manifest list' command. Use '--id=latest' to show the most
recently committed manifest.
"""
deployment: Deployment = ctx.obj
client = deployment.get_client()
Expand All @@ -132,7 +149,15 @@ def show(ctx: click.Context, id: str) -> None:
click.echo(f"Error: No manifest exists with id {id}")


@click.command()
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
Generate a manifest file with (default) configuration to be saved in the default
location of '$HOME/.config/anvil/manifest.yaml'
maas-anvil manifest generate
""",
)
@click.option(
"-o",
"--output",
Expand All @@ -144,11 +169,8 @@ def generate(
ctx: click.Context,
output: Path | None = None,
) -> None:
"""Generate manifest file.

Generate manifest file with the deployed configuration.
If the cluster is not bootstrapped, fallback to default
configuration.
"""Generates a manifest file. Either with the configuration of the currently deployed
MAAS Anvil cluster or, if no cluster was bootstrapped yet, a default configuration.
"""
deployment: Deployment = ctx.obj

Expand Down
15 changes: 13 additions & 2 deletions anvil-python/anvil/commands/prepare_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import click
from rich.console import Console

from anvil.utils import FormatEpilogCommand

console = Console()


Expand Down Expand Up @@ -82,7 +84,16 @@
"""


@click.command()
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
Prepare a node for usage with MAAS Anvil by generating the 'prepare-node-script' and
running it immediately by piping it to bash.
maas-anvil prepare-node-script | bash -x
""",
)
def prepare_node_script() -> None:
"""Generate script to prepare a node for Anvil use."""
"""Generates a script to prepare the node for use with MAAS Anvil.
This must be run on every node on which you want to use MAAS Anvil."""
console.print(PREPARE_NODE_TEMPLATE, soft_wrap=True)
26 changes: 20 additions & 6 deletions anvil-python/anvil/commands/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@
from anvil.commands.upgrades.intra_channel import LatestInChannelCoordinator
from anvil.jobs.manifest import AddManifestStep, Manifest
from anvil.provider.local.deployment import LocalDeployment
from anvil.utils import FormatEpilogCommand

LOG = logging.getLogger(__name__)
console = Console()


@click.command()
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
Refresh the MAAS Anvil cluster.
maas-anvil refresh
""",
)
@click.option(
"-m",
"--manifest",
"manifest_path",
help="Manifest file.",
help=(
"If provided, the cluster is refreshed with the configuration "
"specified in the manifest file."
),
type=click.Path(
exists=True, dir_okay=False, path_type=Path, allow_dash=True
),
Expand All @@ -49,17 +60,20 @@
is_flag=True,
show_default=True,
default=False,
help="Upgrade MAAS Anvil release.",
help=(
"Allows charm upgrades if the new manifest specifies charms in channels "
"with higher tracks than the current one."
),
)
@click.pass_context
def refresh(
ctx: click.Context,
manifest_path: Path | None = None,
upgrade_release: bool = False,
) -> None:
"""Refresh deployment.

Refresh the deployment and allow passing new configuration options.
"""Updates all charms within their current channel.
A manifest file can be passed to refresh the deployment with
new configuration.
"""

deployment: LocalDeployment = ctx.obj
Expand Down
15 changes: 13 additions & 2 deletions anvil-python/anvil/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@

from anvil.jobs.checks import VerifyBootstrappedCheck
from anvil.provider.local.deployment import LocalDeployment
from anvil.utils import FormatEpilogCommand

LOG = logging.getLogger(__name__)
console = Console()


@click.command()
@click.command(
cls=FormatEpilogCommand,
epilog="""
\b
Log into the Juju controller to manually interact with the Juju controller created
by MAAS Anvil.
maas-anvil juju-login
""",
)
@click.pass_context
def juju_login(ctx: click.Context) -> None:
"""Login to the controller with current host user."""
"""Logs into the Juju controller used by MAAS Anvil.
The login is performed using the current host user.
"""
deployment: LocalDeployment = ctx.obj
run_preflight_checks(
[VerifyBootstrappedCheck(deployment.get_client())], console
Expand Down
32 changes: 24 additions & 8 deletions anvil-python/anvil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import click
from snaphelpers import Snap
from sunbeam import log
Expand All @@ -29,30 +30,45 @@
from anvil.commands.utils import juju_login
from anvil.provider.local.commands import LocalProvider
from anvil.provider.local.deployment import LocalDeployment
from anvil.utils import CatchGroup
from anvil.utils import CatchGroup, FormatCommandGroupsGroup

# Update the help options to allow -h in addition to --help for
# triggering the help for various commands
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


@click.group("init", context_settings=CONTEXT_SETTINGS, cls=CatchGroup)
@click.group(
"init", context_settings=CONTEXT_SETTINGS, cls=FormatCommandGroupsGroup
)
@click.option("--quiet", "-q", default=False, is_flag=True)
@click.option("--verbose", "-v", default=False, is_flag=True)
@click.pass_context
def cli(ctx: click.Context, quiet: bool, verbose: bool) -> CatchGroup: # type: ignore[empty-body]
"""Anvil is a MAAS installer for MAAS charms.
"""MAAS Anvil is an installer that makes deploying MAAS charms in HA easy.

To get started with a single node, all-in-one MAAS installation, start
with initializing the local node. Once the local node has been initialized,
run the bootstrap process to get a live MAAS deployment.
To get started run the prepare-node-script command and bootstrap the first
node. For more details read the docs at: github.com/canonical/maas-anvil
"""


@click.group("manifest", context_settings=CONTEXT_SETTINGS, cls=CatchGroup)
@click.group(
"manifest",
context_settings=CONTEXT_SETTINGS,
cls=CatchGroup,
epilog="""
\b
Generate a manifest file with (default) configuration to be saved in the default
location of '$HOME/.config/anvil/manifest.yaml'
maas-anvil manifest generate
""",
)
@click.pass_context
def manifest(ctx: click.Context) -> None:
"""Manage manifests (read-only commands)"""
"""Generates and manages manifest files.
A manifest file is a declarative YAML file with which configurations for
a MAAS Anvil cluster deployment can be set. The manifest commands are read
only. A manifest can be applied with "cluster bootstrap" or "cluster refresh".
"""


def main() -> None:
Expand Down
Loading
Loading