aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-03-27 00:19:20 +0100
committerEwan Mellor <ewan@xensource.com>2007-03-27 00:19:20 +0100
commit99b271fd7d5999dc54a6073da59983fc41b51af8 (patch)
treedb3fd7a3d89771286a603c021adc2ddbdf2c7e98 /tools/libxen
parent6b8760eabada5dd7f76476a589e7425d64a80721 (diff)
downloadxen-99b271fd7d5999dc54a6073da59983fc41b51af8.tar.gz
xen-99b271fd7d5999dc54a6073da59983fc41b51af8.tar.bz2
xen-99b271fd7d5999dc54a6073da59983fc41b51af8.zip
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 <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_network.h33
-rw-r--r--tools/libxen/src/xen_network.c74
2 files changed, 106 insertions, 1 deletions
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;
/**
@@ -220,6 +222,13 @@ xen_network_get_pifs(xen_session *session, struct xen_pif_set **result, xen_netw
/**
+ * 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.
*/
extern bool
@@ -234,6 +243,30 @@ xen_network_set_name_description(xen_session *session, xen_network network, char
/**
+ * 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.
*/
extern bool
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);
}
@@ -239,6 +244,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)
{
abstract_value param_values[] =
@@ -271,6 +293,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)
{