rebrand to krata

This commit is contained in:
Alex Zenla
2024-02-21 20:57:46 +00:00
parent af50f1d996
commit c582f15c54
35 changed files with 139 additions and 136 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "hyphactrl"
name = "kratactrl"
version.workspace = true
edition = "2021"
resolver = "2"
@ -27,7 +27,7 @@ backhand = { workspace = true }
uuid = { workspace = true }
ipnetwork = { workspace = true }
[dependencies.hypha]
[dependencies.krata]
path = "../shared"
[dependencies.nix]
@ -50,5 +50,5 @@ path = "../libs/xen/xenstore"
path = "src/lib.rs"
[[bin]]
name = "hyphactl"
name = "kratactl"
path = "bin/control.rs"

View File

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use clap::{Parser, Subcommand};
use env_logger::Env;
use hyphactrl::ctl::{
use kratactrl::ctl::{
console::ControllerConsole,
destroy::ControllerDestroy,
launch::{ControllerLaunch, ControllerLaunchRequest},
@ -156,9 +156,9 @@ fn default_store_path() -> Option<PathBuf> {
let user_dirs = directories::UserDirs::new()?;
let mut path = user_dirs.home_dir().to_path_buf();
if path == PathBuf::from("/root") {
path.push("/var/lib/hypha")
path.push("/var/lib/krata")
} else {
path.push(".hypha");
path.push(".krata");
}
Some(path)
}

View File

@ -1,7 +1,7 @@
use crate::image::ImageInfo;
use anyhow::Result;
use backhand::{FilesystemWriter, NodeHeader};
use hypha::LaunchInfo;
use krata::LaunchInfo;
use log::trace;
use std::fs;
use std::fs::File;
@ -17,7 +17,7 @@ pub struct ConfigBlock<'a> {
impl ConfigBlock<'_> {
pub fn new<'a>(uuid: &Uuid, image_info: &'a ImageInfo) -> Result<ConfigBlock<'a>> {
let mut dir = std::env::temp_dir().clone();
dir.push(format!("hypha-cfg-{}", uuid));
dir.push(format!("krata-cfg-{}", uuid));
fs::create_dir_all(&dir)?;
let mut file = dir.clone();
file.push("config.squashfs");

View File

@ -23,20 +23,20 @@ impl ControllerDestroy<'_> {
let domid = info.domid;
let mut store = XsdClient::open()?;
let dom_path = store.get_domain_path(domid)?;
let uuid = match store.read_string_optional(format!("{}/hypha/uuid", dom_path).as_str())? {
let uuid = match store.read_string_optional(format!("{}/krata/uuid", dom_path).as_str())? {
None => {
return Err(anyhow!(
"domain {} was not found or not created by hypha",
"domain {} was not found or not created by krata",
domid
))
}
Some(value) => value,
};
if uuid.is_empty() {
return Err(anyhow!("unable to find hypha uuid based on the domain",));
return Err(anyhow!("unable to find krata uuid based on the domain",));
}
let uuid = Uuid::parse_str(&uuid)?;
let loops = store.read_string(format!("{}/hypha/loops", dom_path).as_str())?;
let loops = store.read_string(format!("{}/krata/loops", dom_path).as_str())?;
let loops = ControllerContext::parse_loop_set(&loops);
self.context.xen.destroy(domid)?;
for info in &loops {

View File

@ -2,10 +2,10 @@ use std::{fs, net::Ipv4Addr, str::FromStr};
use advmac::MacAddr6;
use anyhow::{anyhow, Result};
use hypha::{
use ipnetwork::Ipv4Network;
use krata::{
LaunchInfo, LaunchNetwork, LaunchNetworkIpv4, LaunchNetworkIpv6, LaunchNetworkResolver,
};
use ipnetwork::Ipv4Network;
use uuid::Uuid;
use xenclient::{DomainConfig, DomainDisk, DomainNetworkInterface};
use xenstore::client::XsdInterface;
@ -36,7 +36,7 @@ impl ControllerLaunch<'_> {
pub fn perform(&mut self, request: ControllerLaunchRequest) -> Result<(Uuid, u32)> {
let uuid = Uuid::new_v4();
let name = format!("hypha-{uuid}");
let name = format!("krata-{uuid}");
let image_info = self.compile(request.image)?;
let mut gateway_mac = MacAddr6::random();
@ -134,9 +134,9 @@ impl ControllerLaunch<'_> {
}],
filesystems: vec![],
extra_keys: vec![
("hypha/uuid".to_string(), uuid.to_string()),
("krata/uuid".to_string(), uuid.to_string()),
(
"hypha/loops".to_string(),
"krata/loops".to_string(),
format!(
"{}:{}:none,{}:{}:{}",
&image_squashfs_loop.path,
@ -146,29 +146,29 @@ impl ControllerLaunch<'_> {
cfgblk_dir_path,
),
),
("hypha/image".to_string(), request.image.to_string()),
("krata/image".to_string(), request.image.to_string()),
(
"hypha/network/guest/ipv4".to_string(),
"krata/network/guest/ipv4".to_string(),
format!("{}/{}", guest_ipv4, ipv4_network_mask),
),
(
"hypha/network/guest/ipv6".to_string(),
"krata/network/guest/ipv6".to_string(),
format!("{}/{}", guest_ipv6, ipv6_network_mask),
),
(
"hypha/network/guest/mac".to_string(),
"krata/network/guest/mac".to_string(),
container_mac_string.clone(),
),
(
"hypha/network/gateway/ipv4".to_string(),
"krata/network/gateway/ipv4".to_string(),
format!("{}/{}", gateway_ipv4, ipv4_network_mask),
),
(
"hypha/network/gateway/ipv6".to_string(),
"krata/network/gateway/ipv6".to_string(),
format!("{}/{}", gateway_ipv6, ipv6_network_mask),
),
(
"hypha/network/gateway/mac".to_string(),
"krata/network/gateway/mac".to_string(),
gateway_mac_string.clone(),
),
],
@ -193,7 +193,7 @@ impl ControllerLaunch<'_> {
];
for domid_candidate in self.context.xen.store.list_any("/local/domain")? {
let dom_path = format!("/local/domain/{}", domid_candidate);
let ip_path = format!("{}/hypha/network/guest/ipv4", dom_path);
let ip_path = format!("{}/krata/network/guest/ipv4", dom_path);
let existing_ip = self.context.xen.store.read_string_optional(&ip_path)?;
if let Some(existing_ip) = existing_ip {
let ipv4_network = Ipv4Network::from_str(&existing_ip)?;

View File

@ -60,7 +60,7 @@ impl ControllerContext {
let uuid_string = match self
.xen
.store
.read_string_optional(&format!("{}/hypha/uuid", &dom_path))?
.read_string_optional(&format!("{}/krata/uuid", &dom_path))?
{
None => continue,
Some(value) => value,
@ -71,22 +71,22 @@ impl ControllerContext {
let image = self
.xen
.store
.read_string_optional(&format!("{}/hypha/image", &dom_path))?
.read_string_optional(&format!("{}/krata/image", &dom_path))?
.unwrap_or("unknown".to_string());
let loops = self
.xen
.store
.read_string_optional(&format!("{}/hypha/loops", &dom_path))?
.read_string_optional(&format!("{}/krata/loops", &dom_path))?
.unwrap_or("".to_string());
let ipv4 = self
.xen
.store
.read_string_optional(&format!("{}/hypha/network/guest/ipv4", &dom_path))?
.read_string_optional(&format!("{}/krata/network/guest/ipv4", &dom_path))?
.unwrap_or("unknown".to_string());
let ipv6: String = self
.xen
.store
.read_string_optional(&format!("{}/hypha/network/guest/ipv6", &dom_path))?
.read_string_optional(&format!("{}/krata/network/guest/ipv6", &dom_path))?
.unwrap_or("unknown".to_string());
let loops = ControllerContext::parse_loop_set(&loops);
containers.push(ContainerInfo {
@ -105,7 +105,7 @@ impl ControllerContext {
for container in self.list()? {
let uuid_string = container.uuid.to_string();
let domid_string = container.domid.to_string();
if uuid_string == id || domid_string == id || id == format!("hypha-{}", uuid_string) {
if uuid_string == id || domid_string == id || id == format!("krata-{}", uuid_string) {
return Ok(Some(container));
}
}

View File

@ -97,7 +97,7 @@ impl ImageCompiler<'_> {
pub fn compile(&self, image: &ImageName) -> Result<ImageInfo> {
debug!("ImageCompiler compile image={image}");
let mut tmp_dir = std::env::temp_dir().clone();
tmp_dir.push(format!("hypha-compile-{}", Uuid::new_v4()));
tmp_dir.push(format!("krata-compile-{}", Uuid::new_v4()));
let mut image_dir = tmp_dir.clone();
image_dir.push("image");