-
Couldn't load subscription status.
- Fork 5
engineering: Update Host Configuration with sysext/confext paths #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 20 commits
46bd6e1
13c37b3
711c1b3
5613037
412f93b
1f10dfb
cd912ff
f351e60
b271ef8
83a3d09
0e54277
c41f1ea
6e4aefa
357190f
647b4d0
f3ef4f5
1beec72
1e5a9ab
6574217
3143e1c
4b5279c
ff0b194
bf4edc5
89cf9e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,47 @@ impl Subsystem for ExtensionsSubsystem { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| fn update_host_configuration(&self, ctx: &mut EngineContext) -> Result<(), TridentError> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this not need to happen for install? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean? This function is called in |
||
| // Update paths of sysexts in the Host Configuration. | ||
| for sysext in self | ||
| .extensions | ||
| .iter() | ||
| .filter(|ext| ext.ext_type == ExtensionType::Sysext) | ||
| { | ||
| // Find corresponding sysext in Host Configuration. | ||
| let hc_ext = ctx | ||
| .spec | ||
| .os | ||
| .sysexts | ||
| .iter_mut() | ||
| .find(|ext| ext.sha384 == sysext.sha384) | ||
| .structured(InternalError::Internal( | ||
| "Failed to find previously processed sysext in Host Configuration", | ||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ))?; | ||
| hc_ext.path = Some(sysext.path.clone()); | ||
| } | ||
|
|
||
| // Update paths of confexts in the Host Configuration. | ||
| for confext in self | ||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .extensions | ||
| .iter() | ||
| .filter(|ext| ext.ext_type == ExtensionType::Confext) | ||
| { | ||
| // Find corresponding confext in Host Configuration. | ||
| let hc_ext = ctx | ||
| .spec | ||
| .os | ||
| .confexts | ||
| .iter_mut() | ||
| .find(|ext| ext.sha384 == confext.sha384) | ||
| .structured(InternalError::Internal( | ||
| "Failed to find previously processed confext in Host Configuration", | ||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ))?; | ||
| hc_ext.path = Some(confext.path.clone()); | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl ExtensionsSubsystem { | ||
|
|
@@ -469,6 +510,7 @@ mod tests { | |
| use super::*; | ||
|
|
||
| use tempfile::TempDir; | ||
| use url::Url; | ||
|
|
||
| #[test] | ||
| fn test_populate_extensions_empty() { | ||
|
|
@@ -567,6 +609,103 @@ mod tests { | |
| assert!(mount_path.path().join("usr/lib/confexts").exists()); | ||
| assert!(mount_path.path().join("usr/local/lib/confexts").exists()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_update_host_configuration_sysexts() { | ||
| let mut ctx = EngineContext::default(); | ||
| ctx.spec.os.sysexts = vec![ | ||
| Extension { | ||
| url: Url::parse("https://example.com/sysext1.raw").unwrap(), | ||
| sha384: Sha384Hash::from("a".repeat(96)), | ||
| path: None, | ||
| }, | ||
| Extension { | ||
| url: Url::parse("https://example.com/sysext2.raw").unwrap(), | ||
| sha384: Sha384Hash::from("b".repeat(96)), | ||
| path: Some(PathBuf::from("/etc/extensions/sysext2.raw")), | ||
| }, | ||
| ]; | ||
|
|
||
| let subsystem = ExtensionsSubsystem { | ||
| extensions: vec![ | ||
| ExtensionData { | ||
| id: "sysext1".to_string(), | ||
| name: "sysext1".to_string(), | ||
| sha384: Sha384Hash::from("a".repeat(96)), | ||
| path: PathBuf::from("/var/lib/extensions/sysext1.raw"), | ||
| temp_path: PathBuf::from(EXTENSION_IMAGE_STAGING_DIRECTORY).join("sysext1.raw"), | ||
ayaegashi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ext_type: ExtensionType::Sysext, | ||
| }, | ||
| ExtensionData { | ||
| id: "sysext2".to_string(), | ||
| name: "sysext2".to_string(), | ||
| sha384: Sha384Hash::from("b".repeat(96)), | ||
| path: PathBuf::from("/etc/extensions/sysext2.raw"), | ||
| temp_path: PathBuf::from(EXTENSION_IMAGE_STAGING_DIRECTORY).join("sysext2.raw"), | ||
|
|
||
| ext_type: ExtensionType::Sysext, | ||
| }, | ||
| ], | ||
| extensions_old: vec![], | ||
| }; | ||
| subsystem.update_host_configuration(&mut ctx).unwrap(); | ||
|
|
||
| for i in 0..subsystem.extensions.len() { | ||
| assert_eq!( | ||
| ctx.spec.os.sysexts[i].path, | ||
| Some(subsystem.extensions[i].path.clone()) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_update_host_configuration_confexts() { | ||
| let mut ctx = EngineContext::default(); | ||
| ctx.spec.os.confexts = vec![ | ||
| Extension { | ||
| url: Url::parse("https://example.com/confext1.raw").unwrap(), | ||
| sha384: Sha384Hash::from("a".repeat(96)), | ||
| path: None, | ||
| }, | ||
| Extension { | ||
| url: Url::parse("https://example.com/confext2.raw").unwrap(), | ||
| sha384: Sha384Hash::from("b".repeat(96)), | ||
| path: Some(PathBuf::from("/usr/lib/confexts/confext2.raw")), | ||
| }, | ||
| ]; | ||
|
|
||
| let subsystem = ExtensionsSubsystem { | ||
| extensions: vec![ | ||
| ExtensionData { | ||
| id: "confext1".to_string(), | ||
| name: "confext1".to_string(), | ||
| sha384: Sha384Hash::from("a".repeat(96)), | ||
| path: PathBuf::from("/var/lib/confexts/confext1.raw"), | ||
| temp_path: PathBuf::from(EXTENSION_IMAGE_STAGING_DIRECTORY) | ||
| .join("confext1.raw"), | ||
| ext_type: ExtensionType::Confext, | ||
| }, | ||
| ExtensionData { | ||
| id: "confext2".to_string(), | ||
| name: "confext2".to_string(), | ||
| sha384: Sha384Hash::from("b".repeat(96)), | ||
| path: PathBuf::from("/usr/lib/confexts/confext2.raw"), | ||
| temp_path: PathBuf::from("/var/lib/extensions/.staging/confext2.raw"), | ||
| ext_type: ExtensionType::Confext, | ||
| }, | ||
| ], | ||
| extensions_old: vec![], | ||
| }; | ||
| subsystem.update_host_configuration(&mut ctx).unwrap(); | ||
|
|
||
| for i in 0..subsystem.extensions.len() { | ||
| assert_eq!( | ||
| ctx.spec.os.confexts[i].path, | ||
| Some(subsystem.extensions[i].path.clone()) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "functional-test")] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.