forked from altcloud/fence-virt
Make uuids work with libvirt-qpid
Signed-off-by: Lon Hohberger <lon@users.sourceforge.net>
This commit is contained in:
parent
decab46dda
commit
33c16854eb
5
TODO
5
TODO
@ -11,12 +11,13 @@ High Priority / Blockers for v1.0;
|
|||||||
fence who (for example, "vm1 vm2 vm3" can all fence each other, while
|
fence who (for example, "vm1 vm2 vm3" can all fence each other, while
|
||||||
none may fence "vm4 vm5 vm6" since they are in a different cluster).
|
none may fence "vm4 vm5 vm6" since they are in a different cluster).
|
||||||
|
|
||||||
|
* libvirt-qpid security model: mirror what is done in libvirt-qpid
|
||||||
|
for authentication.
|
||||||
|
|
||||||
Future Stuff:
|
Future Stuff:
|
||||||
|
|
||||||
* oVirt backend
|
* oVirt backend
|
||||||
|
|
||||||
* libvirt-qpid backend
|
|
||||||
|
|
||||||
* libccs configuration plugin
|
* libccs configuration plugin
|
||||||
|
|
||||||
* clean up development bits so third parties can develop plugins
|
* clean up development bits so third parties can develop plugins
|
||||||
|
@ -39,6 +39,7 @@ MODULE_PATH=${libdir}/${PACKAGE_NAME}
|
|||||||
fence_virtd_SOURCES = main.c plugin.c
|
fence_virtd_SOURCES = main.c plugin.c
|
||||||
libvirt_so_SOURCES = libvirt.c
|
libvirt_so_SOURCES = libvirt.c
|
||||||
null_so_SOURCES = null.c
|
null_so_SOURCES = null.c
|
||||||
|
libvirt_qpid_so_SOURCES = uuid-test.c
|
||||||
libvirt_qpid_cxx_so_SOURCES = libvirt-qpid.cpp
|
libvirt_qpid_cxx_so_SOURCES = libvirt-qpid.cpp
|
||||||
multicast_so_SOURCES = mcast.c history.c
|
multicast_so_SOURCES = mcast.c history.c
|
||||||
checkpoint_so_SOURCES = virt.c vm_states.c history.c checkpoint.c cpg.c
|
checkpoint_so_SOURCES = virt.c vm_states.c history.c checkpoint.c cpg.c
|
||||||
@ -90,6 +91,7 @@ fence_virtd_SOURCES+=${checkpoint_so_SOURCES}
|
|||||||
LIBS+=$(AIS_LIBS) $(COROSYNC_LIBS) $(CMAN_LIBS)
|
LIBS+=$(AIS_LIBS) $(COROSYNC_LIBS) $(CMAN_LIBS)
|
||||||
endif
|
endif
|
||||||
ifneq ($(mod_libvirt_qpid),no)
|
ifneq ($(mod_libvirt_qpid),no)
|
||||||
|
fence_virtd_SOURCES+=${libvirt_qpid_so_SOURCES}
|
||||||
fence_virtd_cxx_SOURCES+=${libvirt_qpid_cxx_so_SOURCES}
|
fence_virtd_cxx_SOURCES+=${libvirt_qpid_cxx_so_SOURCES}
|
||||||
LIBS+=$(VIRT_QPID)
|
LIBS+=$(VIRT_QPID)
|
||||||
endif
|
endif
|
||||||
@ -116,7 +118,7 @@ multicast.so: ${multicast_so_SOURCES:.c=.o}
|
|||||||
libvirt.so: ${libvirt_so_SOURCES:.c=.o}
|
libvirt.so: ${libvirt_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS)
|
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS)
|
||||||
|
|
||||||
libvirt-qpid.so: ${libvirt_qpid_cxx_so_SOURCES:.cpp=.opp}
|
libvirt-qpid.so: ${libvirt_qpid_so_SOURCES:.c=.o} ${libvirt_qpid_cxx_so_SOURCES:.cpp=.opp}
|
||||||
$(CXX) -o $@ $^ $(LIBS) -shared $(VIRT_QPID)
|
$(CXX) -o $@ $^ $(LIBS) -shared $(VIRT_QPID)
|
||||||
|
|
||||||
null.so: ${null_so_SOURCES:.c=.o}
|
null.so: ${null_so_SOURCES:.c=.o}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include "uuid-test.h"
|
||||||
|
|
||||||
#include <qpid/console/SessionManager.h>
|
#include <qpid/console/SessionManager.h>
|
||||||
|
|
||||||
@ -45,7 +46,6 @@ struct lq_info {
|
|||||||
int pad;
|
int pad;
|
||||||
char *host;
|
char *host;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define VALIDATE(arg) \
|
#define VALIDATE(arg) \
|
||||||
@ -65,8 +65,13 @@ do_lq_request(const char *vm_name, const char *action)
|
|||||||
SessionManager::NameVector names;
|
SessionManager::NameVector names;
|
||||||
Object::Vector domains;
|
Object::Vector domains;
|
||||||
Object *domain = NULL;
|
Object *domain = NULL;
|
||||||
|
const char *property = "name";
|
||||||
unsigned i, tries = 0, found = 0;
|
unsigned i, tries = 0, found = 0;
|
||||||
|
|
||||||
|
if (is_uuid(vm_name) == 1) {
|
||||||
|
property = "uuid";
|
||||||
|
}
|
||||||
|
|
||||||
cs.host = "127.0.0.1";
|
cs.host = "127.0.0.1";
|
||||||
cs.port = 5672;
|
cs.port = 5672;
|
||||||
|
|
||||||
@ -105,7 +110,7 @@ do_lq_request(const char *vm_name, const char *action)
|
|||||||
c = domains[i].getSchema();
|
c = domains[i].getSchema();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (strcmp(domains[i].attrString("name").c_str(),
|
if (strcmp(domains[i].attrString(property).c_str(),
|
||||||
vm_name)) {
|
vm_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -134,7 +139,7 @@ do_lq_request(const char *vm_name, const char *action)
|
|||||||
Object::AttributeMap attrs;
|
Object::AttributeMap attrs;
|
||||||
MethodResponse result;
|
MethodResponse result;
|
||||||
|
|
||||||
std::cout << domain->attrString("name") << " "
|
std::cout << domain->attrString(property) << " "
|
||||||
<< domain->attrString("state") << std::endl;
|
<< domain->attrString("state") << std::endl;
|
||||||
|
|
||||||
domain->invokeMethod(action, attrs, result);
|
domain->invokeMethod(action, attrs, result);
|
||||||
|
60
server/uuid-test.c
Normal file
60
server/uuid-test.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include <uuid/uuid.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
is_uuid(const char *value)
|
||||||
|
{
|
||||||
|
uuid_t id;
|
||||||
|
char test_value[37];
|
||||||
|
|
||||||
|
if (strlen(value) < 36) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uuid_is_null(id) < 0) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uuid_parse(value, id) < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(test_value, 0, sizeof(test_value));
|
||||||
|
uuid_unparse(id, test_value);
|
||||||
|
|
||||||
|
if (strcasecmp(value, test_value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef STANDALONE
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("Usage: uuidtest <value>\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = is_uuid(argv[1]);
|
||||||
|
if (ret == 0) {
|
||||||
|
printf("%s is NOT a uuid\n", argv[1]);
|
||||||
|
} else if (ret == 1) {
|
||||||
|
printf("%s is a uuid\n", argv[1]);
|
||||||
|
} else {
|
||||||
|
printf("Error: %s\n", strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
14
server/uuid-test.h
Normal file
14
server/uuid-test.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __UIID_TEST_H
|
||||||
|
#define __UUID_TEST_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int is_uuid(const char *value);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user