Skip to content

Commit

Permalink
kata-ctl: Re-enable network checks on s390x
Browse files Browse the repository at this point in the history
Fixes: kata-containers#5438

Signed-off-by: Hendrik Brueckner <[email protected]>
  • Loading branch information
hbrueckner committed Oct 18, 2022
1 parent 9f2c7e4 commit 303b379
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/tools/kata-ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# SPDX-License-Identifier: Apache-2.0
#

[workspace]
resolver = "2"

[package]
name = "kata-ctl"
version = "0.0.1"
Expand All @@ -12,9 +15,14 @@ edition = "2018"
[dependencies]
anyhow = "1.0.31"
clap = { version = "3.2.20", features = ["derive", "cargo"] }
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
serde_json = "1.0.85"
thiserror = "1.0.35"

[target.'cfg(target_arch = "s390x")'.dependencies]
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "native-tls"] }

[target.'cfg(not(target_arch = "s390x"))'.dependencies]
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }

[dev-dependencies]
semver = "1.0.12"
21 changes: 19 additions & 2 deletions src/tools/kata-ctl/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ use anyhow::{anyhow, Result};
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
use serde_json::Value;
use std::collections::HashMap;
use std::fs;

const KATA_GITHUB_URL: &str =
"https://api.github.com/repos/kata-containers/kata-containers/releases/latest";

#[cfg(test)]
fn get_cpu_info(cpu_info_file: &str) -> Result<String> {
let contents = fs::read_to_string(cpu_info_file)?;
let contents = std::fs::read_to_string(cpu_info_file)?;
Ok(contents)
}

// get_single_cpu_info returns the contents of the first cpu from
// the specified cpuinfo file by parsing based on a specified delimiter
#[cfg(test)]
pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result<String> {
let contents = get_cpu_info(cpu_info_file)?;

Expand All @@ -40,6 +41,7 @@ pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result<Strin

// get_cpu_flags returns a string of cpu flags from cpuinfo, passed in
// as a string
#[cfg(test)]
pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result<String> {
if cpu_info.is_empty() {
return Err(anyhow!("cpu_info string is empty"))?;
Expand All @@ -63,6 +65,11 @@ pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result<String> {

// get_missing_strings searches for required (strings) in data and returns
// a vector containing the missing strings
#[cfg(any(
target_arch = "aarch64",
target_arch = "powerpc64le",
target_arch = "x86_64"
))]
fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<Vec<String>> {
let mut missing: Vec<String> = Vec::new();

Expand All @@ -75,6 +82,11 @@ fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<
Ok(missing)
}

#[cfg(any(
target_arch = "aarch64",
target_arch = "powerpc64le",
target_arch = "x86_64"
))]
pub fn check_cpu_flags(
retrieved_flags: &str,
required_flags: &'static [&'static str],
Expand All @@ -84,6 +96,11 @@ pub fn check_cpu_flags(
Ok(missing_flags)
}

#[cfg(any(
target_arch = "aarch64",
target_arch = "powerpc64le",
target_arch = "x86_64"
))]
pub fn check_cpu_attribs(
cpu_info: &str,
required_attribs: &'static [&'static str],
Expand Down

0 comments on commit 303b379

Please sign in to comment.