-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[reconfigurator] Add rendezvous_debug_dataset table
Also adds datastore methods and a library crate to populate it.
- Loading branch information
1 parent
2fe668d
commit 8c7db6d
Showing
16 changed files
with
822 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
use crate::schema::rendezvous_debug_dataset; | ||
use crate::typed_uuid::DbTypedUuid; | ||
use chrono::{DateTime, Utc}; | ||
use omicron_uuid_kinds::BlueprintKind; | ||
use omicron_uuid_kinds::BlueprintUuid; | ||
use omicron_uuid_kinds::DatasetKind; | ||
use omicron_uuid_kinds::DatasetUuid; | ||
use omicron_uuid_kinds::ZpoolKind; | ||
use omicron_uuid_kinds::ZpoolUuid; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Database representation of a Debug Dataset available for use. | ||
#[derive( | ||
Queryable, | ||
Insertable, | ||
Debug, | ||
Clone, | ||
Selectable, | ||
Deserialize, | ||
Serialize, | ||
PartialEq, | ||
)] | ||
#[diesel(table_name = rendezvous_debug_dataset)] | ||
pub struct RendezvousDebugDataset { | ||
id: DbTypedUuid<DatasetKind>, | ||
time_created: DateTime<Utc>, | ||
time_tombstoned: Option<DateTime<Utc>>, | ||
pool_id: DbTypedUuid<ZpoolKind>, | ||
blueprint_id_when_recorded: DbTypedUuid<BlueprintKind>, | ||
} | ||
|
||
impl RendezvousDebugDataset { | ||
pub fn new( | ||
id: DatasetUuid, | ||
pool_id: ZpoolUuid, | ||
blueprint_id: BlueprintUuid, | ||
) -> Self { | ||
Self { | ||
id: id.into(), | ||
time_created: Utc::now(), | ||
time_tombstoned: None, | ||
pool_id: pool_id.into(), | ||
blueprint_id_when_recorded: blueprint_id.into(), | ||
} | ||
} | ||
|
||
pub fn id(&self) -> DatasetUuid { | ||
self.id.into() | ||
} | ||
|
||
pub fn pool_id(&self) -> ZpoolUuid { | ||
self.pool_id.into() | ||
} | ||
|
||
pub fn blueprint_id_when_recorded(&self) -> BlueprintUuid { | ||
self.blueprint_id_when_recorded.into() | ||
} | ||
|
||
pub fn is_tombstoned(&self) -> bool { | ||
self.time_tombstoned.is_some() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.