mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-25 21:57:45 +03:00
Update interactive tests for lvm2app lvseg and pvseg apis.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com> Reviewed-by: Petr Rockai <prockai@redhat.com>
This commit is contained in:
parent
55429cde3c
commit
f6531a5f00
124
test/api/test.c
124
test/api/test.c
@ -67,8 +67,12 @@ static void _show_help(void)
|
|||||||
"List the uuids of the VGs that exist in the system\n");
|
"List the uuids of the VGs that exist in the system\n");
|
||||||
printf("'vg_list_pvs vgname': "
|
printf("'vg_list_pvs vgname': "
|
||||||
"List the PVs that exist in VG vgname\n");
|
"List the PVs that exist in VG vgname\n");
|
||||||
|
printf("'pv_list_pvsegs pvname': "
|
||||||
|
"List the PV segments that exist in PV pvname\n");
|
||||||
printf("'vg_list_lvs vgname': "
|
printf("'vg_list_lvs vgname': "
|
||||||
"List the LVs that exist in VG vgname\n");
|
"List the LVs that exist in VG vgname\n");
|
||||||
|
printf("'lv_list_lvsegs vgname lvname': "
|
||||||
|
"List the LV segments that exist in LV vgname/lvname\n");
|
||||||
printf("'vgs_open': "
|
printf("'vgs_open': "
|
||||||
"List the VGs that are currently open\n");
|
"List the VGs that are currently open\n");
|
||||||
printf("'vgs': "
|
printf("'vgs': "
|
||||||
@ -189,17 +193,13 @@ static vg_t _lookup_vg_by_name(char **argv, int argc)
|
|||||||
return vg;
|
return vg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pv_t _lookup_pv_by_name(char **argv, int argc)
|
static pv_t _lookup_pv_by_name(const char *name)
|
||||||
{
|
{
|
||||||
pv_t pv;
|
pv_t pv;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (!(pv = dm_hash_lookup(_pvname_hash, name))) {
|
||||||
printf ("Please enter vg_name\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!(pv = dm_hash_lookup(_pvname_hash, argv[1]))) {
|
|
||||||
printf ("Can't find %s in open PVs - run vg_open first\n",
|
printf ("Can't find %s in open PVs - run vg_open first\n",
|
||||||
argv[1]);
|
name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return pv;
|
return pv;
|
||||||
@ -238,6 +238,7 @@ static void _add_device_to_pvname_hash(struct dm_list *pvs, const char *name)
|
|||||||
dm_hash_insert(_pvname_hash, name, pvl->pv);
|
dm_hash_insert(_pvname_hash, name, pvl->pv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _vg_reduce(char **argv, int argc, lvm_t libh)
|
static void _vg_reduce(char **argv, int argc, lvm_t libh)
|
||||||
{
|
{
|
||||||
vg_t vg;
|
vg_t vg;
|
||||||
@ -496,6 +497,40 @@ static void _pvs_in_vg(char **argv, int argc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _print_property_value(const char *name,
|
||||||
|
struct lvm_property_value v)
|
||||||
|
{
|
||||||
|
if (!v.is_valid)
|
||||||
|
printf("%s = INVALID\n", name);
|
||||||
|
else if (v.is_string)
|
||||||
|
printf("%s = %s\n", name, v.value.string);
|
||||||
|
else
|
||||||
|
printf("%s = %"PRIu64"\n", name, v.value.integer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _pvsegs_in_pv(char **argv, int argc)
|
||||||
|
{
|
||||||
|
struct dm_list *pvsegs;
|
||||||
|
struct lvm_pvseg_list *pvl;
|
||||||
|
pv_t pv;
|
||||||
|
|
||||||
|
if (!(pv = _lookup_pv_by_name(argv[1])))
|
||||||
|
return;
|
||||||
|
pvsegs = lvm_pv_list_pvsegs(pv);
|
||||||
|
if (!pvsegs || dm_list_empty(pvsegs)) {
|
||||||
|
printf("No PV segments in pv %s\n", argv[1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("PV segments in pv %s:\n", argv[1]);
|
||||||
|
dm_list_iterate_items(pvl, pvsegs) {
|
||||||
|
struct lvm_property_value v;
|
||||||
|
v = lvm_pvseg_get_property(pvl->pvseg, "pvseg_start");
|
||||||
|
_print_property_value("pvseg_start", v);
|
||||||
|
v = lvm_pvseg_get_property(pvl->pvseg, "pvseg_size");
|
||||||
|
_print_property_value("pvseg_size", v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _scan_vgs(lvm_t libh)
|
static void _scan_vgs(lvm_t libh)
|
||||||
{
|
{
|
||||||
lvm_scan(libh);
|
lvm_scan(libh);
|
||||||
@ -571,14 +606,6 @@ static void _vg_tag(char **argv, int argc, int add)
|
|||||||
add ? "adding":"removing", argv[2], argv[1]);
|
add ? "adding":"removing", argv[2], argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _print_property_value(struct lvm_property_value value)
|
|
||||||
{
|
|
||||||
if (value.is_string)
|
|
||||||
printf(", value = %s\n", value.value.string);
|
|
||||||
else
|
|
||||||
printf(", value = %"PRIu64"\n", value.value.integer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _pv_get_property(char **argv, int argc)
|
static void _pv_get_property(char **argv, int argc)
|
||||||
{
|
{
|
||||||
pv_t pv;
|
pv_t pv;
|
||||||
@ -588,20 +615,10 @@ static void _pv_get_property(char **argv, int argc)
|
|||||||
printf("Please enter pvname, field_id\n");
|
printf("Please enter pvname, field_id\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(pv = _lookup_pv_by_name(argv, argc)))
|
if (!(pv = _lookup_pv_by_name(argv[1])))
|
||||||
return;
|
return;
|
||||||
v = lvm_pv_get_property(pv, argv[2]);
|
v = lvm_pv_get_property(pv, argv[2]);
|
||||||
if (!v.is_valid)
|
_print_property_value(argv[2], v);
|
||||||
printf("Error ");
|
|
||||||
else
|
|
||||||
printf("Success ");
|
|
||||||
printf("obtaining value of property %s in PV %s",
|
|
||||||
argv[2], argv[1]);
|
|
||||||
if (!v.is_valid) {
|
|
||||||
printf("\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_print_property_value(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _vg_get_property(char **argv, int argc)
|
static void _vg_get_property(char **argv, int argc)
|
||||||
@ -616,17 +633,7 @@ static void _vg_get_property(char **argv, int argc)
|
|||||||
if (!(vg = _lookup_vg_by_name(argv, argc)))
|
if (!(vg = _lookup_vg_by_name(argv, argc)))
|
||||||
return;
|
return;
|
||||||
v = lvm_vg_get_property(vg, argv[2]);
|
v = lvm_vg_get_property(vg, argv[2]);
|
||||||
if (!v.is_valid)
|
_print_property_value(argv[2], v);
|
||||||
printf("Error ");
|
|
||||||
else
|
|
||||||
printf("Success ");
|
|
||||||
printf("obtaining value of property %s in VG %s",
|
|
||||||
argv[2], argv[1]);
|
|
||||||
if (!v.is_valid) {
|
|
||||||
printf("\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_print_property_value(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _lv_get_property(char **argv, int argc)
|
static void _lv_get_property(char **argv, int argc)
|
||||||
@ -641,17 +648,7 @@ static void _lv_get_property(char **argv, int argc)
|
|||||||
if (!(lv = _lookup_lv_by_name(argv[2])))
|
if (!(lv = _lookup_lv_by_name(argv[2])))
|
||||||
return;
|
return;
|
||||||
v = lvm_lv_get_property(lv, argv[3]);
|
v = lvm_lv_get_property(lv, argv[3]);
|
||||||
if (!v.is_valid)
|
_print_property_value(argv[3], v);
|
||||||
printf("Error ");
|
|
||||||
else
|
|
||||||
printf("Success ");
|
|
||||||
printf("obtaining value of property %s in LV %s",
|
|
||||||
argv[3], argv[2]);
|
|
||||||
if (!v.is_valid) {
|
|
||||||
printf("\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_print_property_value(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _vg_set_property(char **argv, int argc)
|
static void _vg_set_property(char **argv, int argc)
|
||||||
@ -774,6 +771,31 @@ static void _lvs_in_vg(char **argv, int argc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _lvsegs_in_lv(char **argv, int argc)
|
||||||
|
{
|
||||||
|
struct dm_list *lvsegs;
|
||||||
|
struct lvm_lvseg_list *lvl;
|
||||||
|
lv_t lv;
|
||||||
|
|
||||||
|
if (!(lv = _lookup_lv_by_name(argv[2])))
|
||||||
|
return;
|
||||||
|
lvsegs = lvm_lv_list_lvsegs(lv);
|
||||||
|
if (!lvsegs || dm_list_empty(lvsegs)) {
|
||||||
|
printf("No LV segments in lv %s\n", lvm_lv_get_name(lv));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("LV segments in lv %s:\n", lvm_lv_get_name(lv));
|
||||||
|
dm_list_iterate_items(lvl, lvsegs) {
|
||||||
|
struct lvm_property_value v;
|
||||||
|
v = lvm_lvseg_get_property(lvl->lvseg, "segtype");
|
||||||
|
_print_property_value("segtype", v);
|
||||||
|
v = lvm_lvseg_get_property(lvl->lvseg, "seg_start_pe");
|
||||||
|
_print_property_value("seg_start_pe", v);
|
||||||
|
v = lvm_lvseg_get_property(lvl->lvseg, "seg_size");
|
||||||
|
_print_property_value("seg_size", v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _lv_deactivate(char **argv, int argc)
|
static void _lv_deactivate(char **argv, int argc)
|
||||||
{
|
{
|
||||||
lv_t lv;
|
lv_t lv;
|
||||||
@ -918,8 +940,12 @@ static int lvmapi_test_shell(lvm_t libh)
|
|||||||
_list_open_vgs();
|
_list_open_vgs();
|
||||||
} else if (!strcmp(argv[0], "vg_list_pvs")) {
|
} else if (!strcmp(argv[0], "vg_list_pvs")) {
|
||||||
_pvs_in_vg(argv, argc);
|
_pvs_in_vg(argv, argc);
|
||||||
|
} else if (!strcmp(argv[0], "pv_list_pvsegs")) {
|
||||||
|
_pvsegs_in_pv(argv, argc);
|
||||||
} else if (!strcmp(argv[0], "vg_list_lvs")) {
|
} else if (!strcmp(argv[0], "vg_list_lvs")) {
|
||||||
_lvs_in_vg(argv, argc);
|
_lvs_in_vg(argv, argc);
|
||||||
|
} else if (!strcmp(argv[0], "lv_list_lvsegs")) {
|
||||||
|
_lvsegs_in_lv(argv, argc);
|
||||||
} else if (!strcmp(argv[0], "list_vg_names")) {
|
} else if (!strcmp(argv[0], "list_vg_names")) {
|
||||||
_list_vg_names(libh);
|
_list_vg_names(libh);
|
||||||
} else if (!strcmp(argv[0], "list_vg_ids")) {
|
} else if (!strcmp(argv[0], "list_vg_ids")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user