Fix guest memory collector name

Change it from GuestLibvirt to GuestMemory. The default configuration
was not updated when the guest memory colletor was renamed. The sample
configuration file has been updated already.

Change-Id: Iaf080a324d3ae8f77dfc710d6ec29ff9eb2326ac
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
trivial: Remove unneeded include from MOMFuncs

MOMFuncs does not make use of RPCServer functionality and therefore does not
need those modules included.  Remove them.

Change-Id: If42db4d757ecbefdee6e4cb9350b7086d37a539f
Signed-off-by: Adam Litke <agl@us.ibm.com>
Remove clientIF from vdsmInterface

VDSM API has removed the clientIF from its interface definition.
So we don't need the instance of clientIF to use VDSM API any more.

Change-Id: Icdf587a2d44f5862136048225611e13ebfc95b4e
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Add an interface to set policy for VDSM

Fix a bug exising in getStatistics together.

Change-Id: I801773b4faa7b20036df864de61fb5df0a9edba6
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Return latest stat record in getStatistics()

I found MOM reported the oldest stat record in its history window when
I wrote a test case for vdsm/mom integration. It can't reflect the real
case in time. So change to report latest entry.

Change-Id: I3a5f1c656c42576dac290d9735096d0d31c3f3ae
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
write_value: use contextmanager to close file

Calling file.close() after an exception caused open() to fail would lead
to UnboundLocalError. Instead, this patch uses `with` to take care of
closing the file when needed. This patch also avoids overwriting the
built-in python type `file` with a local variable.

Signed-off-by: Dan Kenigsberg <danken@redhat.com>
Change-Id: Ic00b319e1e654270826e3fb7045de639006bb3a4
Collect more detailed memory stats by ovirt-guest-agent

The patches for ovirt-guest-agent and vdsm were both accepted.
We we can collect more detailed memory stats from vdsm now.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Change-Id: If2e3f56708aa90222676e15a684dca35c7f10cfc
libvirtInterface: Fix a bug in getVmMemoryStats()

Change-Id: If9ac914f69f53b482812b301ab2ec40a5b990e1d
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Add balloon support for vdsm HypervisorInterface

This patch implements getVmBalloonInfo() and setVmBalloonTarget()
for vdsm HypervisorInterface.

Change-Id: I066c29012ce51c0a6a0429e20b54acf043289475
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Remove statusException

Before the vdsm API refactor work was done, there're two kinds
of exceptions we need handle: connectionException and statusException.
They're both inheriting from vdsmException. connectionException
was removed in previous patch, so a general vdsmException can cover all
cases.

This patch also fixes some style problems together.

Change-Id: I45ff6c32cdb23cae45c8246ab06c75c1a511ee80
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Wrong type of vdsmInterface.get1VmMemoryStats['mem_available']

Probebly a typo, the comma at the end of the line changes the type to a tuple

Change-Id: I6b04762964ca102b5b03cf4a20f88a8b9f41912a
Signed-off-by: Noam Slomianko <nslomian@redhat.com>
trivial: Fix stats_error function call

The stats_error() function expects a single msg argument and cannot handle
varargs like the logging functions.  Use '%' to construct the message before
calling stats_error().

Change-Id: I6991548bbe62abeed50e923947c1002544794204
Signed-off-by: Adam Litke <agl@us.ibm.com>
logging: Reduce verbosity of some vdsmInterface messages

This patch makes some changes to the logging in vdsmInterface.  First, lower the
verbosity of the VM List message to debug since it is cluttering up the log.
It's only really needed if you are debugging an issue around getting the list of
VMs.

Second, convert the getVmMemoryStats errors so they just return error info in
the HypervisorInterfaceError.  This info will be reported as seen fit by the
caller and there is no need to print it at WARNING verbosity here.  Change the
verbosity of stats_error() to WARNING so that when stats collection errors
happen, the user will see the message the first time the error occurs.

Change-Id: I80701029f45f3e1d791846df302eae13ee3354e7
Signed-off-by: Adam Litke <agl@us.ibm.com>
security: momd creates a world-writable pid file

From the bug[1] submitter:
daemonize in src/momd calls os.umask(0) when creating the daemon process.  As a
result, the PID file is world-writable.

This dates back to incorrect example code in APUE.  It's probably best to just
drop the umask call.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=863178

Change-Id: I224f7b5da172ade383f2adfe9d25fd0e6504b9c2
Signed-off-by: Adam Litke <agl@us.ibm.com>
GuestQemuAgent: Cap size when reading guest files

For extra safety, set a default upper limit on the size of files that are
collected from the guest.  This avoids a memory DoS attack on the host by a
malicious guest.

Change-Id: Ic60976cf27c63d2b8e30c9b2a53b74a61ee95594
Signed-off-by: Adam Litke <agl@us.ibm.com>
use scripts for momd and mom-agentd
Merge branch 'master' of github.com:Youscribe/mom