Rename parameters
Rename some parameters in ironic/db to be more consistent with their values. Change-Id: Iaccc1f19cd352eb6e4013bd61fcaf38a61cd6552
This commit is contained in:
parent
35208610e8
commit
e33d9a668d
|
@ -116,10 +116,10 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_node(self, node):
|
def get_node(self, node_id):
|
||||||
"""Return a node.
|
"""Return a node.
|
||||||
|
|
||||||
:param node: The id or uuid of a node.
|
:param node_id: The id or uuid of a node.
|
||||||
:returns: A node.
|
:returns: A node.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -132,11 +132,11 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_nodes_by_chassis(self, chassis, limit=None, marker=None,
|
def get_nodes_by_chassis(self, chassis_id, limit=None, marker=None,
|
||||||
sort_key=None, sort_dir=None):
|
sort_key=None, sort_dir=None):
|
||||||
"""List all the nodes for a given chassis.
|
"""List all the nodes for a given chassis.
|
||||||
|
|
||||||
:param chassis: The id or uuid of a chassis.
|
:param chassis_id: The id or uuid of a chassis.
|
||||||
:param limit: Maximum number of nodes to return.
|
:param limit: Maximum number of nodes to return.
|
||||||
:param marker: the last item of the previous page; we returns the next
|
:param marker: the last item of the previous page; we returns the next
|
||||||
results after this value.
|
results after this value.
|
||||||
|
@ -147,17 +147,17 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def destroy_node(self, node):
|
def destroy_node(self, node_id):
|
||||||
"""Destroy a node and all associated interfaces.
|
"""Destroy a node and all associated interfaces.
|
||||||
|
|
||||||
:param node: The id or uuid of a node.
|
:param node_id: The id or uuid of a node.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def update_node(self, node, values):
|
def update_node(self, node_id, values):
|
||||||
"""Update properties of a node.
|
"""Update properties of a node.
|
||||||
|
|
||||||
:param node: The id or uuid of a node.
|
:param node_id: The id or uuid of a node.
|
||||||
:param values: Dict of values to update.
|
:param values: Dict of values to update.
|
||||||
May be a partial list, eg. when setting the
|
May be a partial list, eg. when setting the
|
||||||
properties for a driver. For example:
|
properties for a driver. For example:
|
||||||
|
@ -173,10 +173,10 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_port(self, port):
|
def get_port(self, port_id):
|
||||||
"""Return a network port representation.
|
"""Return a network port representation.
|
||||||
|
|
||||||
:param port: The id or MAC of a port.
|
:param port_id: The id or MAC of a port.
|
||||||
:returns: A port.
|
:returns: A port.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -202,11 +202,11 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_ports_by_node(self, node, limit=None, marker=None,
|
def get_ports_by_node(self, node_id, limit=None, marker=None,
|
||||||
sort_key=None, sort_dir=None):
|
sort_key=None, sort_dir=None):
|
||||||
"""List all the ports for a given node.
|
"""List all the ports for a given node.
|
||||||
|
|
||||||
:param node: The id or uuid of a node.
|
:param node_id: The id or uuid of a node.
|
||||||
:param limit: Maximum number of ports to return.
|
:param limit: Maximum number of ports to return.
|
||||||
:param marker: the last item of the previous page; we return the next
|
:param marker: the last item of the previous page; we return the next
|
||||||
result set.
|
result set.
|
||||||
|
@ -224,19 +224,19 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def update_port(self, port, values):
|
def update_port(self, port_id, values):
|
||||||
"""Update properties of an port.
|
"""Update properties of an port.
|
||||||
|
|
||||||
:param port: The id or MAC of a port.
|
:param port_id: The id or MAC of a port.
|
||||||
:param values: Dict of values to update.
|
:param values: Dict of values to update.
|
||||||
:returns: A port.
|
:returns: A port.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def destroy_port(self, port):
|
def destroy_port(self, port_id):
|
||||||
"""Destroy an port.
|
"""Destroy an port.
|
||||||
|
|
||||||
:param port: The id or MAC of a port.
|
:param port_id: The id or MAC of a port.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -247,10 +247,10 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_chassis(self, chassis):
|
def get_chassis(self, chassis_id):
|
||||||
"""Return a chassis representation.
|
"""Return a chassis representation.
|
||||||
|
|
||||||
:param chassis: The id or the UUID of a chassis.
|
:param chassis_id: The id or the UUID of a chassis.
|
||||||
:returns: A chassis.
|
:returns: A chassis.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -268,19 +268,19 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def update_chassis(self, chassis, values):
|
def update_chassis(self, chassis_id, values):
|
||||||
"""Update properties of an chassis.
|
"""Update properties of an chassis.
|
||||||
|
|
||||||
:param chassis: The id or the uuid of a chassis.
|
:param chassis_id: The id or the uuid of a chassis.
|
||||||
:param values: Dict of values to update.
|
:param values: Dict of values to update.
|
||||||
:returns: A chassis.
|
:returns: A chassis.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def destroy_chassis(self, chassis):
|
def destroy_chassis(self, chassis_id):
|
||||||
"""Destroy a chassis.
|
"""Destroy a chassis.
|
||||||
|
|
||||||
:param chassis: The id or the uuid of a chassis.
|
:param chassis_id: The id or the uuid of a chassis.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
|
|
@ -190,10 +190,10 @@ class Connection(api.Connection):
|
||||||
sort_key, sort_dir)
|
sort_key, sort_dir)
|
||||||
|
|
||||||
@objects.objectify(objects.Node)
|
@objects.objectify(objects.Node)
|
||||||
def get_nodes_by_chassis(self, chassis, limit=None, marker=None,
|
def get_nodes_by_chassis(self, chassis_id, limit=None, marker=None,
|
||||||
sort_key=None, sort_dir=None):
|
sort_key=None, sort_dir=None):
|
||||||
# get_chassis() to raise an exception if the chassis is not found
|
# get_chassis() to raise an exception if the chassis is not found
|
||||||
chassis_obj = self.get_chassis(chassis)
|
chassis_obj = self.get_chassis(chassis_id)
|
||||||
query = model_query(models.Node)
|
query = model_query(models.Node)
|
||||||
query = query.filter_by(chassis_id=chassis_obj.id)
|
query = query.filter_by(chassis_id=chassis_obj.id)
|
||||||
return _paginate_query(models.Node, limit, marker,
|
return _paginate_query(models.Node, limit, marker,
|
||||||
|
@ -277,14 +277,14 @@ class Connection(api.Connection):
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@objects.objectify(objects.Node)
|
@objects.objectify(objects.Node)
|
||||||
def get_node(self, node):
|
def get_node(self, node_id):
|
||||||
query = model_query(models.Node)
|
query = model_query(models.Node)
|
||||||
query = add_identity_filter(query, node)
|
query = add_identity_filter(query, node_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = query.one()
|
result = query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.NodeNotFound(node=node)
|
raise exception.NodeNotFound(node=node_id)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -303,28 +303,26 @@ class Connection(api.Connection):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def destroy_node(self, node):
|
def destroy_node(self, node_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Node, session=session)
|
query = model_query(models.Node, session=session)
|
||||||
query = add_identity_filter(query, node)
|
query = add_identity_filter(query, node_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
node_ref = query.one()
|
node_ref = query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.NodeNotFound(node=node)
|
raise exception.NodeNotFound(node=node_id)
|
||||||
if node_ref['reservation'] is not None:
|
if node_ref['reservation'] is not None:
|
||||||
raise exception.NodeLocked(node=node)
|
raise exception.NodeLocked(node=node_id)
|
||||||
if node_ref['instance_uuid'] is not None:
|
if node_ref['instance_uuid'] is not None:
|
||||||
raise exception.NodeAssociated(node=node,
|
raise exception.NodeAssociated(node=node_id,
|
||||||
instance=node_ref['instance_uuid'])
|
instance=node_ref['instance_uuid'])
|
||||||
|
|
||||||
# Get node ID, if an UUID was supplied. The ID is
|
# Get node ID, if an UUID was supplied. The ID is
|
||||||
# required for deleting all ports, attached to the node.
|
# required for deleting all ports, attached to the node.
|
||||||
if uuidutils.is_uuid_like(node):
|
if uuidutils.is_uuid_like(node_id):
|
||||||
node_id = node_ref['id']
|
node_id = node_ref['id']
|
||||||
else:
|
|
||||||
node_id = node
|
|
||||||
|
|
||||||
port_query = model_query(models.Port, session=session)
|
port_query = model_query(models.Port, session=session)
|
||||||
port_query = add_port_filter_by_node(port_query, node_id)
|
port_query = add_port_filter_by_node(port_query, node_id)
|
||||||
|
@ -333,27 +331,27 @@ class Connection(api.Connection):
|
||||||
query.delete()
|
query.delete()
|
||||||
|
|
||||||
@objects.objectify(objects.Node)
|
@objects.objectify(objects.Node)
|
||||||
def update_node(self, node, values):
|
def update_node(self, node_id, values):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Node, session=session)
|
query = model_query(models.Node, session=session)
|
||||||
query = add_identity_filter(query, node)
|
query = add_identity_filter(query, node_id)
|
||||||
|
|
||||||
count = query.update(values, synchronize_session='fetch')
|
count = query.update(values, synchronize_session='fetch')
|
||||||
if count != 1:
|
if count != 1:
|
||||||
raise exception.NodeNotFound(node=node)
|
raise exception.NodeNotFound(node=node_id)
|
||||||
ref = query.one()
|
ref = query.one()
|
||||||
return ref
|
return ref
|
||||||
|
|
||||||
@objects.objectify(objects.Port)
|
@objects.objectify(objects.Port)
|
||||||
def get_port(self, port):
|
def get_port(self, port_id):
|
||||||
query = model_query(models.Port)
|
query = model_query(models.Port)
|
||||||
query = add_port_filter(query, port)
|
query = add_port_filter(query, port_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = query.one()
|
result = query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.PortNotFound(port=port)
|
raise exception.PortNotFound(port=port_id)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -368,10 +366,10 @@ class Connection(api.Connection):
|
||||||
sort_key, sort_dir)
|
sort_key, sort_dir)
|
||||||
|
|
||||||
@objects.objectify(objects.Port)
|
@objects.objectify(objects.Port)
|
||||||
def get_ports_by_node(self, node, limit=None, marker=None,
|
def get_ports_by_node(self, node_id, limit=None, marker=None,
|
||||||
sort_key=None, sort_dir=None):
|
sort_key=None, sort_dir=None):
|
||||||
# get_node() to raise an exception if the node is not found
|
# get_node() to raise an exception if the node is not found
|
||||||
node_obj = self.get_node(node)
|
node_obj = self.get_node(node_id)
|
||||||
query = model_query(models.Port)
|
query = model_query(models.Port)
|
||||||
query = query.filter_by(node_id=node_obj.id)
|
query = query.filter_by(node_id=node_obj.id)
|
||||||
return _paginate_query(models.Port, limit, marker,
|
return _paginate_query(models.Port, limit, marker,
|
||||||
|
@ -389,44 +387,44 @@ class Connection(api.Connection):
|
||||||
return port
|
return port
|
||||||
|
|
||||||
@objects.objectify(objects.Port)
|
@objects.objectify(objects.Port)
|
||||||
def update_port(self, port, values):
|
def update_port(self, port_id, values):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Port, session=session)
|
query = model_query(models.Port, session=session)
|
||||||
query = add_port_filter(query, port)
|
query = add_port_filter(query, port_id)
|
||||||
try:
|
try:
|
||||||
ref = query.one()
|
ref = query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.PortNotFound(port=port)
|
raise exception.PortNotFound(port=port_id)
|
||||||
_check_port_change_forbidden(ref, session)
|
_check_port_change_forbidden(ref, session)
|
||||||
|
|
||||||
ref.update(values)
|
ref.update(values)
|
||||||
|
|
||||||
return ref
|
return ref
|
||||||
|
|
||||||
def destroy_port(self, port):
|
def destroy_port(self, port_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Port, session=session)
|
query = model_query(models.Port, session=session)
|
||||||
query = add_port_filter(query, port)
|
query = add_port_filter(query, port_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ref = query.one()
|
ref = query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.PortNotFound(port=port)
|
raise exception.PortNotFound(port=port_id)
|
||||||
_check_port_change_forbidden(ref, session)
|
_check_port_change_forbidden(ref, session)
|
||||||
|
|
||||||
query.delete()
|
query.delete()
|
||||||
|
|
||||||
@objects.objectify(objects.Chassis)
|
@objects.objectify(objects.Chassis)
|
||||||
def get_chassis(self, chassis):
|
def get_chassis(self, chassis_id):
|
||||||
query = model_query(models.Chassis)
|
query = model_query(models.Chassis)
|
||||||
query = add_identity_filter(query, chassis)
|
query = add_identity_filter(query, chassis_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return query.one()
|
return query.one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.ChassisNotFound(chassis=chassis)
|
raise exception.ChassisNotFound(chassis=chassis_id)
|
||||||
|
|
||||||
@objects.objectify(objects.Chassis)
|
@objects.objectify(objects.Chassis)
|
||||||
def get_chassis_list(self, limit=None, marker=None,
|
def get_chassis_list(self, limit=None, marker=None,
|
||||||
|
@ -446,38 +444,38 @@ class Connection(api.Connection):
|
||||||
return chassis
|
return chassis
|
||||||
|
|
||||||
@objects.objectify(objects.Chassis)
|
@objects.objectify(objects.Chassis)
|
||||||
def update_chassis(self, chassis, values):
|
def update_chassis(self, chassis_id, values):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Chassis, session=session)
|
query = model_query(models.Chassis, session=session)
|
||||||
query = add_identity_filter(query, chassis)
|
query = add_identity_filter(query, chassis_id)
|
||||||
|
|
||||||
count = query.update(values)
|
count = query.update(values)
|
||||||
if count != 1:
|
if count != 1:
|
||||||
raise exception.ChassisNotFound(chassis=chassis)
|
raise exception.ChassisNotFound(chassis=chassis_id)
|
||||||
ref = query.one()
|
ref = query.one()
|
||||||
return ref
|
return ref
|
||||||
|
|
||||||
def destroy_chassis(self, chassis):
|
def destroy_chassis(self, chassis_id):
|
||||||
def chassis_not_empty(session):
|
def chassis_not_empty(session):
|
||||||
"""Checks whether the chassis does not have nodes."""
|
"""Checks whether the chassis does not have nodes."""
|
||||||
|
|
||||||
query = model_query(models.Node, session=session)
|
query = model_query(models.Node, session=session)
|
||||||
query = add_node_filter_by_chassis(query, chassis)
|
query = add_node_filter_by_chassis(query, chassis_id)
|
||||||
|
|
||||||
return query.count() != 0
|
return query.count() != 0
|
||||||
|
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
if chassis_not_empty(session):
|
if chassis_not_empty(session):
|
||||||
raise exception.ChassisNotEmpty(chassis=chassis)
|
raise exception.ChassisNotEmpty(chassis=chassis_id)
|
||||||
|
|
||||||
query = model_query(models.Chassis, session=session)
|
query = model_query(models.Chassis, session=session)
|
||||||
query = add_identity_filter(query, chassis)
|
query = add_identity_filter(query, chassis_id)
|
||||||
|
|
||||||
count = query.delete()
|
count = query.delete()
|
||||||
if count != 1:
|
if count != 1:
|
||||||
raise exception.ChassisNotFound(chassis=chassis)
|
raise exception.ChassisNotFound(chassis=chassis_id)
|
||||||
|
|
||||||
@objects.objectify(objects.Conductor)
|
@objects.objectify(objects.Conductor)
|
||||||
def register_conductor(self, values):
|
def register_conductor(self, values):
|
||||||
|
|
Loading…
Reference in New Issue