api/clan: rename 'show_clan_meta' -> 'get_clan_details'

This commit is contained in:
Johannes Kirschbauer
2025-07-07 09:47:27 +02:00
parent 045e297438
commit 1c33f30135
12 changed files with 98 additions and 92 deletions

View File

@@ -13,7 +13,7 @@ export const clanMetaQuery = (uri: string | undefined = undefined) =>
queryFn: async () => { queryFn: async () => {
console.log("fetching clan meta", clanURI); console.log("fetching clan meta", clanURI);
const result = await callApi("show_clan_meta", { const result = await callApi("get_clan_details", {
flake: { identifier: clanURI! }, flake: { identifier: clanURI! },
}).promise; }).promise;

View File

@@ -203,6 +203,6 @@ export const CreateClan = () => {
}; };
type Meta = Extract< type Meta = Extract<
OperationResponse<"show_clan_meta">, OperationResponse<"get_clan_details">,
{ status: "success" } { status: "success" }
>["data"]; >["data"];

View File

@@ -128,7 +128,7 @@ const EditClanForm = (props: EditClanFormProps) => {
); );
}; };
type GeneralData = SuccessQuery<"show_clan_meta">["data"]; type GeneralData = SuccessQuery<"get_clan_details">["data"];
export const ClanDetails = () => { export const ClanDetails = () => {
const params = useParams(); const params = useParams();

View File

@@ -100,7 +100,7 @@ export const Flash = () => {
const deviceQuery = createQuery(() => ({ const deviceQuery = createQuery(() => ({
queryKey: ["block_devices"], queryKey: ["block_devices"],
queryFn: async () => { queryFn: async () => {
const result = await callApi("show_block_devices", {}).promise; const result = await callApi("list_block_devices", {}).promise;
if (result.status === "error") throw new Error("Failed to fetch data"); if (result.status === "error") throw new Error("Failed to fetch data");
return result.data; return result.data;
}, },

View File

@@ -13,7 +13,7 @@ export const clanMetaQuery = (uri: string | undefined = undefined) =>
queryFn: async () => { queryFn: async () => {
console.log("fetching clan meta", clanURI); console.log("fetching clan meta", clanURI);
const result = await callApi("show_clan_meta", { const result = await callApi("get_clan_details", {
flake: { identifier: clanURI! }, flake: { identifier: clanURI! },
}).promise; }).promise;

View File

@@ -202,6 +202,6 @@ export const CreateClan = () => {
}; };
type Meta = Extract< type Meta = Extract<
OperationResponse<"show_clan_meta">, OperationResponse<"get_clan_details">,
{ status: "success" } { status: "success" }
>["data"]; >["data"];

View File

@@ -128,7 +128,7 @@ const EditClanForm = (props: EditClanFormProps) => {
); );
}; };
type GeneralData = SuccessQuery<"show_clan_meta">["data"]; type GeneralData = SuccessQuery<"get_clan_details">["data"];
export const ClanDetails = () => { export const ClanDetails = () => {
const params = useParams(); const params = useParams();

View File

@@ -1,14 +1,14 @@
import argparse import argparse
import logging import logging
from clan_lib.clan.get import show_clan_meta from clan_lib.clan.get import get_clan_details
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def show_command(args: argparse.Namespace) -> None: def show_command(args: argparse.Namespace) -> None:
flake_path = args.flake.path flake_path = args.flake.path
meta = show_clan_meta(flake_path) meta = get_clan_details(flake_path)
print(f"Name: {meta.get('name')}") print(f"Name: {meta.get('name')}")
print(f"Description: {meta.get('description', '-')}") print(f"Description: {meta.get('description', '-')}")

View File

@@ -122,7 +122,7 @@ def blk_from_dict(data: dict) -> BlkInfo:
@API.register @API.register
def show_block_devices() -> Blockdevices: def list_block_devices() -> Blockdevices:
""" """
Api method to show local block devices. Api method to show local block devices.

View File

@@ -1,12 +1,12 @@
from clan_lib.api import API from clan_lib.api import API
from clan_lib.errors import ClanError from clan_lib.errors import ClanError
from clan_lib.flake import Flake from clan_lib.flake import Flake
from clan_lib.nix_models.clan import InventoryMeta as Meta from clan_lib.nix_models.clan import InventoryMeta
from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.inventory_store import InventoryStore
@API.register @API.register
def show_clan_meta(flake: Flake) -> Meta: def get_clan_details(flake: Flake) -> InventoryMeta:
if flake.is_local and not flake.path.exists(): if flake.is_local and not flake.path.exists():
msg = f"Path {flake} does not exist" msg = f"Path {flake} does not exist"
raise ClanError(msg, description="clan directory does not exist") raise ClanError(msg, description="clan directory does not exist")

View File

@@ -0,0 +1,81 @@
{ self }:
{
meta.name = "__CHANGE_ME__"; # Ensure this is unique among all clans you want to use.
inherit self;
machines = {
# "jon" will be the hostname of the machine
jon =
{ pkgs, ... }:
{
imports = [
./modules/shared.nix
./modules/disko.nix
./machines/jon/configuration.nix
];
nixpkgs.hostPlatform = "x86_64-linux";
# Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon";
# You can get your disk id by running the following command on the installer:
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
device = "/dev/disk/by-id/__CHANGE_ME__";
};
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
# Zerotier needs one controller to accept new nodes. Once accepted
# the controller can be offline and routing still works.
clan.core.networking.zerotier.controller.enable = true;
};
# "sara" will be the hostname of the machine
sara =
{ pkgs, ... }:
{
imports = [
./modules/shared.nix
./modules/disko.nix
./machines/sara/configuration.nix
];
nixpkgs.hostPlatform = "x86_64-linux";
# Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara";
# You can get your disk id by running the following command on the installer:
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
device = "/dev/disk/by-id/__CHANGE_ME__";
};
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
/*
After jon is deployed, uncomment the following line
This will allow sara to share the VPN overlay network with jon
The networkId is generated by the first deployment of jon
*/
# clan.core.networking.zerotier.networkId = builtins.readFile ../../vars/per-machine/jon/zerotier/zerotier-network-id/value;
};
};
}

View File

@@ -17,88 +17,13 @@
"x86_64-darwin" "x86_64-darwin"
"aarch64-darwin" "aarch64-darwin"
]; ];
imports = [ inputs.clan-core.flakeModules.default ]; imports = [
inputs.clan-core.flakeModules.default
];
# https://docs.clan.lol/guides/getting-started/flake-parts/ # https://docs.clan.lol/guides/getting-started/flake-parts/
clan = { clan = import ./clan.nix { inherit self; };
meta.name = "__CHANGE_ME__"; # Ensure this is unique among all clans you want to use.
inherit self;
machines = {
# "jon" will be the hostname of the machine
jon =
{ pkgs, ... }:
{
imports = [
./modules/shared.nix
./modules/disko.nix
./machines/jon/configuration.nix
];
nixpkgs.hostPlatform = "x86_64-linux";
# Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon";
# You can get your disk id by running the following command on the installer:
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
device = "/dev/disk/by-id/__CHANGE_ME__";
};
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
# Zerotier needs one controller to accept new nodes. Once accepted
# the controller can be offline and routing still works.
clan.core.networking.zerotier.controller.enable = true;
};
# "sara" will be the hostname of the machine
sara =
{ pkgs, ... }:
{
imports = [
./modules/shared.nix
./modules/disko.nix
./machines/sara/configuration.nix
];
nixpkgs.hostPlatform = "x86_64-linux";
# Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara";
# You can get your disk id by running the following command on the installer:
# Replace <IP> with the IP of the installer printed on the screen or by running the `ip addr` command.
# ssh root@<IP> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = {
device = "/dev/disk/by-id/__CHANGE_ME__";
};
# IMPORTANT! Add your SSH key here
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = throw ''
Don't forget to add your SSH key here!
users.users.root.openssh.authorizedKeys.keys = [ "<YOUR SSH_KEY>" ]
'';
/*
After jon is deployed, uncomment the following line
This will allow sara to share the VPN overlay network with jon
The networkId is generated by the first deployment of jon
*/
# clan.core.networking.zerotier.networkId = builtins.readFile ../../vars/per-machine/jon/zerotier/zerotier-network-id/value;
};
};
};
perSystem = perSystem =
{ pkgs, inputs', ... }: { pkgs, inputs', ... }:
{ {