Commit 269e9bb5 authored by Edileuton Henrique de Oliveira's avatar Edileuton Henrique de Oliveira
Browse files

server: Add agent's version and mirror's timestamp in the inventory queries


Signed-off-by: default avatarEdileuton Henrique de Oliveira <eho09@c3sl.ufpr.br>
parent 296260b3
......@@ -194,19 +194,21 @@ private static String createIdVerificationQuery(String table, String inep) {
* @param kernel OS kernel
* @param timestamp Timestamp
* @param project Project number
* @param mirrorsTimestamp Mirror's timestamp
* @return String
*/
private static String createInventoryQuery(String table, String inep,
String mac, String hdd1Model, String hdd1Size, String hdd1Used,
String hdd2Model, String hdd2Size, String hdd2Used, String hddAd,
String memSize, String model, String type, String distro,
String kernel, String timestamp, String project, String version) {
String kernel, String timestamp, String project, String version, String mirrorsTimestamp) {
StringBuilder sb = new StringBuilder("INSERT INTO ");
sb.append(table);
sb.append(" (project, inep, macaddr, os_type, os_distro, os_kernel,");
sb.append(" (mirrors_timestamp, project, inep, macaddr, version, os_type, os_distro, os_kernel,");
sb.append(" processor, memory, disk1_model, disk1_size, disk1_used,");
sb.append(" disk2_model, disk2_size, disk2_used, extra_hds) VALUES (");
sb.append(" disk2_models, disk2_size, disk2_used, extra_hds) VALUES (");
sb.append(createValueString(mirrorsTimestamp, "str", 1));
/* Project */
sb.append(createValueString(project, "int", 1));
......@@ -217,7 +219,7 @@ private static String createInventoryQuery(String table, String inep,
sb.append(createValueString(mac, "str", 1));
/* Version */
//sb.append(createValueString(version, "str", 1));
sb.append(createValueString(version, "str", 1));
/* SO Type */
sb.append(createValueString(type, "str", 1));
......@@ -1491,6 +1493,7 @@ throws Exception {
int intSize = -1;
int intUsed = -1;
String project = null;
String mirrorsTimestamp = null;
String[] hddModel = new String[0];
String[] hddSize = new String[0];
String[] hddUsed = new String[0];
......@@ -1515,6 +1518,8 @@ throws Exception {
String strVersion = "version";
String strICode = "inep code";
String strMac = "mac";
String strTs = "timestamp"
String strMirrorTs = "mirrors-timestamp"
String strProjSrc = "project source";
String strSrc = "source";
String strMod = "model";
......@@ -1535,6 +1540,7 @@ throws Exception {
NodeList inepTagList = getTagList(invXML, strInep, 1);
NodeList useTagList = getTagList(invXML, strUse, 1);
NodeList invTagList = getTagList(invXML, strInv, 1);
NodeList mirrosTsTagList = getTagList(invXML, strTs, 1);
NodeList projTagList = getTagList(invXML, strProj, 1);
/* Inventory children */
NodeList osTagList = getTagList(invXML, strOS, 1);
......@@ -1667,6 +1673,23 @@ throws Exception {
throw new Exception(getErrorMessage(3, strProj));
}
}
/* MIRROR TIMESTAMP */
Node mirrosTsTag = getChildTag(mirrosTsTagList, strMirrorTs, strTs);
/* Check <mirrors-timestamp> */
if (validateTagName(mirrosTsTag, strTs) == true) {
/* MIRROR TIMESTAMP */
mirrorsTimestamp = getAttributeValue(mirrosTsTag, "value");
if(! mirrorsTimestamp.equals("")){
/* Check MIRROR TIMESTAMP format*/
try {
SimpleDateFormat dt = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy");
Date date = dt.parse(date_s);
} catch (Exception e) {
throw new Exception(getErrorMessage(7, strMirrorTs));
}
}
}
/* INVENTORY */
......@@ -1906,18 +1929,18 @@ throws Exception {
if (quantity == 0) {
query = createInventoryQuery(INVTABLE, inep, macAddr, null, null,
null, null, null, null, hddAd, memSize, model, type,
distro, kernel, dateTimestamp, project, version);
distro, kernel, dateTimestamp, project, version, mirrorsTimestamp);
} else if (quantity == 1) {
query = createInventoryQuery(INVTABLE, inep, macAddr, hddModel[0],
hddSize[0], hddUsed[0], null, null, null, hddAd, memSize,
model, type, distro, kernel, dateTimestamp, project, version);
model, type, distro, kernel, dateTimestamp, project, version, mirrorsTimestamp);
} else {
quantity = quantity - 2;
hddAd = quantity.toString();
query = createInventoryQuery(INVTABLE, inep, macAddr, hddModel[0],
hddSize[0], hddUsed[0], hddModel[1], hddSize[1],
hddUsed[1], hddAd, memSize, model, type, distro,
kernel, dateTimestamp, project, version);
kernel, dateTimestamp, project, version, mirrorsTimestamp);
}
/* Return inventory queries */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment