/******************************************************************************* * 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 * @author Eugene Yarmosh * @author Vadim Revyakin */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #include #include // #include "wsman-client-options.h" static const char **wsman_argv = NULL; static int server_port = 0; static char *cainfo = NULL; static char *cert = NULL; static char *sslkey = NULL; static char *endpoint = 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 noverify_peer = 0; static char noverify_host = 0; static int transport_timeout = 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; char cim_extensions = 0; char cim_references = 0; char cim_associators = 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 char *input = 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_opt = NULL; static char *invoke_method = NULL; static char **properties = NULL; struct _WsActions { char *action; int value; }; typedef struct _WsActions WsActions; WsActions action_data[] = { {"get", WSMAN_ACTION_TRANSFER_GET}, {"put", WSMAN_ACTION_TRANSFER_PUT}, {"create", WSMAN_ACTION_TRANSFER_CREATE}, {"delete", WSMAN_ACTION_TRANSFER_DELETE}, {"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"}, {"cacert", 'c', U_OPTION_ARG_STRING, &cainfo, "Certificate file to verify the peer", ""}, {"cert", 'A', U_OPTION_ARG_STRING, &cert, "Certificate file. The certificate must be in PEM format.", ""}, {"sslkey", 'K', U_OPTION_ARG_STRING, &sslkey, "SSL Key.", ""}, {"username", 'u', U_OPTION_ARG_STRING, &username, "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, "Host name", ""}, {"endpoint", 'b', U_OPTION_ARG_STRING, &endpoint, "End point", ""}, {"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, &noverify_peer, "Not to verify peer certificate", NULL}, {"noverifyhost", 'v', U_OPTION_ARG_NONE, &noverify_host, "Not to verify hostname", NULL}, {"transport-timeout", 'I', U_OPTION_ARG_INT, &transport_timeout, "Transport timeout in seconds", "