Skip to content
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

Add aziot check #83

Merged
merged 41 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8390c75
rough framework for aziot check
daprilik Nov 26, 2020
e890bb0
improve project topology + add streaming-json output
daprilik Nov 24, 2020
5bd64a3
swap out dummy check for unimplemented well_formed_configs check
daprilik Nov 24, 2020
cb66c2e
integrate anyhow
daprilik Nov 26, 2020
cb9d16c
add well formed config checks
daprilik Dec 18, 2020
1a420d1
r u s t f m t
daprilik Nov 30, 2020
7ae2011
add hostname check
daprilik Nov 30, 2020
fafc435
port mini-sntp to aziot
daprilik Dec 2, 2020
afe3361
add host_local_time check
daprilik Dec 2, 2020
e06f1eb
add identity_certificate_expiry check
daprilik Dec 2, 2020
78ddfcf
add certs_preloaded check + tweak identity_cert_expirty
daprilik Dec 4, 2020
e77c38b
add HostConnectDpsEndpoint check
daprilik Dec 7, 2020
2c3d5bc
augment certs_preloaded check to validate nested ids
daprilik Dec 7, 2020
0f93bcc
fine-grained skipping based on which configs are valid
daprilik Dec 7, 2020
aa62b6a
add iothub_hostname to additional_info
daprilik Dec 7, 2020
6e4731b
add daemon running checks
daprilik Dec 8, 2020
d043b20
add copyright headers
daprilik Dec 8, 2020
44d297e
fix mini-sntp packaging
daprilik Dec 8, 2020
81d14bf
add MPL-2 support to third-party-notices.sh
daprilik Dec 8, 2020
603b997
minor PR fixes
daprilik Dec 14, 2020
b52a035
add iotedge connectivity checks
daprilik Dec 14, 2020
c919fca
add check-list JSON output option
daprilik Dec 15, 2020
74f32a1
Merge branch 'main' into aziot-check
daprilik Dec 18, 2020
a6e535a
remove direct dep on cerd from aziot
daprilik Dec 18, 2020
be1c1db
remove direct dep on identityd from aziot
daprilik Dec 18, 2020
2ddb9a9
add more missing copyright headers
daprilik Dec 18, 2020
bd8329a
output section names + description in json-stream
daprilik Dec 22, 2020
1ac11e7
extract aziot-check JSON API into separate crate
daprilik Dec 23, 2020
457313c
CheckOuput -> CheckOutput
daprilik Jan 4, 2021
98bb8a4
Merge branch 'main' into aziot-check
daprilik Jan 4, 2021
f6735c9
clippy *shakes fist*
daprilik Jan 4, 2021
4fd3e53
fix PR comments
daprilik Jan 5, 2021
5e7f3bd
more PR comments
daprilik Jan 5, 2021
c843ef7
fix cerd perms + partial fix to host_connect_iothub
daprilik Jan 5, 2021
6ae866e
fix fat fingered "fix"
daprilik Jan 6, 2021
6d5dd05
fix identity_cert_expiry check when using dynamically issued certs
daprilik Jan 6, 2021
1d5749d
add iothub-hostname flag
daprilik Jan 6, 2021
221d7f7
adress yet more PR comment
daprilik Jan 7, 2021
6d465ad
add localca, est identity + bootstrap cert checks
daprilik Jan 7, 2021
ed70446
phrasing
daprilik Jan 7, 2021
e01315e
Merge branch 'main' into aziot-check
kodiakhq[bot] Jan 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions aziot/src/internal/check/checks/host_connect_iothub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,49 @@ impl HostConnectIotHub {
) -> Result<CheckResult> {
use aziot_identityd_config::ProvisioningType;

let iothub_hostname = match &unwrap_or_skip!(&cache.cfg.identityd)
.provisioning
.provisioning
{
ProvisioningType::Manual {
iothub_hostname, ..
} => iothub_hostname,
ProvisioningType::Dps { .. } => {
// check if the backup config includes the iothub_hostname
match &unwrap_or_skip!(&cache.cfg.identityd_prev)
let iothub_hostname = match &self.iothub_hostname {
Some(s) => s,
None => {
let iothub_hostname = match &unwrap_or_skip!(&cache.cfg.identityd)
.provisioning
.provisioning
{
ProvisioningType::Manual {
iothub_hostname, ..
} => iothub_hostname,
ProvisioningType::Dps { .. } => {
// It's fine if the prev config doesn't exist, so `unwrap_or_skip` isn't
// appropriate here
let backup_hostname = match &cache.cfg.identityd_prev {
None => None,
// check if the backup config includes the iothub_hostname
Some(cfg) => match &cfg.provisioning.provisioning {
ProvisioningType::Manual {
iothub_hostname, ..
} => Some(iothub_hostname),
_ => None,
},
};

if let Some(backup_hostname) = backup_hostname {
backup_hostname
} else {
// the user never manually provisioned, nor have they passed
// the `iothub-hostname` flag.
let reason = "Could not retrieve iothub_hostname from provisioning file.\n\
Please specify the backing IoT Hub name using --iothub-hostname switch if you have that information.\n\
If no hostname is provided, all hub connectivity tests will be skipped.";
arsing marked this conversation as resolved.
Show resolved Hide resolved
return Err(anyhow::Error::msg(reason));
}
}
_ => return Ok(CheckResult::Ignored),
}
};

self.iothub_hostname = Some(iothub_hostname.clone());
iothub_hostname
}
_ => return Ok(CheckResult::Ignored),
};

self.iothub_hostname = Some(iothub_hostname.clone());

let iothub_hostname_url = format!("https://{}:{}", iothub_hostname, self.port_number)
.parse::<hyper::Uri>()
.context("Invalid URL specified in provisioning.iothub_hostname")?;
Expand Down
5 changes: 5 additions & 0 deletions aziot/src/internal/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ pub struct CheckerCfg {
// (Manually populated to match top-level CheckOptions value)
#[structopt(skip)]
pub verbose: bool,

/// Sets the hostname of the Azure IoT Hub that this device would connect to.
/// If using manual provisioning, this does not need to be specified.
#[structopt(long, value_name = "IOTHUB_HOSTNAME")]
pub iothub_hostname: Option<String>,
}

pub struct CheckerShared {
Expand Down