added new fields for node object
This commit is contained in:
parent
4bdc66d07a
commit
8ab294e1dc
|
@ -15,7 +15,7 @@ case "$1" in
|
||||||
list) curl -sS $BASE/nodes/ | python -m json.tool
|
list) curl -sS $BASE/nodes/ | python -m json.tool
|
||||||
echo "";
|
echo "";
|
||||||
;;
|
;;
|
||||||
create-node) curl -sS -H "Content-Type: application/json" -X POST $BASE/nodes/ -d '{"code":"'"$2"'"}' | python -m json.tool
|
create-node) curl -sS -H "Content-Type: application/json" -X POST $BASE/nodes/ -d '{"code":"'"$2"'","location":{}}' | python -m json.tool
|
||||||
echo "";
|
echo "";
|
||||||
;;
|
;;
|
||||||
delete-node) curl -sS -X DELETE $BASE/nodes/$2 | python -m json.tool
|
delete-node) curl -sS -X DELETE $BASE/nodes/$2 | python -m json.tool
|
||||||
|
|
|
@ -19,14 +19,20 @@ class Node(base.APIBase):
|
||||||
uuid = types.uuid
|
uuid = types.uuid
|
||||||
code = wsme.wsattr(wtypes.text)
|
code = wsme.wsattr(wtypes.text)
|
||||||
status = wsme.wsattr(wtypes.text)
|
status = wsme.wsattr(wtypes.text)
|
||||||
|
name= wsme.wsattr(wtypes.text)
|
||||||
|
device= wsme.wsattr(wtypes.text)
|
||||||
|
session= wsme.wsattr(wtypes.text)
|
||||||
|
mobile=types.boolean
|
||||||
|
location=types.jsontype
|
||||||
|
extra=types.jsontype
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_with_links(node, url, expand=True, show_password=True):
|
def _convert_with_links(node, url, expand=True, show_password=True):
|
||||||
'''
|
|
||||||
if not expand:
|
if not expand:
|
||||||
except_list = ['instance_uuid', 'maintenance', 'power_state',
|
except_list = ['name', 'code', 'status','uuid']
|
||||||
'provision_state', 'uuid', 'name']
|
|
||||||
node.unset_fields_except(except_list)
|
node.unset_fields_except(except_list)
|
||||||
|
'''
|
||||||
else:
|
else:
|
||||||
if not show_password:
|
if not show_password:
|
||||||
node.driver_info = ast.literal_eval(strutils.mask_password(
|
node.driver_info = ast.literal_eval(strutils.mask_password(
|
||||||
|
@ -112,22 +118,25 @@ class NodesController(rest.RestController):
|
||||||
nodes = self._get_nodes_by_instance(instance_uuid)
|
nodes = self._get_nodes_by_instance(instance_uuid)
|
||||||
else:
|
else:
|
||||||
filters = {}
|
filters = {}
|
||||||
|
'''
|
||||||
if chassis_uuid:
|
if chassis_uuid:
|
||||||
filters['chassis_uuid'] = chassis_uuid
|
filters['chassis_uuid'] = chassis_uuid
|
||||||
if associated is not None:
|
if associated is not None:
|
||||||
filters['associated'] = associated
|
filters['associated'] = associated
|
||||||
if maintenance is not None:
|
if maintenance is not None:
|
||||||
filters['maintenance'] = maintenance
|
filters['maintenance'] = maintenance
|
||||||
|
'''
|
||||||
nodes = objects.Node.list(pecan.request.context, limit, marker_obj,
|
nodes = objects.Node.list(pecan.request.context, limit, marker_obj,
|
||||||
sort_key=sort_key, sort_dir=sort_dir,
|
sort_key=sort_key, sort_dir=sort_dir,
|
||||||
filters=filters)
|
filters=filters)
|
||||||
|
|
||||||
parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}
|
parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}
|
||||||
|
'''
|
||||||
if associated:
|
if associated:
|
||||||
parameters['associated'] = associated
|
parameters['associated'] = associated
|
||||||
if maintenance:
|
if maintenance:
|
||||||
parameters['maintenance'] = maintenance
|
parameters['maintenance'] = maintenance
|
||||||
|
'''
|
||||||
return NodeCollection.convert_with_links(nodes, limit,
|
return NodeCollection.convert_with_links(nodes, limit,
|
||||||
url=resource_url,
|
url=resource_url,
|
||||||
expand=expand,
|
expand=expand,
|
||||||
|
|
|
@ -154,6 +154,12 @@ class Node(Base):
|
||||||
uuid = Column(String(36))
|
uuid = Column(String(36))
|
||||||
code = Column(String(25))
|
code = Column(String(25))
|
||||||
status = Column(String(15), nullable=True)
|
status = Column(String(15), nullable=True)
|
||||||
|
name = Column(String(255), nullable=True)
|
||||||
|
device = Column(String(255), nullable=True)
|
||||||
|
session = Column(String(255), nullable=True)
|
||||||
|
mobile = Column(Boolean, default=False)
|
||||||
|
location = Column(JSONEncodedDict)
|
||||||
|
extra = Column(JSONEncodedDict)
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'nodes'
|
__tablename__ = 'nodes'
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -33,6 +33,12 @@ class Node(base.IotronicObject):
|
||||||
'uuid': obj_utils.str_or_none,
|
'uuid': obj_utils.str_or_none,
|
||||||
'code': obj_utils.str_or_none,
|
'code': obj_utils.str_or_none,
|
||||||
'status': obj_utils.str_or_none,
|
'status': obj_utils.str_or_none,
|
||||||
|
'name': obj_utils.str_or_none,
|
||||||
|
'device': obj_utils.str_or_none,
|
||||||
|
'session': obj_utils.str_or_none,
|
||||||
|
'mobile': bool,
|
||||||
|
'location': obj_utils.dict_or_none,
|
||||||
|
'extra': obj_utils.dict_or_none,
|
||||||
#'reservation': obj_utils.str_or_none,
|
#'reservation': obj_utils.str_or_none,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,13 @@ CREATE TABLE `nodes` (
|
||||||
`uuid` varchar(36) NOT NULL,
|
`uuid` varchar(36) NOT NULL,
|
||||||
`code` varchar(25) DEFAULT NULL,
|
`code` varchar(25) DEFAULT NULL,
|
||||||
`status` varchar(15) DEFAULT NULL,
|
`status` varchar(15) DEFAULT NULL,
|
||||||
|
`name` varchar(255) DEFAULT NULL,
|
||||||
|
`device` varchar(255) DEFAULT NULL,
|
||||||
|
`session` varchar(255) DEFAULT NULL,
|
||||||
|
`mobile` tinyint(1) DEFAULT NULL,
|
||||||
|
`location` text,
|
||||||
|
`extra` text,
|
||||||
|
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uuid` (`uuid`)
|
UNIQUE KEY `uuid` (`uuid`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;
|
||||||
|
|
Loading…
Reference in New Issue