Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made Sneaky Pete work with RDL as far as prepare call and most user ops.
* Ripped out nova::db::api stuff, which mimicked Nova API in Diablo. * Added nova::guest::HeartBeat class which works with RDLs slimmed down db. * Added "guest_id" property to FlagValues class. * Removed guest_ethernet_device and preset_instance_id props from FlagValues. * Fixed MySqlAppStatus to work with RDL. Mostly changed db names, and made it handle the "NEW" status. * Added == operator to IsoDateTime (needed it for a HeartBeat unit test...). * Changed nova::rpc::Receiver to send ack in the new nicer way. * Log out Sneaky Pete intro flag to program start up to make it easier to see in the logs.
- Loading branch information
Tim Simpson
committed
May 25, 2012
1 parent
aabe019
commit 59658fe
Showing
18 changed files
with
321 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
mkdir /vz/private/$1/agent | ||
sudo cp -rf * /vz/private/$1/agent/ | ||
mkdir /var/lib/vz/private/$1/agent | ||
sudo cp -rf * /var/lib/vz/private/$1/agent/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "nova/guest/HeartBeat.h" | ||
#include <boost/format.hpp> | ||
#include "nova/Log.h" | ||
#include "nova/db/mysql.h" | ||
#include <string.h> | ||
#include "nova/guest/utils.h" | ||
|
||
using boost::format; | ||
using namespace nova::db::mysql; | ||
using boost::optional; | ||
using nova::guest::utils::IsoDateTime; | ||
using std::string; | ||
|
||
namespace nova { namespace guest { | ||
|
||
|
||
HeartBeat::HeartBeat(MySqlConnectionWithDefaultDbPtr con, const char * guest_id) | ||
: con(con), guest_id(guest_id) { | ||
} | ||
|
||
HeartBeat::~HeartBeat() { | ||
} | ||
|
||
|
||
bool HeartBeat::exists() { | ||
con->ensure(); | ||
string query = str(format("SELECT updated_at FROM agent_heartbeats " | ||
"WHERE instance_id='%s'") | ||
% con->escape_string(guest_id.c_str())); | ||
MySqlResultSetPtr results = con->query(query.c_str()); | ||
return results->next(); | ||
} | ||
|
||
void HeartBeat::update() { | ||
IsoDateTime now; | ||
const char * query = exists() | ||
? "UPDATE agent_heartbeats SET updated_at = ? " | ||
"WHERE agent_heartbeats.instance_id = ?" | ||
: "INSERT INTO agent_heartbeats (id, updated_at, instance_id) " | ||
"VALUES(UUID(), ?, ?);" | ||
; | ||
con->ensure(); | ||
MySqlPreparedStatementPtr stmt = con->prepare_statement(query); | ||
stmt->set_string(0, now.c_str()); | ||
stmt->set_string(1, guest_id.c_str()); | ||
stmt->execute(); | ||
} | ||
|
||
|
||
} } // end nova::guest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef __NOVA_GUEST_HEARTBEAT | ||
#define __NOVA_GUEST_HEARTBEAT | ||
|
||
#include "nova/db/mysql.h" | ||
#include <string> | ||
|
||
|
||
namespace nova { namespace guest { | ||
|
||
/** Updates the agent_heartbeats table with the current time. Used to determine | ||
* if Sneaky Pete is still alive. */ | ||
class HeartBeat { | ||
public: | ||
HeartBeat(nova::db::mysql::MySqlConnectionWithDefaultDbPtr con, | ||
const char * guest_id); | ||
|
||
~HeartBeat(); | ||
|
||
void update(); | ||
|
||
private: | ||
|
||
nova::db::mysql::MySqlConnectionWithDefaultDbPtr con; | ||
|
||
bool exists(); | ||
|
||
const std::string guest_id; | ||
}; | ||
|
||
}} // nova::guest | ||
|
||
#endif |
Oops, something went wrong.