From 0b5ff84de72d62ee0a7d0cc10b70747ccb089f26 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Fri, 5 Jan 2007 14:32:01 +0000 Subject: adapt to new Create and Put actions --- src/wsman-client-options.c | 17 ++++++++++------- src/wsman-client-options.h | 3 ++- src/wsman.c | 35 +++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/wsman-client-options.c b/src/wsman-client-options.c index f8ea0ca..4b50e2d 100644 --- a/src/wsman-client-options.c +++ b/src/wsman-client-options.c @@ -92,7 +92,7 @@ static char *cim_namespace = NULL; static char *fragment = NULL; static char *wsm_filter = NULL; static char *wsm_dialect = NULL; -static char *selectors = NULL; +static char *input = NULL; static unsigned long operation_timeout = 0; static unsigned long max_envelope_size = 0; @@ -135,6 +135,8 @@ char wsman_parse_options(int argc, char **argv) "User name", "" }, { "path", 'g', U_OPTION_ARG_STRING, &url_path, "Path", "" }, + { "input", 'J', U_OPTION_ARG_STRING, &input, + "File with resource for Create and Put operations in XML, can be a SOAP envelope", "" }, { "password", 'p', U_OPTION_ARG_STRING, &password, "Password", "" }, { "hostname", 'h', U_OPTION_ARG_STRING, &server, @@ -174,8 +176,6 @@ char wsman_parse_options(int argc, char **argv) "maximal envelope size" , "" }, { "fragment", 'F', U_OPTION_ARG_STRING, &fragment, "Fragment (Supported Dialects: XPATH)" , "" }, - { "selectors", 's', U_OPTION_ARG_STRING, &selectors, - "Selectors for fetching", ""}, { NULL } }; @@ -431,6 +431,12 @@ char * wsman_options_get_test_file (void) { return test_case; } + +char * wsman_options_get_input_file (void) +{ + return input; +} + char * wsman_options_get_enum_mode (void) { return enum_mode; @@ -453,10 +459,7 @@ char * wsman_options_get_filter (void) { return wsm_filter; } -char * wsman_options_get_selectors(void) -{ - return selectors; -} + char * wsman_options_get_dialect (void) { return wsm_dialect; diff --git a/src/wsman-client-options.h b/src/wsman-client-options.h index 130b9dd..8f9374d 100644 --- a/src/wsman-client-options.h +++ b/src/wsman-client-options.h @@ -24,6 +24,7 @@ extern char *wsman_options_get_cafile(void); extern int wsman_options_get_max_elements(void); extern char * wsman_options_get_test_file(void); +extern char * wsman_options_get_input_file(void); extern int wsman_options_get_action(void); extern char *wsman_options_get_resource_uri(void); extern hash_t *wsman_options_get_properties (void); @@ -37,7 +38,7 @@ extern char wsman_options_get_step_request (void); extern char wsman_options_get_estimate_enum (void); extern char * wsman_options_get_fragment (void); extern char * wsman_options_get_filter (void); -extern char * wsman_options_get_selectors (void); + extern char * wsman_options_get_dialect (void); extern const char * wsman_options_get_config_file (void); extern unsigned long wsman_options_get_max_envelope_size (void); diff --git a/src/wsman.c b/src/wsman.c index 840cd85..1b9cd1a 100644 --- a/src/wsman.c +++ b/src/wsman.c @@ -113,7 +113,7 @@ main(int argc, char **argv) WsXmlDocH rqstDoc; actionOptions options; WsXmlDocH enum_response; - + WsXmlDocH resource; char *enumeration_mode, *binding_enumeration_mode, *resource_uri_with_selectors; char *resource_uri = NULL; @@ -155,8 +155,8 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } /* - * Setup Resource URI and Selectors - */ + * Setup Resource URI and Selectors + */ resource_uri_with_selectors = wsman_options_get_resource_uri(); if (resource_uri_with_selectors) { wsman_set_options_from_uri(resource_uri_with_selectors, &options); @@ -182,10 +182,6 @@ main(int argc, char **argv) if (wsman_options_get_dialect()) { options.dialect = wsman_options_get_dialect(); } - if (wsman_options_get_selectors()) { - wsman_add_selectors_from_query_string(&options, - wsman_options_get_selectors()); - } options.properties = wsman_options_get_properties(); options.cim_ns = wsman_options_get_cim_namespace(); @@ -225,14 +221,29 @@ main(int argc, char **argv) } break; case WSMAN_ACTION_TRANSFER_CREATE: - doc = ws_transfer_create(cl, resource_uri, NULL, NULL, options); - if (doc) { - wsman_output(doc); - ws_xml_destroy_doc(doc); + if (wsman_options_get_input_file()) { + resource = wsman_client_read_file(cl, + wsman_options_get_input_file(), "UTF-8", 0); + doc = ws_transfer_create(cl, resource_uri, resource, options); + ws_xml_destroy_doc(resource); + if (doc) { + wsman_output(doc); + ws_xml_destroy_doc(doc); + } + } else { + fprintf(stderr, "Missing resource data\n"); } break; case WSMAN_ACTION_TRANSFER_PUT: - doc = ws_transfer_put1(cl, resource_uri, options); + if (wsman_options_get_input_file()) { + printf("input file provided\n"); + resource = wsman_client_read_file(cl, + wsman_options_get_input_file(), "UTF-8", 0); + doc = ws_transfer_put(cl, resource_uri, resource, options); + ws_xml_destroy_doc(resource); + } else { + doc = ws_transfer_get_and_put(cl, resource_uri, options); + } if (doc) { wsman_output(doc); ws_xml_destroy_doc(doc); -- cgit