|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
#[cfg(feature = "server")] |
|
|
|
|
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; |
|
|
|
|
#[cfg(feature = "server")] |
|
|
|
|
use diesel_derive_enum::DbEnum; |
|
|
|
|
use serde::{Deserialize, Serialize}; |
|
|
|
|
use std::{fmt, time::SystemTime}; |
|
|
|
@ -6,19 +8,24 @@ use strum::Display; |
|
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
|
use crate::builder::NamedJobBuilder; |
|
|
|
|
#[cfg(feature = "server")] |
|
|
|
|
use crate::models::schema::*; |
|
|
|
|
use crate::{ |
|
|
|
|
config::get_self_uid, |
|
|
|
|
messaging::Reportable, |
|
|
|
|
models::schema::*, |
|
|
|
|
unwrap_enum, |
|
|
|
|
utils::{systime_to_string, Platform}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
use uuid::Uuid; |
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, DbEnum, Display)] |
|
|
|
|
#[PgType = "AgentState"] |
|
|
|
|
#[DieselType = "Agentstate"] |
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Display)] |
|
|
|
|
#[cfg_attr(
|
|
|
|
|
feature = "server", |
|
|
|
|
derive(DbEnum), |
|
|
|
|
PgType = "AgentState", |
|
|
|
|
DieselType = "Agentstate" |
|
|
|
|
)] |
|
|
|
|
pub enum AgentState { |
|
|
|
|
New, |
|
|
|
|
Active, |
|
|
|
@ -26,18 +33,12 @@ pub enum AgentState { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//belongs_to
|
|
|
|
|
#[derive(
|
|
|
|
|
Clone, |
|
|
|
|
Debug, |
|
|
|
|
Serialize, |
|
|
|
|
Deserialize, |
|
|
|
|
Identifiable, |
|
|
|
|
Queryable, |
|
|
|
|
Insertable, |
|
|
|
|
AsChangeset, |
|
|
|
|
PartialEq, |
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] |
|
|
|
|
#[cfg_attr(
|
|
|
|
|
feature = "server", |
|
|
|
|
derive(Identifiable, Queryable, Insertable, AsChangeset), |
|
|
|
|
table_name = "agents" |
|
|
|
|
)] |
|
|
|
|
#[table_name = "agents"] |
|
|
|
|
pub struct Agent { |
|
|
|
|
pub alias: Option<String>, |
|
|
|
|
pub hostname: String, |
|
|
|
@ -130,13 +131,13 @@ impl Default for Agent { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
|
mod tests { |
|
|
|
|
use super::*; |
|
|
|
|
// #[cfg(test)]
|
|
|
|
|
// mod tests {
|
|
|
|
|
// use super::*;
|
|
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
|
|
async fn test_gather() { |
|
|
|
|
let cli_info = Agent::gather().await; |
|
|
|
|
assert_eq!(cli_info.alias, None) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// #[tokio::test]
|
|
|
|
|
// async fn test_gather() {
|
|
|
|
|
// let cli_info = Agent::gather().await;
|
|
|
|
|
// assert_eq!(cli_info.alias, None)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|