Wrap interface_list by proper resource class

Server resource is not the right one to represent data for interfaces.
This patch adds new resource class NetworkInterface for this task.

Change-Id: I02cfe520643522006333f6e1e80e029959af6e1c
Closes-Bug: #1554907
This commit is contained in:
Andrey Kurilin 2016-03-09 12:43:26 +03:00
parent 5afb7889af
commit 97d63e3ecc

View File

@ -527,6 +527,15 @@ class Server(base.Resource):
return self.manager.trigger_crash_dump(self) return self.manager.trigger_crash_dump(self)
class NetworkInterface(base.Resource):
@property
def id(self):
return self.port_id
def __repr__(self):
return '<NetworkInterface: %s>' % self.id
class ServerManager(base.BootingManagerWithFind): class ServerManager(base.BootingManagerWithFind):
resource_class = Server resource_class = Server
@ -1636,7 +1645,7 @@ class ServerManager(base.BootingManagerWithFind):
:param server: The :class:`Server` (or its ID) to query. :param server: The :class:`Server` (or its ID) to query.
""" """
return self._list('/servers/%s/os-interface' % base.getid(server), return self._list('/servers/%s/os-interface' % base.getid(server),
'interfaceAttachments') 'interfaceAttachments', obj_class=NetworkInterface)
def interface_attach(self, server, port_id, net_id, fixed_ip): def interface_attach(self, server, port_id, net_id, fixed_ip):
""" """