From 666ac93bab8f4e3214529903a018c133f8ee8917 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Fri, 10 Nov 2006 15:21:26 +0000 Subject: initial check of command line client --- Makefile.am | 13 ++ src/.cvsignore | 8 + src/Makefile.am | 19 ++ src/wsman-client-options.c | 458 +++++++++++++++++++++++++++++++++++++++++++++ src/wsman-client-options.h | 50 +++++ src/wsman.c | 344 ++++++++++++++++++++++++++++++++++ src/wsman.h | 47 +++++ 7 files changed, 939 insertions(+) create mode 100644 Makefile.am create mode 100644 src/.cvsignore create mode 100644 src/Makefile.am create mode 100644 src/wsman-client-options.c create mode 100644 src/wsman-client-options.h create mode 100644 src/wsman.c create mode 100644 src/wsman.h diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..f293069 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ +SUBDIRS = src + +package: dist + cp openwsman.spec /usr/src/packages/SPEC + cp openwsman-*.tar.gz /usr/src/packages/SOURCES + rpmbuild -ba openwsman.spec + +install-data-local: openwsman.pc + $(mkinstalldirs) $(libdir)/pkgconfig + $(INSTALL_DATA) openwsman.pc $(DESTDIR)$(libdir)/pkgconfig + +uninstall-local: + rm -f $(DESTDIR)$(libdir)/pkgconfig/openwsman.pc diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 0000000..884b0f3 --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,8 @@ +Makefile +Makefile.in +*.o +*.lo +*.la +.deps +.libs +wsman diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..341f99f --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,19 @@ +AM_CFLAGS = @CFLAGS@ + +wsman_CFLAGS = \ + $(WSMAN_CFLAGS) + +wsman_LDADD = \ + $(WSMAN_LIBS) + + +wsman_SOURCES = wsman.c \ + wsman-client-options.c \ + wsman-client-options.h \ + wsman.h + +bin_PROGRAMS = \ + wsman + + + diff --git a/src/wsman-client-options.c b/src/wsman-client-options.c new file mode 100644 index 0000000..2c01db9 --- /dev/null +++ b/src/wsman-client-options.c @@ -0,0 +1,458 @@ +/******************************************************************************* + * Copyright (C) 2004-2006 Intel Corp. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corp. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *******************************************************************************/ + +/** + * @author Anas Nashif + */ + +#include +#include +#include +#include +#include + +#include "u/libu.h" + + +#include "wsman-xml-api.h" +#include "wsman-soap.h" +#include "wsman-errors.h" +#include "wsman-client-transport.h" +#include "wsman-client-options.h" +#include "wsman-debug.h" +#include "wsman.h" + +#if 0 +static char *auth_methods[] = { + "basic", + "digest", + "ntlm", + NULL, +}; +#endif + +static const char **wsman_argv = NULL; + + +static int server_port = 0; +static char *cafile = NULL; +static char *username = NULL; +static char *password = NULL; +static char *server = "localhost"; +static char *agent = NULL; +static char *url_path = NULL; +static char *authentication_method = NULL; +static char no_verify_peer = 0; +static char *proxy = NULL; +static char *proxy_upwd = NULL; + + +static int debug_level = -1; +static char *test_case = NULL; +static int enum_max_elements = 0; +char enum_optimize = 0; +char enum_estimate = 0; +char dump_request = 0; +char step = 0; +char request_only = 0; +static char *enum_mode = NULL; +static char *binding_enum_mode = NULL; +static char *enum_context = NULL; + + +static char *cim_namespace = NULL; +static char *fragment = NULL; +static char *wsm_filter = NULL; +static char *wsm_dialect = NULL; + +static unsigned long operation_timeout = 0; +static unsigned long max_envelope_size = 0; + +static char *_action = NULL; +static char *config_file = NULL; +static char *output_file = NULL; +static char *resource_uri = NULL; +static char *invoke_method = NULL; +static char **properties = NULL; + + +WsActions action_data[] = + { + { "get", WSMAN_ACTION_TRANSFER_GET}, + { "put", WSMAN_ACTION_TRANSFER_PUT}, + { "enumerate", WSMAN_ACTION_ENUMERATION}, + { "pull", WSMAN_ACTION_PULL}, + { "release", WSMAN_ACTION_RELEASE}, + { "invoke", WSMAN_ACTION_CUSTOM }, + { "identify", WSMAN_ACTION_IDENTIFY}, + { "test", WSMAN_ACTION_TEST}, + { NULL, 0}, + }; + +char wsman_parse_options(int argc, char **argv) +{ + + char retval = 0; + u_error_t *error = NULL; + + u_option_entry_t options[] = { + { "debug", 'd', U_OPTION_ARG_INT, &debug_level, + "Set the verbosity of debugging output.", "1-6" }, + { "cafile", 'c', U_OPTION_ARG_STRING, &cafile, + "Certificate file", "" }, + { "username", 'u', U_OPTION_ARG_STRING, &username, + "User name", "" }, + { "path", 'g', U_OPTION_ARG_STRING, &url_path, + "Path", "" }, + { "password", 'p', U_OPTION_ARG_STRING, &password, + "Password", "" }, + { "hostname", 'h', U_OPTION_ARG_STRING, &server, + "Host name", "" }, + { "port", 'P', U_OPTION_ARG_INT, &server_port, + "Server Port", ""}, + { "proxy", 'X', U_OPTION_ARG_STRING, &proxy, + "Proxy name", "" }, + { "proxyauth", 'Y', U_OPTION_ARG_STRING, &proxy_upwd, + "Proxy user:pwd", "" }, + { "auth", 'y', U_OPTION_ARG_STRING, &authentication_method, + "Authentication Method", "" }, + { "method", 'a', U_OPTION_ARG_STRING, &invoke_method, + "Method (Works only with 'invoke')", "" }, + { "prop", 'k', U_OPTION_ARG_STRING_ARRAY, &properties, + "Properties with key value pairs (For 'put', 'invoke' and 'create')", + "" }, + { "config-file",'C', U_OPTION_ARG_STRING, &config_file, + "Alternate configuration file", "" }, + { "out-file", 'O', U_OPTION_ARG_STRING, &output_file, + "Write output to file", "" }, + { "noverifypeer",'V', U_OPTION_ARG_NONE, &no_verify_peer, + "Not to verify peer certificate", NULL }, + { NULL } + }; + + + + u_option_entry_t request_options[] = { + { "filter", 'x', U_OPTION_ARG_STRING, &wsm_filter, + "Filter" , "" }, + { "dialect", 'D', U_OPTION_ARG_STRING, &wsm_dialect, + "Filter Dialect" , "" }, + { "timeout", 't', U_OPTION_ARG_INT, &operation_timeout, + "Operation timeout in seconds", "