Commit 36ed0e99 by Arnau Comas Codina

Network Interfaces

parent d0818f18
......@@ -16,7 +16,9 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
def create_interface(self):
""" Creates a set of OpenStack resources to provide the functionality of
a "vlan". These resources consists of a router connected to public
network, a network and a subnet, where the instance gets the local ip
network, a network and a subnet, where the instance gets the local ip.
Returns the ID of the network resource, representing the interface.
"""
project_id = self.openstack.auth['project_id']
......@@ -89,26 +91,45 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
@OpenStackError
def add_vm_to_interface(self, interface_id):
def add_vm_to_interface(self, device_id, interface_id):
""" Attaches the specified device to a "vlan" identified by the
"interface_id" param. This translates on creating a network port into
the corresponding "vlan" and thus assign an ip to the device.
Note that further actions may be required depending on the "vm" to
activate and configure the new interface.
Returns the ID of the Neutron port.
"""
pass
project_id = self.openstack.auth['project_id']
#for subnet in self.openstack.network.subnets(network_id=interface_id):
port = self.openstack.network.create_port(project_id=project_id,
network_id=interface_id, is_admin_state_up=True,
device_id=device_id, device_owner="compute:nova",
is_port_security_enabled=True, binding_vnic_type="normal")
#fixed_ips=[{
# 'subnet_id': subnet.id,
# 'ip_address': '29.29.29.29'}]
# adds a fixed IP address from the network (interface_id) to a server
# instance (device_id)
#self.openstack.compute.add_fixed_ip_to_server(device_id, interface_id)
return port.id
@OpenStackError
def remove_vm_from_interface(self, interface_id):
def remove_vm_from_interface(self, port_id):
""" Detaches the specified device from the "vlan" identified by the
"interface_id" param.
Note that further actions may be required depending on the "vm" to
activate and configure the new interface.
"""
pass
self.openstack.network.delete_port(port_id)
@OpenStackError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment