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 bluechi is online tool #964

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions bluechi.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ predefined number of nodes and with a focus on highly regulated environment
such as those requiring functional safety (for example in cars).


##########################
### bluechi-controller ###
##########################

%package controller
Summary: BlueChi service controller
Requires: systemd
Expand Down Expand Up @@ -90,6 +94,10 @@ This package contains the controller service.
%{_unitdir}/bluechi-controller.socket


#####################
### bluechi-agent ###
#####################

%package agent
Summary: BlueChi service controller agent
Requires: systemd
Expand Down Expand Up @@ -140,6 +148,10 @@ This package contains the node agent.
%{_userunitdir}/bluechi-dep@.service


#######################
### bluechi-selinux ###
#######################

%package selinux
Summary: BlueChi SELinux policy
BuildArch: noarch
Expand Down Expand Up @@ -180,6 +192,10 @@ if [ $1 -eq 0 ]; then
fi


###################
### bluechi-ctl ###
###################

%package ctl
Summary: BlueChi service controller command line tool
Requires: %{name} = %{version}-%{release}
Expand All @@ -204,6 +220,37 @@ This package contains the service controller command line tool.
%{_mandir}/man1/bluechictl.*


#########################
### bluechi-is-online ###
#########################

%package is-online
Summary: Command line tool to monitor the connection state of BlueChi's components
Recommends: bluechi-controller = %{version}-%{release}
Recommends: bluechi-agent = %{version}-%{release}

%if 0%{?with_coverage}
Requires: bluechi-coverage = %{version}-%{release}
%endif

%description is-online
BlueChi is a systemd service controller for multi-nodes environements with a
predefined number of nodes and with a focus on highly regulated environment
such as those requiring functional safety (for example in cars).
This package contains a command line tool for checking and monitoring the
connection state of BlueChi's core components.

%files is-online
%doc README.md
%license LICENSE
%{_bindir}/bluechi-is-online
%{_mandir}/man1/bluechi-is-online.*


#######################
### python3-bluechi ###
#######################

%if %{with_python}
%package -n python3-bluechi
Summary: Python bindings for BlueChi
Expand All @@ -228,6 +275,10 @@ API description and manually written code to simplify recurring tasks.
%endif


########################
### bluechi-coverage ###
########################

%if 0%{?with_coverage}
%package coverage
Summary: Code coverage files for BlueChi
Expand All @@ -244,6 +295,7 @@ will be used during integration tests when creating code coverage report.
%endif



%prep
%autosetup -S git_am

Expand Down
76 changes: 76 additions & 0 deletions doc/man/bluechi-is-online.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
% bluechi-is-online 1

## NAME

bluechi-is-online - Command line tool to check and monitor the connection state of BlueChi's core components.

## SYNOPSIS

**bluechi-is-online** [*system|node|agent*] [*options*]

## DESCRIPTION

Command line tool to check and monitor the connection state of BlueChi's core components. It uses the public D-Bus API provided by `bluechi-controller` and/or `bluechi-agent`.

**bluechi-is-online [OPTIONS]**

## OPTIONS

#### **--help**, **-h**

Print usage statement and exit.

#### **--version**, **-v**

Print current bluechictl version

## Commands

### **bluechi-is-online** [*system*] [*options*]

Checks the connection state of `bluechi-controller` and all expected `bluechi-agent`s. Runs on primary node.
Uses the D-Bus property `Status` of the `org.eclipse.bluechi.Controller` interface.
If the `Status` is `up`, exit code is 0. Otherwise 1.

**Options:**

**--wait**
Initial time to wait till the expected system status is `up`. In milliseconds.

**--monitor**
If set, `bluechi-is-online` continuously monitors the system state after the initial `up` check succeeded.

### **bluechi-is-online** [*node*] [*node_name*] [*options*]

Checks the connection state of a specific node. Runs on primary node.
Uses the D-Bus property `Status` of the `org.eclipse.bluechi.Node` interface.
If the `Status` is `online`, exit code is 0. Otherwise 1.

**Options:**

**--wait**
Initial time to wait till the expected node status is `online`. In milliseconds.

**--monitor**
If set, `bluechi-is-online` continuously monitors the node state after the initial `online` check succeeded.

### **bluechi-is-online** [*agent*] [*options*]

Checks the connection state of the `bluechi-agent` with the controller. Runs on any managed node.
Uses the D-Bus property `Status` of the `org.eclipse.bluechi.Agent` interface.
If the `Status` is `online`, exit code is 0. Otherwise 1.

**Options:**

**--wait**
Initial time to wait till the expected agent status is `online`. In milliseconds.

**--monitor**
If set, `bluechi-is-online` continuously monitors the agent state after the initial `online` check succeeded.

**--switch-timeout**
Time to wait till the agent is expected to connect again on a call to the `SwitchController` API method. In milliseconds.

## Exit Codes

If the respective BlueChi component is online at the time of exiting, 0 is returned. Otherwise, 1 is returned.
1 change: 1 addition & 0 deletions doc/man/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ man1 = [
'bluechi-agent',
'bluechictl',
'bluechi-proxy',
'bluechi-is-online',
]

man5 = [
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ subdir('src/controller')
subdir('src/agent')
subdir('src/client')
subdir('src/proxy')
subdir('src/is-online')

# Subdirectory for the API description
subdir('data')
Expand Down
38 changes: 38 additions & 0 deletions src/is-online/help.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Contributors to the Eclipse BlueChi project
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "help.h"
#include "opt.h"

static void usage_print_header() {
printf("bluechi-is-online checks and monitors the connection state of BlueChi components\n");
printf("\n");
}

static void usage_print_usage(const char *usage) {
printf("Usage: \n");
printf(" %s\n", usage);
printf("\n");
}


void usage() {
usage_print_header();
usage_print_usage("bluechi-is-online [agent|node|system] [OPTIONS]");
printf("Available commands:\n");
printf(" help: \t shows this help message\n");
printf(" version: \t shows the version of bluechi-is-online\n");
printf("Available options:\n");
printf(" --%s: \t keeps monitoring as long as [agent|node|system] is online and exits if it detects an offline state.\n",
ARG_MONITOR);
printf(" --%s: \t Wait n milliseconds for [agent|node|system] to get online.\n", ARG_WAIT);
printf(" --%s: \t Only for [agent]. Wait n milliseconds for after switching controller to get online again.\n",
ARG_SWITCH_CTRL_TIMEOUT);
}

int method_help(UNUSED Command *command, UNUSED void *userdata) {
usage();
return 0;
}
11 changes: 11 additions & 0 deletions src/is-online/help.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Contributors to the Eclipse BlueChi project
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once

#include "libbluechi/cli/command.h"

int method_help(Command *command, void *userdata);
void usage();
Loading