Fix: host ip override
Add default host IP address retrieval to HostConfig and update its references
This commit is contained in:
parent
7e4ab4dd52
commit
bfb4e9b487
@ -1,9 +1,12 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::global::IP_INFO;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct HostConfig {
|
pub struct HostConfig {
|
||||||
pub brain_url: String,
|
pub brain_url: String,
|
||||||
|
#[serde(default = "retrieve_node_ip")]
|
||||||
pub host_ip_address: String,
|
pub host_ip_address: String,
|
||||||
pub operator_wallet: String,
|
pub operator_wallet: String,
|
||||||
pub max_cores_per_app: u32,
|
pub max_cores_per_app: u32,
|
||||||
@ -25,6 +28,10 @@ fn default_reserved_no_of_port() -> u32 {
|
|||||||
16
|
16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn retrieve_node_ip() -> String {
|
||||||
|
IP_INFO.ip.clone()
|
||||||
|
}
|
||||||
|
|
||||||
impl HostConfig {
|
impl HostConfig {
|
||||||
pub fn load_from_disk(path: &str) -> Result<Self> {
|
pub fn load_from_disk(path: &str) -> Result<Self> {
|
||||||
let content = std::fs::read_to_string(path)?;
|
let content = std::fs::read_to_string(path)?;
|
||||||
|
@ -31,7 +31,7 @@ pub async fn register_node(config: &crate::HostConfig) -> Result<Vec<AppContract
|
|||||||
let req = RegisterAppNodeReq {
|
let req = RegisterAppNodeReq {
|
||||||
node_pubkey: PUBLIC_KEY.to_string(),
|
node_pubkey: PUBLIC_KEY.to_string(),
|
||||||
operator_wallet: config.operator_wallet.clone(),
|
operator_wallet: config.operator_wallet.clone(),
|
||||||
main_ip: IP_INFO.ip.clone(),
|
main_ip: config.host_ip_address.clone(),
|
||||||
city: IP_INFO.city.clone(),
|
city: IP_INFO.city.clone(),
|
||||||
region: IP_INFO.region.clone(),
|
region: IP_INFO.region.clone(),
|
||||||
country: IP_INFO.country.clone(),
|
country: IP_INFO.country.clone(),
|
||||||
|
@ -112,10 +112,9 @@ impl AppHandler {
|
|||||||
|
|
||||||
match app_result {
|
match app_result {
|
||||||
Ok(app) => {
|
Ok(app) => {
|
||||||
// TODO: update host resources to brain
|
|
||||||
self.send_node_resources().await;
|
self.send_node_resources().await;
|
||||||
|
|
||||||
info!("Succesfully started VM {uuid}");
|
info!("Succesfully started App {uuid}");
|
||||||
let res = NewAppRes {
|
let res = NewAppRes {
|
||||||
uuid,
|
uuid,
|
||||||
status: "success".to_string(),
|
status: "success".to_string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user