Skip to content

Commit 44b2b84

Browse files
committed
feat: Add instance_uuid to the instance action schema
Change-Id: I5912a18f1a7f60b6eff96aeb9580eb2d05c3ebb6 Changes are triggered by https://review.opendev.org/947667
1 parent 7ce210b commit 44b2b84

File tree

5 files changed

+79
-67
lines changed

5 files changed

+79
-67
lines changed

openstack_tui/.config/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ views:
326326
compute.hypervisor:
327327
fields: [IP, HOSTNAME, STATUS, STATE]
328328
compute.server/instance_action/event:
329-
fields: [EVENT, RESULT, STARTED, FINISHED, HOST]
329+
fields: [EVENT, RESULT, START_TIME, FINISH_TIME, HOST]
330330
compute.server/instance_action:
331-
fields: [ID, ACTION, MESSAGE, STARTED, USER, "SERVER ID"]
331+
fields: [ID, ACTION, MESSAGE, START_TIME, USER_ID]
332332
compute.server:
333333
fields: [ID, NAME, STATUS, CREATED, UPDATED]
334334
# DNS

openstack_tui/src/components/compute/server_instance_action_events.rs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,45 @@ use crate::{
3030
config::Config,
3131
error::TuiError,
3232
mode::Mode,
33-
utils::{ResourceKey, as_string},
33+
utils::ResourceKey,
3434
};
3535

3636
const TITLE: &str = "InstanceAction Events";
3737
const VIEW_CONFIG_KEY: &str = "compute.server/instance_action/event";
3838

39-
#[derive(Deserialize, StructTable)]
39+
/// Event type
40+
#[derive(Clone, Debug, Deserialize, StructTable)]
4041
pub struct ServerInstanceActionEventData {
41-
#[structable(title = "EVENT")]
42-
event: String,
43-
#[structable(title = "RESULT")]
44-
#[serde(deserialize_with = "as_string")]
45-
result: String,
46-
#[structable(title = "STARTED", optional)]
47-
start_time: Option<String>,
48-
#[structable(title = "FINISHED", optional)]
49-
finish_time: Option<String>,
50-
#[structable(title = "HOST", optional)]
51-
host: Option<String>,
42+
/// Even details
43+
#[structable(optional)]
44+
pub details: Option<String>,
45+
46+
/// Event summary
47+
pub event: String,
48+
49+
/// Finish time of the event
50+
#[structable(optional)]
51+
pub finish_time: Option<String>,
52+
53+
/// Hostname
54+
#[structable(optional)]
55+
pub host: Option<String>,
56+
57+
/// Host ID
58+
#[structable(optional)]
59+
pub host_id: Option<String>,
60+
61+
/// Result
62+
#[structable(optional)]
63+
pub result: Option<String>,
64+
65+
/// Event start time
66+
#[structable(optional)]
67+
pub start_time: Option<String>,
68+
69+
/// Traceback
70+
#[structable(optional)]
71+
pub traceback: Option<String>,
5272
}
5373

5474
impl ResourceKey for ServerInstanceActionEventData {

openstack_tui/src/components/compute/server_instance_actions.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
use crossterm::event::KeyEvent;
1616
use eyre::{Result, WrapErr};
1717
use ratatui::prelude::*;
18-
use serde::Deserialize;
19-
use structable::{StructTable, StructTableOptions};
2018
use tokio::sync::mpsc::UnboundedSender;
2119

20+
use openstack_types::compute::v2::server::instance_action::response::list::InstanceActionResponse;
21+
2222
use crate::{
2323
action::Action,
2424
cloud_worker::compute::v2::{
@@ -36,31 +36,14 @@ use crate::{
3636
const TITLE: &str = "ServerInstanceAction Actions";
3737
const VIEW_CONFIG_KEY: &str = "compute.server/instance_action";
3838

39-
#[derive(Deserialize, StructTable)]
40-
pub struct ServerInstanceActionData {
41-
#[structable(title = "ID", wide)]
42-
#[serde(rename = "request_id")]
43-
id: String,
44-
#[structable(title = "ACTION")]
45-
action: String,
46-
#[structable(title = "MESSAGE", optional)]
47-
message: Option<String>,
48-
#[structable(title = "STARTED")]
49-
start_time: String,
50-
#[structable(title = "USER")]
51-
user_id: String,
52-
#[structable(title = "SERVER ID", wide)]
53-
instance_uuid: String,
54-
}
55-
56-
impl ResourceKey for ServerInstanceActionData {
39+
impl ResourceKey for InstanceActionResponse {
5740
fn get_key() -> &'static str {
5841
VIEW_CONFIG_KEY
5942
}
6043
}
6144

6245
pub type ComputeServerInstanceActions<'a> =
63-
TableViewComponentBase<'a, ServerInstanceActionData, ComputeServerInstanceActionList>;
46+
TableViewComponentBase<'a, InstanceActionResponse, ComputeServerInstanceActionList>;
6447

6548
impl Component for ComputeServerInstanceActions<'_> {
6649
fn register_config_handler(&mut self, config: Config) -> Result<(), TuiError> {
@@ -130,8 +113,10 @@ impl Component for ComputeServerInstanceActions<'_> {
130113
if let Some(selected_entry) = self.get_selected() {
131114
// send action to set server instance action filters
132115
let mut req = ComputeServerInstanceActionShowBuilder::default();
133-
req.id(selected_entry.id.clone());
134-
req.server_id(selected_entry.instance_uuid.clone());
116+
req.id(selected_entry.request_id.clone());
117+
if let Some(sid) = &selected_entry.instance_uuid {
118+
req.server_id(sid.clone());
119+
}
135120
if let Some(name) = &self.get_filters().server_name {
136121
req.server_name(name.clone());
137122
}

openstack_types/src/compute/v2/server/instance_action/response/get.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ pub struct InstanceActionResponse {
3737
#[structable(serialize)]
3838
pub events: Vec<Events>,
3939

40+
/// The UUID of the server.
41+
#[serde(default)]
42+
#[structable(optional)]
43+
pub instance_uuid: Option<String>,
44+
4045
/// The related error message for when an action fails.
4146
#[serde(default)]
4247
#[structable(optional)]
@@ -50,7 +55,17 @@ pub struct InstanceActionResponse {
5055
#[structable()]
5156
pub request_id: String,
5257

53-
/// The date and time when the action was started.
58+
/// The date and time when the action was started. The date and time stamp
59+
/// format is [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
60+
///
61+
/// ```text
62+
/// CCYY-MM-DDThh:mm:ss±hh:mm
63+
///
64+
/// ```
65+
///
66+
/// For example, `2015-08-27T09:49:58-05:00`. The `±hh:mm` value, if
67+
/// included, is the time zone as an offset from UTC. In the previous
68+
/// example, the offset value is `-05:00`.
5469
#[serde(default)]
5570
#[structable(optional)]
5671
pub start_time: Option<String>,
@@ -74,10 +89,11 @@ pub struct InstanceActionResponse {
7489
pub updated_at: Option<String>,
7590

7691
/// The ID of the user which initiated the server action.
77-
#[structable()]
78-
pub user_id: String,
92+
#[structable(optional)]
93+
pub user_id: Option<String>,
7994
}
8095

96+
/// Event
8197
/// `Events` type
8298
#[derive(Clone, Debug, Deserialize, Serialize)]
8399
pub struct Events {

openstack_types/src/compute/v2/server/instance_action/response/list.rs

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ pub struct InstanceActionResponse {
2626
#[structable()]
2727
pub action: String,
2828

29-
/// The events which occurred in this action in descending order of
30-
/// creation.
31-
///
32-
/// Policy defaults enable only users with the administrative role or the
33-
/// owner of the server to see instance action event information. Cloud
34-
/// providers can change these permissions through the `policy.json` file.
35-
///
36-
/// **New in version 2.51**
37-
#[structable(serialize)]
38-
pub events: Vec<Events>,
29+
/// The UUID of the server.
30+
#[serde(default)]
31+
#[structable(optional)]
32+
pub instance_uuid: Option<String>,
3933

4034
/// The related error message for when an action fails.
4135
#[serde(default)]
@@ -50,7 +44,17 @@ pub struct InstanceActionResponse {
5044
#[structable()]
5145
pub request_id: String,
5246

53-
/// The date and time when the action was started.
47+
/// The date and time when the action was started. The date and time stamp
48+
/// format is [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
49+
///
50+
/// ```text
51+
/// CCYY-MM-DDThh:mm:ss±hh:mm
52+
///
53+
/// ```
54+
///
55+
/// For example, `2015-08-27T09:49:58-05:00`. The `±hh:mm` value, if
56+
/// included, is the time zone as an offset from UTC. In the previous
57+
/// example, the offset value is `-05:00`.
5458
#[serde(default)]
5559
#[structable(optional)]
5660
pub start_time: Option<String>,
@@ -74,19 +78,6 @@ pub struct InstanceActionResponse {
7478
pub updated_at: Option<String>,
7579

7680
/// The ID of the user which initiated the server action.
77-
#[structable()]
78-
pub user_id: String,
79-
}
80-
81-
/// `Events` type
82-
#[derive(Clone, Debug, Deserialize, Serialize)]
83-
pub struct Events {
84-
pub details: Option<String>,
85-
pub event: String,
86-
pub finish_time: Option<String>,
87-
pub host: Option<String>,
88-
pub host_id: Option<String>,
89-
pub result: Option<String>,
90-
pub start_time: Option<String>,
91-
pub traceback: Option<String>,
81+
#[structable(optional)]
82+
pub user_id: Option<String>,
9283
}

0 commit comments

Comments
 (0)