added new fields for node object

This commit is contained in:
root 2015-11-23 17:15:59 +01:00
parent 4bdc66d07a
commit 8ab294e1dc
5 changed files with 33 additions and 5 deletions

View File

@ -15,7 +15,7 @@ case "$1" in
list) curl -sS $BASE/nodes/ | python -m json.tool
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 "";
;;
delete-node) curl -sS -X DELETE $BASE/nodes/$2 | python -m json.tool

View File

@ -19,14 +19,20 @@ class Node(base.APIBase):
uuid = types.uuid
code = 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
def _convert_with_links(node, url, expand=True, show_password=True):
'''
if not expand:
except_list = ['instance_uuid', 'maintenance', 'power_state',
'provision_state', 'uuid', 'name']
except_list = ['name', 'code', 'status','uuid']
node.unset_fields_except(except_list)
'''
else:
if not show_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)
else:
filters = {}
'''
if chassis_uuid:
filters['chassis_uuid'] = chassis_uuid
if associated is not None:
filters['associated'] = associated
if maintenance is not None:
filters['maintenance'] = maintenance
'''
nodes = objects.Node.list(pecan.request.context, limit, marker_obj,
sort_key=sort_key, sort_dir=sort_dir,
filters=filters)
parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}
'''
if associated:
parameters['associated'] = associated
if maintenance:
parameters['maintenance'] = maintenance
'''
return NodeCollection.convert_with_links(nodes, limit,
url=resource_url,
expand=expand,

View File

@ -154,6 +154,12 @@ class Node(Base):
uuid = Column(String(36))
code = Column(String(25))
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'
'''

View File

@ -33,6 +33,12 @@ class Node(base.IotronicObject):
'uuid': obj_utils.str_or_none,
'code': 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,
}

View File

@ -33,6 +33,13 @@ CREATE TABLE `nodes` (
`uuid` varchar(36) NOT NULL,
`code` varchar(25) 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`),
UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;