pax_global_header00006660000000000000000000000064123033301250014502gustar00rootroot0000000000000052 comment=6f94776be47b4581e3dd487edad1414975bb58d5 wsmancli-2.3.1/000077500000000000000000000000001230333012500133225ustar00rootroot00000000000000wsmancli-2.3.1/.gitignore000066400000000000000000000011151230333012500153100ustar00rootroot00000000000000core *~ Makefile Makefile.am Makefile.in aclocal.m4 autom4te.cache config.cache config.guess config.h config.h.in config.log config.status config.sub configure configure.in depcomp install-sh libtool ltconfig ltmain.sh missing mkinstalldirs stamp-h* *.pc *.pc.in Doxyfile .project .cdtproject wsman_config.h wsman_config.h.in openwsman.spec build *.bz2 m4 *.o *.lo *.la *.class .deps .libs examples/cpp/EnumInstance examples/cpp/Identify examples/create_resource examples/enum_epr examples/win32_service examples/wsmid_identify src/wseventmgr src/wsman tests/interop/interop wsmancli.spec wsmancli-2.3.1/ChangeLog000066400000000000000000000031761230333012500151030ustar00rootroot00000000000000Version 2.3.1 - exit with non-zero code if connection fails - man pages (Kent Baxley) - read credentials from environment wsman: WSMAN_USER, WSMAN_PASS, WSMAN_EVENT_USER, WSMAN_EVENT_PASS wseventmgr: WSEVENTMGR_USER, WSEVENTMGR_PASS, WSEVENTMGR_EVENT_USER, WSEVENTMGR_EVENT_PASS - add --non-interactive cli parameter to prevent asking for credentials Version 2.3.0 - don't crash on filter parse error (Zoltan Micskei) - remove -Q (don't send request) option - complain about bad filter expression - fix autotools build for MacOS (Dan Villiom Podlaski Christiansen) Version 2.2.7.1 - adapt to reduced libu exposure in openwsman Version 2.2.7 - fix the default port setting to match wsmc_create() call. Use https (port 5986) when cainfo is set. - in debug mode, dump the complete response XML if it can't be parsed (Chris Poblete) Version 2.2.6 - fix segfault in output_file handling (Chris Poblete) Version 2.2.5 - fix integral parameters on big endian architectures (Kamil Dudka) Version 2.2.4 - Enhance enumerate with association filter to have the ability to specify the optional elements namely: AssociationClassName, Role, ResultClassName, ResultRole and IncludeResultProperty. (IncludeResultProperty is a list, specify it as a comma separated list in the “U” option.) (Chris Poblete) Bugfixes - fix default ports (5985/5986) - fix --sslkey handling - add warning if ssl used without --cacert Version 2.2.3 Bugfix release, synchronize version with openwsman - fix double free error on enumeration (Chris Poblete) - add '--version' to print version and build timestamp wsmancli-2.3.1/Makefile.am000066400000000000000000000004241230333012500153560ustar00rootroot00000000000000SUBDIRS = src man AUTOMAKE_OPTIONS = no-dist-gzip dist-bzip2 if BUILD_EXAMPLES SUBDIRS += examples endif if BUILD_TESTS SUBDIRS += tests endif package: dist cp wsmancli.spec /usr/src/packages/SPEC cp wsmancli-*.tar.gz /usr/src/packages/SOURCES rpmbuild -ba wsmancli.spec wsmancli-2.3.1/README.WIN000066400000000000000000000003411230333012500146340ustar00rootroot00000000000000README for wsmancli on Windows ------------------------------ wsmancli.vcproj, wseventmgr.vcproj, and wsmancli.sln are project files for Visual Studio 2005 (VS2005). You can open these in VS2008 which will do a conversion. wsmancli-2.3.1/bootstrap000077500000000000000000000003441230333012500152660ustar00rootroot00000000000000#!/bin/sh UNAME=`uname` if [ "$UNAME" = "Darwin" ]; then LIBTOOLIZE=glibtoolize else LIBTOOLIZE=libtoolize fi $LIBTOOLIZE --copy --force --automake aclocal autoheader automake --add-missing --copy --foreign autoconf wsmancli-2.3.1/configure.in000066400000000000000000000032251230333012500156350ustar00rootroot00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT(wsmancli, 2.3.1) AC_CONFIG_SRCDIR(wsmancli.spec.in) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE AC_ISC_POSIX AC_PROG_CC AC_PROG_CXX AM_PROG_CC_STDC AC_HEADER_STDC AM_PROG_LIBTOOL WSMAN_PKG=$PACKAGE_NAME AC_SUBST(WSMAN_PKG) PACKAGE_BUILDTS=`date +%Y%m%d%H%M` AC_SUBST(PACKAGE_BUILDTS) PKG_CHECK_MODULES(OPENWSMAN, [openwsman >= 2.2.7]) have_cunit=no AC_CHECK_HEADERS([CUnit/Basic.h], have_cunit="yes" ) AM_CONDITIONAL(BUILD_CUNIT_TESTS, test "$have_cunit" == "yes") examples_default=no AC_ARG_WITH(examples, [ --with-examples=[no/yes] build examples [default=no]],, with_examples=$examples_default) AM_CONDITIONAL(BUILD_EXAMPLES, test "x$with_examples" = "xyes") tests_default=no AC_ARG_WITH(tests, [ --with-tests=[no/yes] build tests [default=no]],, with_tests=$tests_default) AM_CONDITIONAL(BUILD_TESTS, test "x$with_tests" = "xyes") dnl ************************************* dnl *** Warnings to show if using GCC *** dnl ************************************* AC_ARG_ENABLE(more-warnings, [ --disable-more-warnings Inhibit compiler warnings], set_more_warnings=no) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then CFLAGS="$CFLAGS \ -Wall -Wstrict-prototypes -Wmissing-declarations \ -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ -Wunused -Werror" fi AC_OUTPUT([ wsmancli.spec Makefile src/Makefile examples/Makefile examples/cpp/Makefile tests/Makefile tests/interop/Makefile tests/cunit/Makefile man/Makefile ]) wsmancli-2.3.1/doc/000077500000000000000000000000001230333012500140675ustar00rootroot00000000000000wsmancli-2.3.1/doc/wsman.xml000066400000000000000000000261101230333012500157360ustar00rootroot00000000000000 wsman 1 wsman openwsman command-line client /usr/bin/wsman action resource uri Description Openwsman provides a command-line tool, wsman, to perform basic operations on the command-line. These operations include Get, Put, Invoke, Identify, Delete, Create, and Enumerate. The command-line tool also has several switches to allow for optional features of the WS-Management specification and Testing. Options All wsman operations require and action and a group of options. The resource uri is required for the Identify action, otherwise it is required for all actions. Support Actions get Creates and sends a Get request to the specified remote system. In most cases this action requires a resource uri with a set of selectors which can be specfied as query paramters in the URI (See below for examples). The result of this action is an XML output of the envelope with the resource and its properties. put Creates and sends a Put request to the specified remote system. In most cases this action requires a resource uri with a set of selectors which can be specfied as query paramters in the URI (See below for examples). This action also requires input which can be specified either as properties or as an XML input representing the new resource. The result of this action is an XML output of the envelope with the new resource and its properties. invoke Creates and sends a request with a custom action to the specified remote system. In most cases this action requires a resource uri with a set of selectors which can be specfied as query paramters in the URI (See below for examples). This action also requires input which can be specified either as properties or as an XML input representing the arguments of the custom action. The result of this action is an XML output of the envelope with the output of the custom action. enumerate Creates and sends an Enumeration request to the specified remote system. This action also peforms Pull actions using the enumeration context provided by the enumeration response and following pull responses. The result of this action is an XML output of the envelope with the resource or resources and its/their properties. identify Creates and sends an Identify request to the specified remote system. The result of this action is an XML output with properties of the services defined by the specification. Basic Startup Options -u username, --username username User name -c filename, --cafile=filename Certificate file for SSL connections -g path, --path=path URL path of the service, for example /wsman. -p password, --password=password User password. -J filename, --input=filename File with resource for Create and Put operations in XML, can be a SOAP envelope -d 1-6, --debug=1-6 Debug level -h hostname, --hostname=hostname Hostname of the remote machine. -P port, --port=port Port of the service -X proxy, --proxy=proxy Remote proxy address -Y user:pass, --proxyauth=user:pass Remote proxy credentials -y basic|digest|gss, --auth=basic|digest|gss Authentication method to be used. By default the method is selected automatically depending on the challange from the server. This options is used to force an authentication method. -a custom method, --method=custom method Custom method name. -k key=val, --prop=key=val A key/value pair to pass properties for custom methods and put action. -C config file, --config-file=config file Alternate configuration file. -O filename, --out-file=filename Redirect output to a file instead of console. -V, --noverifypeer Do not verify peer certificate with SSL connections Enumeration Options Request flags and options CIM Options Test and Internal Options wsmancli-2.3.1/examples/000077500000000000000000000000001230333012500151405ustar00rootroot00000000000000wsmancli-2.3.1/examples/.cvsignore000066400000000000000000000000651230333012500171410ustar00rootroot00000000000000Makefile Makefile.in *.o *.lo *.la .deps .libs wsman wsmancli-2.3.1/examples/Makefile.am000066400000000000000000000006461230333012500172020ustar00rootroot00000000000000SUBDIRS = cpp AM_CFLAGS = @CFLAGS@ CFLAGS = \ $(OPENWSMAN_CFLAGS) LDADD = \ $(OPENWSMAN_LIBS) \ -lwsman_curl_client_transport wsmid_identify_SOURCES = wsmid_identify.c win32_service_SOURCES = \ win32_service.c enum_epr_SOURCES = \ enum_epr.c create_resource_SOURCES = \ create_resource.c noinst_PROGRAMS = \ wsmid_identify \ win32_service \ enum_epr \ create_resource wsmancli-2.3.1/examples/README000066400000000000000000000042751230333012500160300ustar00rootroot00000000000000 wsmid_identify -------------- Summary: Issue an Identify request and de-serialize the result. Options: -p, --product Print Product Vendor -v, --version Print Product Version -P, --protocol Print Protocol Version -u, --endpoint= Endpoint in form of a URL Example: % ./wsmid_identify -u http://wsman:secret@example.com:8889/wsman Openwsman Project 0.7.0 supporting protocol http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd serialize ---------- Summary: Examples using the XML serialization and de-serialization API. Options: None Example: run ./serialize in the local directory which will do several serialization and de-serialization routines. For more details, check the file 'doc/README.serialization' in the openwsman repository for detailed documentation of the serialization API. win32_service ---------------- Summary: A command-line client to manage and display services on a Microsoft Windows machine with WS-Management support (Vista). Options: -u, --endpoint= Endpoint in form of a URL -l, --list-all List all services -d, --desc Show service description -s, --stop Stop service -S, --start Start service -X, --status Get service status -D, --dump Dump request For actions related to one service, add the name of the service as an argument. Example: ./win32_service -u http://wsman:secret@example.com:80/wsman -l -X ... ... wmiApSrv State: Stopped WMPNetworkSvc State: Stopped WPCSvc State: Stopped WPDBusEnum State: Running wscsvc State: Running WSearch State: Running wuauserv State: Running wudfsvc State: Stopped ... ... ./win32_service -u http://wsman:secret@example.com:80/wsman -d wudfsvc wudfsvc State: Stopped Description: Manages user-mode driver host processes wsmancli-2.3.1/examples/cpp/000077500000000000000000000000001230333012500157225ustar00rootroot00000000000000wsmancli-2.3.1/examples/cpp/.cvsignore000066400000000000000000000000651230333012500177230ustar00rootroot00000000000000Makefile Makefile.in *.o *.lo *.la .deps .libs wsman wsmancli-2.3.1/examples/cpp/EnumInstance.cpp000066400000000000000000000017521230333012500210240ustar00rootroot00000000000000#include #include #include using std::cout; using namespace WsmanClientNamespace; int main(int argc, char* argv[]) { const char *endpoint, *resource_uri; u_uri_t *uri; if (argc< 3) { fprintf(stderr, "Usage: %s \n", argv[0]); } endpoint= argv[1]; resource_uri = argv[2]; if (!endpoint || !resource_uri) { fprintf(stderr, "endpoint option required\n"); return 1; } if (endpoint != NULL) if (u_uri_parse((const char *) endpoint, &uri) != 0 ) return 1; OpenWsmanClient *client = new OpenWsmanClient( uri->host, uri->port, uri->path, uri->scheme, "digest", uri->user, uri->pwd); vector vec; try { client->Enumerate(resource_uri, vec ); } catch (GeneralWsmanException &e) { printf("GeneralWsmanException:\n"); printf("%s\n", e.what()); } for (vector::iterator iter = vec.begin(); iter != vec.end(); ++iter) { cout << "item: " << *iter << "\n"; } return 0; } wsmancli-2.3.1/examples/cpp/Identify.cpp000066400000000000000000000015071230333012500202040ustar00rootroot00000000000000#include #include #include using std::cout; using namespace WsmanClientNamespace; int main(int argc, char* argv[]) { const char *endpoint, *resource_uri; string out; u_uri_t *uri; if (argc< 2) { fprintf(stderr, "Usage: %s \n", argv[0]); } endpoint= argv[1]; if (!endpoint) { fprintf(stderr, "endpoint option required\n"); return 1; } if (endpoint != NULL) if (u_uri_parse((const char *) endpoint, &uri) != 0 ) return 1; OpenWsmanClient *client = new OpenWsmanClient( uri->host, uri->port, uri->path, uri->scheme, "digest", uri->user, uri->pwd); try { out = client->Identify(); } catch (GeneralWsmanException &e) { printf("GeneralWsmanException:\n"); printf("%s\n", e.what()); } cout << "Identify: " << out << "\n"; return 0; } wsmancli-2.3.1/examples/cpp/Makefile.am000066400000000000000000000003531230333012500177570ustar00rootroot00000000000000 LDADD = \ $(OPENWSMAN_LIBS) -lwsman_clientpp CXXFLAGS = \ $(OPENWSMAN_CFLAGS) EnumInstance_SOURCES = \ EnumInstance.cpp Identify_SOURCES = \ Identify.cpp noinst_PROGRAMS = \ EnumInstance \ Identify wsmancli-2.3.1/examples/create_resource.c000066400000000000000000000120611230333012500204560ustar00rootroot00000000000000/******************************************************************************* * 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 #include "wsman-xml-serializer.h" #include "wsman-client-api.h" #include "wsman-client-transport.h" #include "u/libu.h" #define RESOURCE_URI "http://example.com/wbem/wscim/1/schema/1/EXL_ExamplePolicy" #define CLASSNAME "EXL_ExamplePolicy" /* struct __XmlSerializerInfo Handles_TypeInfo[] = { SER_UINT32("Handles", 1, 1) }; */ SER_TYPEINFO_UINT32; struct __EXL_ExamplePolicy { XML_TYPE_STR ElementName; XML_TYPE_STR Description; XML_TYPE_STR Caption; XML_TYPE_STR InstanceID; XML_TYPE_STR PolicyName; XML_TYPE_UINT32 PolicyPrecedence; XML_TYPE_DYN_ARRAY Handles; XML_TYPE_BOOL DefaultTest; }; typedef struct __EXL_ExamplePolicy EXL_ExamplePolicy; SER_START_ITEMS(EXL_ExamplePolicy) SER_NS_STR(RESOURCE_URI, "ElementName", 1), SER_NS_STR(RESOURCE_URI, "Description", 1), SER_NS_STR(RESOURCE_URI, "Caption", 1), SER_NS_STR(RESOURCE_URI, "InstanceID", 1), SER_NS_STR(RESOURCE_URI, "PolicyName", 1), SER_NS_UINT32(RESOURCE_URI, "PolicyPrecedence", 1 ), SER_NS_DYN_ARRAY(RESOURCE_URI, "Handles", 1, 10, uint32), SER_NS_BOOL(RESOURCE_URI, "DefaultTest", 1), SER_END_ITEMS(EXL_ExamplePolicy); static char *endpoint = NULL; static char dump; int main(int argc, char** argv) { WsManClient *cl; WsXmlDocH doc; client_opt_t *options; char retval = 0; u_error_t *error = NULL; u_option_entry_t opt[] = { { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint, "Endpoint in form of a URL", "" }, { "dump", 'd', U_OPTION_ARG_NONE, &dump, "Dump request", NULL }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "Create Resource"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); u_uri_t *uri; if (endpoint) { if (u_uri_parse((const char *)endpoint, &uri)!=0 ) return 1; } if (!endpoint || !uri) { fprintf(stderr, "endpoint option required\n"); return 1; } cl = wsmc_create( uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); wsmc_transport_init(cl, NULL); options = wsmc_options_init(); if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST ); options->max_envelope_size = 51200; options->timeout = 60000; EXL_ExamplePolicy *d = u_malloc(sizeof(EXL_ExamplePolicy)); d->ElementName = u_strdup("name"); d->DefaultTest = 1; int *array = NULL; int count = 4; array = (int *) malloc (sizeof (int) * count); array[0] = 1; array[1] = 0; array[2] = 3; array[3] = 5; d->Handles.count = count; d->Handles.data = array; doc = wsmc_action_create_serialized(cl, RESOURCE_URI, options, d, EXL_ExamplePolicy_TypeInfo); if (doc) ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc)); if (uri) { u_uri_free(uri); } wsmc_options_destroy(options); wsmc_release(cl); return 0; } wsmancli-2.3.1/examples/enum_epr.c000066400000000000000000000133761230333012500171300ustar00rootroot00000000000000/******************************************************************************* * 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 #include "u/libu.h" #include "wsman-client-api.h" #include "wsman-client-transport.h" static char *endpoint = NULL; struct __WsmanEpr { hash_t *selectors; char* resource_uri; }; typedef struct __WsmanEpr WsmanEpr; static int collect_epr(WsManClient *cl, WsXmlDocH doc, void *data) { if (!doc) { return 0; } list_t *list = (list_t *)data; WsXmlNodeH resource_uri_node, node1, node2, node3, node4; WsmanEpr *epr = (WsmanEpr *)u_zalloc(sizeof(WsmanEpr)); WsXmlNodeH body = ws_xml_get_soap_body(doc); if (body != NULL) node1 = ws_xml_get_child(body, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP); else return 0; if (node1 != NULL ) node2 = ws_xml_get_child(node1, 0, XML_NS_ENUMERATION, WSENUM_ITEMS); else return 0; if (node2 != NULL) node3 = ws_xml_get_child(node2, 0, XML_NS_ADDRESSING, WSA_EPR); else return 0; if (node3 != NULL) node4 = ws_xml_get_child(node3, 0, XML_NS_ADDRESSING, WSA_REFERENCE_PARAMETERS); else return 0; if (node4 != NULL) resource_uri_node = ws_xml_get_child(node4, 0, XML_NS_WS_MAN, WSM_RESOURCE_URI); else return 0; if (resource_uri_node != NULL) { epr->resource_uri = u_strdup(ws_xml_get_node_text(resource_uri_node)); } else { return 0; } epr->selectors = hash_create(HASHCOUNT_T_MAX, 0, 0); WsXmlNodeH selectors = ws_xml_get_child(node4, 0, XML_NS_WS_MAN, WSM_SELECTOR_SET); if ( selectors ) { WsXmlNodeH selector; int index = 0; while( (selector = ws_xml_get_child(selectors, index++, XML_NS_WS_MAN, WSM_SELECTOR)) ) { char* attrVal = ws_xml_find_attr_value(selector, XML_NS_WS_MAN, WSM_NAME); if ( attrVal == NULL ) attrVal = ws_xml_find_attr_value(selector, NULL, WSM_NAME); if ( attrVal ) { if (!hash_alloc_insert(epr->selectors, u_strdup(attrVal), u_strdup(ws_xml_get_node_text(selector)))) { error("hash_alloc_insert failed"); } } } } lnode_t *n = lnode_create(epr); list_append(list, n); return 1; } int main(int argc, char** argv) { WsManClient *cl; client_opt_t *options; char retval = 0; u_error_t *error = NULL; u_option_entry_t opt[] = { { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint, "Endpoint in form of a URL", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "Win32 Service"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); u_uri_t *uri; if (endpoint) { u_uri_parse((const char *)endpoint, &uri); } if (!endpoint || !uri) { fprintf(stderr, "endpoint option required\n"); return 1; } cl = wsmc_create( uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); wsmc_transport_init(cl, NULL); options = wsmc_options_init(); wsmc_set_action_option(options, FLAG_ENUMERATION_ENUM_EPR); list_t *l = list_create(LISTCOUNT_T_MAX); wsmc_action_enumerate_and_pull(cl, argv[1] , options, NULL, collect_epr, l ); printf("returned items: %d\n", (int)list_count(l)); lnode_t *node = list_first(l); while(node) { WsmanEpr* epr = (WsmanEpr*) node->list_data; hscan_t hs; hnode_t *hn; printf("%s\n", epr->resource_uri); hash_scan_begin(&hs, epr->selectors); while ((hn = hash_scan_next(&hs))) { printf("\t%s = %s\n", (char*) hnode_getkey(hn), (char*) hnode_get(hn) ); } node = list_next (l, node); } if (uri) { u_uri_free(uri); } wsmc_options_destroy(options); wsmc_release(cl); return 0; } wsmancli-2.3.1/examples/session_api_transfer_create.c000066400000000000000000000052661230333012500230600ustar00rootroot00000000000000#include "wsman-client-api.h" #include "wsman-xml-serializer.h" #define CLASSNAME "EXL_ExamplePolicy" SER_TYPEINFO_UINT32; struct __EXL_ExamplePolicy { XML_TYPE_STR ElementName; XML_TYPE_STR Description; XML_TYPE_STR Caption; XML_TYPE_STR InstanceID; XML_TYPE_STR PolicyName; XML_TYPE_UINT32 PolicyPrecedence; XML_TYPE_DYN_ARRAY Handles; XML_TYPE_BOOL DefaultTest; }; typedef struct __EXL_ExamplePolicy EXL_ExamplePolicy; SER_START_ITEMS(EXL_ExamplePolicy) SER_STR("ElementName", 1), SER_STR("Description", 1), SER_STR("Caption", 1), SER_STR("InstanceID", 1), SER_STR("PolicyName", 1), SER_UINT32("PolicyPrecedence", 1 ), SER_DYN_ARRAY("Handles", 1, 10, uint32), SER_BOOL("DefaultTest", 1), SER_END_ITEMS(EXL_ExamplePolicy); int main(int argc, char** argv) { int sid; int i = 0; char *res; const char *resource_uri = "http://example.com/wbem/wscim/1/schema/1/EXL_ExamplePolicy"; int retval; u_error_t *error = NULL; char *user = NULL; char *passwd = NULL; u_option_entry_t opt[] = { { "user", 'u', U_OPTION_ARG_STRING, &user, "user name", "" }, { "passwd", 'p', U_OPTION_ARG_STRING, &passwd, "password", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "adv api example"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); if (!user || !passwd) { printf("\t new_api_example: user and passwd are required\n"); return 1; } sid = wsman_session_open("localhost", 8889, "/wsman", "http", user, passwd, 0); if (sid < 0) { printf("Open session failed\n"); return 0; } wsman_session_resource_locator_set(sid, resource_uri); EXL_ExamplePolicy *d = u_malloc(sizeof(EXL_ExamplePolicy)); d->ElementName = u_strdup("name"); d->DefaultTest = 1; int *array = NULL; int count = 4; array = (int *) malloc (sizeof (int) * count); array[0] = 1; array[1] = 0; array[2] = 3; array[3] = 5; d->Handles.count = count; d->Handles.data = array; printf("\n******** Opened session id %d ********\n\n", sid); res = wsman_session_serialize(sid, d, EXL_ExamplePolicy_TypeInfo); res = wsman_session_transfer_create(sid, res, 0); if (!res) { printf("******** Transfer Create failed - %s ********\n\n", wsman_session_error(sid)); return 0; } printf ("******** Transfer Create response ********\n%s\n", res); wsman_session_close(sid); printf("******** Closed session id %d ********\n\n", sid); return 1; } wsmancli-2.3.1/examples/session_example.c000066400000000000000000000030401230333012500204770ustar00rootroot00000000000000#include "wsman-client-api.h" int main(int argc, char** argv) { int sid; char *response; char retval = 0; const char *resource_uri = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem"; u_error_t *error = NULL; char *user = NULL; char *passwd = NULL; u_option_entry_t opt[] = { { "user", 'u', U_OPTION_ARG_STRING, &user, "user name", "" }, { "passwd", 'p', U_OPTION_ARG_STRING, &passwd, "password", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "adv api example"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 0; } u_error_free(error); if (!user || !passwd) { printf("\t new_api_example: user and passwd are required\n"); return 0; } sid = wsman_session_open("localhost", 8889, "/wsman", "http", user, passwd, 0); if (sid < 0) { printf("Open session failed\n"); return 0; } printf("\n******** Opened session id %d ********\n\n", sid); response = wsman_session_identify(sid, 0); if (!response) { printf("******** Identify failed - %s ********\n\n", wsman_session_error(sid)); goto end; } printf("******** Identify response *******\n%s\n", response); end: wsman_session_close(sid); printf("******** Closed session id %d ********\n\n", sid); return retval; } wsmancli-2.3.1/examples/session_invoke.c000066400000000000000000000040671230333012500203510ustar00rootroot00000000000000#include "wsman-client-api.h" int main(int argc, char** argv) { int sid; int eid; char *response; char retval = 0; const char *resource_uri = "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_SystemTimeService"; u_error_t *error = NULL; char *user = NULL; char *passwd = NULL; u_option_entry_t opt[] = { { "user", 'u', U_OPTION_ARG_STRING, &user, "user name", "" }, { "passwd", 'p', U_OPTION_ARG_STRING, &passwd, "password", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "adv api example"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 0; } u_error_free(error); if (!user || !passwd) { printf("\t new_api_example: user and passwd are required\n"); return 0; } sid = wsman_session_open("localhost", 8889, "/wsman", "http", user, passwd, 0); if (sid < 0) { printf("Open session failed\n"); return 0; } printf("\n******** Opened session id %d ********\n\n", sid); eid = wsman_session_enumerate(sid, resource_uri, NULL, NULL, FLAG_ENUMERATION_ENUM_EPR); if (eid < 0) { printf("******** Enumeration failed - %s ********\n\n", wsman_session_error(sid)); goto end; } response = wsman_enumerator_pull(eid); if (!response) { printf("******** Pull failed - %s ********\n\n", wsman_enumerator_error(eid)); } wsman_enumerator_release(eid); wsman_session_resource_locator_set(sid, response); response = wsman_session_invoke(sid, "ManageSystemTime", "TRUE", 0); if (!response) { printf("******** Invoke failed - %s ********\n\n", wsman_session_error(sid)); goto end; } printf("******** Invoke response *******\n%s\n", response); retval = 1; end: wsman_session_close(sid); printf("******** Closed session id %d ********\n\n", sid); return retval; } wsmancli-2.3.1/examples/session_transfer_get_put.c000066400000000000000000000047041230333012500224270ustar00rootroot00000000000000#include "wsman-client-api.h" int main(int argc, char** argv) { int sid; int eid; int sid1; int i = 0; char *response; char retval = 0; const char *resource_uri = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem"; u_error_t *error = NULL; char *user = NULL; char *passwd = NULL; u_option_entry_t opt[] = { { "user", 'u', U_OPTION_ARG_STRING, &user, "user name", "" }, { "passwd", 'p', U_OPTION_ARG_STRING, &passwd, "password", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "adv api example"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); if (!user || !passwd) { printf("\t new_api_example: user and passwd are required\n"); return 1; } sid = wsman_session_open("localhost", 8889, "/wsman", "http", user, passwd, 0); if (sid < 0) { printf("Open session failed\n"); return 0; } printf("\n******** Opened session id %d ********\n\n", sid); eid = wsman_session_enumerate(sid, resource_uri, NULL, NULL, FLAG_ENUMERATION_ENUM_EPR); if (eid < 0) { printf("******** Enumeration failed - %s ********\n\n", wsman_session_error(sid)); return 0; } while (wsman_enumerator_end(eid)) { i++; response = wsman_enumerator_pull(eid); if (!response) { printf("******** Pull (%d) failed - %s ********\n\n", i, wsman_enumerator_error(eid)); break; } printf("******** Pull response (%d) *******\n%s\n", i, response); sid1 = wsman_session_resource_locator_new(sid, response); response = wsman_session_transfer_get(sid1, 0); if (!response) { printf("******** Transfer Get failed - %s ********\n\n", wsman_session_error(sid1)); goto continuep; } printf ("******** Transfer Get response ********\n%s\n", response); response = wsman_session_transfer_put(sid1, response, 0); if (!response) { printf("******** Transfer Put failed - %s ********\n\n", wsman_session_error(sid1)); goto continuep; } printf ("******** Transfer Put response ********\n%s\n", response); continuep: wsman_session_close(sid1); } wsman_session_close(sid); printf("******** Closed session id %d ********\n\n", sid); return 1; } wsmancli-2.3.1/examples/win32_service.c000066400000000000000000000205131230333012500177670ustar00rootroot00000000000000/******************************************************************************* * 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 #include "wsman-api.h" #include "u/libu.h" #define RESOURCE_URI "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service" #define CLASSNAME "Win32_Service" /* boolean AcceptPause; boolean AcceptStop; string Caption; uint32 CheckPoint; string CreationClassName; string Description; boolean DesktopInteract; string DisplayName; string ErrorControl; uint32 ExitCode; datetime InstallDate; string Name; string PathName; uint32 ProcessId; uint32 ServiceSpecificExitCode; string ServiceType; boolean Started; string StartMode; string StartName; string State; string Status; string SystemCreationClassName; string SystemName; uint32 TagId; uint32 WaitHint; */ struct __CIM_Servie { XML_TYPE_BOOL AcceptPause; XML_TYPE_BOOL AcceptStop; XML_TYPE_STR Caption; XML_TYPE_UINT32 CheckPoint; XML_TYPE_STR CreationClassName; XML_TYPE_STR Description; XML_TYPE_BOOL DesktopInteract; XML_TYPE_STR DisplayName; XML_TYPE_STR ErrorControl; XML_TYPE_UINT32 ExitCode; XML_TYPE_STR InstallDate; XML_TYPE_STR Name; XML_TYPE_STR PathName; XML_TYPE_UINT32 ProcessId; XML_TYPE_UINT32 ServiceSpecificExitCode; XML_TYPE_STR ServiceType; XML_TYPE_BOOL Started; XML_TYPE_STR StartMode; XML_TYPE_STR StartName; XML_TYPE_STR State; XML_TYPE_STR Status; XML_TYPE_STR SystemCreationClassName; XML_TYPE_STR SystemName; XML_TYPE_UINT32 TagId; XML_TYPE_UINT32 WaitHint; }; typedef struct __CIM_Servie CIM_Servie; SER_START_ITEMS(CIM_Servie) SER_NS_BOOL(RESOURCE_URI,"AcceptPause", 1), SER_NS_BOOL(RESOURCE_URI,"AcceptStop", 1), SER_NS_STR(RESOURCE_URI,"Caption", 1), SER_NS_UINT32(RESOURCE_URI,"CheckPoint", 1), SER_NS_STR(RESOURCE_URI,"CreationClassName", 1), SER_NS_STR(RESOURCE_URI,"Description", 1), SER_NS_BOOL(RESOURCE_URI,"DesktopInteract", 1), SER_NS_STR(RESOURCE_URI,"DisplayName", 1), SER_NS_STR(RESOURCE_URI,"ErrorControl", 1), SER_NS_UINT32(RESOURCE_URI,"ExitCode", 1), SER_NS_STR(RESOURCE_URI,"InstallDate", 1), SER_NS_STR(RESOURCE_URI,"Name", 1), SER_NS_STR(RESOURCE_URI,"PathName", 1), SER_NS_UINT32(RESOURCE_URI,"ProcessId", 1), SER_NS_UINT32(RESOURCE_URI,"ServiceSpecificExitCode", 1), SER_NS_STR(RESOURCE_URI,"ServiceType", 1), SER_NS_BOOL(RESOURCE_URI,"Started", 1), SER_NS_STR(RESOURCE_URI,"StartMode", 1), SER_NS_STR(RESOURCE_URI,"StartName", 1), SER_NS_STR(RESOURCE_URI,"State", 1), SER_NS_STR(RESOURCE_URI,"Status", 1), SER_NS_STR(RESOURCE_URI,"SystemCreationClassName", 1), SER_NS_STR(RESOURCE_URI,"SystemName", 1), SER_NS_UINT32(RESOURCE_URI,"TagId", 1), SER_NS_UINT32(RESOURCE_URI,"WaitHint", 1), SER_END_ITEMS(CIM_Servie); static char *endpoint = NULL; char listall = 0; char stop = 0; char start = 0; char desc = 0; char status = 0; char dump = 0; static void print_info(CIM_Servie *service) { if (service->Name) { printf("%s\n", service->Name ); } else { printf("Error\n"); return; } if (status) printf("\tState: %s\n", service->State ); if (desc) printf("\tDescription: %s\n\n", service->Description ); } static int list_services(WsManClient *cl, WsXmlDocH doc, void *data) { if (!doc) { return 0; } if (dump) ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc)); WsXmlNodeH node = ws_xml_get_soap_body(doc); node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP); node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_ITEMS); if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) { CIM_Servie *service = ws_deserialize( wsmc_get_serialization_context( cl ), node, CIM_Servie_TypeInfo, CLASSNAME, RESOURCE_URI, NULL, 0, 0); print_info(service); return 1; } return 0; } int main(int argc, char** argv) { WsManClient *cl; WsXmlDocH doc; client_opt_t *options; char retval = 0; u_error_t *error = NULL; u_option_entry_t opt[] = { { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint, "Endpoint in form of a URL", "" }, { "list-all", 'l', U_OPTION_ARG_NONE, &listall, "List all services", NULL }, { "desc", 'd', U_OPTION_ARG_NONE, &desc, "Show service description", NULL }, { "stop", 's', U_OPTION_ARG_NONE, &stop, "Stop service", NULL }, { "start", 'S', U_OPTION_ARG_NONE, &start, "Start service", NULL }, { "status", 'X', U_OPTION_ARG_NONE, &status, "Get service status", NULL }, { "dump", 'D', U_OPTION_ARG_NONE, &dump, "Dump request", NULL }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "Win32 Service"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); u_uri_t *uri; if (endpoint) { u_uri_parse((const char *)endpoint, &uri); } if (!endpoint || !uri) { fprintf(stderr, "endpoint option required\n"); return 1; } cl = wsmc_create( uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); wsmc_transport_init(cl, NULL); options = wsmc_options_init(); if (listall) { if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST ); wsmc_action_enumerate_and_pull(cl, RESOURCE_URI, options, NULL, list_services, NULL ); } else if (start && argv[1]) { if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST ); wsmc_add_selector(options, "Name", argv[1]); doc = wsmc_action_invoke(cl, RESOURCE_URI, options, "StartService", NULL); ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc)); ws_xml_destroy_doc(doc); } else if (stop && argv[1]) { if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST ); wsmc_add_selector(options, "Name", argv[1]); doc = wsmc_action_invoke(cl, RESOURCE_URI, options, "StopService", NULL); ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc)); ws_xml_destroy_doc(doc); } else if ( argv[1] ) { if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST ); wsmc_add_selector(options, "Name", argv[1]); doc = wsmc_action_get(cl, RESOURCE_URI, options); if (doc) { WsXmlNodeH node = ws_xml_get_soap_body(doc); if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) { CIM_Servie *service = ws_deserialize( wsmc_get_serialization_context( cl ), node, CIM_Servie_TypeInfo, CLASSNAME, RESOURCE_URI, NULL, 0, 0); desc = 1; status = 1; print_info(service); } } ws_xml_destroy_doc(doc); } if (uri) { u_uri_free(uri); } wsmc_options_destroy(options); wsmc_release(cl); return 0; } wsmancli-2.3.1/examples/wsmid_identify.c000066400000000000000000000124011230333012500203200ustar00rootroot00000000000000/******************************************************************************* * 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 #include "wsman-api.h" #include "u/libu.h" struct __wsmid_identify { XML_TYPE_STR ProtocolVersion; XML_TYPE_STR ProductVendor; XML_TYPE_STR ProductVersion; }; typedef struct __wsmid_identify wsmid_identify; SER_START_ITEMS(wsmid_identify) SER_NS_STR(XML_NS_WSMAN_ID, "ProtocolVersion", 1), SER_NS_STR(XML_NS_WSMAN_ID, "ProductVendor", 1), SER_NS_STR(XML_NS_WSMAN_ID, "ProductVersion", 1), SER_END_ITEMS(wsmid_identify); static char vendor = 0; static char version = 0; static char protocol = 0; static char *endpoint = NULL; static int debug_level = -1; static void initialize_logging(void) { debug_add_handler(wsman_debug_message_handler, DEBUG_LEVEL_ALWAYS, NULL); } int main(int argc, char** argv) { WsManClient *cl; WsXmlDocH doc; client_opt_t *options; char retval = 0; u_error_t *error = NULL; WsSerializerContextH cntx = NULL; initialize_logging(); u_option_entry_t opt[] = { { "product", 'p', U_OPTION_ARG_NONE, &vendor, "Print Product Vendor", NULL }, { "version", 'v', U_OPTION_ARG_NONE, &version, "Print Product Version", NULL }, { "protocol", 'P', U_OPTION_ARG_NONE, &protocol, "Print Protocol Version", NULL }, { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint, "Endpoint in form of a URL", "" }, { NULL } }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf ("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); wsman_debug_set_level(debug_level); u_uri_t *uri; if (endpoint) { u_uri_parse((const char *)endpoint, &uri); } if (!endpoint || !uri) { fprintf(stderr, "endpoint option required\n"); return 1; } /* fprintf( stderr, "wsman_create_client( host %s, port %d, path %s, scheme %s, user %s, passwd %s\n", uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); */ cl = wsmc_create( uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); options = wsmc_options_init(); doc = wsmc_action_identify(cl, options); if (doc) { WsXmlNodeH soapBody = ws_xml_get_soap_body(doc); if (ws_xml_get_child(soapBody, 0, XML_NS_WSMAN_ID, "IdentifyResponse")) { cntx = ws_serializer_init(); debug("cntx: %p", cntx); wsmid_identify *id = ws_deserialize(cntx, soapBody, wsmid_identify_TypeInfo, "IdentifyResponse", XML_NS_WSMAN_ID, NULL, 0, 0); if (!id) { fprintf(stderr, "Serialization failed\n"); return 1; } if (vendor) printf("%s\n", id->ProductVendor); if (version) printf("%s\n", id->ProductVersion); if (protocol) printf("%s\n", id->ProtocolVersion); if (!protocol && !vendor && !version && id) { printf("\n"); printf("%s %s supporting protocol %s\n", id->ProductVendor, id->ProductVersion,id->ProtocolVersion); } } if (uri) { u_uri_free(uri); } ws_xml_destroy_doc(doc); } else { if (wsmc_get_response_code(cl) != 200) { fprintf(stderr, "Connection failed. response code = %ld\n", wsmc_get_response_code(cl)); if (wsmc_get_fault_string(cl)) { fprintf(stderr, "%s\n", wsmc_get_fault_string(cl)); } } } wsmc_options_destroy(options); wsmc_release(cl); return 0; } wsmancli-2.3.1/examples/wsmid_identify_no_options.c000066400000000000000000000101551230333012500225730ustar00rootroot00000000000000/******************************************************************************* * 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 #ifdef HAVE_UNISTD_H #include #endif #include #include #include "u/libu.h" #include "wsman-client-api.h" #include "wsman-client-transport.h" #include "wsman-xml-serializer.h" struct __wsmid_identify { char* ProtocolVersion; char* ProductVendor; char* ProductVersion; }; typedef struct __wsmid_identify wsmid_identify; SER_START_ITEMS("IdentifyResponse", wsmid_identify) SER_STR("ProtocolVersion", 1, 1), SER_STR("ProductVendor", 1, 1), SER_STR("ProductVersion", 1, 1), SER_END_ITEMS("IdentifyResponse", wsmid_identify); static char vendor = 0; static char version = 0; static char protocol = 0; static char *endpoint = NULL; int main(int argc, char** argv) { WsManClient *cl; WsXmlDocH doc; client_opt_t options; char retval = 0; WsXmlNodeH soapBody; u_uri_t *uri; endpoint = argv[1]; if (endpoint) { u_uri_parse((const char *)endpoint, &uri); } if (!endpoint || !uri) { fprintf(stderr, "endpoint option required\n"); return 1; } wsmc_transport_init(NULL); cl = wsman_create_client( uri->host, uri->port, uri->path, uri->scheme, uri->user, uri->pwd); wsmc_options_init(&options); //wsman_set_action_option(&options,FLAG_DUMP_REQUEST ); doc = wsman_identify(cl, options); soapBody = ws_xml_get_soap_body(doc); if (ws_xml_get_child(soapBody, 0, XML_NS_WSMAN_ID, "IdentifyResponse")) { wsmid_identify *id = ws_deserialize(wsmc_get_context(cl), soapBody, wsmid_identify_TypeInfo,"IdentifyResponse", XML_NS_WSMAN_ID, XML_NS_WSMAN_ID, 0, 0); if (vendor) printf("%s\n", id->ProductVendor); if (version) printf("%s\n", id->ProductVersion); if (protocol) printf("%s\n", id->ProtocolVersion); if (!protocol && !vendor && !version ) { printf("\n"); printf("%s %s supporting protocol %s\n", id->ProductVendor, id->ProductVersion,id->ProtocolVersion); } } if (uri) { u_uri_free(uri); } if (doc) { ws_xml_destroy_doc(doc); } wsmc_options_destroy(&options); wsman_release_client(cl); return 0; } wsmancli-2.3.1/man/000077500000000000000000000000001230333012500140755ustar00rootroot00000000000000wsmancli-2.3.1/man/Makefile.am000066400000000000000000000000721230333012500161300ustar00rootroot00000000000000man_MANS = wsman.1 wseventmgr.1 EXTRA_DIST = $(man_MANS) wsmancli-2.3.1/man/wseventmgr.1000066400000000000000000000035671230333012500163730ustar00rootroot00000000000000.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. .TH wseventmgr "1" "July 2012" "Unknown option --version" "User Commands" .SH NAME wseventmgr \- WS-MAN CLI .SH DESCRIPTION .SS "Usage:" .IP wseventmgr [Option...] .PP Help Options .HP \-?, \fB\-\-help\fR .TP \fB\-\-help\-all\fR Show help options .TP \fB\-\-help\-event\fR Subscription Options .PP Application Options .TP \fB\-d\fR, \fB\-\-debug\fR=\fI1\-6\fR Set the verbosity of debugging output. .TP \fB\-R\fR, \fB\-\-print\-request\fR print request on stdout .TP \fB\-j\fR, \fB\-\-encoding\fR Set request message encoding .TP \fB\-c\fR, \fB\-\-cacert=\fR Certificate file to verify the peer .TP \fB\-A\fR, \fB\-\-cert=\fR Certificate file. The certificate must be in PEM format. .TP \fB\-K\fR, \fB\-\-sslkey=\fR SSL Key. .TP \fB\-u\fR, \fB\-\-username=\fR User name Can also be passed by setting the WSEVENTMGR_USER environment variable. The command line option takes precedence. .TP \fB\-g\fR, \fB\-\-path=\fR Path .TP \fB\-p\fR, \fB\-\-password=\fR Password Can also be passed by setting the WSEVENTMGR_PASS environment variable. The command line option takes precedence. .TP \fB\-h\fR, \fB\-\-hostname=\fR Host name .TP \fB\-b\fR, \fB\-\-endpoint=\fR End point .TP \fB\-P\fR, \fB\-\-port=\fR Server Port .TP \fB\-X\fR, \fB\-\-proxy=\fR Proxy name .TP \fB\-Y\fR, \fB\-\-proxyauth=\fR Proxy user:pwd .TP \fB\-y\fR, \fB\-\-auth=\fR Authentication Method .TP \fB\-C\fR, \fB\-\-config\-file=\fR Alternate configuration file .TP \fB\-O\fR, \fB\-\-out\-file=\fR Write output to file .TP \fB\-V\fR, \fB\-\-noverifypeer\fR Not to verify peer certificate .TP \fB\-v\fR, \fB\-\-noverifyhost\fR Not to verify hostname .TP \fB\-I\fR, \fB\-\-transport\-timeout=\fR