[libvirt] [PATCH] build: fix recent 'make syntax-check' failure
by Eric Blake
* src/esx/esx_vi_methods.h: Placate cppi.
---
Pushing under the rule for obvious build fixes.
src/esx/esx_vi_methods.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/esx/esx_vi_methods.h b/src/esx/esx_vi_methods.h
index 7b6be4e..c78c649 100644
--- a/src/esx/esx_vi_methods.h
+++ b/src/esx/esx_vi_methods.h
@@ -2,7 +2,7 @@
/*
* esx_vi_methods.h: client for the VMware VI API 2.5 to manage ESX hosts
*
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009, 2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -45,6 +45,6 @@ int esxVI_ValidateMigration
esxVI_ManagedObjectReference *host, /* optional */
esxVI_Event **output); /* optional, list */
-#include "esx_vi_methods.generated.h"
+# include "esx_vi_methods.generated.h"
#endif /* __ESX_VI_METHODS_H__ */
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"
by Jim Meyering
echo -e is not portable.
This is the sole remaining use in all of libvirt.
>From a58cf340b5ebbca2157f43c6f23d4d6f56b848c7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 14 Apr 2010 13:25:46 +0200
Subject: [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"
* tests/schematestutils.sh: Use printf rather than echo -e.
---
tests/schematestutils.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
index f172857..f2b3b50 100644
--- a/tests/schematestutils.sh
+++ b/tests/schematestutils.sh
@@ -22,7 +22,7 @@ do
test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret
if test "$verbose" = "1" && test $ret != 0 ; then
- echo -e "$cmd\n$result"
+ printf '%s\n' "$cmd" "$result"
fi
if test "$ret" != 0 ; then
f=`expr $f + 1`
--
1.7.1.rc1.248.gcefbb
14 years, 7 months
[libvirt] [RFC] maint: forbid most files without extension
by Eric Blake
* .gitignore: Add rule that requires . in name, then add exemptions.
---
Given Chris' recent accident in committing a binary file, then
blasting the list with it, here's a (hack) approach to prevent a
relapse in the future. It assumes that non-binary files either
have an extension, or are easy enough to enumerate.
Personally, I do NOT want to apply this patch. It has the nasty
side-effect of rendering .git/info/exclude useless (git unfortunately
stops processing ignore rules once it finds an explicit accept rule,
so any reject rules in .git/info/exclude for files containing '.' are
overruled as accepts by this patch). Hence, this is only an RFC,
documenting my thought process.
.gitignore | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index a7466fd..7d2bce3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,41 @@
+# To reduce likelihood of committing binaries, require that a '.' be
+# in all non-directories, then add exceptions as needed.
+*
+!*.*
+!/AUTHORS
+!/ChangeLog-old
+!/HACKING
+!README
+!TODO
+!/bootstrap
+!/examples/apparmor/TEMPLATE
+!/examples/apparmor/libvirt-qemu
+!/tests/capabilityschematest
+!/tests/cpuset
+!/tests/daemon-conf
+!/tests/define-dev-segfault
+!/tests/domainschematest
+!/tests/int-overflow
+!/tests/interfaceschematest
+!/tests/libvirtd-fail
+!/tests/libvirtd-pool
+!/tests/networkschematest
+!/tests/nodedevschematest
+!/tests/nwfilterschematest
+!/tests/qemuhelpdata/kvm-74
+!/tests/qemuhelpdata/kvm-86
+!/tests/read-bufsiz
+!/tests/read-non-seekable
+!/tests/start
+!/tests/storagepoolschematest
+!/tests/storagevolschematest
+!/tests/undefine
+!/tests/vcpupin
+!/tests/virsh-all
+!/tests/virsh-synopsis
+!/tests/virt-aa-helper-test
+
+# Other files to exclude
*#*#
*.#*#
*.a
--
1.6.6.1
14 years, 7 months
[libvirt] clang vs. libvirt
by Jim Meyering
I've been running the clang static analyzer against libvirt
regularly, but it's usually been that of F12 or F13. Yesterday
I used rawhide's version of clang:
scan-build -o clang ./autogen.sh --enable-compile-warnings=error &&
scan-build -o clang make -j6
and it spotted a few new problems.
Most are false positives, but a few were not.
Here are the latest additions.
I have an additional handful of patches that address the
remaining false positives, and will post those later today.
14 years, 7 months
[libvirt] [PATCH] Implement forgotten backend of virInterfaceIsActive()
by Laine Stump
Somehow the backend of this function was never implemented in
libvirt's netcf driver, and nobody noticed until now. (The required
netcf function was already in place, so nothing needs to change
there.)
---
src/interface/netcf_driver.c | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index 708f1f8..7163066 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -511,6 +511,35 @@ cleanup:
return ret;
}
+static int interfaceIsActive(virInterfacePtr ifinfo)
+{
+ struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ unsigned int flags = 0;
+
+ interfaceDriverLock(driver);
+
+ iface = interfaceDriverGetNetcfIF(driver->netcf, ifinfo);
+ if (!iface) {
+ /* helper already reported error */
+ goto cleanup;
+ }
+
+ if (ncf_if_status(iface, &flags) < 0) {
+ const char *errmsg, *details;
+ int errcode = ncf_error(driver->netcf, &errmsg, &details);
+ interfaceReportError(netcf_to_vir_err(errcode),
+ "failed to get status of interface %s (netcf: %s - %s)",
+ ifinfo->name, errmsg, details ? details : "");
+ goto cleanup;
+ }
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return flags & NETCF_IFACE_ACTIVE ? 1 : 0;
+}
+
static virInterfaceDriver interfaceDriver = {
"Interface",
interfaceOpenInterface, /* open */
@@ -526,7 +555,7 @@ static virInterfaceDriver interfaceDriver = {
interfaceUndefine, /* interfaceUndefine */
interfaceCreate, /* interfaceCreate */
interfaceDestroy, /* interfaceDestroy */
- NULL, /* interfaceIsActive */
+ interfaceIsActive, /* interfaceIsActive */
};
int interfaceRegister(void) {
--
1.6.6.1
14 years, 7 months
[libvirt] hellolibvirt: no hypervisor driver available for xen:///
by Ganesh Pagade
Hi,
I downloaded and built the latest libvirt source code 0.8. I installed the
library in a custom directory libvirt-0.8.0-install/ keeping all other
configurations default.
After this I tried to execute the example hellolibvirt:
[hellolibvirt]# ./hellolibvirt xen
Attempting to connect to hypervisor
libvir: Remote error : unable to connect to
'/root/ganeshp/libvirt-0.8.0-install/var/run/libvirt/libvirt-sock', libvirtd
may need to be started: Connection refused
No connection to hypervisor
Parameter error when attempting to get last error
My libvirtd was running from /etc/init.d/libvirtd. Still why is it trying to
connect to the newly built libvirtd?
I stopped the /etc/init.d/libvirtd and started my newly built daemon:
[hellolibvirt]# /root/ganeshp/libvirt-0.8.0-install/sbin/libvirtd start &
04:47:07.534: warning : qemudStartup:1574 : Unable to create cgroup for
driver: No such device or address
04:47:07.540: error : parse_socket:126 : cannot open
/sys/devices/system/cpu/cpu1/topology/physical_package_id: No such file or
directory
04:47:07.540: warning : qemudCapsInit:1068 : Failed to get host CPU
04:47:07.544: warning : lxcStartup:1835 : Unable to create cgroup for
driver: No such device or address
After this I tried running hellolibvirt example again:
[hellolibvirt]# ./hellolibvirt xen
Attempting to connect to hypervisor
04:48:43.166: error : virLibConnError:450 : no hypervisor driver available
for xen:///
libvir: error : no hypervisor driver available for xen:///
libvir: error : no hypervisor driver available for xen:///
No connection to hypervisor
Parameter error when attempting to get last error
I do not understand why the program is not able to find the xen driver. I am
able to launch VMM GUI and create VMs using xen connection. The system
already has xen hypervisor (3.1.0).
Even the newly built virsh gives similar errors. Whereas /usr/bin/virsh
works perfectly fine.
Am I missing some configuration or dependency? Any pointers/suggestion would
greatly help. Thanks.
Regards,
-Ganesh
14 years, 7 months
[libvirt] [PATCH] Run test suite as part of RPM build process
by Daniel P. Berrange
To ensure that patches in the RPM don't break any functionality
it is neccessary to run the test suites during build. It currently
has 3 tests disabled
- daemon-conf: this is totally broken, since it relies on
being able to resolve the 'libvirt' group & being able to
resolve hostnames at daemon startup. This isn't possible
in a mock build root
- seclabeltest: fails to initialize selinux in the mock
build root. Possibly fixable
- nodeinfotest: broken on s390 + ppc - this is a real bug
* libvirt.spec.in: Add a %check section, with 3 tests
temporarily disabled
---
libvirt.spec.in | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 748a1e7..a8b078a 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -618,6 +618,17 @@ chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/libvirtd
%clean
rm -fr %{buildroot}
+%check
+cd tests
+# These 3 tests don't current work in a mock build root
+for i in nodeinfotest daemon-conf seclabeltest
+do
+ rm -f $i
+ echo -e "#!/bin/sh\nexit 0" > $i
+ chmod +x $i
+done
+make check
+
%pre
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
# Normally 'setup' adds this in /etc/passwd, but this is
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Fix off-by-one check in QEMU memory stats
by Daniel P. Berrange
The QEMU memory stats JSON monitor command was too cautious in
checking array bounds, dropping the last requested stat
* src/qemu/qemu_monitor_json.c: Fix off-by-1 check in memory
stats
---
src/qemu/qemu_monitor_json.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7c0d372..3c97e9d 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -965,7 +965,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
goto cleanup;
}
- if (virJSONValueObjectHasKey(data, "mem_swapped_in") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "mem_swapped_in") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "mem_swapped_in", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon mem_swapped_in"));
@@ -976,7 +976,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
stats[got].val = (mem/1024);
got++;
}
- if (virJSONValueObjectHasKey(data, "mem_swapped_out") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "mem_swapped_out") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "mem_swapped_out", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon mem_swapped_out"));
@@ -987,7 +987,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
stats[got].val = (mem/1024);
got++;
}
- if (virJSONValueObjectHasKey(data, "major_page_faults") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "major_page_faults") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "major_page_faults", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon major_page_faults"));
@@ -998,7 +998,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
stats[got].val = mem;
got++;
}
- if (virJSONValueObjectHasKey(data, "minor_page_faults") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "minor_page_faults") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "minor_page_faults", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon minor_page_faults"));
@@ -1009,7 +1009,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
stats[got].val = mem;
got++;
}
- if (virJSONValueObjectHasKey(data, "free_mem") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "free_mem") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "free_mem", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon free_mem"));
@@ -1020,7 +1020,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
stats[got].val = (mem/1024);
got++;
}
- if (virJSONValueObjectHasKey(data, "total_mem") && (got < (nr_stats-1))) {
+ if (virJSONValueObjectHasKey(data, "total_mem") && (got < nr_stats)) {
if (virJSONValueObjectGetNumberUlong(data, "total_mem", &mem) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon total_mem"));
--
1.6.6.1
14 years, 7 months
[libvirt] php bindings
by David W King
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I know this topic has come up multiple times in the past and every time
it does people keep commenting on how it would be a good thing to do but
they just don't have the time. So my question is, has anyone found the
time to work on php bindings for libvirt?
- --
David King
Goshen College ITS
davidwk(a)goshen.edu
574-535-7726
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAku7NWoACgkQH+/Vg7DylXYcEACgmvs0p0YIF3pzu8Cp9xkNk+zZ
2YgAni7YdROnRIrvmpyh1kbb5MH8kT2Y
=DSLD
-----END PGP SIGNATURE-----
14 years, 7 months
[libvirt] [PATCH] esx: Extend esx_vi_generator.py to cover methods too
by Matthias Bolte
Generate almost all SOAP method mapping code.
Update the driver code to use the complete paramater list of some methods
that had parameters skipped before.
Improve the ESX_VI__METHOD marco to do automatic output deserialization
based on output occurrence. Also incorporate automatic _this binding and
output pointer check.
---
src/esx/esx_driver.c | 26 +-
src/esx/esx_vi.c | 7 +-
src/esx/esx_vi_generator.input | 191 +++++++++-
src/esx/esx_vi_generator.py | 489 ++++++++++++++++++------
src/esx/esx_vi_methods.c | 854 ++++++----------------------------------
src/esx/esx_vi_methods.h | 132 +------
6 files changed, 723 insertions(+), 976 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 4ed9890..e3340c9 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1333,7 +1333,8 @@ esxDomainResume(virDomainPtr domain)
goto failure;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, &task) < 0 ||
+ if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto failure;
@@ -1710,8 +1711,9 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
esxVI_PerfCounterInfo *perfCounterInfo = NULL;
esxVI_PerfCounterInfo *perfCounterInfoList = NULL;
esxVI_PerfQuerySpec *querySpec = NULL;
+ esxVI_PerfEntityMetricBase *perfEntityMetricBase = NULL;
+ esxVI_PerfEntityMetricBase *perfEntityMetricBaseList = NULL;
esxVI_PerfEntityMetric *perfEntityMetric = NULL;
- esxVI_PerfEntityMetric *perfEntityMetricList = NULL;
esxVI_PerfMetricIntSeries *perfMetricIntSeries = NULL;
esxVI_Long *value = NULL;
@@ -1883,17 +1885,26 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
querySpec->metricId->instance = (char *)"";
querySpec->format = (char *)"normal";
- if (esxVI_QueryPerf(priv->host, querySpec, &perfEntityMetricList) < 0) {
+ if (esxVI_QueryPerf(priv->host, querySpec,
+ &perfEntityMetricBaseList) < 0) {
querySpec->entity = NULL;
querySpec->metricId->instance = NULL;
querySpec->format = NULL;
goto failure;
}
- for (perfEntityMetric = perfEntityMetricList; perfEntityMetric != NULL;
- perfEntityMetric = perfEntityMetric->_next) {
+ for (perfEntityMetricBase = perfEntityMetricBaseList;
+ perfEntityMetricBase != NULL;
+ perfEntityMetricBase = perfEntityMetricBase->_next) {
VIR_DEBUG0("perfEntityMetric ...");
+ perfEntityMetric =
+ esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
+
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0("QueryPerf returned object with unexpected type");
+ }
+
perfMetricIntSeries =
esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
@@ -1927,7 +1938,7 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
esxVI_Int_Free(&counterIdList);
esxVI_PerfCounterInfo_Free(&perfCounterInfoList);
esxVI_PerfQuerySpec_Free(&querySpec);
- esxVI_PerfEntityMetric_Free(&perfEntityMetricList);
+ esxVI_PerfEntityMetricBase_Free(&perfEntityMetricBaseList);
return result;
@@ -2367,7 +2378,8 @@ esxDomainCreate(virDomainPtr domain)
goto failure;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, &task) < 0 ||
+ if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto failure;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 1a71558..4318ff1 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -444,7 +444,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
goto failure;
}
- if (esxVI_Login(ctx, username, password, &ctx->session) < 0) {
+ if (esxVI_Login(ctx, username, password, NULL, &ctx->session) < 0) {
goto failure;
}
@@ -1344,7 +1344,7 @@ esxVI_EnsureSession(esxVI_Context *ctx)
if (active != esxVI_Boolean_True) {
esxVI_UserSession_Free(&ctx->session);
- if (esxVI_Login(ctx, ctx->username, ctx->password,
+ if (esxVI_Login(ctx, ctx->username, ctx->password, NULL,
&ctx->session) < 0) {
return -1;
}
@@ -1378,7 +1378,8 @@ esxVI_EnsureSession(esxVI_Context *ctx)
if (currentSession == NULL) {
esxVI_UserSession_Free(&ctx->session);
- if (esxVI_Login(ctx, ctx->username, ctx->password, &ctx->session) < 0) {
+ if (esxVI_Login(ctx, ctx->username, ctx->password, NULL,
+ &ctx->session) < 0) {
goto failure;
}
} else if (STRNEQ(ctx->session->key, currentSession->key)) {
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 9c545eb..a016c63 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -28,7 +28,22 @@
# - ol for an optional list
# - i for an ignored item or list
#
-# Object member sequence has to match the WSDL sequence
+# Object member sequence has to match the WSDL sequence.
+#
+#
+# Method definition:
+#
+# method <name> [returns <type> <occurrence>]
+# <type> <name> <occurrence>
+# ...
+# end
+#
+# The _this paramater can have a type attached to it:
+#
+# _this:<type>
+#
+# The <type> refers to one of the ServiceContent members. This make the
+# generator auto-bind _this to the corresponding ServiceContent member.
#
@@ -436,3 +451,177 @@ object VirtualMachineSnapshotTree
Boolean quiesced r
VirtualMachineSnapshotTree childSnapshotList ol
end
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Methods
+#
+
+method AnswerVM
+ ManagedObjectReference _this r
+ String questionId r
+ String answerChoice r
+end
+
+
+method CancelTask
+ ManagedObjectReference _this r
+end
+
+
+method CreateFilter returns ManagedObjectReference r
+ ManagedObjectReference _this:PropertyCollector r
+ PropertyFilterSpec spec r
+ Boolean partialUpdates r
+end
+
+
+method CreateSnapshot_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ String name r
+ String description o
+ Boolean memory r
+ Boolean quiesce r
+end
+
+
+method DestroyPropertyFilter
+ ManagedObjectReference _this r
+end
+
+
+method FindByIp returns ManagedObjectReference o
+ ManagedObjectReference _this:SearchIndex r
+ ManagedObjectReference datacenter o
+ String ip r
+ Boolean vmSearch r
+end
+
+
+method FindByUuid returns ManagedObjectReference o
+ ManagedObjectReference _this:SearchIndex r
+ ManagedObjectReference datacenter o
+ String uuid r
+ Boolean vmSearch r
+end
+
+
+method Login returns UserSession r
+ ManagedObjectReference _this:SessionManager r
+ String userName r
+ String password r
+ String locale o
+end
+
+
+method Logout
+ ManagedObjectReference _this:SessionManager r
+end
+
+
+method MigrateVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ ManagedObjectReference pool o
+ ManagedObjectReference host o
+ VirtualMachineMovePriority priority r
+ VirtualMachinePowerState state o
+end
+
+
+method PowerOffVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+end
+
+
+method PowerOnVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ ManagedObjectReference host o
+end
+
+
+method QueryAvailablePerfMetric returns PerfMetricId ol
+ ManagedObjectReference _this:PerformanceManager r
+ ManagedObjectReference entity r
+ DateTime beginTime o
+ DateTime endTime o
+ Int intervalId o
+end
+
+
+method QueryPerf returns PerfEntityMetricBase ol
+ ManagedObjectReference _this:PerformanceManager r
+ PerfQuerySpec querySpec rl
+end
+
+
+method QueryPerfCounter returns PerfCounterInfo ol
+ ManagedObjectReference _this:PerformanceManager r
+ Int counterId rl
+end
+
+
+method RebootGuest
+ ManagedObjectReference _this r
+end
+
+
+method ReconfigVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ VirtualMachineConfigSpec spec r
+end
+
+
+method RegisterVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ String path r
+ String name o
+ Boolean asTemplate r
+ ManagedObjectReference pool o
+ ManagedObjectReference host o
+end
+
+
+method RemoveSnapshot_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ Boolean removeChildren r
+end
+
+
+method RetrieveProperties returns ObjectContent ol
+ ManagedObjectReference _this:PropertyCollector r
+ PropertyFilterSpec specSet rl
+end
+
+
+method RevertToSnapshot_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+ ManagedObjectReference host o
+end
+
+
+method SessionIsActive returns Boolean r
+ ManagedObjectReference _this:SessionManager r
+ String sessionID r
+ String userName r
+end
+
+
+method ShutdownGuest
+ ManagedObjectReference _this r
+end
+
+
+method SuspendVM_Task returns ManagedObjectReference r
+ ManagedObjectReference _this r
+end
+
+
+method UnregisterVM
+ ManagedObjectReference _this r
+end
+
+
+method WaitForUpdates returns UpdateSet r
+ ManagedObjectReference _this:PropertyCollector r
+ String version o
+end
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index b933d5b..272b219 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -27,34 +27,247 @@ import os.path
+OCCURRENCE__REQUIRED_ITEM = "r"
+OCCURRENCE__REQUIRED_LIST = "rl"
+OCCURRENCE__OPTIONAL_ITEM = "o"
+OCCURRENCE__OPTIONAL_LIST = "ol"
+OCCURRENCE__IGNORED = "i"
+valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
+ OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_ITEM,
+ OCCURRENCE__OPTIONAL_LIST,
+ OCCURRENCE__IGNORED]
-class Property:
- OCCURRENCE__REQUIRED_ITEM = "r"
- OCCURRENCE__REQUIRED_LIST = "rl"
- OCCURRENCE__OPTIONAL_ITEM = "o"
- OCCURRENCE__OPTIONAL_LIST = "ol"
- OCCURRENCE__IGNORED = "i"
-
- valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
- OCCURRENCE__REQUIRED_LIST,
- OCCURRENCE__OPTIONAL_ITEM,
- OCCURRENCE__OPTIONAL_LIST,
- OCCURRENCE__IGNORED]
+
+
+
+
+
+class Parameter:
+ autobind_map = { "PerformanceManager" : "perfManager",
+ "PropertyCollector" : "propertyCollector",
+ "SearchIndex" : "searchIndex",
+ "SessionManager" : "sessionManager" }
def __init__(self, type, name, occurrence):
self.type = type
+ self.occurrence = occurrence
+
+ if ':' in name and name.startswith("_this"):
+ self.name, self.autobind_type = name.split(":")
+ else:
+ self.name = name
+ self.autobind_type = None
+
+
+ def is_enum(self):
+ global predefined_enums
+ global enums_by_name
+
+ return self.type in predefined_enums or self.type in enums_by_name
+
+
+ def generate_paramater(self, is_last = False, is_header = True, offset = 0):
+ if self.occurrence == OCCURRENCE__IGNORED:
+ raise ValueError("invalid function parameter occurrence value '%s'" % self.occurrence)
+ elif self.autobind_type is not None:
+ return ""
+ else:
+ string = " "
+ string += " " * offset
+ string += "%s%s" % (self.get_type_string(), self.name)
+
+ if is_last:
+ if is_header:
+ string += "); "
+ else:
+ string += "), "
+ else:
+ string += ", "
+
+ while len(string) < 59:
+ string += " "
+
+ return string + self.get_occurrence_comment() + "\n"
+
+
+ def generate_return(self, offset = 0, end_of_line = ";"):
+ if self.occurrence == OCCURRENCE__IGNORED:
+ raise ValueError("invalid function parameteroccurrence value '%s'" % self.occurrence)
+ else:
+ string = " "
+ string += " " * offset
+ string += "%s*%s)%s" % (self.get_type_string(), self.name, end_of_line)
+
+ while len(string) < 59:
+ string += " "
+
+ return string + self.get_occurrence_comment() + "\n"
+
+
+ def generate_require_code(self):
+ if self.occurrence in [OCCURRENCE__REQUIRED_ITEM,
+ OCCURRENCE__REQUIRED_LIST]:
+ return " ESX_VI__METHOD__PARAMETER__REQUIRE(%s)\n" % self.name
+ else:
+ return ""
+
+
+ def generate_serialize_code(self):
+ if self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__METHOD__PARAMETER__SERIALIZE(%s, %s)\n" % (self.type, self.name)
+
+
+ def get_type_string(self):
+ if self.type == "String" and \
+ self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
+ return "const char *"
+ elif self.is_enum():
+ return "esxVI_%s " % self.type
+ else:
+ return "esxVI_%s *" % self.type
+
+
+ def get_occurrence_comment(self):
+ if self.occurrence == OCCURRENCE__REQUIRED_ITEM:
+ return "/* required */"
+ elif self.occurrence == OCCURRENCE__REQUIRED_LIST:
+ return "/* required, list */"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_ITEM:
+ return "/* optional */"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_LIST:
+ return "/* optional, list */"
+
+ raise ValueError("unknown occurrence value '%s'" % self.occurrence)
+
+
+ def get_occurrence_short_enum(self):
+ if self.occurrence == OCCURRENCE__REQUIRED_ITEM:
+ return "RequiredItem"
+ elif self.occurrence == OCCURRENCE__REQUIRED_LIST:
+ return "RequiredList"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_ITEM:
+ return "OptionalItem"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_LIST:
+ return "OptionalList"
+
+ raise ValueError("unknown occurrence value '%s'" % self.occurrence)
+
+
+
+class Method:
+ def __init__(self, name, parameters, returns):
+ self.name = name
+ self.parameters = []
+ self.autobind_parameter = None
+ self.returns = returns
+
+ for parameter in parameters:
+ if parameter.autobind_type is None:
+ self.parameters.append(parameter)
+ else:
+ self.autobind_parameter = parameter
+
+
+ def generate_header(self):
+ header = "int esxVI_%s\n" % self.name
+ header += " (esxVI_Context *ctx"
+
+ if len(self.parameters) > 0 or self.returns is not None:
+ header += ",\n"
+
+ for parameter in self.parameters[:-1]:
+ header += parameter.generate_paramater()
+
+ if self.returns is None:
+ header += self.parameters[-1].generate_paramater(is_last = True)
+ else:
+ header += self.parameters[-1].generate_paramater()
+ header += self.returns.generate_return()
+ else:
+ header += ");\n"
+
+ header += "\n"
+
+ return header
+
+
+ def generate_source(self):
+ source = "/* esxVI_%s */\n" % self.name
+ source += "ESX_VI__METHOD(%s," % self.name
+
+ if self.autobind_parameter is not None:
+ source += " %s,\n" % Parameter.autobind_map[self.autobind_parameter.autobind_type]
+ else:
+ source += " /* explicit _this */,\n"
+
+ source += " (esxVI_Context *ctx"
+
+ if len(self.parameters) > 0 or self.returns is not None:
+ source += ",\n"
+
+ for parameter in self.parameters[:-1]:
+ source += parameter.generate_paramater(is_header = False, offset = 9)
+
+ if self.returns is None:
+ source += self.parameters[-1].generate_paramater(is_last = True, is_header = False, offset = 9)
+ else:
+ source += self.parameters[-1].generate_paramater(is_header = False, offset = 9)
+ source += self.returns.generate_return(offset = 9, end_of_line = ",")
+ else:
+ source += "),\n"
+
+ if self.returns is None:
+ source += " void, None,\n"
+ else:
+ source += " %s, %s,\n" % (self.returns.type, self.returns.get_occurrence_short_enum())
+
+ source += "{\n"
+
+ if self.autobind_parameter is not None:
+ source += self.autobind_parameter.generate_require_code()
+
+ for parameter in self.parameters:
+ source += parameter.generate_require_code()
+
+ source += "},\n"
+ source += "{\n"
+
+ if self.autobind_parameter is not None:
+ source += self.autobind_parameter.generate_serialize_code()
+
+ for parameter in self.parameters:
+ source += parameter.generate_serialize_code()
+
+ source += "})\n\n\n\n"
+
+ return source
+
+
+
+class Property:
+ def __init__(self, type, name, occurrence):
+ self.type = type
self.name = name
self.occurrence = occurrence
+
def is_enum(self):
global predefined_enums
global enums_by_name
return self.type in predefined_enums or self.type in enums_by_name
+
def generate_struct_member(self):
- if self.occurrence == Property.OCCURRENCE__IGNORED:
+ if self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
else:
string = " %s%s; " % (self.get_type_string(), self.name)
@@ -62,36 +275,39 @@ class Property:
while len(string) < 59:
string += " "
- return string + "/* %s */\n" % self.get_occurrence_string()
+ return string + self.get_occurrence_comment() + "\n"
+
def generate_free_code(self):
if self.type == "String" and \
- self.occurrence not in [Property.OCCURRENCE__REQUIRED_LIST,
- Property.OCCURRENCE__OPTIONAL_LIST,
- Property.OCCURRENCE__IGNORED]:
+ self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST,
+ OCCURRENCE__IGNORED]:
return " VIR_FREE(item->%s);\n" % self.name
elif self.is_enum():
return ""
else:
- if self.occurrence == Property.OCCURRENCE__IGNORED:
+ if self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
else:
return " esxVI_%s_Free(&item->%s);\n" % (self.type, self.name)
+
def generate_validate_code(self):
- if self.occurrence in [Property.OCCURRENCE__REQUIRED_ITEM,
- Property.OCCURRENCE__REQUIRED_LIST]:
+ if self.occurrence in [OCCURRENCE__REQUIRED_ITEM,
+ OCCURRENCE__REQUIRED_LIST]:
return " ESX_VI__TEMPLATE__PROPERTY__REQUIRE(%s)\n" % self.name
- elif self.occurrence == Property.OCCURRENCE__IGNORED:
+ elif self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
else:
return ""
+
def generate_deep_copy_code(self):
- if self.occurrence == Property.OCCURRENCE__IGNORED:
+ if self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
- elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
- Property.OCCURRENCE__OPTIONAL_LIST]:
+ elif self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_LIST(%s, %s)\n" % (self.type, self.name)
elif self.type == "String":
return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(String, %s)\n" % self.name
@@ -100,54 +316,53 @@ class Property:
else:
return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY(%s, %s)\n" % (self.type, self.name)
+
def generate_serialize_code(self):
- if self.occurrence == Property.OCCURRENCE__IGNORED:
+ if self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
- elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
- Property.OCCURRENCE__OPTIONAL_LIST]:
+ elif self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(%s, %s)\n" % (self.type, self.name)
elif self.type == "String":
return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, %s)\n" % self.name
else:
return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(%s, %s)\n" % (self.type, self.name)
+
def generate_deserialize_code(self):
- if self.occurrence == Property.OCCURRENCE__IGNORED:
+ if self.occurrence == OCCURRENCE__IGNORED:
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(%s) /* FIXME */\n" % self.name
- elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
- Property.OCCURRENCE__OPTIONAL_LIST]:
+ elif self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(%s, %s)\n" % (self.type, self.name)
elif self.type == "String":
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, %s)\n" % self.name
else:
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(%s, %s)\n" % (self.type, self.name)
+
def get_type_string(self):
if self.type == "String" and \
- self.occurrence not in [Property.OCCURRENCE__REQUIRED_LIST,
- Property.OCCURRENCE__OPTIONAL_LIST]:
+ self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
return "char *"
elif self.is_enum():
return "esxVI_%s " % self.type
else:
return "esxVI_%s *" % self.type
- def get_occurrence_string(self):
- if self.occurrence == Property.OCCURRENCE__REQUIRED_ITEM:
- return "required"
- elif self.occurrence == Property.OCCURRENCE__REQUIRED_LIST:
- return "required, list"
- elif self.occurrence == Property.OCCURRENCE__OPTIONAL_ITEM:
- return "optional"
- elif self.occurrence == Property.OCCURRENCE__OPTIONAL_LIST:
- return "optional, list"
-
- raise ValueError("unknown cardinality value '%s'" % self.cardinality)
-
-
-
+ def get_occurrence_comment(self):
+ if self.occurrence == OCCURRENCE__REQUIRED_ITEM:
+ return "/* required */"
+ elif self.occurrence == OCCURRENCE__REQUIRED_LIST:
+ return "/* required, list */"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_ITEM:
+ return "/* optional */"
+ elif self.occurrence == OCCURRENCE__OPTIONAL_LIST:
+ return "/* optional, list */"
+ raise ValueError("unknown occurrence value '%s'" % self.occurrence)
@@ -159,6 +374,7 @@ class Object:
FEATURE__SERIALIZE = (1 << 5)
FEATURE__DESERIALIZE = (1 << 6)
+
def __init__(self, name, extends, properties, features = 0, extended_by = None):
self.name = name
self.extends = extends
@@ -166,10 +382,6 @@ class Object:
self.properties = properties
self.extended_by = extended_by
- self.properties_by_name = {}
-
- for property in self.properties:
- self.properties_by_name[property.name] = property
def generate_struct_members(self, add_banner = False, struct_gap = False):
global objects_by_name
@@ -201,6 +413,7 @@ class Object:
return members
+
def generate_free_code(self, add_banner = False):
global objects_by_name
source = ""
@@ -226,6 +439,7 @@ class Object:
return source
+
def generate_validate_code(self, add_banner = False):
global objects_by_name
source = ""
@@ -251,6 +465,7 @@ class Object:
return source
+
def generate_dynamic_cast_code(self):
global objects_by_name
source = ""
@@ -266,6 +481,7 @@ class Object:
return source
+
def generate_deep_copy_code(self, add_banner = False):
global objects_by_name
source = ""
@@ -291,6 +507,7 @@ class Object:
return source
+
def generate_serialize_code(self, add_banner = False):
global objects_by_name
source = ""
@@ -309,6 +526,7 @@ class Object:
return source
+
def generate_deserialize_code(self, add_banner = False):
global objects_by_name
source = ""
@@ -327,18 +545,22 @@ class Object:
return source
+
def generate_typedef(self):
return "typedef struct _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
+
def generate_typeenum(self):
return " esxVI_Type_%s,\n" % self.name
+
def generate_typetostring(self):
string = " case esxVI_Type_%s:\n" % self.name
string += " return \"%s\";\n\n" % self.name
return string
+
def generate_typefromstring(self):
string = " else if (STREQ(type, \"%s\")) {\n" % self.name
string += " return esxVI_Type_%s;\n" % self.name
@@ -346,6 +568,7 @@ class Object:
return string
+
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
header += " * VI Type: %s\n" % self.name
@@ -424,6 +647,7 @@ class Object:
return header
+
def generate_source(self):
source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
source += " * VI Type: %s\n" % self.name
@@ -601,11 +825,6 @@ class Object:
-
-
-
-
-
class Enum:
FEATURE__ANY_TYPE = (1 << 1)
FEATURE__SERIALIZE = (1 << 2)
@@ -617,18 +836,22 @@ class Enum:
self.values = values
self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
+
def generate_typedef(self):
return "typedef enum _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
+
def generate_typeenum(self):
return " esxVI_Type_%s,\n" % self.name
+
def generate_typetostring(self):
string = " case esxVI_Type_%s:\n" % self.name
string += " return \"%s\";\n\n" % self.name
return string
+
def generate_typefromstring(self):
string = " else if (STREQ(type, \"%s\")) {\n" % self.name
string += " return esxVI_Type_%s;\n" % self.name
@@ -636,6 +859,7 @@ class Enum:
return string
+
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
header += " * VI Enum: %s\n" % self.name
@@ -664,6 +888,7 @@ class Enum:
return header
+
def generate_source(self):
source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
source += " * VI Enum: %s\n" % self.name
@@ -698,20 +923,12 @@ class Enum:
-
-
def report_error(message):
print "error: " + message
sys.exit(1)
-def usage():
- print "%s <input-filename> <output-directory>" % sys.argv[0]
- sys.exit(0)
-
-
-
def capitalize_first(string):
return string[:1].upper() + string[1:]
@@ -744,7 +961,7 @@ def parse_object(block):
if len(items) != 3:
report_error("line %d: invalid property" % line[0])
- if items[2] not in Property.valid_occurrences:
+ if items[2] not in valid_occurrences:
report_error("line %d: invalid occurrence" % line[0])
properties.append(Property(type = items[0], name = items[1],
@@ -775,6 +992,44 @@ def parse_enum(block):
+def parse_method(block):
+ # expected format: method <name> [returns <type> <occurrence>]
+ header_items = block[0][1].split()
+
+ if len(header_items) < 2:
+ report_error("line %d: invalid block header" % (number))
+
+ assert header_items[0] == "method"
+
+ name = header_items[1]
+ returns = None
+
+ if len(header_items) > 2:
+ if header_items[2] != "returns":
+ report_error("line %d: invalid block header" % (number))
+ else:
+ returns = Parameter(type = header_items[3], name = "output",
+ occurrence = header_items[4])
+
+ parameters = []
+
+ for line in block[1:]:
+ # expected format: <type> <name> <occurrence>
+ items = line[1].split()
+
+ if len(items) != 3:
+ report_error("line %d: invalid property" % line[0])
+
+ if items[2] not in valid_occurrences:
+ report_error("line %d: invalid occurrence" % line[0])
+
+ parameters.append(Parameter(type = items[0], name = items[1],
+ occurrence = items[2]))
+
+ return Method(name = name, parameters = parameters, returns = returns)
+
+
+
def inherit_features(obj):
if obj.extended_by is not None:
for extended_by in obj.extended_by:
@@ -834,7 +1089,7 @@ additional_object_features = { "Event" : Object.FEATURE__LI
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
"ObjectContent" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST,
"PerfCounterInfo" : Object.FEATURE__LIST,
- "PerfEntityMetric" : Object.FEATURE__LIST,
+ "PerfEntityMetric" : Object.FEATURE__LIST | Object.FEATURE__DYNAMIC_CAST,
"PerfQuerySpec" : Object.FEATURE__LIST,
"PerfMetricIntSeries" : Object.FEATURE__DYNAMIC_CAST,
"PropertyFilterSpec" : Object.FEATURE__LIST,
@@ -859,7 +1114,6 @@ removed_object_features = { "DynamicProperty" : Object.FEATURE__SERIA
-
if "srcdir" in os.environ:
input_filename = os.path.join(os.environ["srcdir"], "esx/esx_vi_generator.input")
output_dirname = os.path.join(os.environ["srcdir"], "esx")
@@ -869,18 +1123,21 @@ else:
-typedef = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typedef"))
-typeenum = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typeenum"))
-typetostring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typetostring"))
-typefromstring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typefromstring"))
-header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.h"))
-source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
+types_typedef = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typedef"))
+types_typeenum = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typeenum"))
+types_typetostring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typetostring"))
+types_typefromstring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typefromstring"))
+types_header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.h"))
+types_source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
+methods_header = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
+methods_source = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
number = 0
objects_by_name = {}
enums_by_name = {}
+methods_by_name = {}
block = None
@@ -896,7 +1153,7 @@ for line in file(input_filename, "rb").readlines():
if len(line) < 1:
continue
- if line.startswith("object") or line.startswith("enum"):
+ if line.startswith("object") or line.startswith("enum") or line.startswith("method"):
if block is not None:
report_error("line %d: nested block found" % (number))
else:
@@ -907,9 +1164,12 @@ for line in file(input_filename, "rb").readlines():
if block[0][1].startswith("object"):
obj = parse_object(block)
objects_by_name[obj.name] = obj
- else:
+ elif block[0][1].startswith("enum"):
enum = parse_enum(block)
enums_by_name[enum.name] = enum
+ else:
+ method = parse_method(block)
+ methods_by_name[method.name] = method
block = None
else:
@@ -926,7 +1186,7 @@ for enum in enums_by_name.values():
for obj in objects_by_name.values():
for property in obj.properties:
- if property.occurrence != Property.OCCURRENCE__IGNORED and \
+ if property.occurrence != OCCURRENCE__IGNORED and \
not is_known_type(property.type):
report_error("object '%s' contains unknown property type '%s'" % (obj.name, property.type))
@@ -936,8 +1196,8 @@ for obj in objects_by_name.values():
# detect list usage
for property in obj.properties:
- if (property.occurrence == Property.OCCURRENCE__REQUIRED_LIST or \
- property.occurrence == Property.OCCURRENCE__OPTIONAL_LIST) and \
+ if (property.occurrence == OCCURRENCE__REQUIRED_LIST or \
+ property.occurrence == OCCURRENCE__OPTIONAL_LIST) and \
property.type not in predefined_objects:
objects_by_name[property.type].features |= Object.FEATURE__LIST
@@ -951,7 +1211,7 @@ for obj in objects_by_name.values():
# spread deep copy onto properties
if obj.features & Object.FEATURE__DEEP_COPY:
for property in obj.properties:
- if property.occurrence != Property.OCCURRENCE__IGNORED and \
+ if property.occurrence != OCCURRENCE__IGNORED and \
property.type not in predefined_objects and \
property.type in objects_by_name:
objects_by_name[property.type].features |= Object.FEATURE__DEEP_COPY
@@ -976,55 +1236,62 @@ for obj in objects_by_name.values():
-typedef.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
-typeenum.write("/* Generated by esx_vi_generator.py */\n\n")
-typetostring.write("/* Generated by esx_vi_generator.py */\n\n")
-typefromstring.write("/* Generated by esx_vi_generator.py */\n\n")
-header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
-source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
-
-
-typedef.write("/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
- " * VI Enums\n" +
- " */\n\n")
+types_typedef.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+types_typeenum.write("/* Generated by esx_vi_generator.py */\n\n")
+types_typetostring.write("/* Generated by esx_vi_generator.py */\n\n")
+types_typefromstring.write("/* Generated by esx_vi_generator.py */\n\n")
+types_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+types_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+methods_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+methods_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+# output enums
+types_typedef.write("/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Enums\n" +
+ " */\n\n")
names = enums_by_name.keys()
names.sort()
-
for name in names:
- typedef.write(enums_by_name[name].generate_typedef())
- typeenum.write(enums_by_name[name].generate_typeenum())
- typetostring.write(enums_by_name[name].generate_typetostring())
- typefromstring.write(enums_by_name[name].generate_typefromstring())
- header.write(enums_by_name[name].generate_header())
- source.write(enums_by_name[name].generate_source())
+ types_typedef.write(enums_by_name[name].generate_typedef())
+ types_typeenum.write(enums_by_name[name].generate_typeenum())
+ types_typetostring.write(enums_by_name[name].generate_typetostring())
+ types_typefromstring.write(enums_by_name[name].generate_typefromstring())
+ types_header.write(enums_by_name[name].generate_header())
+ types_source.write(enums_by_name[name].generate_source())
-typedef.write("\n\n\n" +
- "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
- " * VI Types\n" +
- " */\n\n")
+# output objects
+types_typedef.write("\n\n\n" +
+ "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Types\n" +
+ " */\n\n")
+types_typeenum.write("\n")
+types_typetostring.write("\n")
+types_typefromstring.write("\n")
-typeenum.write("\n")
-typetostring.write("\n")
-typefromstring.write("\n")
+names = objects_by_name.keys()
+names.sort()
+for name in names:
+ types_typedef.write(objects_by_name[name].generate_typedef())
+ types_typeenum.write(objects_by_name[name].generate_typeenum())
+ types_typetostring.write(objects_by_name[name].generate_typetostring())
+ types_typefromstring.write(objects_by_name[name].generate_typefromstring())
+ types_header.write(objects_by_name[name].generate_header())
+ types_source.write(objects_by_name[name].generate_source())
-names = objects_by_name.keys()
-names.sort()
+# output methods
+names = methods_by_name.keys()
+names.sort()
for name in names:
- typedef.write(objects_by_name[name].generate_typedef())
- typeenum.write(objects_by_name[name].generate_typeenum())
- typetostring.write(objects_by_name[name].generate_typetostring())
- typefromstring.write(objects_by_name[name].generate_typefromstring())
- header.write(objects_by_name[name].generate_header())
- source.write(objects_by_name[name].generate_source())
+ methods_header.write(methods_by_name[name].generate_header())
+ methods_source.write(methods_by_name[name].generate_source())
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index b2b3e8d..5c52167 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -51,18 +51,88 @@
-#define ESX_VI__METHOD(_name, _parameters, _occurrence, _prolog, _validate, \
- _serialize, _deserialize) \
+#define ESX_VI__METHOD__CHECK_OUTPUT__None \
+ /* nothing */
+
+
+
+#define ESX_VI__METHOD__CHECK_OUTPUT__NotNone \
+ if (output == NULL || *output != 0) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
+ return -1; \
+ }
+
+
+
+#define ESX_VI__METHOD__CHECK_OUTPUT__RequiredItem \
+ ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+
+
+
+#define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
+ ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+
+
+
+#define ESX_VI__METHOD__CHECK_OUTPUT__OptionalItem \
+ ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+
+
+
+#define ESX_VI__METHOD__CHECK_OUTPUT__OptionalList \
+ ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+
+
+
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__None(_type) \
+ /* nothing */
+
+
+
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredItem(_type) \
+ if (esxVI_##_type##_Deserialize(response->node, output) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type) \
+ if (esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalItem(_type) \
+ if (response->node != NULL && \
+ esxVI_##_type##_Deserialize(response->node, output) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalList(_type) \
+ if (response->node != NULL && \
+ esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__METHOD(_name, _this_from_service, _parameters, _output_type, \
+ _occurrence, _validate, _serialize) \
int \
esxVI_##_name _parameters \
{ \
int result = 0; \
- const char* method_name = #_name; \
+ const char *methodName = #_name; \
virBuffer buffer = VIR_BUFFER_INITIALIZER; \
char *request = NULL; \
esxVI_Response *response = NULL; \
\
- _prolog \
+ ESX_VI__METHOD__PARAMETER__THIS__##_this_from_service \
+ \
+ ESX_VI__METHOD__CHECK_OUTPUT__##_occurrence \
\
_validate \
\
@@ -81,14 +151,12 @@
\
request = virBufferContentAndReset(&buffer); \
\
- if (esxVI_Context_Execute(ctx, #_name, request, &response, \
+ if (esxVI_Context_Execute(ctx, methodName, request, &response, \
esxVI_Occurrence_##_occurrence) < 0) { \
goto failure; \
} \
\
- if (response->node != NULL) { \
- _deserialize \
- } \
+ ESX_VI__METHOD__DESERIALIZE_OUTPUT__##_occurrence(_output_type) \
\
cleanup: \
VIR_FREE(request); \
@@ -106,19 +174,44 @@
-#define ESX_VI__METHOD__CHECK_SERVICE() \
+#define ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(_type, _name) \
+ esxVI_##_type *_this = NULL; \
+ \
if (ctx->service == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call")); \
return -1; \
- }
+ } \
+ \
+ _this = ctx->service->_name;
-#define ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(_name) \
- if (_name == NULL || *_name != NULL) { \
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
- return -1; \
- }
+#define ESX_VI__METHOD__PARAMETER__THIS__/* explicit _this */ \
+ /* nothing */
+
+
+
+#define ESX_VI__METHOD__PARAMETER__THIS__perfManager \
+ ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \
+ perfManager)
+
+
+
+#define ESX_VI__METHOD__PARAMETER__THIS__propertyCollector \
+ ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \
+ propertyCollector)
+
+
+
+#define ESX_VI__METHOD__PARAMETER__THIS__searchIndex \
+ ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \
+ searchIndex)
+
+
+
+#define ESX_VI__METHOD__PARAMETER__THIS__sessionManager \
+ ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \
+ sessionManager)
@@ -132,17 +225,7 @@
if (_name == 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
"Required parameter '%s' is missing for call to %s", \
- #_name, method_name); \
- return -1; \
- }
-
-
-
-#define ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(_name) \
- if (_name == 0) { \
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Required parameter '_this' is missing for call to %s", \
- method_name); \
+ #_name, methodName); \
return -1; \
}
@@ -169,13 +252,6 @@
-#define ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(_type, _name) \
- if (esxVI_##_type##_Serialize(_name, "_this", &buffer) < 0) { \
- goto failure; \
- }
-
-
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Methods
*/
@@ -220,553 +296,16 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx,
-/* esxVI_Login */
-ESX_VI__METHOD(Login,
- (esxVI_Context *ctx,
- const char *userName, const char *password,
- esxVI_UserSession **userSession),
- RequiredItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(userSession)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
- ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
- ESX_VI__METHOD__PARAMETER__REQUIRE(password)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->sessionManager)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, password)
-},
-{
- if (esxVI_UserSession_Deserialize(response->node, userSession) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_Logout */
-ESX_VI__METHOD(Logout, (esxVI_Context *ctx), None,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->sessionManager)
-},
-{
-})
-
-
-
-/* esxVI_SessionIsActive */
-ESX_VI__METHOD(SessionIsActive,
- (esxVI_Context *ctx, const char *sessionID,
- const char *userName, esxVI_Boolean *active),
- RequiredItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
-
- if (active == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
- ESX_VI__METHOD__PARAMETER__REQUIRE(sessionID)
- ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->sessionManager)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, sessionID)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
-},
-{
- if (esxVI_Boolean_Deserialize(response->node, active) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_RetrieveProperties */
-ESX_VI__METHOD(RetrieveProperties,
- (esxVI_Context *ctx,
- esxVI_PropertyFilterSpec *specSet, /* list */
- esxVI_ObjectContent **objectContentList),
- OptionalList,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(objectContentList)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__REQUIRE(specSet)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PropertyFilterSpec, specSet)
-},
-{
- if (esxVI_ObjectContent_DeserializeList(response->node,
- objectContentList) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_PowerOnVM_Task */
-ESX_VI__METHOD(PowerOnVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_PowerOffVM_Task */
-ESX_VI__METHOD(PowerOffVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_SuspendVM_Task */
-ESX_VI__METHOD(SuspendVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_MigrateVM_Task */
-ESX_VI__METHOD(MigrateVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_VirtualMachineMovePriority priority,
- esxVI_VirtualMachinePowerState state,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
- ESX_VI__METHOD__PARAMETER__REQUIRE(priority)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineMovePriority, priority)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_ReconfigVM_Task */
-ESX_VI__METHOD(ReconfigVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_VirtualMachineConfigSpec *spec,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
- ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineConfigSpec, spec)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_RegisterVM_Task */
-ESX_VI__METHOD(RegisterVM_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *folder,
- const char *path, const char *name,
- esxVI_Boolean asTemplate,
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(folder)
- ESX_VI__METHOD__PARAMETER__REQUIRE(path)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, folder)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, path)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, name)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, asTemplate)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_CreateSnapshot_Task */
-ESX_VI__METHOD(CreateSnapshot_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- const char *name, const char *description,
- esxVI_Boolean memory, esxVI_Boolean quiesce,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
- ESX_VI__METHOD__PARAMETER__REQUIRE(name)
- ESX_VI__METHOD__PARAMETER__REQUIRE(memory)
- ESX_VI__METHOD__PARAMETER__REQUIRE(quiesce)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, name)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, description)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, memory)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, quiesce)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_RevertToSnapshot_Task */
-ESX_VI__METHOD(RevertToSnapshot_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachineSnapshot,
- esxVI_ManagedObjectReference *host,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachineSnapshot)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachineSnapshot)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_RemoveSnapshot_Task */
-ESX_VI__METHOD(RemoveSnapshot_Task,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachineSnapshot,
- esxVI_Boolean removeChildren,
- esxVI_ManagedObjectReference **task),
- RequiredItem,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachineSnapshot)
- ESX_VI__METHOD__PARAMETER__REQUIRE(removeChildren)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachineSnapshot)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, removeChildren)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_CancelTask */
-ESX_VI__METHOD(CancelTask,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *task),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(task)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, task)
-},
-{
-})
-
-
-
-/* esxVI_UnregisterVM */
-ESX_VI__METHOD(UnregisterVM,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
-})
-
-
-
-/* esxVI_AnswerVM */
-ESX_VI__METHOD(AnswerVM,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- const char *questionId,
- const char *answerChoice),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
- ESX_VI__METHOD__PARAMETER__REQUIRE(questionId)
- ESX_VI__METHOD__PARAMETER__REQUIRE(answerChoice)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, questionId)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, answerChoice)
-},
-{
-})
-
-
-
-/* esxVI_CreateFilter */
-ESX_VI__METHOD(CreateFilter,
- (esxVI_Context *ctx,
- esxVI_PropertyFilterSpec *spec,
- esxVI_Boolean partialUpdates,
- esxVI_ManagedObjectReference **propertyFilter),
- RequiredItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(propertyFilter)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
- ESX_VI__METHOD__PARAMETER__REQUIRE(partialUpdates)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(PropertyFilterSpec, spec)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, partialUpdates)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node,
- propertyFilter) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_DestroyPropertyFilter */
-ESX_VI__METHOD(DestroyPropertyFilter,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *propertyFilter),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(propertyFilter)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- propertyFilter)
-},
-{
-})
-
-
-
-/* esxVI_WaitForUpdates */
-ESX_VI__METHOD(WaitForUpdates,
- (esxVI_Context *ctx,
- const char *version,
- esxVI_UpdateSet **updateSet),
- RequiredItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(updateSet)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__REQUIRE(version)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->propertyCollector)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, version)
-},
-{
- if (esxVI_UpdateSet_Deserialize(response->node, updateSet) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_RebootGuest */
-ESX_VI__METHOD(RebootGuest,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
-})
-
-
-
-/* esxVI_ShutdownGuest */
-ESX_VI__METHOD(ShutdownGuest,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine),
- None,
-{
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- virtualMachine)
-},
-{
-})
-
-
-
/* esxVI_ValidateMigration */
-ESX_VI__METHOD(ValidateMigration,
+ESX_VI__METHOD(ValidateMigration, /* special _this */,
(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *vm, /* list */
- esxVI_VirtualMachinePowerState state,
- esxVI_String *testType, /* list */
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_Event **eventList),
- OptionalList,
-{
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(eventList)
-},
+ esxVI_ManagedObjectReference *vm, /* required, list */
+ esxVI_VirtualMachinePowerState state, /* optional */
+ esxVI_String *testType, /* optional, list */
+ esxVI_ManagedObjectReference *pool, /* optional */
+ esxVI_ManagedObjectReference *host, /* optional */
+ esxVI_Event **output), /* optional, list */
+ Event, OptionalList,
{
ESX_VI__METHOD__PARAMETER__REQUIRE(vm)
},
@@ -781,165 +320,8 @@ ESX_VI__METHOD(ValidateMigration,
ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(String, testType)
ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
-},
-{
- if (esxVI_Event_DeserializeList(response->node, eventList) < 0) {
- goto failure;
- }
})
-/* esxVI_FindByIp */
-ESX_VI__METHOD(FindByIp,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *datacenter,
- const char *ip,
- esxVI_Boolean vmSearch,
- esxVI_ManagedObjectReference **managedObjectReference),
- OptionalItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
- ESX_VI__METHOD__PARAMETER__REQUIRE(ip)
- ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->searchIndex)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, ip)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node,
- managedObjectReference) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_FindByUuid */
-ESX_VI__METHOD(FindByUuid,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *datacenter,
- const char *uuid, /* string */
- esxVI_Boolean vmSearch,
- esxVI_ManagedObjectReference **managedObjectReference),
- OptionalItem,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
- ESX_VI__METHOD__PARAMETER__REQUIRE(uuid)
- ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->searchIndex)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, uuid)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
-},
-{
- if (esxVI_ManagedObjectReference_Deserialize(response->node,
- managedObjectReference) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_QueryAvailablePerfMetric */
-ESX_VI__METHOD(QueryAvailablePerfMetric,
- (esxVI_Context *ctx,
- esxVI_ManagedObjectReference *entity,
- esxVI_DateTime *beginTime,
- esxVI_DateTime *endTime,
- esxVI_Int *intervalId,
- esxVI_PerfMetricId **perfMetricIdList),
- OptionalList,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfMetricIdList)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__REQUIRE(entity)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, entity)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, beginTime)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, endTime)
- ESX_VI__METHOD__PARAMETER__SERIALIZE(Int, intervalId)
-},
-{
- if (esxVI_PerfMetricId_DeserializeList(response->node,
- perfMetricIdList) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_QueryPerfCounter */
-ESX_VI__METHOD(QueryPerfCounter,
- (esxVI_Context *ctx,
- esxVI_Int *counterId, /* list */
- esxVI_PerfCounterInfo **perfCounterInfoList),
- OptionalList,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfCounterInfoList)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__REQUIRE(counterId)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(Int, counterId)
-},
-{
- if (esxVI_PerfCounterInfo_DeserializeList(response->node,
- perfCounterInfoList) < 0) {
- goto failure;
- }
-})
-
-
-
-/* esxVI_QueryPerf */
-ESX_VI__METHOD(QueryPerf,
- (esxVI_Context *ctx,
- esxVI_PerfQuerySpec *querySpec, /* list */
- esxVI_PerfEntityMetric **perfEntityMetricList),
- OptionalList,
-{
- ESX_VI__METHOD__CHECK_SERVICE()
- ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfEntityMetricList)
-},
-{
- ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__REQUIRE(querySpec)
-},
-{
- ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
- ctx->service->perfManager)
- ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PerfQuerySpec, querySpec)
-},
-{
- if (esxVI_PerfEntityMetric_DeserializeList(response->node,
- perfEntityMetricList) < 0) {
- goto failure;
- }
-})
+#include "esx_vi_methods.generated.c"
diff --git a/src/esx/esx_vi_methods.h b/src/esx/esx_vi_methods.h
index 9ff8b4b..7b6be4e 100644
--- a/src/esx/esx_vi_methods.h
+++ b/src/esx/esx_vi_methods.h
@@ -32,123 +32,19 @@
* VI Methods
*/
-int esxVI_RetrieveServiceContent(esxVI_Context *ctx,
- esxVI_ServiceContent **serviceContent);
-
-int esxVI_Login(esxVI_Context *ctx, const char *userName, const char *password,
- esxVI_UserSession **userSession);
-
-int esxVI_Logout(esxVI_Context *ctx);
-
-int esxVI_SessionIsActive(esxVI_Context *ctx, const char *sessionID,
- const char *userName, esxVI_Boolean *active);
-
-int esxVI_RetrieveProperties(esxVI_Context *ctx,
- esxVI_PropertyFilterSpec *specSet, /* list */
- esxVI_ObjectContent **objectContentList);
-
-int esxVI_PowerOnVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_PowerOffVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_SuspendVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_MigrateVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_VirtualMachineMovePriority priority,
- esxVI_VirtualMachinePowerState state,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_ReconfigVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- esxVI_VirtualMachineConfigSpec *spec,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_RegisterVM_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *folder,
- const char *path, const char *name,
- esxVI_Boolean asTemplate,
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_CreateSnapshot_Task(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- const char *name, const char *description,
- esxVI_Boolean memory, esxVI_Boolean quiesce,
- esxVI_ManagedObjectReference **task);
-
-int esxVI_RevertToSnapshot_Task
- (esxVI_Context *ctx, esxVI_ManagedObjectReference *virtualMachineSnapshot,
- esxVI_ManagedObjectReference *host, esxVI_ManagedObjectReference **task);
-
-int esxVI_RemoveSnapshot_Task
- (esxVI_Context *ctx, esxVI_ManagedObjectReference *virtualMachineSnapshot,
- esxVI_Boolean removeChildren, esxVI_ManagedObjectReference **task);
-
-int esxVI_CancelTask(esxVI_Context *ctx, esxVI_ManagedObjectReference *task);
-
-int esxVI_UnregisterVM(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine);
-
-int esxVI_AnswerVM(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine,
- const char *questionId, const char *answerChoice);
-
-int esxVI_CreateFilter(esxVI_Context *ctx,
- esxVI_PropertyFilterSpec *spec,
- esxVI_Boolean partialUpdates,
- esxVI_ManagedObjectReference **propertyFilter);
-
-int esxVI_DestroyPropertyFilter(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *propertyFilter);
-
-int esxVI_WaitForUpdates(esxVI_Context *ctx, const char *version,
- esxVI_UpdateSet **updateSet);
-
-int esxVI_RebootGuest(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine);
-
-int esxVI_ShutdownGuest(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *virtualMachine);
-
-int esxVI_ValidateMigration(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *vm, /* list */
- esxVI_VirtualMachinePowerState state,
- esxVI_String *testType, /* list */ // FIXME: see ValidateMigrationTestType
- esxVI_ManagedObjectReference *pool,
- esxVI_ManagedObjectReference *host,
- esxVI_Event **eventList);
-
-int esxVI_FindByIp(esxVI_Context *ctx, esxVI_ManagedObjectReference *datacenter,
- const char *ip, esxVI_Boolean vmSearch,
- esxVI_ManagedObjectReference **managedObjectReference);
-
-int esxVI_FindByUuid(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *datacenter,
- const char *uuid, /* string */
- esxVI_Boolean vmSearch,
- esxVI_ManagedObjectReference **managedObjectReference);
-
-int esxVI_QueryAvailablePerfMetric(esxVI_Context *ctx,
- esxVI_ManagedObjectReference *entity,
- esxVI_DateTime *beginTime,
- esxVI_DateTime *endTime,
- esxVI_Int *intervalId,
- esxVI_PerfMetricId **perfMetricIdList);
-
-int esxVI_QueryPerfCounter(esxVI_Context *ctx, esxVI_Int *counterId, /* list */
- esxVI_PerfCounterInfo **perfCounterInfoList);
-
-int esxVI_QueryPerf(esxVI_Context *ctx, esxVI_PerfQuerySpec *querySpecList,
- esxVI_PerfEntityMetric **perfEntityMetricList);
+int esxVI_RetrieveServiceContent
+ (esxVI_Context *ctx,
+ esxVI_ServiceContent **serviceContent); /* required */
+
+int esxVI_ValidateMigration
+ (esxVI_Context *ctx,
+ esxVI_ManagedObjectReference *vm, /* required, list */
+ esxVI_VirtualMachinePowerState state, /* optional */
+ esxVI_String *testType, /* optional, list */
+ esxVI_ManagedObjectReference *pool, /* optional */
+ esxVI_ManagedObjectReference *host, /* optional */
+ esxVI_Event **output); /* optional, list */
+
+#include "esx_vi_methods.generated.h"
#endif /* __ESX_VI_METHODS_H__ */
--
1.6.3.3
14 years, 7 months