From 99b271fd7d5999dc54a6073da59983fc41b51af8 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Tue, 27 Mar 2007 00:19:20 +0100 Subject: Added network.other_config map. To make this easier, add a new automatic plumbing facility from the XendNetwork class into XendAPI (credit to Tom Wilkie for the idea). Signed-off-by: Ewan Mellor --- tools/libxen/include/xen_network.h | 33 +++++++++++++++++ tools/libxen/src/xen_network.c | 74 +++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 1 deletion(-) (limited to 'tools/libxen') diff --git a/tools/libxen/include/xen_network.h b/tools/libxen/include/xen_network.h index f1bff0e229..988495f2f4 100644 --- a/tools/libxen/include/xen_network.h +++ b/tools/libxen/include/xen_network.h @@ -22,6 +22,7 @@ #include "xen_common.h" #include "xen_network_decl.h" #include "xen_pif_decl.h" +#include "xen_string_string_map.h" #include "xen_vif_decl.h" @@ -68,6 +69,7 @@ typedef struct xen_network_record char *name_description; struct xen_vif_record_opt_set *vifs; struct xen_pif_record_opt_set *pifs; + xen_string_string_map *other_config; } xen_network_record; /** @@ -219,6 +221,13 @@ extern bool xen_network_get_pifs(xen_session *session, struct xen_pif_set **result, xen_network network); +/** + * Get the other_config field of the given network. + */ +extern bool +xen_network_get_other_config(xen_session *session, xen_string_string_map **result, xen_network network); + + /** * Set the name/label field of the given network. */ @@ -233,6 +242,30 @@ extern bool xen_network_set_name_description(xen_session *session, xen_network network, char *description); +/** + * Set the other_config field of the given network. + */ +extern bool +xen_network_set_other_config(xen_session *session, xen_network network, xen_string_string_map *other_config); + + +/** + * Add the given key-value pair to the other_config field of the given + * network. + */ +extern bool +xen_network_add_to_other_config(xen_session *session, xen_network network, char *key, char *value); + + +/** + * Remove the given key and its corresponding value from the + * other_config field of the given network. If the key is not in that Map, + * then do nothing. + */ +extern bool +xen_network_remove_from_other_config(xen_session *session, xen_network network, char *key); + + /** * Return a list of all the networks known to the system. */ diff --git a/tools/libxen/src/xen_network.c b/tools/libxen/src/xen_network.c index 723616204c..01393f6773 100644 --- a/tools/libxen/src/xen_network.c +++ b/tools/libxen/src/xen_network.c @@ -24,6 +24,7 @@ #include "xen_internal.h" #include "xen_network.h" #include "xen_pif.h" +#include "xen_string_string_map.h" #include "xen_vif.h" @@ -52,7 +53,10 @@ static const struct_member xen_network_record_struct_members[] = .offset = offsetof(xen_network_record, vifs) }, { .key = "PIFs", .type = &abstract_type_ref_set, - .offset = offsetof(xen_network_record, pifs) } + .offset = offsetof(xen_network_record, pifs) }, + { .key = "other_config", + .type = &abstract_type_string_string_map, + .offset = offsetof(xen_network_record, other_config) } }; const abstract_type xen_network_record_abstract_type_ = @@ -78,6 +82,7 @@ xen_network_record_free(xen_network_record *record) free(record->name_description); xen_vif_record_opt_set_free(record->vifs); xen_pif_record_opt_set_free(record->pifs); + xen_string_string_map_free(record->other_config); free(record); } @@ -238,6 +243,23 @@ xen_network_get_pifs(xen_session *session, struct xen_pif_set **result, xen_netw } +bool +xen_network_get_other_config(xen_session *session, xen_string_string_map **result, xen_network network) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = network } + }; + + abstract_type result_type = abstract_type_string_string_map; + + *result = NULL; + XEN_CALL_("network.get_other_config"); + return session->ok; +} + + bool xen_network_set_name_label(xen_session *session, xen_network network, char *label) { @@ -270,6 +292,56 @@ xen_network_set_name_description(xen_session *session, xen_network network, char } +bool +xen_network_set_other_config(xen_session *session, xen_network network, xen_string_string_map *other_config) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = network }, + { .type = &abstract_type_string_string_map, + .u.set_val = (arbitrary_set *)other_config } + }; + + xen_call_(session, "network.set_other_config", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_network_add_to_other_config(xen_session *session, xen_network network, char *key, char *value) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = network }, + { .type = &abstract_type_string, + .u.string_val = key }, + { .type = &abstract_type_string, + .u.string_val = value } + }; + + xen_call_(session, "network.add_to_other_config", param_values, 3, NULL, NULL); + return session->ok; +} + + +bool +xen_network_remove_from_other_config(xen_session *session, xen_network network, char *key) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = network }, + { .type = &abstract_type_string, + .u.string_val = key } + }; + + xen_call_(session, "network.remove_from_other_config", param_values, 2, NULL, NULL); + return session->ok; +} + + bool xen_network_get_all(xen_session *session, struct xen_network_set **result) { -- cgit v1.2.3