mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-08 10:27:07 +01:00
Added Device.DeviceInfo.VendorLogFile.{i}.Upload() command support
This commit is contained in:
parent
ddb4259271
commit
da27610783
3 changed files with 61 additions and 0 deletions
|
|
@ -433,6 +433,26 @@ end:
|
|||
return res;
|
||||
}
|
||||
|
||||
int bbf_upload_log(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
// Upload the config file
|
||||
time_t start_time = time(NULL);
|
||||
long res_code = upload_file(config_name, url, username, password);
|
||||
time_t complete_time = time(NULL);
|
||||
|
||||
// Send Transfer Complete Event
|
||||
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Upload");
|
||||
|
||||
// Check if the upload operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
res = -1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
int bbf_config_restore(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)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ void reset_diagnostic_state(char *sec_name);
|
|||
void init_diagnostics_operation(char *sec_name, char *operation_path);
|
||||
void set_diagnostics_interface_option(struct dmctx *ctx, char *sec_name, char *value);
|
||||
int start_upload_download_diagnostic(int diagnostic_type);
|
||||
int bbf_upload_log(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path);
|
||||
int bbf_config_backup(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path);
|
||||
int bbf_config_restore(const char *url, const char *username, const char *password,
|
||||
|
|
|
|||
|
|
@ -811,6 +811,44 @@ static int get_process_state(char* refparam, struct dmctx *ctx, void *data, char
|
|||
/*************************************************************
|
||||
* OPERATE COMMANDS
|
||||
*************************************************************/
|
||||
static operation_args vendor_log_file_upload_args = {
|
||||
.in = (const char *[]) {
|
||||
"URL",
|
||||
"Username",
|
||||
"Password",
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
static int get_operate_args_DeviceInfoVendorLogFile_Upload(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = (char *)&vendor_log_file_upload_args;
|
||||
return 0;
|
||||
}
|
||||
static int operate_DeviceInfoVendorLogFile_Upload(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char upload_path[256] = {'\0'};
|
||||
char upload_command[32] = {'\0'};
|
||||
char *vlf_file_path = NULL;
|
||||
|
||||
char *ret = strrchr(refparam, '.');
|
||||
strncpy(upload_path, refparam, ret - refparam +1);
|
||||
DM_STRNCPY(upload_command, ret+1, sizeof(upload_command));
|
||||
|
||||
char *user = dmjson_get_value((json_object *)value, 1, "Username");
|
||||
char *pass = dmjson_get_value((json_object *)value, 1, "Password");
|
||||
char *url = dmjson_get_value((json_object *)value, 1, "URL");
|
||||
|
||||
if (url[0] == '\0')
|
||||
return CMD_INVALID_ARGUMENTS;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "log_file", &vlf_file_path);
|
||||
|
||||
int res = bbf_upload_log(url, user, pass, vlf_file_path, upload_command, upload_path);
|
||||
|
||||
return res ? CMD_FAIL : CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static operation_args vendor_config_file_backup_args = {
|
||||
.in = (const char *[]) {
|
||||
"URL",
|
||||
|
|
@ -1074,6 +1112,7 @@ DMLEAF tDeviceInfoVendorLogFileParams[] = {
|
|||
{"Name", &DMREAD, DMT_STRING, get_vlf_name, NULL, BBFDM_BOTH},
|
||||
{"MaximumSize", &DMREAD, DMT_UNINT, get_vlf_max_size, NULL, BBFDM_BOTH},
|
||||
{"Persistent", &DMREAD, DMT_BOOL, get_vlf_persistent, NULL, BBFDM_BOTH},
|
||||
{"Upload()", &DMASYNC, DMT_COMMAND, get_operate_args_DeviceInfoVendorLogFile_Upload, operate_DeviceInfoVendorLogFile_Upload, BBFDM_USP},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue