adapting CLI to the surreal brain
This commit is contained in:
parent
fb8558f7a9
commit
8c58aa59ef
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1182,7 +1182,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "detee-shared"
|
name = "detee-shared"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@gitea.detee.cloud/testnet/proto.git?branch=main#b5289f1f5ba3ddae2ee066d6deb073ce92436b71"
|
source = "git+ssh://git@gitea.detee.cloud/testnet/proto.git?branch=surreal_brain#fb38352e1b47837b14f32d8df5ae7f6b17202aae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"prost",
|
"prost",
|
||||||
|
@ -34,7 +34,7 @@ tokio-retry = "0.3.0"
|
|||||||
detee-sgx = { git = "ssh://git@gitea.detee.cloud/testnet/detee-sgx.git", branch = "hratls", features=["hratls", "qvl"] }
|
detee-sgx = { git = "ssh://git@gitea.detee.cloud/testnet/detee-sgx.git", branch = "hratls", features=["hratls", "qvl"] }
|
||||||
shadow-rs = { version = "1.1.1", features = ["metadata"] }
|
shadow-rs = { version = "1.1.1", features = ["metadata"] }
|
||||||
|
|
||||||
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto.git", branch = "main" }
|
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto.git", branch = "surreal_brain" }
|
||||||
# detee-shared = { path = "../detee-shared" }
|
# detee-shared = { path = "../detee-shared" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -309,7 +309,7 @@ impl Config {
|
|||||||
|
|
||||||
pub fn get_brain_info() -> (String, String) {
|
pub fn get_brain_info() -> (String, String) {
|
||||||
match Self::init_config().network.as_str() {
|
match Self::init_config().network.as_str() {
|
||||||
"staging" => ("https://159.65.58.38:31337".to_string(), "staging-brain".to_string()),
|
"staging" => ("https://149.36.48.100:31337".to_string(), "staging-brain".to_string()),
|
||||||
"localhost" => ("https://localhost:31337".to_string(), "staging-brain".to_string()),
|
"localhost" => ("https://localhost:31337".to_string(), "staging-brain".to_string()),
|
||||||
_ => ("https://164.92.249.180:31337".to_string(), "testnet-brain".to_string()),
|
_ => ("https://164.92.249.180:31337".to_string(), "testnet-brain".to_string()),
|
||||||
}
|
}
|
||||||
|
@ -49,18 +49,18 @@ impl crate::HumanOutput for VmContract {
|
|||||||
"The VM {} has the UUID {}, and it runs on the node {}",
|
"The VM {} has the UUID {}, and it runs on the node {}",
|
||||||
self.hostname, self.uuid, self.node_pubkey
|
self.hostname, self.uuid, self.node_pubkey
|
||||||
);
|
);
|
||||||
if self.public_ipv4.is_empty() {
|
if self.vm_public_ipv4.is_empty() {
|
||||||
println!(
|
println!(
|
||||||
"The VM has no public IPv4. The ports published by the VM are: {:?}",
|
"The VM has no public IPv4. The ports mapped from the host to the VM are: {:?}",
|
||||||
self.exposed_ports
|
self.mapped_ports
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!("The Public IPv4 address of the VM is: {}", self.public_ipv4);
|
println!("The Public IPv4 address of the VM is: {}", self.vm_public_ipv4);
|
||||||
}
|
}
|
||||||
if self.public_ipv6.is_empty() {
|
if self.vm_public_ipv6.is_empty() {
|
||||||
println!("The VM does not have a public IPv6 address.");
|
println!("The VM does not have a public IPv6 address.");
|
||||||
} else {
|
} else {
|
||||||
println!("The Public IPv6 address of the VM is: {}", self.public_ipv6);
|
println!("The Public IPv6 address of the VM is: {}", self.vm_public_ipv6);
|
||||||
}
|
}
|
||||||
println!(
|
println!(
|
||||||
"The VM has {} vCPUS, {}MB of memory and a disk of {} GB.",
|
"The VM has {} vCPUS, {}MB of memory and a disk of {} GB.",
|
||||||
|
@ -64,20 +64,16 @@ impl TryFrom<grpc::proto::VmContract> for VmSshArgs {
|
|||||||
args.user = "root".to_string();
|
args.user = "root".to_string();
|
||||||
args.key_path =
|
args.key_path =
|
||||||
Config::init_config().get_ssh_pubkey()?.trim_end_matches(".pub").to_string();
|
Config::init_config().get_ssh_pubkey()?.trim_end_matches(".pub").to_string();
|
||||||
if !contract.public_ipv4.is_empty() {
|
if !contract.vm_public_ipv4.is_empty() {
|
||||||
args.ip = contract.public_ipv4;
|
args.ip = contract.vm_public_ipv4;
|
||||||
args.port = "22".to_string();
|
args.port = "22".to_string();
|
||||||
} else {
|
} else {
|
||||||
args.port = contract.exposed_ports[0].to_string();
|
args.port = contract.mapped_ports[0].host_port.to_string();
|
||||||
log::info!(
|
log::debug!(
|
||||||
"This VM does not have a public IP. Getting node IP for node {}",
|
"This VM does not have a public IP. Using node public IP: {}",
|
||||||
contract.node_pubkey
|
contract.node_ip
|
||||||
);
|
);
|
||||||
let node = block_on(snp::grpc::get_one_node(proto::VmNodeFilters {
|
args.ip = contract.node_ip;
|
||||||
node_pubkey: contract.node_pubkey.clone(),
|
|
||||||
..Default::default()
|
|
||||||
}))?;
|
|
||||||
args.ip = node.ip;
|
|
||||||
}
|
}
|
||||||
Ok(args)
|
Ok(args)
|
||||||
}
|
}
|
||||||
@ -97,12 +93,6 @@ pub struct Dtrfs {
|
|||||||
|
|
||||||
impl Dtrfs {
|
impl Dtrfs {
|
||||||
pub fn print_dtrfs_list() -> Vec<Self> {
|
pub fn print_dtrfs_list() -> Vec<Self> {
|
||||||
// let mut dtrfs_vec = Vec::new();
|
|
||||||
// dtrfs_vec.push(DEFAULT_DTRFS.clone());
|
|
||||||
// dtrfs_vec.push(ALTERNATIVE_INIT[0].clone());
|
|
||||||
// dtrfs_vec.push(ALTERNATIVE_INIT[1].clone());
|
|
||||||
// dtrfs_vec
|
|
||||||
|
|
||||||
vec![DEFAULT_DTRFS.clone(), ALTERNATIVE_INIT[0].clone(), ALTERNATIVE_INIT[1].clone()]
|
vec![DEFAULT_DTRFS.clone(), ALTERNATIVE_INIT[0].clone(), ALTERNATIVE_INIT[1].clone()]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,15 +124,6 @@ impl super::HumanOutput for Vec<Distro> {
|
|||||||
|
|
||||||
impl Distro {
|
impl Distro {
|
||||||
pub fn get_template_list() -> Vec<Self> {
|
pub fn get_template_list() -> Vec<Self> {
|
||||||
// let mut distro_vec = Vec::new();
|
|
||||||
// distro_vec.push(DEFAULT_ARCHLINUX.clone());
|
|
||||||
// distro_vec.push(DEFAULT_UBUNTU.clone());
|
|
||||||
// distro_vec.push(DEFAULT_FEDORA.clone());
|
|
||||||
// distro_vec.push(ALTERNATIVE_DISTROS[0].clone());
|
|
||||||
// distro_vec.push(ALTERNATIVE_DISTROS[1].clone());
|
|
||||||
// distro_vec.push(ALTERNATIVE_DISTROS[2].clone());
|
|
||||||
// distro_vec
|
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
DEFAULT_ARCHLINUX.clone(),
|
DEFAULT_ARCHLINUX.clone(),
|
||||||
DEFAULT_UBUNTU.clone(),
|
DEFAULT_UBUNTU.clone(),
|
||||||
@ -203,25 +184,13 @@ fn display_mins(minutes: &u64) -> String {
|
|||||||
|
|
||||||
impl From<proto::VmContract> for VmContract {
|
impl From<proto::VmContract> for VmContract {
|
||||||
fn from(brain_contract: proto::VmContract) -> Self {
|
fn from(brain_contract: proto::VmContract) -> Self {
|
||||||
let node_pubkey = brain_contract.node_pubkey.clone();
|
|
||||||
let location = match block_on(snp::grpc::get_one_node(proto::VmNodeFilters {
|
|
||||||
node_pubkey: node_pubkey.clone(),
|
|
||||||
..Default::default()
|
|
||||||
})) {
|
|
||||||
Ok(node) => format!("{}, {} ({})", node.city, node.region, node.country),
|
|
||||||
Err(e) => {
|
|
||||||
log::warn!("Could not get information about node {node_pubkey} fram brain: {e:?}");
|
|
||||||
String::new()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
uuid: brain_contract.uuid,
|
uuid: brain_contract.uuid,
|
||||||
hostname: brain_contract.hostname,
|
hostname: brain_contract.hostname,
|
||||||
vcpus: brain_contract.vcpus,
|
vcpus: brain_contract.vcpus,
|
||||||
mem: brain_contract.memory_mb,
|
mem: brain_contract.memory_mb,
|
||||||
disk: brain_contract.disk_size_gb,
|
disk: brain_contract.disk_size_gb,
|
||||||
location,
|
location: brain_contract.location,
|
||||||
cost_h: (brain_contract.nano_per_minute * 60) as f64 / 1_000_000_000.0,
|
cost_h: (brain_contract.nano_per_minute * 60) as f64 / 1_000_000_000.0,
|
||||||
time_left: brain_contract.locked_nano / brain_contract.nano_per_minute,
|
time_left: brain_contract.locked_nano / brain_contract.nano_per_minute,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user