Commit 342ad2e5 authored by Sebastien Gougeaud's avatar Sebastien Gougeaud Committed by Thomas Leibovici
Browse files

refactor: unify medium and device admin statuses



Remove some duplication by merging the admin statuses of media and
devices, which is now identified as a rsc_adm_status (standing for
ReSourCe ADMin status).

This attribute is now a part of the resource data structure.

Change-Id: I0f75d7864c61b3642beb5989a8a3bfcce5a3ae2f
Signed-off-by: default avatarSebastien Gougeaud <sebastien.gougeaud@cea.fr>
Reviewed-on: https://cws-fleury.labs.ocre.cea.fr/gerrit/6545


Reviewed-by: Linter
Tested-by: default avatarJenkins s8open_nr <s8open_nr@ccc.ocre.cea.fr>
Reviewed-by: default avatarQuentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: default avatarThomas Leibovici <thomas.leibovici@cea.fr>
parent 3611fa38
......@@ -48,18 +48,18 @@ The syntax is: {<combo>: [<criteria0>, <criteria1>, ...]}
== Examples ==
# Retrieve unlocked devices:
{"DSS::DEV::adm_status": PHO_DEV_ADM_ST_UNLOCKED}
{"DSS::DEV::adm_status": PHO_RSC_ADM_ST_UNLOCKED}
# Retrieve unlocked tape drives:
{"$AND": [
{"DSS::DEV::adm_status": PHO_DEV_ADM_ST_UNLOCKED},
{"DSS::DEV::adm_status": PHO_RSC_ADM_ST_UNLOCKED},
{"DSS::DEV::family": PHO_DEV_TAPE}
]}
# Retrieve unlocked tapes with free space >=10GB, formatted and not full:
{"$AND": [
{"DSS::MDA::family": PHO_DEV_TAPE},
{"DSS::MDA::adm_status": PHO_MDA_ADM_ST_UNLOCKED},
{"DSS::MDA::adm_status": PHO_RSC_ADM_ST_UNLOCKED},
{"$GTE": {"DSS::MDA::vol_free: 10737418240}},
{"DSS::MDA::lock": ""},
{"$NOR": [
......
......@@ -46,8 +46,7 @@ from ClusterShell.NodeSet import NodeSet
from phobos.core.admin import Client as AdminClient
from phobos.core.cfg import load_file as cfg_load_file
from phobos.core.const import (PHO_LIB_SCSI,
PHO_DEV_ADM_ST_LOCKED, PHO_DEV_ADM_ST_UNLOCKED,
PHO_MDA_ADM_ST_LOCKED, PHO_MDA_ADM_ST_UNLOCKED)
PHO_RSC_ADM_ST_LOCKED, PHO_RSC_ADM_ST_UNLOCKED)
from phobos.core.dss import Client as DSSClient
from phobos.core.ffi import DevInfo, MediaInfo, ResourceFamily
from phobos.core.ldm import LibAdapter
......@@ -638,7 +637,7 @@ class DeviceOptHandler(BaseResourceOptHandler):
self.logger.error("Device %s is in use by %s.",
serial, device[0].lock.lock)
continue
device[0].adm_status = PHO_DEV_ADM_ST_LOCKED
device[0].rsc.adm_status = PHO_RSC_ADM_ST_LOCKED
devices.append(device[0])
if len(devices) != len(serials):
......@@ -668,9 +667,9 @@ class DeviceOptHandler(BaseResourceOptHandler):
self.logger.error("Device %s is in use by %s.",
serial, device[0].lock.lock)
continue
if device[0].adm_status == PHO_DEV_ADM_ST_UNLOCKED:
if device[0].rsc.adm_status == PHO_RSC_ADM_ST_UNLOCKED:
self.logger.warn("Device %s is already unlocked", serial)
device[0].adm_status = PHO_DEV_ADM_ST_UNLOCKED
device[0].rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED
devices.append(device[0])
if len(devices) != len(serials):
......@@ -835,7 +834,7 @@ class MediaOptHandler(BaseResourceOptHandler):
uid, media[0].lock.lock)
continue
media[0].adm_status = PHO_MDA_ADM_ST_LOCKED
media[0].rsc.adm_status = PHO_RSC_ADM_ST_LOCKED
results.append(media[0])
if len(results) != len(uids):
......@@ -862,10 +861,10 @@ class MediaOptHandler(BaseResourceOptHandler):
uid, media[0].lock.lock)
continue
if media[0].adm_status == PHO_MDA_ADM_ST_UNLOCKED:
if media[0].rsc.adm_status == PHO_RSC_ADM_ST_UNLOCKED:
self.logger.warn("Media %s is already unlocked", uid)
media[0].adm_status = PHO_MDA_ADM_ST_UNLOCKED
media[0].rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED
results.append(media[0])
if len(results) != len(uids):
......
......@@ -76,15 +76,15 @@ static PyObject *py_rsc_family2str(PyObject *self, PyObject *args)
return Py_BuildValue("s", str_repr);
}
static PyObject *py_adm_status2str(PyObject *self, PyObject *args)
static PyObject *py_rsc_adm_status2str(PyObject *self, PyObject *args)
{
enum dev_adm_status status;
enum rsc_adm_status status;
const char *str_repr;
if (!PyArg_ParseTuple(args, "i", &status))
return NULL;
str_repr = adm_status2str(status);
str_repr = rsc_adm_status2str(status);
return Py_BuildValue("s", str_repr);
}
......@@ -136,7 +136,7 @@ static PyMethodDef ConstMethods[] = {
"printable extent state name."},
{"rsc_family2str", py_rsc_family2str, METH_VARARGS,
"printable dev family name."},
{"adm_status2str", py_adm_status2str, METH_VARARGS,
{"rsc_adm_status2str", py_rsc_adm_status2str, METH_VARARGS,
"printable fs status."},
{"fs_status2str", py_fs_status2str, METH_VARARGS,
"printable fs status."},
......@@ -176,6 +176,13 @@ PyMODINIT_FUNC initconst(void)
PyModule_AddIntMacro(mod, PHO_RSC_DIR);
PyModule_AddIntMacro(mod, PHO_RSC_LAST);
/* enum rsc_adm_status */
PyModule_AddIntMacro(mod, PHO_RSC_ADM_ST_INVAL);
PyModule_AddIntMacro(mod, PHO_RSC_ADM_ST_LOCKED);
PyModule_AddIntMacro(mod, PHO_RSC_ADM_ST_UNLOCKED);
PyModule_AddIntMacro(mod, PHO_RSC_ADM_ST_FAILED);
PyModule_AddIntMacro(mod, PHO_RSC_ADM_ST_LAST);
/* enum lib_type */
PyModule_AddIntMacro(mod, PHO_LIB_INVAL);
PyModule_AddIntMacro(mod, PHO_LIB_DUMMY);
......@@ -188,18 +195,6 @@ PyMODINIT_FUNC initconst(void)
PyModule_AddIntMacro(mod, PHO_FS_LTFS);
PyModule_AddIntMacro(mod, PHO_FS_LAST);
/* enum dev_adm_status */
PyModule_AddIntMacro(mod, PHO_DEV_ADM_ST_INVAL);
PyModule_AddIntMacro(mod, PHO_DEV_ADM_ST_LOCKED);
PyModule_AddIntMacro(mod, PHO_DEV_ADM_ST_UNLOCKED);
PyModule_AddIntMacro(mod, PHO_DEV_ADM_ST_LAST);
/* enum media_adm_status */
PyModule_AddIntMacro(mod, PHO_MDA_ADM_ST_INVAL);
PyModule_AddIntMacro(mod, PHO_MDA_ADM_ST_LOCKED);
PyModule_AddIntMacro(mod, PHO_MDA_ADM_ST_UNLOCKED);
PyModule_AddIntMacro(mod, PHO_MDA_ADM_ST_LAST);
/* enum address_type */
PyModule_AddIntMacro(mod, PHO_ADDR_INVAL);
PyModule_AddIntMacro(mod, PHO_ADDR_PATH);
......
......@@ -35,8 +35,7 @@ from abc import ABCMeta, abstractmethod, abstractproperty
from phobos.core.const import str2fs_type
from phobos.core.const import PHO_ADDR_HASH1
from phobos.core.const import PHO_MDA_ADM_ST_LOCKED, PHO_MDA_ADM_ST_UNLOCKED
from phobos.core.const import PHO_DEV_ADM_ST_LOCKED, PHO_DEV_ADM_ST_UNLOCKED
from phobos.core.const import PHO_RSC_ADM_ST_LOCKED, PHO_RSC_ADM_ST_UNLOCKED
from phobos.core.const import DSS_SET_INSERT, DSS_SET_UPDATE, DSS_SET_DELETE
from phobos.core.ffi import DevInfo, Id, MediaInfo, MediaStats, Resource
......@@ -262,13 +261,10 @@ class DeviceManager(BaseObjectManager):
"""
state = ldm_device_query(device_type, device_path)
host = gethostname().split('.')[0]
if locked:
status = PHO_DEV_ADM_ST_LOCKED
else:
status = PHO_DEV_ADM_ST_UNLOCKED
status = PHO_RSC_ADM_ST_LOCKED if locked else PHO_RSC_ADM_ST_UNLOCKED
dev_info = DevInfo(Resource(Id(state.lds_family, state.lds_serial),
state.lds_model), device_path, host, status)
state.lds_model, status), device_path, host)
self.insert([dev_info])
......@@ -302,15 +298,12 @@ class MediaManager(BaseObjectManager):
def add(self, family, fstype, model, name, tags=None, locked=False):
"""Insert media into DSS."""
media = MediaInfo()
media.rsc = Resource(Id(family, name), model)
status = PHO_RSC_ADM_ST_LOCKED if locked else PHO_RSC_ADM_ST_UNLOCKED
media = MediaInfo(Resource(Id(family,name), model, status))
media.fs.type = str2fs_type(fstype)
media.addr_type = PHO_ADDR_HASH1
media.tags = tags or []
if locked:
media.adm_status = PHO_MDA_ADM_ST_LOCKED
else:
media.adm_status = PHO_MDA_ADM_ST_UNLOCKED
media.stats = MediaStats()
......
......@@ -33,7 +33,7 @@ from ctypes import *
from phobos.core.const import (PHO_LABEL_MAX_LEN, PHO_URI_MAX,
PHO_RSC_DIR, PHO_RSC_DISK, PHO_RSC_TAPE,
fs_type2str, fs_status2str,
adm_status2str, rsc_family2str)
rsc_adm_status2str, rsc_family2str)
LIBPHOBOS_NAME = "libphobos_store.so"
LIBPHOBOS = CDLL(LIBPHOBOS_NAME)
......@@ -108,7 +108,8 @@ class Resource(Structure):
"""Resource."""
_fields_ = [
('id', Id),
('model', c_char_p)
('model', c_char_p),
('adm_status', c_int),
]
class ResourceFamily(int):
......@@ -130,14 +131,13 @@ class DevInfo(Structure, CLIManagedResourceMixin):
('rsc', Resource),
('path', c_char_p),
('host', c_char_p),
('adm_status', c_int),
('lock', DSSLock)
]
def get_display_fields(self):
"""Return a dict of available fields and optional display formatters."""
return {
'adm_status': adm_status2str,
'adm_status': rsc_adm_status2str,
'family': rsc_family2str,
'host': None,
'model': None,
......@@ -162,6 +162,11 @@ class DevInfo(Structure, CLIManagedResourceMixin):
"""Wrapper to get model"""
return self.rsc.model
@property
def adm_status(self):
"""Wrapper to get adm_status"""
return self.rsc.adm_status
@property
def lock_status(self):
"""Wrapper to get lock status"""
......@@ -221,7 +226,6 @@ class MediaInfo(Structure, CLIManagedResourceMixin):
_fields_ = [
('rsc', Resource),
('addr_type', c_int),
('adm_status', c_int),
('fs', MediaFS),
('stats', MediaStats),
('_tags', Tags),
......@@ -231,7 +235,7 @@ class MediaInfo(Structure, CLIManagedResourceMixin):
def get_display_fields(self):
"""Return a dict of available fields and optional display formatters."""
return {
'adm_status': adm_status2str,
'adm_status': rsc_adm_status2str,
'addr_type': None,
'model': None,
'name': None,
......@@ -271,6 +275,11 @@ class MediaInfo(Structure, CLIManagedResourceMixin):
"""Wrapper to get medium model"""
return self.rsc.model
@property
def adm_status(self):
"""Wrapper to get adm_status"""
return self.rsc.adm_status
@property
def expanded_fs_info(self):
"""Wrapper to get media fs info as dict"""
......
......@@ -62,9 +62,9 @@ struct dev_info *dev_info_dup(const struct dev_info *dev)
dev_out->rsc.id = dev->rsc.id;
dev_out->rsc.model = strdup_safe(dev->rsc.model);
dev_out->rsc.adm_status = dev->rsc.adm_status;
dev_out->path = strdup_safe(dev->path);
dev_out->host = strdup_safe(dev->host);
dev_out->adm_status = dev->adm_status;
return dev_out;
}
......
......@@ -1214,7 +1214,7 @@ static int get_media_setrequest(PGconn *conn, struct media_info *item_list,
rsc_family2str(p_media->rsc.id.family),
model,
medium_name,
media_adm_status2str(p_media->adm_status),
rsc_adm_status2str(p_media->rsc.adm_status),
fs_type2str(p_media->fs.type),
address_type2str(p_media->addr_type),
fs_status2str(p_media->fs.status),
......@@ -1229,7 +1229,7 @@ static int get_media_setrequest(PGconn *conn, struct media_info *item_list,
update_query[DSS_MEDIA],
rsc_family2str(p_media->rsc.id.family),
model,
media_adm_status2str(p_media->adm_status),
rsc_adm_status2str(p_media->rsc.adm_status),
fs_type2str(p_media->fs.type),
address_type2str(p_media->addr_type),
fs_status2str(p_media->fs.status),
......@@ -1276,7 +1276,7 @@ static int get_device_setrequest(PGconn *conn, struct dev_info *item_list,
g_string_append_printf(request, insert_query_values[DSS_DEVICE],
rsc_family2str(p_dev->rsc.id.family), model,
p_dev->rsc.id.name, p_dev->host,
media_adm_status2str(p_dev->adm_status),
rsc_adm_status2str(p_dev->rsc.adm_status),
p_dev->path, i < item_cnt-1 ? "," : ";");
free(model);
} else if (action == DSS_SET_UPDATE) {
......@@ -1287,7 +1287,7 @@ static int get_device_setrequest(PGconn *conn, struct dev_info *item_list,
g_string_append_printf(request, update_query[DSS_DEVICE],
rsc_family2str(p_dev->rsc.id.family),
model, p_dev->host,
media_adm_status2str(p_dev->adm_status),
rsc_adm_status2str(p_dev->rsc.adm_status),
p_dev->path, p_dev->rsc.id.name);
free(model);
}
......@@ -1565,14 +1565,14 @@ static int dss_device_from_pg_row(void *void_dev, PGresult *res, int row_num)
{
struct dev_info *dev = void_dev;
dev->rsc.id.family = str2rsc_family(PQgetvalue(res, row_num, 0));
dev->rsc.model = get_str_value(res, row_num, 1);
dev->rsc.id.family = str2rsc_family(PQgetvalue(res, row_num, 0));
dev->rsc.model = get_str_value(res, row_num, 1);
pho_id_name_set(&dev->rsc.id, get_str_value(res, row_num, 2));
dev->adm_status = str2adm_status(PQgetvalue(res, row_num, 3));
dev->host = get_str_value(res, row_num, 4);
dev->path = get_str_value(res, row_num, 5);
dev->lock.lock = get_str_value(res, row_num, 6);
dev->lock.lock_ts = strtoul(PQgetvalue(res, row_num, 7), NULL, 10);
dev->rsc.adm_status = str2rsc_adm_status(PQgetvalue(res, row_num, 3));
dev->host = get_str_value(res, row_num, 4);
dev->path = get_str_value(res, row_num, 5);
dev->lock.lock = get_str_value(res, row_num, 6);
dev->lock.lock_ts = strtoul(PQgetvalue(res, row_num, 7), NULL, 10);
return 0;
}
......@@ -1592,17 +1592,17 @@ static int dss_media_from_pg_row(void *void_media, PGresult *res, int row_num)
struct media_info *medium = void_media;
int rc;
medium->rsc.id.family = str2rsc_family(PQgetvalue(res, row_num, 0));
medium->rsc.model = get_str_value(res, row_num, 1);
medium->rsc.id.family = str2rsc_family(PQgetvalue(res, row_num, 0));
medium->rsc.model = get_str_value(res, row_num, 1);
pho_id_name_set(&medium->rsc.id, PQgetvalue(res, row_num, 2));
medium->adm_status = str2media_adm_status(PQgetvalue(res, row_num, 3));
medium->addr_type = str2address_type(PQgetvalue(res, row_num, 4));
medium->fs.type = str2fs_type(PQgetvalue(res, row_num, 5));
medium->fs.status = str2fs_status(PQgetvalue(res, row_num, 6));
medium->rsc.adm_status = str2rsc_adm_status(PQgetvalue(res, row_num, 3));
medium->addr_type = str2address_type(PQgetvalue(res, row_num, 4));
medium->fs.type = str2fs_type(PQgetvalue(res, row_num, 5));
medium->fs.status = str2fs_status(PQgetvalue(res, row_num, 6));
strncpy(medium->fs.label, PQgetvalue(res, row_num, 7),
sizeof(medium->fs.label));
medium->lock.lock = get_str_value(res, row_num, 10);
medium->lock.lock_ts = strtoul(PQgetvalue(res, row_num, 11), NULL, 10);
medium->lock.lock = get_str_value(res, row_num, 10);
medium->lock.lock_ts = strtoul(PQgetvalue(res, row_num, 11), NULL, 10);
/* No dynamic allocation here */
rc = dss_media_stats_decode(&medium->stats, PQgetvalue(res, row_num, 8));
......
......@@ -279,10 +279,43 @@ static inline int pho_id_name_set(struct pho_id *id, const char *name)
return 0;
}
/** Resource administrative state */
enum rsc_adm_status {
PHO_RSC_ADM_ST_INVAL = -1,
PHO_RSC_ADM_ST_LOCKED = 0,
PHO_RSC_ADM_ST_UNLOCKED = 1,
PHO_RSC_ADM_ST_FAILED = 2,
PHO_RSC_ADM_ST_LAST
};
static const char * const RSC_ADM_STATUS_NAMES[] = {
[PHO_RSC_ADM_ST_LOCKED] = "locked",
[PHO_RSC_ADM_ST_UNLOCKED] = "unlocked",
[PHO_RSC_ADM_ST_FAILED] = "failed"
};
static inline const char *rsc_adm_status2str(enum rsc_adm_status adm_st)
{
if (adm_st >= PHO_RSC_ADM_ST_LAST || adm_st < 0)
return NULL;
return RSC_ADM_STATUS_NAMES[adm_st];
}
static inline enum rsc_adm_status str2rsc_adm_status(const char *str)
{
int i;
for (i = 0; i < PHO_RSC_ADM_ST_LAST; i++)
if (!strcmp(str, RSC_ADM_STATUS_NAMES[i]))
return i;
return PHO_RSC_ADM_ST_INVAL;
}
/** Resource */
struct pho_resource {
struct pho_id id; /**< Resource identifier. */
char *model; /**< Resource model (if applicable). */
struct pho_id id; /**< Resource identifier. */
char *model; /**< Resource model (if applicable). */
enum rsc_adm_status adm_status; /**< Administrative status */
};
/** describe a piece of data in a layout */
......@@ -311,41 +344,6 @@ static inline bool is_ext_addr_set(const struct pho_ext_loc *loc)
return loc->extent->address.buff != NULL;
}
/**
* Device Administrative state
*/
enum dev_adm_status {
PHO_DEV_ADM_ST_INVAL = -1,
PHO_DEV_ADM_ST_LOCKED = 0,
PHO_DEV_ADM_ST_UNLOCKED = 1,
PHO_DEV_ADM_ST_FAILED = 2,
PHO_DEV_ADM_ST_LAST
};
static const char * const dev_adm_st_names[] = {
[PHO_DEV_ADM_ST_LOCKED] = "locked",
[PHO_DEV_ADM_ST_UNLOCKED] = "unlocked",
[PHO_DEV_ADM_ST_FAILED] = "failed",
};
static inline const char *adm_status2str(enum dev_adm_status adm_st)
{
if (adm_st >= PHO_DEV_ADM_ST_LAST || adm_st < 0)
return NULL;
return dev_adm_st_names[adm_st];
}
static inline enum dev_adm_status str2adm_status(const char *str)
{
int i;
for (i = 0; i < PHO_DEV_ADM_ST_LAST; i++)
if (!strcmp(str, dev_adm_st_names[i]))
return i;
return PHO_DEV_ADM_ST_INVAL;
}
/**
* Device operational state
*/
......@@ -390,7 +388,6 @@ struct dev_info {
* So, use string instead of enum. */
char *path;
char *host;
enum dev_adm_status adm_status;
struct pho_lock lock;
};
......@@ -420,38 +417,6 @@ struct media_fs {
char label[PHO_LABEL_MAX_LEN + 1];
};
/**
* Media Administrative state
*/
enum media_adm_status {
PHO_MDA_ADM_ST_INVAL = -1,
PHO_MDA_ADM_ST_LOCKED = 0,
PHO_MDA_ADM_ST_UNLOCKED = 1,
PHO_MDA_ADM_ST_LAST
};
static const char * const media_adm_st_names[] = {
[PHO_MDA_ADM_ST_LOCKED] = "locked",
[PHO_MDA_ADM_ST_UNLOCKED] = "unlocked",
};
static inline const char *media_adm_status2str(enum media_adm_status adm_st)
{
if (adm_st >= PHO_MDA_ADM_ST_LAST || adm_st < 0)
return NULL;
return media_adm_st_names[adm_st];
}
static inline enum media_adm_status str2media_adm_status(const char *str)
{
int i;
for (i = 0; i < PHO_MDA_ADM_ST_LAST; i++)
if (!strcmp(str, media_adm_st_names[i]))
return i;
return PHO_MDA_ADM_ST_INVAL;
}
/**
* A simple array of tags (strings)
*/
......@@ -466,7 +431,6 @@ struct tags {
struct media_info {
struct pho_resource rsc; /**< Resource information */
enum address_type addr_type; /**< Way to address this media */
enum media_adm_status adm_status; /**< Administrative status */
struct media_fs fs; /**< Local filesystem information */
struct media_stats stats; /**< Usage metrics */
struct tags tags; /**< Tags used for filtering */
......
......@@ -558,7 +558,7 @@ static int sched_load_dev_state(struct lrs_sched *sched)
" {\"DSS::DEV::family\": \"%s\"}"
"]}",
get_hostname(),
adm_status2str(PHO_DEV_ADM_ST_UNLOCKED),
rsc_adm_status2str(PHO_RSC_ADM_ST_UNLOCKED),
rsc_family2str(family));
if (rc)
return rc;
......@@ -816,7 +816,7 @@ static int sched_select_media(struct lrs_sched *sched,
" %s%s"
"]}",
rsc_family2str(family),
media_adm_status2str(PHO_MDA_ADM_ST_UNLOCKED),
rsc_adm_status2str(PHO_RSC_ADM_ST_UNLOCKED),
/**
* @TODO add criteria to limit the maximum number of
* data fragments:
......@@ -2014,7 +2014,7 @@ static int sched_format(struct lrs_sched *sched, const struct pho_id *id,
if (unlock) {
pho_verb("Unlocking media '%s'", id->name);
media_info->adm_status = PHO_MDA_ADM_ST_UNLOCKED;
media_info->rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED;
}
rc = dss_media_set(&sched->dss, media_info, 1, DSS_SET_UPDATE);
......
......@@ -203,7 +203,7 @@ int main(int argc, char **argv)
"serial:%s adm_st:%s",
rsc_family2str(dev->rsc.id.family), dev->host,
dev->rsc.model, dev->path, dev->rsc.id.name,
adm_status2str(dev->adm_status));
rsc_adm_status2str(dev->rsc.adm_status));
}
break;
case DSS_MEDIA:
......@@ -212,7 +212,7 @@ int main(int argc, char **argv)
"address_type:%s fs_type:%s fs_status:%s",
media->rsc.id.name,
media->rsc.model,
media_adm_status2str(media->adm_status),
rsc_adm_status2str(media->rsc.adm_status),
address_type2str(media->addr_type),
fs_type2str(media->fs.type),
fs_status2str(media->fs.status));
......
......@@ -83,11 +83,11 @@ static void add_dir(struct admin_handle *adm, struct dss_handle *dss,
strtok(hostname, ".");
/* Add dir media */
media->rsc.id.family = PHO_RSC_DIR;
pho_id_name_set(&media->rsc.id, path);
media->rsc.id.family = PHO_RSC_DIR;
media->rsc.adm_status = PHO_RSC_ADM_ST_LOCKED;
media->fs.type = PHO_FS_POSIX;
media->addr_type = PHO_ADDR_HASH1;
media->adm_status = PHO_MDA_ADM_ST_LOCKED;
ASSERT_RC(dss_media_set(dss, media, 1, DSS_SET_INSERT));
/* Add dir device */
......@@ -97,9 +97,9 @@ static void add_dir(struct admin_handle *adm, struct dss_handle *dss,
pho_id_name_set(&dev->rsc.id, dev_st.lds_serial ? : "");
dev->rsc.id.family = dev_st.lds_family;
dev->rsc.model = dev_st.lds_model ? strdup(dev_st.lds_model) : NULL;
dev->rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED;
dev->path = (char *) path;
dev->host = hostname;
dev->adm_status = PHO_DEV_ADM_ST_UNLOCKED;
ldm_dev_state_fini(&dev_st);
ASSERT_RC(dss_device_set(dss, dev, 1, DSS_SET_INSERT));
......@@ -130,9 +130,9 @@ static void add_drive(struct admin_handle *adm, struct dss_handle *dss,
pho_id_name_set(&dev->rsc.id, dev_st.lds_serial ? : "");
dev->rsc.id.family = dev_st.lds_family;
dev->rsc.model = dev_st.lds_model ? strdup(dev_st.lds_model) : NULL;
dev->rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED;
dev->path = (char *) path;
dev->host = hostname;
dev->adm_status = PHO_DEV_ADM_ST_UNLOCKED;
ldm_dev_state_fini(&dev_st);
......@@ -148,12 +148,12 @@ static void add_tape(struct admin_handle *adm, struct dss_handle *dss,
struct media_info *media)
{
/* Add dir media */
media->rsc.id.family = PHO_RSC_TAPE;
pho_id_name_set(&media->rsc.id, tape_id);
media->rsc.id.family = PHO_RSC_TAPE;
media->rsc.model = strdup(model);
media->rsc.adm_status = PHO_RSC_ADM_ST_UNLOCKED;
media->fs.type = PHO_FS_LTFS;
media->addr_type = PHO_ADDR_HASH1;
media->adm_status = PHO_MDA_ADM_ST_UNLOCKED;
ASSERT_RC(dss_media_set(dss, media, 1, DSS_SET_INSERT));
/* This can fail if the tape has already been formatted */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment