Monitor child CA versions and send version to parent/repo (#622, #620)

This commit is contained in:
Tim Bruijnzeels
2021-08-10 15:45:54 +02:00
committed by GitHub
parent a189e6867c
commit 37ce99298e
11 changed files with 384 additions and 118 deletions
+7 -2
View File
@@ -9,8 +9,8 @@ use rpki::uri;
use crate::cli::options::KrillUserDetails;
use crate::cli::report::{ApiResponse, ReportError};
use crate::commons::api::{
AllCertAuthIssues, CaRepoDetails, CertAuthIssues, ChildCaInfo, ParentCaContact, ParentStatuses, PublisherDetails,
PublisherList, RepoStatus, Token,
AllCertAuthIssues, CaRepoDetails, CertAuthIssues, ChildCaInfo, ChildrenConnectionStats, ParentCaContact,
ParentStatuses, PublisherDetails, PublisherList, RepoStatus, Token,
};
use crate::commons::bgp::BgpAnalysisAdvice;
use crate::commons::remote::rfc8183;
@@ -258,6 +258,11 @@ impl KrillClient {
delete(&self.server, &self.token, &uri).await?;
Ok(ApiResponse::Empty)
}
CaCommand::ChildConnections(handle) => {
let uri = format!("api/v1/cas/{}/stats/children/connections", handle);
let stats: ChildrenConnectionStats = get_json(&self.server, &self.token, &uri).await?;
Ok(ApiResponse::ChildrenStats(stats))
}
CaCommand::KeyRollInit(handle) => {
let uri = format!("api/v1/cas/{}/keys/roll_init", handle);
+22 -1
View File
@@ -9,9 +9,9 @@ use std::{env, fmt};
use bytes::Bytes;
use clap::{App, Arg, ArgMatches, SubCommand};
use rpki::uri;
use rpki::repository::crypto::KeyIdentifier;
use rpki::repository::x509::Time;
use rpki::uri;
use crate::commons::crypto::{IdCert, SignSupport};
use crate::commons::remote::rfc8183;
@@ -469,6 +469,15 @@ impl Options {
app.subcommand(sub)
}
fn make_cas_children_connections_sc<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
let mut sub = SubCommand::with_name("connections").about("Show connections stats for children of a CA");
sub = Self::add_general_args(sub);
sub = Self::add_my_ca_arg(sub);
app.subcommand(sub)
}
fn make_cas_children_sc<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
let mut sub = SubCommand::with_name("children").about("Manage children for a CA");
@@ -477,6 +486,7 @@ impl Options {
sub = Self::make_cas_children_info_sc(sub);
sub = Self::make_cas_children_remove_sc(sub);
sub = Self::make_cas_children_response_sc(sub);
sub = Self::make_cas_children_connections_sc(sub);
app.subcommand(sub)
}
@@ -1409,6 +1419,14 @@ impl Options {
Ok(Options::make(general_args, command))
}
fn parse_matches_cas_children_connections(matches: &ArgMatches) -> Result<Options, Error> {
let general_args = GeneralArgs::from_matches(matches)?;
let my_ca = Self::parse_my_ca(matches)?;
let command = Command::CertAuth(CaCommand::ChildConnections(my_ca));
Ok(Options::make(general_args, command))
}
fn parse_matches_cas_children(matches: &ArgMatches) -> Result<Options, Error> {
if let Some(m) = matches.subcommand_matches("add") {
Self::parse_matches_cas_children_add(m)
@@ -1420,6 +1438,8 @@ impl Options {
Self::parse_matches_cas_children_update(m)
} else if let Some(m) = matches.subcommand_matches("remove") {
Self::parse_matches_cas_children_remove(m)
} else if let Some(m) = matches.subcommand_matches("connections") {
Self::parse_matches_cas_children_connections(m)
} else {
Err(Error::UnrecognizedSubCommand)
}
@@ -2087,6 +2107,7 @@ pub enum CaCommand {
ChildAdd(Handle, AddChildRequest),
ChildUpdate(Handle, ChildHandle, UpdateChildRequest),
ChildDelete(Handle, ChildHandle),
ChildConnections(Handle),
// Key Management
KeyRollInit(Handle),
+5 -2
View File
@@ -5,8 +5,8 @@ use serde::Serialize;
use crate::commons::api::{
AllCertAuthIssues, CaCommandDetails, CaRepoDetails, CertAuthInfo, CertAuthIssues, CertAuthList, ChildCaInfo,
CommandHistory, ParentCaContact, ParentStatuses, PublisherDetails, PublisherList, RepoStatus, RoaDefinitions,
RtaList, RtaPrepResponse, ServerInfo,
ChildrenConnectionStats, CommandHistory, ParentCaContact, ParentStatuses, PublisherDetails, PublisherList,
RepoStatus, RoaDefinitions, RtaList, RtaPrepResponse, ServerInfo,
};
use crate::commons::bgp::{BgpAnalysisAdvice, BgpAnalysisReport, BgpAnalysisSuggestion};
use crate::commons::remote::api::ClientInfos;
@@ -36,6 +36,7 @@ pub enum ApiResponse {
ParentStatuses(ParentStatuses),
ChildInfo(ChildCaInfo),
ChildrenStats(ChildrenConnectionStats),
PublisherDetails(PublisherDetails),
PublisherList(PublisherList),
@@ -81,6 +82,7 @@ impl ApiResponse {
ApiResponse::ParentCaContact(contact) => Ok(Some(contact.report(fmt)?)),
ApiResponse::ParentStatuses(statuses) => Ok(Some(statuses.report(fmt)?)),
ApiResponse::ChildInfo(info) => Ok(Some(info.report(fmt)?)),
ApiResponse::ChildrenStats(stats) => Ok(Some(stats.report(fmt)?)),
ApiResponse::PublisherList(list) => Ok(Some(list.report(fmt)?)),
ApiResponse::PublisherDetails(details) => Ok(Some(details.report(fmt)?)),
ApiResponse::RepoStats(stats) => Ok(Some(stats.report(fmt)?)),
@@ -177,6 +179,7 @@ impl Report for CaCommandDetails {}
impl Report for PublisherList {}
impl Report for RepoStats {}
impl Report for ChildrenConnectionStats {}
impl Report for PublisherDetails {}