mirror of
https://dev.iopsys.eu/system/sysmngr.git
synced 2025-12-10 00:06:19 +01:00
Align with bbfdm new design
This commit is contained in:
parent
7d5bf8e075
commit
28f575dd0e
6 changed files with 17 additions and 14 deletions
|
|
@ -52,7 +52,7 @@ static int dmmap_synchronizeVcfInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int bbf_config_backup(const char *url, const char *username, const char *password,
|
||||
static int bbf_config_backup(struct ubus_context *ctx, const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
|
|
@ -79,7 +79,7 @@ static int bbf_config_backup(const char *url, const char *username, const char *
|
|||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(CONFIG_BACKUP) && remove(CONFIG_BACKUP))
|
||||
|
|
@ -89,7 +89,7 @@ end:
|
|||
}
|
||||
|
||||
|
||||
static int bbf_config_restore(const char *url, const char *username, const char *password,
|
||||
static int bbf_config_restore(struct ubus_context *ctx, const char *url, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *command, const char *obj_path)
|
||||
{
|
||||
|
|
@ -134,7 +134,7 @@ static int bbf_config_restore(const char *url, const char *username, const char
|
|||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download");
|
||||
send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(config_restore) && strncmp(url, FILE_URI, strlen(FILE_URI)) && remove(config_restore))
|
||||
|
|
@ -274,7 +274,7 @@ static int operate_DeviceInfoVendorConfigFile_Backup(char *refparam, struct dmct
|
|||
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &vcf_name);
|
||||
|
||||
int res = bbf_config_backup(url, user, pass, vcf_name, backup_command, backup_path);
|
||||
int res = bbf_config_backup(ctx->ubus_ctx, url, user, pass, vcf_name, backup_command, backup_path);
|
||||
|
||||
return res ? USP_FAULT_COMMAND_FAILURE : 0;
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ static int operate_DeviceInfoVendorConfigFile_Restore(char *refparam, struct dmc
|
|||
char *checksum_algorithm = dmjson_get_value((json_object *)value, 1, "CheckSumAlgorithm");
|
||||
char *checksum = dmjson_get_value((json_object *)value, 1, "CheckSum");
|
||||
|
||||
int res = bbf_config_restore(url, user, pass, file_size, checksum_algorithm, checksum, restore_command, restore_path);
|
||||
int res = bbf_config_restore(ctx->ubus_ctx, url, user, pass, file_size, checksum_algorithm, checksum, restore_command, restore_path);
|
||||
|
||||
return res ? USP_FAULT_COMMAND_FAILURE : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ static void dmubus_receive_sysupgrade(struct ubus_context *ctx, struct ubus_even
|
|||
return;
|
||||
}
|
||||
|
||||
static int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password,
|
||||
static int bbf_fw_image_download(struct ubus_context *ctx, const char *url, const char *auto_activate, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *bank_id, const char *command, const char *obj_path, const char *commandKey, const char *keep)
|
||||
{
|
||||
|
|
@ -280,7 +280,7 @@ static int bbf_fw_image_download(const char *url, const char *auto_activate, con
|
|||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
|
||||
// Remove temporary file if ubus upgrade failed and file exists
|
||||
if (file_exists(fw_image_path) && strncmp(url, FILE_URI, strlen(FILE_URI)))
|
||||
|
|
@ -563,7 +563,7 @@ static int operate_DeviceInfoFirmwareImage_Download(char *refparam, struct dmctx
|
|||
#endif
|
||||
char *bank_id = get_fwbank_option_value(data, "id");
|
||||
|
||||
int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey, keep_config);
|
||||
int res = bbf_fw_image_download(ctx->ubus_ctx, url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey, keep_config);
|
||||
|
||||
if (res == 1) {
|
||||
bbfdm_set_fault_message(ctx, "Firmware validation failed");
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ static void send_memory_critical_state_event(unsigned int mem_utilization)
|
|||
|
||||
blobmsg_close_array(&bb, arr);
|
||||
|
||||
BBFDM_UBUS_INVOKE_SYNC("bbfdm", "notify_event", bb.head, 5000, NULL, NULL);
|
||||
BBFDM_UBUS_SEND_EVENT("bbfdm.event", bb.head);
|
||||
|
||||
BBFDM_DEBUG("'MemoryCriticalState!' event sent successfully with utilization at %u%%.", mem_utilization);
|
||||
|
||||
blob_buf_free(&bb);
|
||||
|
|
|
|||
|
|
@ -414,7 +414,8 @@ static void send_cpu_critical_state_event(unsigned int cpu_utilization)
|
|||
|
||||
blobmsg_close_array(&bb, arr);
|
||||
|
||||
BBFDM_UBUS_INVOKE_SYNC("bbfdm", "notify_event", bb.head, 5000, NULL, NULL);
|
||||
BBFDM_UBUS_SEND_EVENT("bbfdm.event", bb.head);
|
||||
|
||||
BBFDM_DEBUG("'CPUCriticalState!' event sent successfully with utilization at %u%%.", cpu_utilization);
|
||||
|
||||
blob_buf_free(&bb);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ bool validate_file_system_size(const char *file_size)
|
|||
return true;
|
||||
}
|
||||
|
||||
void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url,
|
||||
void send_transfer_complete_event(struct ubus_context *ubus_ctx, const char *command, const char *obj_path, const char *transfer_url,
|
||||
char *fault_string, time_t start_t, time_t complete_t, const char *commandKey, const char *transfer_type)
|
||||
{
|
||||
char start_time[32] = {0};
|
||||
|
|
@ -145,7 +145,8 @@ void send_transfer_complete_event(const char *command, const char *obj_path, con
|
|||
fill_blob_param(&bb, "FaultString", fault_string, DMT_TYPE[DMT_STRING], 0);
|
||||
blobmsg_close_array(&bb, arr);
|
||||
|
||||
dmubus_call_blob_msg_set("bbfdm", "notify_event", &bb);
|
||||
|
||||
ubus_send_event(ubus_ctx, "bbfdm.event", bb.head);
|
||||
|
||||
blob_buf_free(&bb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool validate_checksum_value(const char *file_path, const char *checksum_algorit
|
|||
bool validate_file_system_size(const char *file_size);
|
||||
bool validate_server_response_code(const char *url, int response_code);
|
||||
|
||||
void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url,
|
||||
void send_transfer_complete_event(struct ubus_context *ubus_ctx, const char *command, const char *obj_path, const char *transfer_url,
|
||||
char *fault_string, time_t start_t, time_t complete_t, const char *commandKey, const char *transfer_type);
|
||||
|
||||
int sysmngr_get_uptime(void);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue