commit ed461d0da64d3e3c82c9c9ca5c867a3ec3a991c4
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Thu May 12 17:41:26 2011 -0600
Support registration in RHEV-M 2.2.
The support of RHEV-M was initially developed with RHEV 3 im mind.
However, RHEV 3 is not yet available, and the version in field is
RHEV 2.2. Fortunately, these almost perfectly compatible. Only the
following small adjustments were required:
- Cancel the workaround for bz#670397, because it used hardcoded
base API. The base differs in 2.2.
- Make sure that we transmit data over SSL (albeit in an insecure
way for now). The 2.2 only accepts SSL connections by default.
- Make some comparisons case-insensitive.
Also, we updated the documentation somewhat.
bootstrap.conf | 1 +
dc-rhev-image.c | 51 ++++++++++++++++++++++++++++++++++---------------
doc/registrations.md | 7 ++++++
3 files changed, 43 insertions(+), 16 deletions(-)
---
diff --git a/bootstrap.conf b/bootstrap.conf
index a903da1..ac139fc 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -26,6 +26,7 @@ gnulib_modules='
announce-gen
base64
c-ctype
+c-strcase
calloc-posix
close
closeout
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index b9c3479..1488468 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
@@ -50,6 +51,7 @@
#include "progname.h"
#include "dirname.h"
#include "xalloc.h"
+#include "c-strcase.h"
/*
* Note that we almost never prefix with TAG due to compatibility with EC2.
@@ -452,7 +454,7 @@ static struct stor_dom *apistordom_1(struct config *cfg, xmlChar
*uuidsd,
}
/*
- * XXX canonicalize host in case of e.g. raw IPv4/IPv6 address.
+ * FIXME canonicalize host in case of e.g. raw IPv4/IPv6 address.
*/
ettext = etaddr->children; /* mysterious indirection */
if (!ettext || ettext->type!=XML_TEXT_NODE || !ettext->content)
@@ -514,10 +516,8 @@ static struct stor_dom *apistordom(struct config *cfg,
CURLcode rcc;
int rc;
- // XXX GET /rhevm-api/storagedomains/ crashes server, see bz#670397
// So for now we ignore the pathsd and use a query instead.
- // rc = asprintf(&url, "%s%s", connection->base, pathsd);
- rc = asprintf(&url, "%s%s", connection->base,
"/rhevm-api/storagedomains/?search=type%20%21%3D%20fcp");
+ rc = asprintf(&url, "%s%s", connection->base, pathsd);
if (rc < 0)
goto err_alloc;
@@ -566,7 +566,7 @@ static struct stor_dom *apistordom(struct config *cfg,
ettext = ettype->children; /* mysterious indirection */
if (!ettext || ettext->type!=XML_TEXT_NODE || !ettext->content)
continue;
- if (strcmp((char *)ettext->content, "EXPORT") != 0)
+ if (c_strcasecmp((char *)ettext->content, "EXPORT") != 0)
continue;
etstor = xmlGetChild(et, "storage");
@@ -579,7 +579,7 @@ static struct stor_dom *apistordom(struct config *cfg,
ettext = ettype->children; /* mysterious indirection */
if (!ettext || ettext->type!=XML_TEXT_NODE || !ettext->content)
continue;
- if (strcmp((char *)ettext->content, "NFS") != 0)
+ if (c_strcasecmp((char *)ettext->content, "NFS") != 0)
continue;
uuidsd = xmlGetProp(et, (xmlChar *)"id");
@@ -595,8 +595,9 @@ static struct stor_dom *apistordom(struct config *cfg,
}
if (!sd) {
- fprintf(stderr, "ERROR NFS storage domain for `%s' not found\n",
- url);
+ fprintf(stderr,
+ "ERROR NFS storage domain for `%s:%s' not found\n",
+ cfg->nfshost, cfg->nfspath);
exit(EXIT_FAILURE);
}
@@ -812,7 +813,8 @@ static struct stor_dom *apistart(struct config *cfg)
{
struct http_uri huri;
struct stor_dom *sd;
- char *host, *path, *base;
+ char *scheme, *host, *path, *base;
+ bool is_ssl;
char *pathsd, *pathdc;
char *authraw, *authhdr;
size_t authrlen, authhlen;
@@ -837,16 +839,35 @@ static struct stor_dom *apistart(struct config *cfg)
host = strndup(huri.hostname, huri.hostname_len);
if (!host)
goto err_alloc;
+ scheme = strndup(huri.scheme, huri.scheme_len);
+ if (!host)
+ goto err_alloc;
+
+ if (strcmp(scheme, "http") == 0) {
+ is_ssl = false;
+ } else if (strcmp(scheme, "https") == 0) {
+ is_ssl = true;
+ } else {
+ fprintf(stderr, "ERROR Invalid URL scheme `%s'\n", scheme);
+ exit(EXIT_FAILURE);
+ }
if (huri.port)
- rc = asprintf(&base, "http://%s:%u", host, huri.port);
+ rc = asprintf(&base, "%s://%s:%u", scheme, host, huri.port);
else
- rc = asprintf(&base, "http://%s", host);
+ rc = asprintf(&base, "%s://%s", scheme, host);
if (rc < 0)
goto err_alloc;
connection.base = base;
connection.curl = curl_easy_init();
+ if (is_ssl) {
+ /*
+ * FIXME We should check the certificates, not ignore the problem.
+ */
+ curl_easy_setopt(connection.curl, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_easy_setopt(connection.curl, CURLOPT_SSL_VERIFYPEER, 0);
+ }
headers = NULL;
@@ -880,8 +901,6 @@ static struct stor_dom *apistart(struct config *cfg)
apipaths(&connection, headers, path, &pathsd, &pathdc);
/*
- * We should pull the API version and check that it's more than 2.3 XXX
- *
* Step 2, connect again, get domains
*/
sd = apistordom(cfg, &connection, headers, pathsd);
@@ -1430,7 +1449,7 @@ static void copyimage(struct config *cfg, struct stor_dom *sd,
uuid_t tpl_uuid)
uuid_generate_random(vol_uuid);
uuid_generate_random(img_uuid);
- /* XXX Do something about garbage-collecting iwhd.* directories */
+ /* FIXME Do something about garbage-collecting iwhd.* directories */
uuid_unparse_lower(img_uuid, uuidbuf);
rc = asprintf(&tmpimgdir, "%s/iwhd.%s", domdir, uuidbuf);
@@ -1573,8 +1592,8 @@ int main(int argc, char **argv, char **envp)
cfg_veripick(&cfg.nfshost, cfgname, jcfg, "nfshost");
cfg_veripick(&cfg.nfspath, cfgname, jcfg, "nfspath");
/*
- * nfsdir: A directory where sysadmin or boot scripts or autofs mounted
- * the same area that RHEV-M considers an export domain (/mnt/vdsm/rhevm23).
+ * nfsdir: A directory where sysadmin, boot scripts or autofs mounted the
+ * same area that RHEV-M considers an export domain (/mnt/vdsm/rhevm23).
* N.B. If iwhd is running on the NFS server itself, nfsdir can be the
* exported directory itself (like /home/vdsm/rhevm23). We verify that
* the directory contains an expected structure, so attach it to RHEV-M
diff --git a/doc/registrations.md b/doc/registrations.md
index 6a12688..cfcf8bb 100644
--- a/doc/registrations.md
+++ b/doc/registrations.md
@@ -75,6 +75,13 @@ tricks with wrapping dc-rhev-image into a script that calls sudo.
Do not attempt it if you value your sanity.
The area S must be mounted at H (example below assumes /mnt/iwhd-fish).
+For the curl example below, mount like this:
+ mount -t nfs -o v3 fish.usersys.redhat.com:/home/vdsm/v1 /mnt/iwhd-fish
+
+In RHEL 6 and Fedora 14, NFS mounts default to v4, which causes some
+weird file ownership issues. Verify by checking what RHEV-M created
+on the next step. The /mnt/iwhd-fish should contain files owned by vdsm.
+Note that this has nothing to do with root_squash.
Finally, RHEV-M must be told to "import" and "attach" so-called
"export storage domain". At this time, RHEV-M server mounts the area S