Skip to content

Commit

Permalink
bug: remove sunbeam leftovers (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
skatsaounis authored Jun 26, 2024
1 parent 2902b7e commit 3efcfa5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
3 changes: 2 additions & 1 deletion anvil-python/anvil/commands/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
from rich.console import Console
from snaphelpers import Snap
from sunbeam.commands.juju import WriteCharmLogStep, WriteJujuStatusStep
from sunbeam.jobs.checks import DaemonGroupCheck
from sunbeam.jobs.common import (
run_plan,
run_preflight_checks,
)
from sunbeam.jobs.deployment import Deployment
from sunbeam.jobs.juju import JujuHelper

from anvil.jobs.checks import DaemonGroupCheck

LOG = logging.getLogger(__name__)
console = Console()
snap = Snap()
Expand Down
2 changes: 1 addition & 1 deletion anvil-python/anvil/commands/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
ClusterServiceUnavailableException,
ManifestItemNotFoundException,
)
from sunbeam.jobs.checks import DaemonGroupCheck, VerifyBootstrappedCheck
from sunbeam.jobs.common import FORMAT_TABLE, FORMAT_YAML, run_preflight_checks
from sunbeam.jobs.deployment import Deployment
from sunbeam.utils import asdict_with_extra_fields
import yaml

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

LOG = logging.getLogger(__name__)
Expand Down
35 changes: 27 additions & 8 deletions anvil-python/anvil/jobs/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
# limitations under the License.

import logging
import os

from sunbeam.jobs.checks import Check
from sunbeam.jobs.checks import (
DaemonGroupCheck as SunbeamDaemonGroupCheck,
SystemRequirementsCheck as SunbeamSystemRequirementsCheck,
VerifyBootstrappedCheck as SunbeamVerifyBootstrappedCheck,
)
from sunbeam.jobs.common import (
get_host_total_cores,
get_host_total_ram,
Expand All @@ -26,15 +31,9 @@
LOG = logging.getLogger(__name__)


class SystemRequirementsCheck(Check):
class SystemRequirementsCheck(SunbeamSystemRequirementsCheck):
"""Check if machine has minimum 4 cores and 16GB RAM."""

def __init__(self) -> None:
super().__init__(
"Check for system requirements",
"Checking for host configuration of minimum 4 core and 16G RAM",
)

def run(self) -> bool:
host_total_ram = get_host_total_ram()
host_total_cores = get_host_total_cores()
Expand All @@ -43,3 +42,23 @@ def run(self) -> bool:
LOG.warning(self.message)

return True


class DaemonGroupCheck(SunbeamDaemonGroupCheck):
"""Check if user is member of socket group."""

def run(self) -> bool:
ret: bool = super().run()
if not ret:
self.message: str = self.message.replace("sunbeam", "anvil")
return ret


class VerifyBootstrappedCheck(SunbeamVerifyBootstrappedCheck):
"""Check deployment has been bootstrapped."""

def run(self) -> bool:
ret: bool = super().run()
if not ret:
self.message: str = self.message.replace("sunbeam", "anvil")
return ret
2 changes: 1 addition & 1 deletion anvil-python/anvil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def manifest(ctx: click.Context) -> None:

def main() -> None:
snap = Snap()
logfile = log.prepare_logfile(snap.paths.user_common / "logs", "sunbeam")
logfile = log.prepare_logfile(snap.paths.user_common / "logs", "anvil")
log.setup_root_logging(logfile)
cli.add_command(prepare_node_cmds.prepare_node_script)
cli.add_command(inspect_cmds.inspect)
Expand Down
5 changes: 1 addition & 4 deletions anvil-python/anvil/provider/local/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from sunbeam import utils

# from sunbeam.commands import refresh as refresh_cmds
from sunbeam.commands import resize as resize_cmds
from sunbeam.commands.clusterd import (
ClusterAddJujuUserStep,
ClusterAddNodeStep,
Expand All @@ -48,7 +47,6 @@
)
from sunbeam.commands.terraform import TerraformInitStep
from sunbeam.jobs.checks import (
DaemonGroupCheck,
JujuSnapCheck,
LocalShareCheck,
SshKeysConnectedCheck,
Expand Down Expand Up @@ -93,7 +91,7 @@
DeployPostgreSQLApplicationStep,
RemovePostgreSQLUnitStep,
)
from anvil.jobs.checks import SystemRequirementsCheck
from anvil.jobs.checks import DaemonGroupCheck, SystemRequirementsCheck
from anvil.jobs.common import (
Role,
roles_to_str_list,
Expand Down Expand Up @@ -140,7 +138,6 @@ def register_cli(
cluster.add_command(join)
cluster.add_command(list)
cluster.add_command(remove)
cluster.add_command(resize_cmds.resize)
# cluster.add_command(refresh_cmds.refresh)

def deployment_type(self) -> tuple[str, type[Deployment]]:
Expand Down

0 comments on commit 3efcfa5

Please sign in to comment.