Skip to content

Commit

Permalink
Add new plugin variable handling to python-sd plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent b74f979 commit 853c945
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
27 changes: 11 additions & 16 deletions src/plugins/stored/bareos_sd_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,18 @@
bsdVarType = 3,
bsdVarJobId = 4,
bsdVarClient = 5,
bsdVarNumVols = 6,
bsdVarPool = 7,
bsdVarPool = 6,
bsdVarPoolType = 7,
bsdVarStorage = 8,
bsdVarCatalog = 9,
bsdVarMediaType = 10,
bsdVarJobName = 11,
bsdVarJobStatus = 12,
bsdVarPriority = 13,
bsdVarVolumeName = 14,
bsdVarCatalogRes = 15,
bsdVarJobErrors = 16,
bsdVarJobFiles = 17,
bsdVarSDJobFiles = 18,
bsdVarSDErrors = 19,
bsdVarFDJobStatus = 20,
bsdVarSDJobStatus = 21,
bsdCompatible = 22
bsdVarMediaType = 9,
bsdVarJobName = 10,
bsdVarJobStatus = 11,
bsdVarVolumeName = 12,
bsdVarJobErrors = 13,
bsdVarJobFiles = 14,
bsdVarJobBytes = 15,
bsdVarCompatible = 16,
bsdVarPluginDir = 17
)

bsdwVariable = dict(
Expand Down
36 changes: 34 additions & 2 deletions src/plugins/stored/python-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,10 @@ static PyObject *PyBareosGetValue(PyObject *self, PyObject *args)
}

switch (var) {
case bsdVarJobId: {
case bsdVarJobId:
case bsdVarLevel:
case bsdVarType:
case bsdVarJobStatus: {
int value;

ctx = PyGetbpContext(pyCtx);
Expand All @@ -816,7 +819,25 @@ static PyObject *PyBareosGetValue(PyObject *self, PyObject *args)
}
break;
}
case bsdVarJobName: {
case bsdVarJobErrors:
case bsdVarJobFiles:
case bsdVarJobBytes: {
uint64_t value = 0;

ctx = PyGetbpContext(pyCtx);
if (bfuncs->getBareosValue(ctx, (bsdrVariable)var, &value) == bRC_OK) {
pRetVal = PyLong_FromUnsignedLong(value);
}
break;
}
case bsdVarJobName:
case bsdVarJob:
case bsdVarClient:
case bsdVarPool:
case bsdVarPoolType:
case bsdVarStorage:
case bsdVarMediaType:
case bsdVarVolumeName: {
char *value;

ctx = PyGetbpContext(pyCtx);
Expand All @@ -825,6 +846,17 @@ static PyObject *PyBareosGetValue(PyObject *self, PyObject *args)
}
break;
}
case bsdVarCompatible: {
bool value;

if (bfuncs->getBareosValue(NULL, (bsdrVariable)var, &value) == bRC_OK) {
long bool_value;

bool_value = (value) ? 1 : 0;
pRetVal = PyBool_FromLong(bool_value);
}
break;
}
case bsdVarPluginDir: {
char *value;

Expand Down

0 comments on commit 853c945

Please sign in to comment.