mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 15:50:26 +01:00
ibft: rename function names for ibft plugin
This commit is contained in:
parent
912526f543
commit
68f33a846e
7 changed files with 107 additions and 107 deletions
|
|
@ -31,34 +31,34 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMIbftConnection {
|
||||
struct _NMSIbftConnection {
|
||||
NMSettingsConnection parent;
|
||||
};
|
||||
|
||||
struct _NMIbftConnectionClass {
|
||||
struct _NMSIbftConnectionClass {
|
||||
NMSettingsConnectionClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NMIbftConnection, nm_ibft_connection, NM_TYPE_SETTINGS_CONNECTION)
|
||||
G_DEFINE_TYPE (NMSIbftConnection, nms_ibft_connection, NM_TYPE_SETTINGS_CONNECTION)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_ibft_connection_init (NMIbftConnection *connection)
|
||||
nms_ibft_connection_init (NMSIbftConnection *connection)
|
||||
{
|
||||
}
|
||||
|
||||
NMIbftConnection *
|
||||
nm_ibft_connection_new (const GPtrArray *block, GError **error)
|
||||
NMSIbftConnection *
|
||||
nms_ibft_connection_new (const GPtrArray *block, GError **error)
|
||||
{
|
||||
NMConnection *source;
|
||||
GObject *object;
|
||||
|
||||
source = connection_from_block (block, error);
|
||||
source = nms_ibft_reader_get_connection_from_block (block, error);
|
||||
if (!source)
|
||||
return NULL;
|
||||
|
||||
object = g_object_new (NM_TYPE_IBFT_CONNECTION, NULL);
|
||||
object = g_object_new (NMS_TYPE_IBFT_CONNECTION, NULL);
|
||||
/* Update settings with what was read from iscsiadm */
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
source,
|
||||
|
|
@ -67,11 +67,11 @@ nm_ibft_connection_new (const GPtrArray *block, GError **error)
|
|||
error))
|
||||
g_clear_object (&object);
|
||||
|
||||
return (NMIbftConnection *) object;
|
||||
return (NMSIbftConnection *) object;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_ibft_connection_class_init (NMIbftConnectionClass *ibft_connection_class)
|
||||
nms_ibft_connection_class_init (NMSIbftConnectionClass *ibft_connection_class)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,24 +18,24 @@
|
|||
* Copyright 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_IBFT_CONNECTION_H
|
||||
#define NM_IBFT_CONNECTION_H
|
||||
#ifndef __NMS_IBFT_CONNECTION_H__
|
||||
#define __NMS_IBFT_CONNECTION_H__
|
||||
|
||||
#include <nm-settings-connection.h>
|
||||
|
||||
#define NM_TYPE_IBFT_CONNECTION (nm_ibft_connection_get_type ())
|
||||
#define NM_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IBFT_CONNECTION, NMIbftConnection))
|
||||
#define NM_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IBFT_CONNECTION, NMIbftConnectionClass))
|
||||
#define NM_IS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IBFT_CONNECTION))
|
||||
#define NM_IS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IBFT_CONNECTION))
|
||||
#define NM_IBFT_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IBFT_CONNECTION, NMIbftConnectionClass))
|
||||
#define NMS_TYPE_IBFT_CONNECTION (nms_ibft_connection_get_type ())
|
||||
#define NMS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnection))
|
||||
#define NMS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass))
|
||||
#define NMS_IS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_CONNECTION))
|
||||
#define NMS_IS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_CONNECTION))
|
||||
#define NMS_IBFT_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass))
|
||||
|
||||
typedef struct _NMIbftConnection NMIbftConnection;
|
||||
typedef struct _NMIbftConnectionClass NMIbftConnectionClass;
|
||||
typedef struct _NMSIbftConnection NMSIbftConnection;
|
||||
typedef struct _NMSIbftConnectionClass NMSIbftConnectionClass;
|
||||
|
||||
GType nm_ibft_connection_get_type (void);
|
||||
GType nms_ibft_connection_get_type (void);
|
||||
|
||||
NMIbftConnection *nm_ibft_connection_new (const GPtrArray *block,
|
||||
GError **error);
|
||||
NMSIbftConnection *nms_ibft_connection_new (const GPtrArray *block,
|
||||
GError **error);
|
||||
|
||||
#endif /* NM_IBFT_CONNECTION_H */
|
||||
#endif /* __NMS_IBFT_CONNECTION_H__ */
|
||||
|
|
|
|||
|
|
@ -39,49 +39,49 @@
|
|||
typedef struct {
|
||||
GHashTable *connections; /* uuid::connection */
|
||||
gboolean initialized;
|
||||
} SettingsPluginIbftPrivate;
|
||||
} NMSIbftPluginPrivate;
|
||||
|
||||
struct _SettingsPluginIbft {
|
||||
struct _NMSIbftPlugin {
|
||||
GObject parent;
|
||||
SettingsPluginIbftPrivate _priv;
|
||||
NMSIbftPluginPrivate _priv;
|
||||
};
|
||||
|
||||
struct _SettingsPluginIbftClass {
|
||||
struct _NMSIbftPluginClass {
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (SettingsPluginIbft, settings_plugin_ibft, G_TYPE_OBJECT, 0,
|
||||
G_DEFINE_TYPE_EXTENDED (NMSIbftPlugin, nms_ibft_plugin, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
|
||||
settings_plugin_interface_init))
|
||||
|
||||
#define SETTINGS_PLUGIN_IBFT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIbft, SETTINGS_IS_PLUGIN_IBFT)
|
||||
#define NMS_IBFT_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSIbftPlugin, NMS_IS_IBFT_PLUGIN)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static SettingsPluginIbft *settings_plugin_ibft_get (void);
|
||||
static NMSIbftPlugin *nms_ibft_plugin_get (void);
|
||||
|
||||
NM_DEFINE_SINGLETON_GETTER (SettingsPluginIbft, settings_plugin_ibft_get, SETTINGS_TYPE_PLUGIN_IBFT);
|
||||
NM_DEFINE_SINGLETON_GETTER (NMSIbftPlugin, nms_ibft_plugin_get, NMS_TYPE_IBFT_PLUGIN);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
read_connections (SettingsPluginIbft *self)
|
||||
read_connections (NMSIbftPlugin *self)
|
||||
{
|
||||
SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self);
|
||||
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
|
||||
GSList *blocks = NULL, *iter;
|
||||
GError *error = NULL;
|
||||
NMIbftConnection *connection;
|
||||
NMSIbftConnection *connection;
|
||||
|
||||
if (!read_ibft_blocks ("/sbin/iscsiadm", &blocks, &error)) {
|
||||
if (!nms_ibft_reader_load_blocks ("/sbin/iscsiadm", &blocks, &error)) {
|
||||
nm_log_dbg (LOGD_SETTINGS, "ibft: failed to read iscsiadm records: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
for (iter = blocks; iter; iter = iter->next) {
|
||||
connection = nm_ibft_connection_new (iter->data, &error);
|
||||
connection = nms_ibft_connection_new (iter->data, &error);
|
||||
if (connection) {
|
||||
nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'",
|
||||
nm_connection_get_id (NM_CONNECTION (connection)));
|
||||
|
|
@ -100,11 +100,11 @@ read_connections (SettingsPluginIbft *self)
|
|||
static GSList *
|
||||
get_connections (NMSettingsPlugin *config)
|
||||
{
|
||||
SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (config);
|
||||
SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self);
|
||||
NMSIbftPlugin *self = NMS_IBFT_PLUGIN (config);
|
||||
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
|
||||
GSList *list = NULL;
|
||||
GHashTableIter iter;
|
||||
NMIbftConnection *connection;
|
||||
NMSIbftConnection *connection;
|
||||
|
||||
if (!priv->initialized) {
|
||||
read_connections (self);
|
||||
|
|
@ -148,9 +148,9 @@ init (NMSettingsPlugin *config)
|
|||
}
|
||||
|
||||
static void
|
||||
settings_plugin_ibft_init (SettingsPluginIbft *self)
|
||||
nms_ibft_plugin_init (NMSIbftPlugin *self)
|
||||
{
|
||||
SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self);
|
||||
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
|
||||
|
||||
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
}
|
||||
|
|
@ -158,19 +158,19 @@ settings_plugin_ibft_init (SettingsPluginIbft *self)
|
|||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (object);
|
||||
SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self);
|
||||
NMSIbftPlugin *self = NMS_IBFT_PLUGIN (object);
|
||||
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
|
||||
|
||||
if (priv->connections) {
|
||||
g_hash_table_destroy (priv->connections);
|
||||
priv->connections = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (settings_plugin_ibft_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nms_ibft_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_plugin_ibft_class_init (SettingsPluginIbftClass *req_class)
|
||||
nms_ibft_plugin_class_init (NMSIbftPluginClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
|
||||
|
|
@ -202,5 +202,5 @@ settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface)
|
|||
G_MODULE_EXPORT GObject *
|
||||
nm_settings_plugin_factory (void)
|
||||
{
|
||||
return g_object_ref (settings_plugin_ibft_get ());
|
||||
return g_object_ref (nms_ibft_plugin_get ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,20 +18,19 @@
|
|||
* Copyright 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _PLUGIN_H_
|
||||
#define _PLUGIN_H_
|
||||
#ifndef __NMS_IBFT_PLUGIN_H__
|
||||
#define __NMS_IBFT_PLUGIN_H__
|
||||
|
||||
#define SETTINGS_TYPE_PLUGIN_IBFT (settings_plugin_ibft_get_type ())
|
||||
#define SETTINGS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbft))
|
||||
#define SETTINGS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass))
|
||||
#define SETTINGS_IS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IBFT))
|
||||
#define SETTINGS_IS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IBFT))
|
||||
#define SETTINGS_PLUGIN_IBFT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass))
|
||||
#define NMS_TYPE_IBFT_PLUGIN (nms_ibft_plugin_get_type ())
|
||||
#define NMS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPlugin))
|
||||
#define NMS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass))
|
||||
#define NMS_IS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_PLUGIN))
|
||||
#define NMS_IS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_PLUGIN))
|
||||
#define NMS_IBFT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass))
|
||||
|
||||
typedef struct _SettingsPluginIbft SettingsPluginIbft;
|
||||
typedef struct _SettingsPluginIbftClass SettingsPluginIbftClass;
|
||||
typedef struct _NMSIbftPlugin NMSIbftPlugin;
|
||||
typedef struct _NMSIbftPluginClass NMSIbftPluginClass;
|
||||
|
||||
GType settings_plugin_ibft_get_type (void);
|
||||
|
||||
#endif /* _PLUGIN_H_ */
|
||||
GType nms_ibft_plugin_get_type (void);
|
||||
|
||||
#endif /* __NMS_IBFT_PLUGIN_H__ */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nms-ibft-reader.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -35,7 +37,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nms-ibft-reader.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg)
|
||||
|
||||
|
|
@ -75,7 +77,7 @@ remove_most_whitespace (const char *src)
|
|||
#define TAG_END "# END RECORD"
|
||||
|
||||
/**
|
||||
* read_ibft_blocks:
|
||||
* nms_ibft_reader_load_blocks:
|
||||
* @iscsiadm_path: path to iscsiadm program
|
||||
* @out_blocks: on return if successful, a #GSList of #GPtrArray, or %NULL on
|
||||
* failure
|
||||
|
|
@ -88,9 +90,9 @@ remove_most_whitespace (const char *src)
|
|||
* Returns: %TRUE on success, %FALSE on errors
|
||||
*/
|
||||
gboolean
|
||||
read_ibft_blocks (const char *iscsiadm_path,
|
||||
GSList **out_blocks,
|
||||
GError **error)
|
||||
nms_ibft_reader_load_blocks (const char *iscsiadm_path,
|
||||
GSList **out_blocks,
|
||||
GError **error)
|
||||
{
|
||||
const char *argv[4] = { iscsiadm_path, "-m", "fw", NULL };
|
||||
const char *envp[1] = { NULL };
|
||||
|
|
@ -205,20 +207,20 @@ match_iscsiadm_tag (const char *line, const char *tag)
|
|||
}
|
||||
|
||||
/**
|
||||
* parse_ibft_config:
|
||||
* @data: an array of iscsiadm interface block lines
|
||||
* nms_ibft_reader_parse_block:
|
||||
* @block: an array of iscsiadm interface block lines
|
||||
* @error: return location for errors
|
||||
* @...: pairs of key (const char *) : location (const char **) indicating the
|
||||
* key to look for and the location to store the retrieved value in
|
||||
*
|
||||
* Parses an iscsiadm interface block into variables requested by the caller.
|
||||
* Callers should verify the returned data is complete and valid. Returned
|
||||
* strings are owned by @data and should not be used after @data is freed.
|
||||
* strings are owned by @block and should not be used after @block is freed.
|
||||
*
|
||||
* Returns: %TRUE if at least , %FALSE on failure
|
||||
*/
|
||||
gboolean
|
||||
parse_ibft_config (const GPtrArray *data, GError **error, ...)
|
||||
nms_ibft_reader_parse_block (const GPtrArray *block, GError **error, ...)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
const char **out_value, *p;
|
||||
|
|
@ -226,16 +228,16 @@ parse_ibft_config (const GPtrArray *data, GError **error, ...)
|
|||
const char *key;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (data->len > 0, FALSE);
|
||||
g_return_val_if_fail (block != NULL, FALSE);
|
||||
g_return_val_if_fail (block->len > 0, FALSE);
|
||||
|
||||
/* Find requested keys and populate return values */
|
||||
va_start (ap, error);
|
||||
while ((key = va_arg (ap, const char *))) {
|
||||
out_value = va_arg (ap, const char **);
|
||||
*out_value = NULL;
|
||||
for (i = 0; i < data->len; i++) {
|
||||
p = match_iscsiadm_tag (g_ptr_array_index (data, i), key);
|
||||
for (i = 0; i < block->len; i++) {
|
||||
p = match_iscsiadm_tag (g_ptr_array_index (block, i), key);
|
||||
if (p) {
|
||||
*out_value = p;
|
||||
success = TRUE;
|
||||
|
|
@ -270,14 +272,14 @@ ip4_setting_add_from_block (const GPtrArray *block,
|
|||
|
||||
g_assert (block);
|
||||
|
||||
if (!parse_ibft_config (block, error,
|
||||
ISCSI_BOOTPROTO_TAG, &s_method,
|
||||
ISCSI_IPADDR_TAG, &s_ipaddr,
|
||||
ISCSI_SUBNET_TAG, &s_netmask,
|
||||
ISCSI_GATEWAY_TAG, &s_gateway,
|
||||
ISCSI_DNS1_TAG, &s_dns1,
|
||||
ISCSI_DNS2_TAG, &s_dns2,
|
||||
NULL))
|
||||
if (!nms_ibft_reader_parse_block (block, error,
|
||||
ISCSI_BOOTPROTO_TAG, &s_method,
|
||||
ISCSI_IPADDR_TAG, &s_ipaddr,
|
||||
ISCSI_SUBNET_TAG, &s_netmask,
|
||||
ISCSI_GATEWAY_TAG, &s_gateway,
|
||||
ISCSI_DNS1_TAG, &s_dns1,
|
||||
ISCSI_DNS2_TAG, &s_dns2,
|
||||
NULL))
|
||||
goto error;
|
||||
|
||||
if (!s_method) {
|
||||
|
|
@ -376,11 +378,11 @@ connection_setting_add (const GPtrArray *block,
|
|||
char *id, *uuid;
|
||||
const char *s_hwaddr = NULL, *s_ip4addr = NULL, *s_vlanid;
|
||||
|
||||
if (!parse_ibft_config (block, error,
|
||||
ISCSI_VLAN_ID_TAG, &s_vlanid,
|
||||
ISCSI_HWADDR_TAG, &s_hwaddr,
|
||||
ISCSI_IPADDR_TAG, &s_ip4addr,
|
||||
NULL))
|
||||
if (!nms_ibft_reader_parse_block (block, error,
|
||||
ISCSI_VLAN_ID_TAG, &s_vlanid,
|
||||
ISCSI_HWADDR_TAG, &s_hwaddr,
|
||||
ISCSI_IPADDR_TAG, &s_ip4addr,
|
||||
NULL))
|
||||
return FALSE;
|
||||
if (!s_hwaddr) {
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -421,7 +423,7 @@ is_ibft_vlan_device (const GPtrArray *block)
|
|||
{
|
||||
char *s_vlan_id = NULL;
|
||||
|
||||
if (parse_ibft_config (block, NULL, ISCSI_VLAN_ID_TAG, &s_vlan_id, NULL)) {
|
||||
if (nms_ibft_reader_parse_block (block, NULL, ISCSI_VLAN_ID_TAG, &s_vlan_id, NULL)) {
|
||||
g_assert (s_vlan_id);
|
||||
|
||||
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it
|
||||
|
|
@ -449,7 +451,7 @@ vlan_setting_add_from_block (const GPtrArray *block,
|
|||
/* This won't fail since this function shouldn't be called unless the
|
||||
* iBFT VLAN ID exists and is > 0.
|
||||
*/
|
||||
success = parse_ibft_config (block, NULL, ISCSI_VLAN_ID_TAG, &vlan_id_str, NULL);
|
||||
success = nms_ibft_reader_parse_block (block, NULL, ISCSI_VLAN_ID_TAG, &vlan_id_str, NULL);
|
||||
g_assert (success);
|
||||
g_assert (vlan_id_str);
|
||||
|
||||
|
|
@ -479,7 +481,7 @@ wired_setting_add_from_block (const GPtrArray *block,
|
|||
g_assert (block);
|
||||
g_assert (connection);
|
||||
|
||||
if (!parse_ibft_config (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) {
|
||||
if (!nms_ibft_reader_parse_block (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) {
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG);
|
||||
return FALSE;
|
||||
|
|
@ -500,7 +502,7 @@ wired_setting_add_from_block (const GPtrArray *block,
|
|||
}
|
||||
|
||||
NMConnection *
|
||||
connection_from_block (const GPtrArray *block, GError **error)
|
||||
nms_ibft_reader_get_connection_from_block (const GPtrArray *block, GError **error)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
gboolean is_vlan = FALSE;
|
||||
|
|
@ -508,7 +510,7 @@ connection_from_block (const GPtrArray *block, GError **error)
|
|||
|
||||
g_assert (block);
|
||||
|
||||
if (!parse_ibft_config (block, error, ISCSI_IFACE_TAG, &iface, NULL)) {
|
||||
if (!nms_ibft_reader_parse_block (block, error, ISCSI_IFACE_TAG, &iface, NULL)) {
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"iBFT: malformed iscsiadm record: missing " ISCSI_IFACE_TAG);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -18,18 +18,17 @@
|
|||
* Copyright 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __READER_H__
|
||||
#define __READER_H__
|
||||
#ifndef __NMS_IBFT_READER_H__
|
||||
#define __NMS_IBFT_READER_H__
|
||||
|
||||
#include <nm-connection.h>
|
||||
|
||||
gboolean read_ibft_blocks (const char *iscsiadm_path,
|
||||
GSList **out_blocks,
|
||||
GError **error);
|
||||
gboolean nms_ibft_reader_load_blocks (const char *iscsiadm_path,
|
||||
GSList **out_blocks,
|
||||
GError **error);
|
||||
|
||||
NMConnection *connection_from_block (const GPtrArray *block, GError **error);
|
||||
NMConnection *nms_ibft_reader_get_connection_from_block (const GPtrArray *block, GError **error);
|
||||
|
||||
/* For testcases */
|
||||
gboolean parse_ibft_config (const GPtrArray *data, GError **error, ...) G_GNUC_NULL_TERMINATED;
|
||||
gboolean nms_ibft_reader_parse_block (const GPtrArray *block, GError **error, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
#endif /* __READER_H__ */
|
||||
#endif /* __NMS_IBFT_READER_H__ */
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ read_block (const char *iscsiadm_path, const char *expected_mac)
|
|||
GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
success = read_ibft_blocks (iscsiadm_path, &blocks, &error);
|
||||
success = nms_ibft_reader_load_blocks (iscsiadm_path, &blocks, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (success);
|
||||
g_assert (blocks);
|
||||
|
|
@ -52,7 +52,7 @@ read_block (const char *iscsiadm_path, const char *expected_mac)
|
|||
for (iter = blocks; iter; iter = iter->next) {
|
||||
const char *s_hwaddr = NULL;
|
||||
|
||||
if (!parse_ibft_config (iter->data, NULL, "iface.hwaddress", &s_hwaddr, NULL))
|
||||
if (!nms_ibft_reader_parse_block (iter->data, NULL, "iface.hwaddress", &s_hwaddr, NULL))
|
||||
continue;
|
||||
g_assert (s_hwaddr);
|
||||
if (nm_utils_hwaddr_matches (s_hwaddr, -1, expected_mac, -1)) {
|
||||
|
|
@ -80,7 +80,7 @@ test_read_ibft_dhcp (void)
|
|||
|
||||
block = read_block (TEST_IBFT_DIR "/iscsiadm-test-dhcp", expected_mac_address);
|
||||
|
||||
connection = connection_from_block (block, &error);
|
||||
connection = nms_ibft_reader_get_connection_from_block (block, &error);
|
||||
g_assert_no_error (error);
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ test_read_ibft_static (void)
|
|||
|
||||
block = read_block (TEST_IBFT_DIR "/iscsiadm-test-static", expected_mac_address);
|
||||
|
||||
connection = connection_from_block (block, &error);
|
||||
connection = nms_ibft_reader_get_connection_from_block (block, &error);
|
||||
g_assert_no_error (error);
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ test_read_ibft_malformed (gconstpointer user_data)
|
|||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*malformed iscsiadm record*");
|
||||
|
||||
success = read_ibft_blocks (iscsiadm_path, &blocks, &error);
|
||||
success = nms_ibft_reader_load_blocks (iscsiadm_path, &blocks, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (success);
|
||||
g_assert (blocks == NULL);
|
||||
|
|
@ -204,7 +204,7 @@ test_read_ibft_bad_address (gconstpointer user_data)
|
|||
|
||||
block = read_block (iscsiadm_path, expected_mac_address);
|
||||
|
||||
connection = connection_from_block (block, &error);
|
||||
connection = nms_ibft_reader_get_connection_from_block (block, &error);
|
||||
g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
|
||||
g_assert (strstr (error->message, "iBFT: malformed iscsiadm record: invalid"));
|
||||
g_clear_error (&error);
|
||||
|
|
@ -229,7 +229,7 @@ test_read_ibft_vlan (void)
|
|||
|
||||
block = read_block (TEST_IBFT_DIR "/iscsiadm-test-vlan", expected_mac_address);
|
||||
|
||||
connection = connection_from_block (block, &error);
|
||||
connection = nms_ibft_reader_get_connection_from_block (block, &error);
|
||||
g_assert_no_error (error);
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue