-
Notifications
You must be signed in to change notification settings - Fork 85
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
update: add support for netavark update
command
#503
Merged
openshift-merge-robot
merged 1 commit into
containers:main
from
flouthoc:netavark-network-update
Dec 5, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod setup; | ||
pub mod teardown; | ||
pub mod update; | ||
pub mod version; |
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,59 @@ | ||
use crate::dns::aardvark::Aardvark; | ||
use crate::error::{NetavarkError, NetavarkResult}; | ||
use crate::network::core_utils; | ||
|
||
use clap::Parser; | ||
use log::debug; | ||
use std::path::Path; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Update { | ||
/// Network name to update | ||
#[clap(forbid_empty_values = true, required = true)] | ||
network_name: String, | ||
/// DNS Servers to update for the network | ||
#[clap(long, required = true, forbid_empty_values = true)] | ||
network_dns_servers: Vec<String>, | ||
} | ||
|
||
impl Update { | ||
/// Updates network dns servers for an already configured network | ||
pub fn new(network_name: String, network_dns_servers: Vec<String>) -> Self { | ||
Self { | ||
network_name, | ||
network_dns_servers, | ||
} | ||
} | ||
|
||
pub fn exec( | ||
&self, | ||
config_dir: String, | ||
aardvark_bin: String, | ||
rootless: bool, | ||
) -> NetavarkResult<()> { | ||
let dns_port = core_utils::get_netavark_dns_port()?; | ||
|
||
if Path::new(&aardvark_bin).exists() { | ||
let path = Path::new(&config_dir).join("aardvark-dns"); | ||
if let Ok(path_string) = path.into_os_string().into_string() { | ||
let aardvark_interface = | ||
Aardvark::new(path_string, rootless, aardvark_bin, dns_port); | ||
if let Err(err) = aardvark_interface | ||
.modify_network_dns_servers(&self.network_name, &self.network_dns_servers) | ||
{ | ||
return Err(NetavarkError::wrap( | ||
"unable to modify network dns servers", | ||
NetavarkError::Io(err), | ||
)); | ||
} | ||
} else { | ||
return Err(NetavarkError::msg( | ||
"Unable to parse aardvark config directory", | ||
)); | ||
} | ||
} | ||
|
||
debug!("Network update complete"); | ||
Ok(()) | ||
} | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not relevant to the test, just remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not understand this bit, we are just getting a random port for the test since we are still starting the aardvark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean don't pass anything and default to
53
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but now that I look at it again I think this is fine since we should make sure the changed dns port still works.