Virtual machine Management Terminal User Interface
修訂 | b0c6d0e1a367fca204f3c23405a25dc08d9f5f9c (tree) |
---|---|
時間 | 2022-05-04 13:23:29 |
作者 | Koine Yuusuke(koinec) <koinec@user...> |
Commiter | Koine Yuusuke(koinec) |
[Implement] show HVisor Status
[Implement] show Guest Status Color
@@ -84,8 +84,12 @@ int | ||
84 | 84 | |
85 | 85 | if( has_colors() ) { |
86 | 86 | start_color(); |
87 | + // init_pair( 0, COLOR_WHITE, COLOR_BLACK ); // VMList Guest | |
87 | 88 | init_pair( 1, COLOR_WHITE, COLOR_BLACK ); // VMList Guest |
88 | - init_pair( 2, COLOR_GREEN, COLOR_BLACK ); // VMList HVisor | |
89 | + init_pair( 2, COLOR_GREEN, COLOR_BLACK ); // VMList HVisor (Running) | |
90 | + init_pair( 3, COLOR_CYAN, COLOR_BLACK ); // VMList Guest (Running) | |
91 | + init_pair( 4, COLOR_YELLOW, COLOR_BLACK ); // VMList Guest (Others) | |
92 | + init_pair( 5, COLOR_RED, COLOR_BLACK ); // VMList HVisor (Not Running) | |
89 | 93 | init_pair( 10, COLOR_YELLOW, COLOR_BLUE ); // VmTui Title Line |
90 | 94 | init_pair( 11, COLOR_WHITE, COLOR_BLUE ); // Guest Info Title Line |
91 | 95 | init_pair( 12, COLOR_GREEN, COLOR_BLUE ); // HVisor Info Title Line |
@@ -162,11 +162,12 @@ int | ||
162 | 162 | int i_now; |
163 | 163 | int i_end; |
164 | 164 | int i_line = 0; |
165 | + int i_attr; | |
165 | 166 | HVisor *p_hvisor; |
166 | 167 | Guest *p_guest; |
167 | 168 | VmList_Item *p_item; |
168 | 169 | char str_fmt[32]; |
169 | - char str_gstat[8]; | |
170 | + char str_stat[16]; | |
170 | 171 | |
171 | 172 | i_err = TuiVmList_CreateList(); |
172 | 173 |
@@ -189,18 +190,28 @@ int | ||
189 | 190 | |
190 | 191 | if( GUEST_ID_NONE == p_item->i_guest ) { |
191 | 192 | // HVisor --- |
193 | + p_hvisor = HVisor_Ref( p_item->i_hvisor ); | |
194 | + | |
195 | + if( HVISOR_STATUS_CONNECTED & p_hvisor->dw_status ) { | |
196 | + strncpy( str_stat, "* ONLINE", 15 ); | |
197 | + i_attr = COLOR_PAIR(2); // Green-Black | |
198 | + } | |
199 | + else { | |
200 | + strncpy( str_stat, "X NotConnect", 15 ); | |
201 | + i_attr = COLOR_PAIR(5); // Red-Black | |
202 | + } | |
203 | + | |
192 | 204 | if( gi_line_now == i_line ) |
193 | - { wattrset( gp_vmlist_win, COLOR_PAIR(2) | A_BOLD | A_REVERSE ); } | |
205 | + { wattrset( gp_vmlist_win, i_attr | A_BOLD | A_REVERSE ); } | |
194 | 206 | else |
195 | - { wattrset( gp_vmlist_win, COLOR_PAIR(2) | A_BOLD ); } | |
207 | + { wattrset( gp_vmlist_win, i_attr | A_BOLD ); } | |
196 | 208 | |
197 | - p_hvisor = HVisor_Ref( p_item->i_hvisor ); | |
198 | 209 | |
199 | - // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(8) | |
210 | + // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(10) | |
200 | 211 | // ConnectType: "Local", "SSH(vmbhyve) |
201 | - snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-8s", | |
202 | - (COLS - 2 - 16 - 8 - 2 - 2) , (COLS - 2 - 16 - 8 - 2 - 2) ); | |
203 | - mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_hvisor->str_name, "contype", "state" ); | |
212 | + snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-14s", | |
213 | + (COLS - 2 - 16 - 14 - 2 - 2) , (COLS - 2 - 16 - 14 - 2 - 2) ); | |
214 | + mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_hvisor->str_name, "contype", str_stat ); | |
204 | 215 | |
205 | 216 | HVisor_Release( p_hvisor ); |
206 | 217 |
@@ -208,35 +219,41 @@ int | ||
208 | 219 | } |
209 | 220 | else { |
210 | 221 | // Guest --- |
211 | - if( gi_line_now == i_line ) | |
212 | - { wattrset( gp_vmlist_win, COLOR_PAIR(0) | A_REVERSE ); } | |
213 | - else | |
214 | - { wattrset( gp_vmlist_win, COLOR_PAIR(0) ); } | |
215 | - | |
216 | 222 | p_guest = Guest_Ref( p_item->i_guest ); |
217 | 223 | |
218 | 224 | switch( p_guest->dw_status ) { |
219 | 225 | case GUEST_STATUS_STOP: |
220 | - strncpy( str_gstat, "Stop", 7 ); | |
226 | + strncpy( str_stat, " Stop", 15 ); | |
227 | + i_attr = COLOR_PAIR(1); // White-Black | |
221 | 228 | break; |
222 | 229 | case GUEST_STATUS_RUN: |
223 | - strncpy( str_gstat, "RUN", 7 ); | |
230 | + strncpy( str_stat, "* RUN", 15 ); | |
231 | + i_attr = COLOR_PAIR(3); // Cyan-Black | |
224 | 232 | break; |
225 | 233 | case GUEST_STATUS_WAIT: |
226 | - strncpy( str_gstat, "Wait", 7 ); | |
234 | + strncpy( str_stat, "- Wait", 15 ); | |
235 | + i_attr = COLOR_PAIR(4); // Yellow-Black | |
227 | 236 | break; |
228 | 237 | case GUEST_STATUS_UNKNOWN: |
229 | - strncpy( str_gstat, "UNKNOWN", 7 ); | |
238 | + strncpy( str_stat, "? UNKNOWN", 15 ); | |
239 | + i_attr = COLOR_PAIR(4); // Yellow-Black | |
230 | 240 | break; |
231 | 241 | default: |
232 | - strncpy( str_gstat, "BUG!!", 7 ); | |
242 | + strncpy( str_stat, "! BUG!!", 15 ); | |
243 | + i_attr = COLOR_PAIR(4); // Yellow-Black | |
233 | 244 | break; |
234 | 245 | } |
235 | 246 | |
247 | + if( gi_line_now == i_line ) | |
248 | + { wattrset( gp_vmlist_win, i_attr | A_REVERSE ); } | |
249 | + else | |
250 | + { wattrset( gp_vmlist_win, i_attr ); } | |
236 | 251 | |
237 | - snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-8s", | |
238 | - (COLS - 4 - 16 - 8 - 2 - 2) , (COLS - 4 - 16 - 8 - 2 - 2) ); | |
239 | - mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_guest->str_vmname, "type", str_gstat ); | |
252 | + // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(10) | |
253 | + // ConnectType: "Local", "SSH(vmbhyve) | |
254 | + snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-14s", | |
255 | + (COLS - 4 - 16 - 14 - 2 - 2) , (COLS - 4 - 16 - 14 - 2 - 2) ); | |
256 | + mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_guest->str_vmname, "type", str_stat ); | |
240 | 257 | |
241 | 258 | Guest_Release( p_guest ); |
242 | 259 |