[iwhd] t/basic: add a query-test
by Jim Meyering
commit eee3e581ae580cc0fa1d9eaaafb9e8efadd51d00
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Jun 10 17:03:50 2011 +0200
t/basic: add a query-test
t/basic | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/t/basic b/t/basic
index 800c08d..ccfc54d 100644
--- a/t/basic
+++ b/t/basic
@@ -164,6 +164,17 @@ tr -s '\t \n' ' ' < q.xml > k && mv k q.xml
printf '[ { "bucket": "b99", "key": "my_file" } ] ' > exp.xml
compare q.xml exp.xml || fail=1
+# Run a query that produces nontrivial output by creating many
+# objects that match:
+for i in $(seq 500); do
+ obj=http://localhost:$port/b99/99999999999999999999-$i
+ echo x | curl -T - $obj
+ printf mock | curl -T - $obj/target
+done
+curl -H 'Accept: */json' -d '$target=="mock"' \
+ http://localhost:$port/b99/_query > q
+cat q
+
# Before 2011-02-07, this would cause iwhd to hang.
printf hang | curl -T - http://localhost:$port/no-such/fff
12 years, 11 months
[iwhd] Indent OVF
by Pete Zaitcev
commit e71e87e22ad4f01884d7dc32212df4a69fb14358
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Jun 8 20:40:36 2011 -0600
Indent OVF
This does exactly nothing, but helps debugging a lot. Before, I spent
time indenting the dumped files by hand. Really not worth saving a few
whitespaces.
dc-rhev-image.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 39ffacf..39a5225 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -991,6 +991,7 @@ static void spitovf(struct config *cfg, struct stor_dom *sd,
tmpovf);
exit(EXIT_FAILURE);
}
+ xmlTextWriterSetIndent(writer, 1);
rc = xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
if (rc < 0) {
12 years, 11 months
[iwhd] Change "back slash" to "backslash".
by Pete Zaitcev
commit 60508cd056fd99dc4582a0e1b076bd0ffad37d48
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Thu Jun 9 10:41:49 2011 -0600
Change "back slash" to "backslash".
NEWS | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 80bdc69..9ab25a3 100644
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,7 @@ iwhd NEWS -*- outline -*-
"start" function also fails.
It is now possible to use Windows.Domain\Administrator as a user name
- in a cloud with Windows credentials. The back slash was causing an
+ in a cloud with Windows credentials. The backslash was causing an
internal error due to improper JSON escaping.
12 years, 11 months
[iwhd] build: fix "make rpm" to work more reliably
by Jim Meyering
commit 40ead3a858ba1e03280038e7a55afc8f43f045b8
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Jun 8 18:18:39 2011 +0200
build: fix "make rpm" to work more reliably
* Makefile.am (rpm): Set LDFLAGS to add --build-id.
Otherwise, "make rpm" fails with a "No build ID note found in ..."
diagnostic for each of the dc-*-image programs.
Also make _version, to be sure to increment version number.
Makefile.am | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1b6b5f8..dd80d97 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,8 +79,11 @@ iwhd.spec: iwhd.spec.in Makefile
# like "0.0.273-1621" that contain a "-". Repack the tarball
# to one with "." substituted for any - in the version string.
.PHONY: rpm
-rpm: dist iwhd.spec
- chmod 644 $(distdir).tar.gz
+rpm:
+ $(MAKE) clean
+ $(MAKE) _version
+ umask 022; $(MAKE) LDFLAGS='-Wl,--build-id' dist
+ umask 022; export LDFLAGS='-Wl,--build-id'; \
case $(VERSION) in \
*-*) \
v=$$(echo $(VERSION)|tr - .); \
12 years, 11 months
[iwhd] maint: add dc-vmware-image to the spec file
by Jim Meyering
commit 9ca9fee87753b858bfdcda2b363c265972be090c
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Jun 8 16:59:55 2011 +0200
maint: add dc-vmware-image to the spec file
* iwhd.spec.in (%files): Add %{_bindir}/dc-vmware-image.
iwhd.spec.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/iwhd.spec.in b/iwhd.spec.in
index 660e3a0..5d39ffc 100644
--- a/iwhd.spec.in
+++ b/iwhd.spec.in
@@ -60,6 +60,7 @@ rm -rf %{buildroot}
%doc AUTHORS COPYING README NEWS
%{_bindir}/iwhd
%{_bindir}/dc-rhev-image
+%{_bindir}/dc-vmware-image
%{_mandir}/man8/iwhd.8*
%{_sysconfdir}/rc.d/init.d/iwhd
%{_sysconfdir}/iwhd/conf.js
12 years, 11 months
[iwhd] Escape the generated JSON
by Pete Zaitcev
commit 74c902ecc2b518ce666c3649ec8c730a9a0c301b
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Jun 8 20:36:03 2011 -0600
Escape the generated JSON
I forgot to escape JSON that is generated to be an argument for back-end.
But the password string can contain just about anything, for example.
This was found by using Windows username in form of DOMAIN\USER, when
it caused an "invalid escape" condition in JSON parser.
NEWS | 4 +++
backend.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 77 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 110500b..80bdc69 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ iwhd NEWS -*- outline -*-
mongod failed to start in time. Now, when mongod fails to start, that
"start" function also fails.
+ It is now possible to use Windows.Domain\Administrator as a user name
+ in a cloud with Windows credentials. The back slash was causing an
+ internal error due to improper JSON escaping.
+
* Noteworthy changes in release 0.95 (2011-05-17) [stable]
diff --git a/backend.c b/backend.c
index 251d730..fb1c525 100644
--- a/backend.c
+++ b/backend.c
@@ -1344,6 +1344,76 @@ fs_bcreate (const provider_t *prov, const char *bucket)
return MHD_HTTP_OK;
}
+static char *json_escape(const char *str)
+{
+ char *escaped_str, *p;
+ int cnt;
+ int i;
+
+ cnt = 0;
+ for (i = 0; str[i]; i++) {
+ if (str[i] == '\\' || str[i] == '"')
+ cnt++;
+ cnt++;
+ }
+ escaped_str = malloc(cnt+1);
+ if (!escaped_str)
+ return NULL;
+ p = escaped_str;
+ for (i = 0; str[i]; i++) {
+ if (str[i] == '\\' || str[i] == '"')
+ *p++ = '\\';
+ *p++ = str[i];
+ }
+ *p++ = '\0';
+ return escaped_str;
+}
+
+static char *
+fs_rhevm_genconf(const char *bucket, const char *key, const char *api_url,
+ const char *api_user, const char *api_secret,
+ const char *nfs_host, const char *nfs_path, const char *nfs_dir)
+{
+ int rc;
+ char *b, *k, *url, *user, *pass, *nhost, *npath, *ndir;
+ char *ret = NULL;
+
+ b = json_escape(bucket);
+ k = json_escape(key);
+ url = json_escape(api_url);
+ user = json_escape(api_user);
+ pass = json_escape(api_secret);
+ nhost = json_escape(nfs_host);
+ npath = json_escape(nfs_path);
+ ndir = json_escape(nfs_dir);
+ if (!b || !k || !url || !user || !pass || !nhost || !npath || !ndir)
+ goto err;
+
+ rc = asprintf(&ret,
+ "{\n"
+ " \"image\" : \"%s/%s\",\n"
+ " \"apiurl\" : \"%s\",\n"
+ " \"apiuser\" : \"%s\",\n"
+ " \"apipass\" : \"%s\",\n"
+ " \"nfshost\" : \"%s\",\n"
+ " \"nfspath\" : \"%s\",\n"
+ " \"nfsdir\" : \"%s\"\n"
+ "}\n",
+ b, k, url, user, pass, nhost, npath, ndir);
+ if (rc < 0)
+ ret = NULL; /* for undefined behaviour in asprintf() */
+ err:
+ free(ndir);
+ free(npath);
+ free(nhost);
+ free(pass);
+ free(user);
+ free(url);
+ free(k);
+ free(b);
+ return ret;
+}
+
static int
fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
Hash_table *args)
@@ -1367,7 +1437,6 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
char *s;
char ami_id_buf[64];
regmatch_t match[2];
- int rc;
strcpy(ami_id_buf, "none");
@@ -1449,21 +1518,10 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
ret = MHD_HTTP_INTERNAL_SERVER_ERROR;
- rc = asprintf(&conf_text,
- "{\n"
- " \"image\" : \"%s/%s\",\n"
- " \"apiurl\" : \"%s\",\n"
- " \"apiuser\" : \"%s\",\n"
- " \"apipass\" : \"%s\",\n"
- " \"nfshost\" : \"%s\",\n"
- " \"nfspath\" : \"%s\",\n"
- " \"nfsdir\" : \"%s\"\n"
- "}\n",
- ms->bucket, ms->key,
+ conf_text = fs_rhevm_genconf(ms->bucket, ms->key,
api_url, api_user, api_secret,
- nfs_host, nfs_path, nfs_dir
- );
- if (rc < 0) {
+ nfs_host, nfs_path, nfs_dir);
+ if (!conf_text) {
error (0, 0, _("no core"));
goto cleanup;
}
12 years, 11 months
[iwhd] Syntax sugar in dc-rhev-image.c
by Pete Zaitcev
commit b81aef160e730e82a6b582f422a0445969657a6b
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Jun 8 20:39:20 2011 -0600
Syntax sugar in dc-rhev-image.c
Old garbage is not always benign. There was a forgotten comment that
described now-deleted code.
dc-rhev-image.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index a1a4999..39ffacf 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -499,7 +499,6 @@ static struct stor_dom *apistordom_1(struct config *cfg, xmlChar *uuidsd)
}
sd->address = cfg->nfshost;
sd->path = cfg->nfspath;
-
return sd;
}
@@ -518,7 +517,6 @@ static struct stor_dom *apistordom(struct config *cfg,
CURLcode rcc;
int rc;
- // So for now we ignore the pathsd and use a query instead.
rc = asprintf(&url, "%s%s", connection->base, pathsd);
if (rc < 0)
goto err_alloc;
@@ -709,7 +707,6 @@ static char *apipool(struct config *cfg, struct api_conn *connection,
xmlDocPtr doc;
xmlNode *etroot;
xmlNode *etdc, *etlink;
- // xmlNode *ettype, *etstor, *ettext;
xmlChar *uuiddc;
xmlChar *rel, *href;
CURLcode rcc;
12 years, 11 months
[iwhd] Suppress the INFO
by Pete Zaitcev
commit 31fe683d4a89cfbc68bd7c0db9b64bfdcf47e4fc
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Jun 8 20:37:33 2011 -0600
Suppress the INFO
I managed to hoist myself on my own petard by forgetting that INFO messages
are not fatal. We should drop warnings from back-ends completely.
Also, refactor a bit with more descriptive function name. I myself was
unable to figure out what this code did at first. This ought to be more
explicit.
dc-rhev-image.c | 41 +++++++++++++++++++++++------------------
1 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 84db216..a1a4999 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -434,23 +434,21 @@ static xmlNode *xmlGetChild(xmlNode *node, const char *name)
return NULL;
}
-static struct stor_dom *apistordom_1(struct config *cfg, xmlChar *uuidsd,
- xmlNode *etstor)
+static bool check_stor(struct config *cfg, xmlNode *etstor)
{
xmlNode *ettext, *etaddr, *etpath;
- struct stor_dom *sd;
etaddr = xmlGetChild(etstor, "address");
if (!etaddr) {
fprintf(stderr,
"WARNIING NFS storage domain without address\n");
- return NULL;
+ return false;
}
etpath = xmlGetChild(etstor, "path");
if (!etpath) {
fprintf(stderr,
"WARNIING NFS storage domain without path\n");
- return NULL;
+ return false;
}
/*
@@ -460,6 +458,7 @@ static struct stor_dom *apistordom_1(struct config *cfg, xmlChar *uuidsd,
if (!ettext || ettext->type!=XML_TEXT_NODE || !ettext->content)
return NULL;
if (strcmp((char *)ettext->content, cfg->nfshost) != 0) {
+#if 0 /* XXX really find a better way */
/*
* Why even print this message? Because we want to do at least
* something if configuration is ham-fisted. However, this
@@ -468,22 +467,25 @@ static struct stor_dom *apistordom_1(struct config *cfg, xmlChar *uuidsd,
*/
fprintf(stderr, "INFO Host `%s' does not match cfg `%s'\n",
(char *)ettext->content, cfg->nfshost);
- return NULL;
+#endif
+ return false;
}
- ettext = etpath->children; /* mysterious indirection */
+ ettext = etpath->children;
if (!ettext || ettext->type!=XML_TEXT_NODE || !ettext->content)
- return NULL;
+ return false;
if (strcmp((char *)ettext->content, cfg->nfspath) != 0) {
- /*
- * Why even print this message? Because we want to do at least
- * something if configuration is ham-fisted. However, this
- * will pop up for every server that has 2 NFS storage domains.
- * For now we cop-out by tagging it "INFO".
- */
- fprintf(stderr, "INFO Host `%s' does not match cfg `%s'\n",
- (char *)ettext->content, cfg->nfshost);
- return NULL;
+#if 0 /* XXX really find a better way */
+ fprintf(stderr, "INFO Path `%s' does not match cfg `%s'\n",
+ (char *)ettext->content, cfg->nfspath);
+#endif
+ return false;
}
+ return true;
+}
+
+static struct stor_dom *apistordom_1(struct config *cfg, xmlChar *uuidsd)
+{
+ struct stor_dom *sd;
if (!(sd = malloc(sizeof(struct stor_dom)))) {
fprintf(stderr, "ERROR No core\n");
@@ -582,13 +584,16 @@ static struct stor_dom *apistordom(struct config *cfg,
if (c_strcasecmp((char *)ettext->content, "NFS") != 0)
continue;
+ if (!check_stor(cfg, etstor))
+ continue;
+
uuidsd = xmlGetProp(et, (xmlChar *)"id");
if (!uuidsd) {
fprintf(stderr,
"WARNING NFS storage domain without UUID\n");
continue;
}
- sd = apistordom_1(cfg, uuidsd, etstor);
+ sd = apistordom_1(cfg, uuidsd);
xmlFree(uuidsd);
if (sd)
break;
12 years, 11 months
[iwhd] build: update gnulib submodule to latest
by Jim Meyering
commit 659943b3d04d8d025f64d34b3adf42320410dc71
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Jun 7 10:45:38 2011 +0200
build: update gnulib submodule to latest
gnulib | 2 +-
gnulib-tests/.gitignore | 1 +
lib/.gitignore | 2 ++
3 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gnulib b/gnulib
index 4104cd4..79aac72 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 4104cd4f7746f8ba7e75e3292c78c2c528b0c88a
+Subproject commit 79aac72351f56c4998c4cd176a7fd30a1598972b
diff --git a/gnulib-tests/.gitignore b/gnulib-tests/.gitignore
index ead8ced..d3de313 100644
--- a/gnulib-tests/.gitignore
+++ b/gnulib-tests/.gitignore
@@ -111,6 +111,7 @@
/test-iconv-h.c
/test-iconv.c
/test-ignore-value.c
+/test-intprops.c
/test-inttostr.c
/test-inttypes.c
/test-iswblank.c
diff --git a/lib/.gitignore b/lib/.gitignore
index aef2b8b..d5a1680 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -147,6 +147,8 @@
/str-kmp.h
/str-two-way.h
/streq.h
+/strerror-override.c
+/strerror-override.h
/strerror.c
/striconv.c
/striconv.h
12 years, 11 months
[iwhd] tests: don't generate 20MB of log output for t/exercise
by Jim Meyering
commit 8af978c81ff8cafb1e0de1aa48668a93c1ecdb83
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Jun 6 20:08:59 2011 +0200
tests: don't generate 20MB of log output for t/exercise
* t/exercise (iwhd_pid): Turn off iwhd's -v (--verbose) option,
thus avoiding ~20MB of log output.
Use curl's -s option to further remove useless log output.
Also, create many (thousands of) buckets in parallel,
not just the 40 we'll use in the body of the test. This uses
GNU parallel, based on a suggestion from Ole Tange.
t/exercise | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/t/exercise b/t/exercise
index ca57145..0b9f420 100755
--- a/t/exercise
+++ b/t/exercise
@@ -28,7 +28,7 @@ printf '[{"path": "FS", "type": "fs", "name": "primary"}]\n' \
> iwhd.cfg || fail=1
MALLOC_PERTURB_=31 MALLOC_CHECK_=3 \
- iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
+ iwhd -p $port -c iwhd.cfg -d localhost:$m_port &
iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
@@ -49,12 +49,11 @@ create_many()
local n_procs=$(nproc || echo 2)
n_procs=$(expr $n_procs \* 3 / 2)
- for i in $(seq $nb); do
- # Create a bucket.
- local b=http://localhost:$port/b-$i
- curl_w -XPUT $b > http-code || fail=1
- test "$(cat http-code)" = 201 || fail=1
- done
+ # Create many buckets in parallel, though we'll use only
+ # the first $nb of them in the following loop.
+ seq 2000 | parallel -j 200% curl -s --write-out '%{http_code}' -XPUT \
+ http://localhost:$port/b-{} > http-code || fail=1
+ grep -q 201 http-code || fail=1
seq 20000 > data
for i in $(seq $nb); do
@@ -62,7 +61,7 @@ create_many()
for j in $(seq --format=%04g 50); do
# Create an object in that bucket.
local obj=$b/9756a40c-7668-11e0-$j-0015c5f4d7e4
- echo "curl -S -T - $obj < data"
+ echo "curl -s -S -T - $obj < data"
done
done |parallel --halt-on-error=2 -j $n_procs || fail=1
}
12 years, 11 months