Added delete virtual interface API and Minor correction for virtual interface response
Change-Id: I40b7cb14c123746ade93b712a4b06354bc0bacea
This commit is contained in:
parent
392a916695
commit
2c388d0a7d
@ -909,6 +909,16 @@ class ServersClient(AutoMarshallingHTTPClient):
|
||||
|
||||
def create_virtual_interface(self, server_id, network_id,
|
||||
requestslib_kwargs=None):
|
||||
"""
|
||||
@summary: creates a virtual interface for a network and
|
||||
attaches the network to a server instance.
|
||||
@param server_id: The id of an existing server.
|
||||
@type server_id: String
|
||||
@param network_id: The UUID for the network
|
||||
@type network_id: string
|
||||
@return: virtual interface response object
|
||||
@rtype: Requests.response
|
||||
"""
|
||||
virtual_interface = RequestVirtualInterface(network_id=network_id)
|
||||
url = '{base_url}/servers/{server_id}/os-virtual-interfacesv2'.format(
|
||||
base_url=self.url, server_id=server_id)
|
||||
@ -918,8 +928,35 @@ class ServersClient(AutoMarshallingHTTPClient):
|
||||
requestslib_kwargs=requestslib_kwargs)
|
||||
|
||||
def list_virtual_interfaces(self, server_id, requestslib_kwargs=None):
|
||||
"""
|
||||
@summary: lists virtual interfaces configured for a server instance.
|
||||
@param server_id: The id of an existing server.
|
||||
@type server_id: String
|
||||
@return: list of virtual interfaces
|
||||
@rtype: Requests.response
|
||||
"""
|
||||
url = '{base_url}/servers/{server_id}/os-virtual-interfacesv2'.format(
|
||||
base_url=self.url, server_id=server_id)
|
||||
return self.request('GET', url,
|
||||
response_entity_type=ResponseVirtualInterface,
|
||||
requestslib_kwargs=requestslib_kwargs)
|
||||
|
||||
def delete_virtual_interface(self, server_id, virtual_interface_id,
|
||||
requestslib_kwargs=None):
|
||||
"""
|
||||
@summary: deletes the specified virtual interface from the
|
||||
specified server instance.
|
||||
@param server_id: The id of an existing server.
|
||||
@type server_id: String
|
||||
@param virtual_interface_id: ID of the virtual interface
|
||||
which has to be deleted.
|
||||
@type virtual_interface_id: String
|
||||
@return: resp
|
||||
@rtype: Requests.response
|
||||
"""
|
||||
url = ('{base_url}/servers/{server_id}/os-virtual-interfacesv2/'
|
||||
'{vif_id}'.format(base_url=self.url, server_id=server_id,
|
||||
vif_id=virtual_interface_id))
|
||||
return self.request('DELETE', url,
|
||||
response_entity_type=None,
|
||||
requestslib_kwargs=requestslib_kwargs)
|
||||
|
@ -20,13 +20,13 @@ from cafe.engine.models.base import AutoMarshallingModel
|
||||
|
||||
class VirtualInterface(AutoMarshallingModel):
|
||||
|
||||
def __init__(self, id_=None, mac_address=None, ip_addresses=None):
|
||||
def __init__(self, id=None, mac_address=None, ip_addresses=None):
|
||||
|
||||
"""
|
||||
An object that represents the data of a Virtual Interface.
|
||||
"""
|
||||
super(VirtualInterface, self).__init__()
|
||||
self.id = id_
|
||||
self.id = id
|
||||
self.mac_address = mac_address
|
||||
self.ip_addresses = ip_addresses or []
|
||||
|
||||
@ -63,16 +63,17 @@ class VirtualInterface(AutoMarshallingModel):
|
||||
@classmethod
|
||||
def _json_to_obj(cls, serialized_str):
|
||||
ret = None
|
||||
vif = 'virtual_interface'
|
||||
json_dict = json.loads(serialized_str)
|
||||
vif = 'virtual_interface'
|
||||
vifs = 'virtual_interfaces'
|
||||
if vif in json_dict:
|
||||
interface_dict = json_dict.get(vif)
|
||||
ip_addrs = IPAddress._dict_to_obj(interface_dict)
|
||||
interface_dict['ip_addresses'] = ip_addrs
|
||||
ret = VirtualInterface(**interface_dict)
|
||||
if vif in json_dict:
|
||||
if vifs in json_dict:
|
||||
ret = []
|
||||
for interface_dict in json_dict.get(vif):
|
||||
for interface_dict in json_dict.get(vifs):
|
||||
ip_addrs = IPAddress._dict_to_obj(interface_dict)
|
||||
interface_dict['ip_addresses'] = ip_addrs
|
||||
ret.append(VirtualInterface(**interface_dict))
|
||||
|
Loading…
x
Reference in New Issue
Block a user