summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2012-09-21 13:06:24 +0200
committerRoman Rakus <rrakus@redhat.com>2012-09-21 13:06:24 +0200
commit1285ef838782a6399606fc5af96e288236edf8e2 (patch)
tree0edba1d4488e50e0409e559dedf59ba2f3219b7c /src
parent7faa01fbaed22c074afeab82c4de811f29d6e8d2 (diff)
downloadopenlmi-providers-1285ef838782a6399606fc5af96e288236edf8e2.tar.gz
openlmi-providers-1285ef838782a6399606fc5af96e288236edf8e2.tar.xz
openlmi-providers-1285ef838782a6399606fc5af96e288236edf8e2.zip
account: DeleteInstance on LMI_Group
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/account/LMI_GroupProvider.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/account/LMI_GroupProvider.c b/src/account/LMI_GroupProvider.c
index 5de5318..3ffec5a 100644
--- a/src/account/LMI_GroupProvider.c
+++ b/src/account/LMI_GroupProvider.c
@@ -122,7 +122,45 @@ static CMPIStatus LMI_GroupDeleteInstance(
const CMPIResult* cr,
const CMPIObjectPath* cop)
{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+ LMI_Group lg;
+ const char *name = NULL;
+ struct lu_context *luc = NULL;
+ struct lu_error *error = NULL;
+ struct lu_ent *lue = NULL;
+ char errmsg[256];
+
+ LMI_Group_InitFromObjectPath(&lg, _cb, cop);
+ name = lg.Name.chars;
+
+ luc = lu_start(NULL, 0, NULL, NULL, lu_prompt_console_quiet, NULL, &error);
+ if (!luc)
+ {
+ fprintf(stderr, "Error initializing: %s\n", lu_strerror(error));
+ exit(1);
+ }
+
+ lue = lu_ent_new();
+ if (!lu_group_lookup_name(luc, name, lue, &error))
+ { /* Group not found */
+ snprintf(errmsg, 256, "Non existing group: %s\n", name);
+ lu_ent_free(lue);
+ lu_end(luc);
+ CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, errmsg);
+ }
+
+ if (!lu_group_delete(luc, lue, &error))
+ {
+ snprintf(errmsg, 256, "Group %s could not be deleted: %s\n", name,
+ lu_strerror(error));
+ lu_ent_free(lue);
+ lu_end(luc);
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ }
+
+ lu_ent_free(lue);
+ lu_end(luc);
+
+ CMReturn(CMPI_RC_OK);
}
static CMPIStatus LMI_GroupExecQuery(