public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: wysochanski@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2/test/api test.c
Date: Mon, 27 Jul 2009 17:45:00 -0000	[thread overview]
Message-ID: <20090727174523.23110.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-27 17:45:22

Modified files:
	test/api       : test.c 

Log message:
	Update test/api/test.c to include lvm_vg_reduce and lvm_vg_extend.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/test.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17

--- LVM2/test/api/test.c	2009/07/26 20:59:02	1.16
+++ LVM2/test/api/test.c	2009/07/27 17:45:21	1.17
@@ -72,6 +72,10 @@
 	       "List the VGs that are currently open\n");
 	printf("'vgs': "
 	       "List all VGs known to the system\n");
+	printf("'vg_extend vgname device: "
+	       "Issue a lvm_vg_extend() API call on VG 'vgname'\n");
+	printf("'vg_reduce vgname device: "
+	       "Issue a lvm_vg_reduce() API call on VG 'vgname'\n");
 	printf("'vg_open vgname ['r' | 'w']': "
 	       "Issue a lvm_vg_open() API call on VG 'vgname'\n");
 	printf("'vg_close vgname': "
@@ -172,6 +176,80 @@
 	}
 }
 
+static void _remove_device_from_pvname_hash(struct dm_list *pvs, const char *name)
+{
+	struct lvm_pv_list *pvl;
+	dm_list_iterate_items(pvl, pvs) {
+		if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
+			dm_hash_remove(_pvname_hash, name);
+	}
+}
+static void _add_device_to_pvname_hash(struct dm_list *pvs, const char *name)
+{
+	struct lvm_pv_list *pvl;
+	dm_list_iterate_items(pvl, pvs) {
+		if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
+			dm_hash_insert(_pvname_hash, name, pvl->pv);
+	}
+}
+static void _vg_reduce(char **argv, int argc, lvm_t libh)
+{
+	vg_t *vg;
+	struct dm_list *pvs;
+
+	if (argc < 2) {
+		printf ("Please enter vg_name\n");
+		return;
+	}
+	if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
+	    !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+		printf ("VG not open\n");
+		return;
+	}
+	if (lvm_vg_reduce(vg, argv[2])) {
+		printf("Error reducing %s by %s\n", argv[1], argv[2]);
+		return;
+	}
+
+	printf("Success reducing vg %s by %s\n", argv[1], argv[2]);
+
+	/*
+	 * Add the device into the hashes for lookups
+	 */
+	pvs = lvm_vg_list_pvs(vg);
+	if (pvs && !dm_list_empty(pvs))
+		_remove_device_from_pvname_hash(pvs, argv[2]);
+}
+
+static void _vg_extend(char **argv, int argc, lvm_t libh)
+{
+	vg_t *vg;
+	struct dm_list *pvs;
+
+	if (argc < 2) {
+		printf ("Please enter vg_name\n");
+		return;
+	}
+	if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
+	    !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+		printf ("VG not open\n");
+		return;
+	}
+	if (lvm_vg_extend(vg, argv[2])) {
+		printf("Error extending %s with %s\n", argv[1], argv[2]);
+		return;
+	}
+
+	printf("Success extending vg %s with %s\n", argv[1], argv[2]);
+
+	/*
+	 * Add the device into the hashes for lookups
+	 */
+	pvs = lvm_vg_list_pvs(vg);
+	if (pvs && !dm_list_empty(pvs))
+		_add_device_to_pvname_hash(pvs, argv[2]);
+}
+
 static void _vg_open(char **argv, int argc, lvm_t libh)
 {
 	vg_t *vg;
@@ -443,6 +521,10 @@
 			break;
 		} else if (!strcmp(argv[0], "?") || !strcmp(argv[0], "help")) {
 			_show_help();
+		} else if (!strcmp(argv[0], "vg_extend")) {
+			_vg_extend(argv, argc, libh);
+		} else if (!strcmp(argv[0], "vg_reduce")) {
+			_vg_reduce(argv, argc, libh);
 		} else if (!strcmp(argv[0], "vg_open")) {
 			_vg_open(argv, argc, libh);
 		} else if (!strcmp(argv[0], "vg_close")) {


             reply	other threads:[~2009-07-27 17:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27 17:45 wysochanski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-03-01 23:29 zkabelac
2011-03-01 23:18 zkabelac
2010-11-25 14:35 mornfall
2010-11-17 20:13 mornfall
2010-11-17 19:17 mornfall
2010-10-25 14:09 wysochanski
2010-05-19 11:53 wysochanski
2010-02-24 18:16 wysochanski
2009-08-07 21:22 wysochanski
2009-07-28 14:12 wysochanski
2009-07-28 13:49 wysochanski
2009-07-27 21:02 wysochanski
2009-07-26 20:59 wysochanski
2009-07-26 20:58 wysochanski
2009-07-26 14:37 wysochanski
2009-07-26 13:08 wysochanski
2009-07-26 13:07 wysochanski
2009-07-26  2:35 wysochanski
2009-07-26  2:35 wysochanski
2009-07-24 12:51 wysochanski
2009-07-24  4:15 wysochanski
2009-07-23 23:40 wysochanski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090727174523.23110.qmail@sourceware.org \
    --to=wysochanski@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).