Skip to content

Commit

Permalink
Fix vPoller Clients
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Jan 7, 2014
1 parent cc32a73 commit 627809c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ main(int argc, char *argv[])
const char *msg_out_template = ""
"{"
"\"type\": \"%s\", "
"\"vcenter\": \"%s\", "
"\"hostname\": \"%s\", "
"\"name\": \"%s\", "
"\"info.url\": \"%s\", "
"\"cmd\": \"%s\", "
Expand All @@ -104,7 +104,7 @@ main(int argc, char *argv[])
*property, /* The property we want as defined in the vSphere Web Services SDK */
*url, /* Datastore URL, only applicable to datastores object type */
*cmd, /* The command to be processed, e.g. 'poll' or 'discover' */
*vcenter; /* The vCenter server we send the request message to */
*vsphere_host; /* The vSphere host we send the request message to */

char *result; /* A pointer to hold the result from our request */

Expand All @@ -126,7 +126,7 @@ main(int argc, char *argv[])
bool objtype_datastores = false; /* Flag to indicate that a 'Datastores' object has been requested */

/* Initialize some of the message properties */
objtype = name = property = url = cmd = vcenter = result = NULL;
objtype = name = property = url = cmd = vsphere_host = result = NULL;

/* Get the command-line options and arguments */
while ((ch = getopt(argc, argv, "DHe:r:t:n:p:u:c:V:")) != -1) {
Expand All @@ -152,7 +152,7 @@ main(int argc, char *argv[])
cmd = optarg;
break;
case 'V':
vcenter = optarg;
vsphere_host = optarg;
break;
case 'r':
retries = atol(optarg);
Expand All @@ -172,7 +172,7 @@ main(int argc, char *argv[])
argv += optind;

/* Sanity check the provided options and arguments */
if (cmd == NULL || vcenter == NULL || objtype == NULL) {
if (cmd == NULL || vsphere_host == NULL || objtype == NULL) {
usage();
return (EX_USAGE);
}
Expand Down Expand Up @@ -201,7 +201,7 @@ main(int argc, char *argv[])
}

/* Create the message to send out */
snprintf(msg_buf, 1023, msg_out_template, objtype, vcenter, name, url, cmd, property);
snprintf(msg_buf, 1023, msg_out_template, objtype, vsphere_host, name, url, cmd, property);

/* Create a new ZeroMQ Context and Socket */
zcontext = zmq_ctx_new();
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions src/vpoller-client
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def main():

usage="""
Usage:
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] (-D|-H) -c discover -V <vcenter> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -H -n <name> -p <property> -c poll -V <vcenter> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -D -u <datastore-url> -p <property> -c poll -V <vcenter> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] (-D|-H) -c discover -V <host> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -H -n <name> -p <property> -c poll -V <host> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -D -u <datastore-url> -p <property> -c poll -V <host> -e <endpoint>
vpoller-client --help
vpoller-client --version
Expand All @@ -51,7 +51,7 @@ Options:
-v, --version Display version and exit
-D, --datastores Retrieve a datastore object property
-H, --hosts Retrieve a host object property
-V <vcenter>, --vcenter <vcenter> The vCenter server to send the request to
-V <host>, --vsphere-host <host> The vSphere host to send the request to
-c <cmd>, --command <cmd> The command to perform, either "poll" or "discover"
-n <name>, --name <name> Name of the ESX host, only applicable to hosts object type
-p <property>, --property <property> Name of the property as defined by the vSphere Web SDK
Expand All @@ -78,12 +78,12 @@ Options:

client = VPollerClient(endpoint=args["--endpoint"], retries=int(args["--retries"]), timeout=int(args["--timeout"]))

msg = { "type": "hosts" if args["--hosts"] else "datastores",
"vcenter": args["--vcenter"],
"name": args["--name"],
"info.url": args["--url"],
"cmd": args["--command"],
"property": args["--property"],
msg = { "type": "hosts" if args["--hosts"] else "datastores",
"hostname": args["--vsphere-host"],
"name": args["--name"],
"info.url": args["--url"],
"cmd": args["--command"],
"property": args["--property"],
}

result = client.run(msg)
Expand Down
1 change: 0 additions & 1 deletion src/vpoller/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ def discover_hosts(self):
if not self.viserver.is_connected():
self.reconnect()

#
# Properties we want to retrieve are 'name' and 'runtime.powerState'
#
# Check the vSphere Web Services SDK API for more information on the properties
Expand Down

0 comments on commit 627809c

Please sign in to comment.