1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
pub use ppcore_def::*;
use serde::{Deserialize, Serialize};
pub const OPS_ID_LEN: usize = 4;
pub const DEFAULT_REQ_ID: u64 = std::u64::MAX;
pub type UUID = u64;
pub type ServerAddr = String;
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct Req<T: Serialize> {
pub uuid: u64,
pub cli_id: Option<CliId>,
pub msg: T,
}
impl<T: Serialize> Req<T> {
pub fn new(uuid: u64, msg: T) -> Self {
Self::newx(uuid, None, msg)
}
pub fn newx(uuid: u64, cli_id: Option<CliId>, msg: T) -> Self {
Req { uuid, cli_id, msg }
}
}
#[allow(missing_docs)]
#[derive(
Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd,
)]
pub enum RetStatus {
Fail,
Success,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Resp {
pub uuid: u64,
pub status: RetStatus,
pub msg: Vec<u8>,
}
#[allow(missing_docs)]
#[derive(
Clone,
Debug,
Default,
Deserialize,
Serialize,
Eq,
PartialEq,
Ord,
PartialOrd,
)]
pub struct RespGetServerInfo {
pub vm_total: u32,
pub cpu_total: u32,
pub cpu_used: u32,
pub mem_total: u32,
pub mem_used: u32,
pub disk_total: u32,
pub disk_used: u32,
pub supported_list: Vec<String>,
}
pub type RespGetEnvList = Vec<EnvMeta>;
#[allow(missing_docs)]
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ReqGetEnvInfo {
pub env_set: Vec<EnvId>,
}
pub type RespGetEnvInfo = Vec<EnvInfo>;
#[allow(missing_docs)]
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ReqAddEnv {
pub env_id: EnvId,
pub vm_kind: Option<VmKind>,
pub os_prefix: Vec<String>,
pub life_time: Option<u64>,
pub cpu_num: Option<u32>,
pub mem_size: Option<u32>,
pub disk_size: Option<u32>,
pub port_set: Vec<Port>,
pub dup_each: Option<u8>,
}
#[allow(missing_docs)]
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ReqUpdateEnvLife {
pub env_id: EnvId,
pub life_time: u64,
pub is_fucker: bool,
}
#[allow(missing_docs)]
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ReqDelEnv {
pub env_id: EnvId,
}
#[allow(missing_docs)]
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ReqUpdateEnvKickVm {
pub env_id: EnvId,
pub os_prefix: Vec<String>,
}