mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Update interactive unit test for liblvm - add vg_write, general cleanup.
This commit is contained in:
parent
9ac1af7160
commit
e3f0940aae
@ -225,6 +225,15 @@ static void _vg_reduce(char **argv, int argc, lvm_t libh)
|
|||||||
_remove_device_from_pvname_hash(pvs, argv[2]);
|
_remove_device_from_pvname_hash(pvs, argv[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print "Error" or "Success" depending on lvm status */
|
||||||
|
static int _lvm_status_to_pass_fail(int rc)
|
||||||
|
{
|
||||||
|
if (rc)
|
||||||
|
printf("Error ");
|
||||||
|
else
|
||||||
|
printf("Success ");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
static void _config_override(char **argv, int argc, lvm_t libh)
|
static void _config_override(char **argv, int argc, lvm_t libh)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@ -236,10 +245,7 @@ static void _config_override(char **argv, int argc, lvm_t libh)
|
|||||||
}
|
}
|
||||||
snprintf(tmp, 63, "devices{filter=[\"a|%s|\", \"r|.*|\"]}", argv[1]);
|
snprintf(tmp, 63, "devices{filter=[\"a|%s|\", \"r|.*|\"]}", argv[1]);
|
||||||
rc = lvm_config_override(libh, tmp);
|
rc = lvm_config_override(libh, tmp);
|
||||||
if (rc)
|
_lvm_status_to_pass_fail(rc);
|
||||||
printf("Error ");
|
|
||||||
else
|
|
||||||
printf("Success ");
|
|
||||||
printf("overriding LVM configuration\n");
|
printf("overriding LVM configuration\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,10 +253,7 @@ static void _config_reload(char **argv, int argc, lvm_t libh)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
rc = lvm_config_reload(libh);
|
rc = lvm_config_reload(libh);
|
||||||
if (rc)
|
_lvm_status_to_pass_fail(rc);
|
||||||
printf("Error ");
|
|
||||||
else
|
|
||||||
printf("Success ");
|
|
||||||
printf("reloading LVM configuration\n");
|
printf("reloading LVM configuration\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,6 +324,37 @@ static void _vg_open(char **argv, int argc, lvm_t libh)
|
|||||||
if (pvs && !dm_list_empty(pvs))
|
if (pvs && !dm_list_empty(pvs))
|
||||||
_add_pvs_to_pvname_hash(pvs);
|
_add_pvs_to_pvname_hash(pvs);
|
||||||
}
|
}
|
||||||
|
/* Lookup the vg and remove it from the vgname and vgid hashes */
|
||||||
|
static vg_t *_lookup_and_remove_vg(const char *vgname)
|
||||||
|
{
|
||||||
|
vg_t *vg=NULL;
|
||||||
|
|
||||||
|
while((vg = dm_hash_lookup(_vgname_hash, vgname))) {
|
||||||
|
dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
|
||||||
|
dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
|
||||||
|
}
|
||||||
|
while(vg && (vg = dm_hash_lookup(_vgid_hash, vgname))) {
|
||||||
|
dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
|
||||||
|
dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
|
||||||
|
}
|
||||||
|
return vg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _vg_write(char **argv, int argc)
|
||||||
|
{
|
||||||
|
vg_t *vg;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf ("Please enter vg_name\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vg = _lookup_vg_by_name(argv, argc);
|
||||||
|
if (vg)
|
||||||
|
rc = lvm_vg_write(vg);
|
||||||
|
_lvm_status_to_pass_fail(rc);
|
||||||
|
printf("writing VG %s\n", lvm_vg_get_name(vg));
|
||||||
|
}
|
||||||
|
|
||||||
static void _vg_close(char **argv, int argc)
|
static void _vg_close(char **argv, int argc)
|
||||||
{
|
{
|
||||||
@ -330,16 +364,9 @@ static void _vg_close(char **argv, int argc)
|
|||||||
printf ("Please enter vg_name\n");
|
printf ("Please enter vg_name\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while((vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
|
vg = _lookup_and_remove_vg(argv[1]);
|
||||||
dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
|
if (vg)
|
||||||
dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
|
|
||||||
lvm_vg_close(vg);
|
lvm_vg_close(vg);
|
||||||
}
|
|
||||||
while((vg = dm_hash_lookup(_vgid_hash, argv[1]))) {
|
|
||||||
dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
|
|
||||||
dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
|
|
||||||
lvm_vg_close(vg);
|
|
||||||
}
|
|
||||||
/* FIXME: remove LVs from lvname_hash */
|
/* FIXME: remove LVs from lvname_hash */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,6 +466,7 @@ static void _lvs_in_vg(char **argv, int argc)
|
|||||||
static void _lv_deactivate(char **argv, int argc)
|
static void _lv_deactivate(char **argv, int argc)
|
||||||
{
|
{
|
||||||
lv_t *lv;
|
lv_t *lv;
|
||||||
|
int rc=0;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf("Please enter vgname, lvname\n");
|
printf("Please enter vgname, lvname\n");
|
||||||
@ -446,17 +474,15 @@ static void _lv_deactivate(char **argv, int argc)
|
|||||||
}
|
}
|
||||||
if (!(lv = _lookup_lv_by_name(argv[2])))
|
if (!(lv = _lookup_lv_by_name(argv[2])))
|
||||||
return;
|
return;
|
||||||
if (lvm_lv_deactivate(lv))
|
rc = lvm_lv_deactivate(lv);
|
||||||
printf("Error ");
|
_lvm_status_to_pass_fail(rc);
|
||||||
else {
|
|
||||||
printf("Success ");
|
|
||||||
}
|
|
||||||
printf("De-activating LV %s in VG %s\n",
|
printf("De-activating LV %s in VG %s\n",
|
||||||
argv[2], argv[1]);
|
argv[2], argv[1]);
|
||||||
}
|
}
|
||||||
static void _lv_activate(char **argv, int argc)
|
static void _lv_activate(char **argv, int argc)
|
||||||
{
|
{
|
||||||
lv_t *lv;
|
lv_t *lv;
|
||||||
|
int rc=0;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf("Please enter vgname, lvname\n");
|
printf("Please enter vgname, lvname\n");
|
||||||
@ -464,11 +490,8 @@ static void _lv_activate(char **argv, int argc)
|
|||||||
}
|
}
|
||||||
if (!(lv = _lookup_lv_by_name(argv[2])))
|
if (!(lv = _lookup_lv_by_name(argv[2])))
|
||||||
return;
|
return;
|
||||||
if (lvm_lv_activate(lv))
|
rc = lvm_lv_activate(lv);
|
||||||
printf("Error ");
|
_lvm_status_to_pass_fail(rc);
|
||||||
else {
|
|
||||||
printf("Success ");
|
|
||||||
}
|
|
||||||
printf("activating LV %s in VG %s\n",
|
printf("activating LV %s in VG %s\n",
|
||||||
argv[2], argv[1]);
|
argv[2], argv[1]);
|
||||||
}
|
}
|
||||||
@ -563,6 +586,8 @@ static int lvmapi_test_shell(lvm_t libh)
|
|||||||
_vg_extend(argv, argc, libh);
|
_vg_extend(argv, argc, libh);
|
||||||
} else if (!strcmp(argv[0], "vg_reduce")) {
|
} else if (!strcmp(argv[0], "vg_reduce")) {
|
||||||
_vg_reduce(argv, argc, libh);
|
_vg_reduce(argv, argc, libh);
|
||||||
|
} else if (!strcmp(argv[0], "vg_write")) {
|
||||||
|
_vg_write(argv, argc);
|
||||||
} else if (!strcmp(argv[0], "vg_open")) {
|
} else if (!strcmp(argv[0], "vg_open")) {
|
||||||
_vg_open(argv, argc, libh);
|
_vg_open(argv, argc, libh);
|
||||||
} else if (!strcmp(argv[0], "vg_close")) {
|
} else if (!strcmp(argv[0], "vg_close")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user