Compare commits

...

7 Commits

Author SHA1 Message Date
Mike Hansen
84789e07ce OLS 410
Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-05-28 10:08:52 -04:00
Mike Hansen
10cc5bec80 Merge pull request #19 from Telecominfraproject/OLS-578-Tag-ols-ucentral-client-and-ols-ucentral-schema-4.0.0-pre-release
[OLS-578] Tag ols-ucentral-client and ols-ucentral-schema 4.0.0 pre-r…
2025-02-07 08:06:04 -05:00
Mike Hansen
ca74a49604 [OLS-578] Tag ols-ucentral-client and ols-ucentral-schema 4.0.0 pre-release
Take the schema version from tag v4.0.0-rc1
Update version.json to 4.0.0

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-02-05 08:36:43 -05:00
Mike Hansen
fb10d141d0 Merge pull request #18 from Telecominfraproject/OLS-563-version-client-tag-and-update-schema-ref
[OLS-563] Add version to ols-ucentral-client
2025-02-03 09:27:55 -05:00
Mike Hansen
176d2b9f36 [OLS-563] Add version to ols-ucentral-client
Dockerfile updated to pull tagged version of schema to get the schema.json file.
This will make subsequent versioning much easier.

Once this is merged we can tag the client as 3.2.7 and then move forward to 4.x as we did with the schema.

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-01-31 16:48:09 -05:00
Mike Hansen
41d50f4650 Merge pull request #17 from Telecominfraproject/OLS-563-Add-version-to-ols-ucentral-client
[OLS-563] Add version to ols-ucentral-client
2025-01-27 09:36:05 -05:00
Mike Hansen
00ae4001e7 [OLS-563] Add version to ols-ucentral-client
Add version to ols-ucentral-client
Augment the build to pull the schema version file from the ols-ucentral-schema repo (if present) based on commit id of
schema used as baseline for this client version.
Use both it and the version to provide the version information in the connect message.

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-01-22 19:49:46 -05:00
10 changed files with 170 additions and 23 deletions

View File

@@ -2,8 +2,11 @@ FROM debian:buster
LABEL Description="Ucentral client (Build) environment"
ARG HOME /root
ARG EXTERNAL_LIBS ${HOME}/ucentral-external-libs
ARG SCHEMA="4.1.0-rc1"
ARG SCHEMA_VERSION="v${SCHEMA}"
ARG SCHEMA_ZIP_FILE="${SCHEMA_VERSION}.zip"
ARG SCHEMA_UNZIPPED="ols-ucentral-schema-${SCHEMA}"
ARG OLS_SCHEMA_SRC="https://github.com/Telecominfraproject/ols-ucentral-schema/archive/refs/tags/${SCHEMA_ZIP_FILE}"
SHELL ["/bin/bash", "-c"]
RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
@@ -23,13 +26,16 @@ RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
autoconf \
libtool \
pkg-config \
libjsoncpp-dev
libjsoncpp-dev \
unzip
RUN git config --global http.sslverify false
RUN git clone https://github.com/DaveGamble/cJSON.git ${HOME}/ucentral-external-libs/cJSON/
RUN git clone https://libwebsockets.org/repo/libwebsockets ${HOME}/ucentral-external-libs/libwebsockets/
RUN git clone --recurse-submodules -b v1.50.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc ${HOME}/ucentral-external-libs/grpc/
RUN git clone --recursive --branch v7.1.4 https://github.com/zhaojh329/rtty.git ${HOME}/ucentral-external-libs/rtty/
ADD ${OLS_SCHEMA_SRC} /tmp/
# The following libs should be prebuilt in docker-build-env img to speed-up
# recompilation of only the ucentral-client itself
@@ -41,6 +47,8 @@ RUN cd ${HOME}/ucentral-external-libs/cJSON/ && \
make install
RUN cd ${HOME}/ucentral-external-libs/libwebsockets/ && \
git branch --all && \
git checkout a9b8fe7ebf61b8c0e7891e06e70d558412933a33 && \
mkdir build && \
cd build && \
cmake .. && \
@@ -62,3 +70,8 @@ RUN cd ${HOME}/ucentral-external-libs/rtty/ && \
cd build && \
cmake .. && \
make -j4
RUN unzip /tmp/${SCHEMA_ZIP_FILE} -d ${HOME}/ucentral-external-libs/
RUN cd ${HOME}/ucentral-external-libs/ && \
mv ${SCHEMA_UNZIPPED} ols-ucentral-schema

View File

@@ -50,8 +50,13 @@ build-ucentral-app: run-host-env
@echo Running ucentralclient docker-build-env container to build ucentral-client...;
docker exec -t ${CONTAINER_NAME} /root/ols-nos/docker-build-client.sh
docker cp ${CONTAINER_NAME}:/root/deliverables/ src/docker/
# copy the schema version, if it is there
docker cp ${CONTAINER_NAME}:/root/ucentral-external-libs/ols-ucentral-schema/schema.json src/docker/ || true
docker container stop ${CONTAINER_NAME} > /dev/null 2>&1 || true;
docker container rm ${CONTAINER_NAME} > /dev/null 2>&1 || true;
if [ -f version.json ]; then
cp version.json src/docker/
fi
build-ucentral-docker-img: build-ucentral-app
pushd src
@@ -91,6 +96,8 @@ clean:
rm -rf src/docker/deliverables || true;
rm -rf src/docker/lib* || true;
rm -rf src/docker/ucentral-client || true;
rm -rf src/docker/version.json || true;
rm -rf src/docker/schema.json || true;
rm -rf src/debian/ucentral-client.substvars 2>/dev/null || true;
rm -rf src/debian/shasta-ucentral-client.debhelper.log 2>/dev/null || true;
rm -rf src/debian/.debhelper src/debian/ucentral-client 2>/dev/null || true;

View File

@@ -21,6 +21,8 @@ COPY /ucentral-client /usr/local/bin/ucentral-client
COPY /rtty /usr/local/bin/
COPY /lib* /usr/local/lib/
COPY /version.jso[n] /etc/
COPY /schema.jso[n] /etc/
RUN ldconfig
RUN ls -l /usr/local/bin/ucentral-client

View File

@@ -2,4 +2,8 @@ plat.a: plat-example.o
ar crs $@ $^
%.o: %.c
ifdef PLATFORM_REVISION
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include -D PLATFORM_REVISION='"$(PLATFORM_REVISION)"' $^
else
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include $^
endif

View File

@@ -2,6 +2,7 @@
#include <ucentral-platform.h>
#include <ucentral-log.h>
#include <plat-revision.h>
#define UNUSED_PARAM(param) (void)((param))
@@ -12,7 +13,11 @@ int plat_init(void)
int plat_info_get(struct plat_platform_info *info)
{
UNUSED_PARAM(info);
*info = (struct plat_platform_info){0};
snprintf(info->platform, sizeof info->platform, "%s", "Example Platform" );
snprintf(info->hwsku, sizeof info->hwsku, "%s", "example-platform-sku");
snprintf(info->mac, sizeof info->mac, "%s", "24:fe:9a:0f:48:f0");
return 0;
}
@@ -156,10 +161,45 @@ int plat_port_num_get(uint16_t *num_of_active_ports)
UNUSED_PARAM(num_of_active_ports);
return 0;
}
int plat_revision_get(char *str, size_t str_max_len)
{
snprintf(str, str_max_len, PLATFORM_REVISION);
return 0;
}
int plat_reboot_cause_get(struct plat_reboot_cause *cause)
{
UNUSED_PARAM(cause);
return 0;
}
int plat_event_subscribe(const struct plat_event_callbacks *cbs)
{
UNUSED_PARAM(cbs);
return 0;
}
void plat_event_unsubscribe(void)
{
return;
}
int plat_running_img_name_get(char *str, size_t str_max_len)
{
UNUSED_PARAM(str_max_len);
UNUSED_PARAM(str);
return 0;
}
int plat_metrics_save(const struct plat_metrics_cfg *cfg)
{
UNUSED_PARAM(cfg);
return 0;
}
int plat_metrics_restore(struct plat_metrics_cfg *cfg)
{
UNUSED_PARAM(cfg);
return 0;
}
int plat_run_script(struct plat_run_script *p)
{
UNUSED_PARAM(p);
return 0;
}

View File

@@ -0,0 +1,14 @@
#ifndef _PLAT_REVISION
#define _PLAT_REVISION
#define XSTR(x) STR(x)
#define STR(x) #x
#define PLATFORM_REL_NUM 3.2.0
#define PLATFORM_BUILD_NUM 5
#ifndef PLATFORM_REVISION
#define PLATFORM_REVISION "Rel " XSTR(PLATFORM_REL_NUM) " build " XSTR(PLATFORM_BUILD_NUM)
#endif
#endif

View File

@@ -406,17 +406,46 @@ err:
proto_destroy_blob(&blob);
}
void
connect_send(void)
{
static cJSON *readJsonFile(const char *filename) {
FILE *file = fopen(filename, "r");
if (!file) {
fprintf(stderr, "Error opening file: %s\n", filename);
return NULL;
}
cJSON *ret;
// Get the file size
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
fseek(file, 0, SEEK_SET);
// Read the entire file into a buffer
char *buffer = (char *)malloc(fileSize + 1);
fread(buffer, 1, fileSize, file);
buffer[fileSize] = '\0'; // Null-terminate the string
// Close the file
fclose(file);
ret = cJSON_Parse(buffer);
return ret;
}
void connect_send(void) {
/* WIP: TMP hardcode; to be removed*/
unsigned mac[6];
struct plat_platform_info pinfo = {0};
struct plat_metrics_cfg restore_metrics = { 0 };
struct plat_metrics_cfg restore_metrics = {0};
struct blob blob = {0};
uint64_t uuid_buf; /* fixed storage size */
cJSON *params;
cJSON *cap;
cJSON *ver;
int ret;
blob.obj = proto_new_blob("connect");
@@ -446,7 +475,6 @@ connect_send(void)
if (password) {
if (!cJSON_AddStringToObject(params, "password", password))
goto err;
memset(password, 0, strlen(password));
free(password);
password = NULL;
@@ -456,30 +484,60 @@ connect_send(void)
if (!cap)
goto err;
ver = cJSON_AddObjectToObject(cap, "version");
if (!ver)
goto err;
if (plat_info_get(&pinfo)) {
UC_LOG_CRIT("failed to get platform info");
} else {
if (!cJSON_AddStringToObject(cap, "compatible", pinfo.hwsku))
goto err;
if (!cJSON_AddStringToObject(cap, "model", pinfo.platform))
goto err;
}
if (!cJSON_AddStringToObject(cap, "serial", client.serial))
goto err;
if (!cJSON_AddStringToObject(cap, "firmware", client.firmware))
goto err;
cJSON *client_version_json = readJsonFile(client.ols_client_version_file);
if (!client_version_json)
goto err;
if (!cJSON_AddItemToObject(ver, "switch", client_version_json))
goto err;
else
UC_LOG_DBG("client version added to connect.capabilities.version");
cJSON *schema_version_json = readJsonFile(client.ols_schema_version_file);
if (!schema_version_json) {
UC_LOG_DBG("No schema version present.");
}
else {
if (!cJSON_AddItemToObject(ver, "schema", schema_version_json))
goto err;
else
UC_LOG_DBG("schema version added to connect.capabilities.version");
}
if (!cJSON_AddStringToObject(cap, "compatible", pinfo.hwsku))
goto err;
if (!cJSON_AddStringToObject(cap, "model", pinfo.platform))
goto err;
if (!cJSON_AddStringToObject(cap, "platform", "switch"))
goto err;
if (client.serial &&
sscanf(client.serial, "%2x%2x%2x%2x%2x%2x",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) == 6) {
sscanf(client.serial, "%2x%2x%2x%2x%2x%2x",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) == 6) {
char label_mac[32];
snprintf(label_mac, sizeof label_mac,
"%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
"%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
if (!cJSON_AddStringToObject(cap, "label_macaddr", label_mac)) {
goto err;
}
} else {
}
else {
UC_LOG_DBG("failed to parse serial as label_macaddr");
}
@@ -490,11 +548,11 @@ connect_send(void)
if (ucentral_metrics.state.enabled)
plat_state_poll(state_send,
ucentral_metrics.state.interval);
ucentral_metrics.state.interval);
if (ucentral_metrics.healthcheck.enabled)
plat_health_poll(health_send,
ucentral_metrics.healthcheck.interval);
ucentral_metrics.healthcheck.interval);
}
UC_LOG_DBG("xmit connect\n");

View File

@@ -67,6 +67,8 @@ lws_protocols protocols[] = {
struct client_config client = {
.redirector_file = "/tmp/ucentral-redirector.json",
.redirector_file_dbg = "/tmp/firstcontact.hdr",
.ols_schema_version_file = "/etc/schema.json",
.ols_client_version_file = "/etc/version.json",
.server = NULL,
.port = 15002,
.path = "/",

View File

@@ -41,6 +41,8 @@ extern "C" {
struct client_config {
const char *redirector_file;
const char *redirector_file_dbg;
const char *ols_client_version_file;
const char *ols_schema_version_file;
const char *server;
int16_t port;
const char *path;

5
version.json Normal file
View File

@@ -0,0 +1,5 @@
{
"major": 4,
"minor": 1,
"patch": 0
}