Create a bridge in compute OVS to allocate VMs
:return: True if success
"""
+ if self.test:
+ return
command = 'sudo ovs-vsctl --may-exist add-br br-int -- set Bridge br-int stp_enable=true'
print self.name, ': command:', command
(_, stdout, _) = self.ssh_conn.exec_command(command)
def is_port_free(self, vlan, net_uuid):
"""
- Check if por is free before delete from the compute.
+ Check if there not ovs ports of a network in a compute host.
:param vlan: vlan port id
:param net_uuid: network id
:return: True if is not free
self.db_lock.acquire()
result, content = self.db.get_table(
FROM='ports as p join instances as i on p.instance_id=i.uuid',
- WHERE={"i.host_id": self.host_id, 'p.type': 'instance:bridge', 'p.net_id': net_uuid}
+ WHERE={"i.host_id": self.host_id, 'p.type': 'instance:ovs', 'p.net_id': net_uuid}
)
self.db_lock.release()
:param net_uuid:
:return: True if success
"""
+ if self.test:
+ return
if not self.is_port_free(vlan, net_uuid):
return True
self.delete_port_to_ovs_bridge(vlan, net_uuid)
:param vlan: vlan port id
:return:
"""
+ if self.test:
+ return
self.create_linux_bridge(vlan)
self.add_port_to_ovs_bridge(vlan)
:param remote_ip: tunnel endpoint remote compute ip.
:return:
"""
+ if self.test:
+ return
command = 'sudo ovs-vsctl add-port br-int ' + vxlan_interface + \
' -- set Interface ' + vxlan_interface + ' type=vxlan options:remote_ip=' + remote_ip + \
' -- set Port ' + vxlan_interface + ' other_config:stp-path-cost=10'
:param vxlan_interface: vlxan name to be delete it.
:return: True if success.
"""
+ if self.test:
+ return
command = 'sudo ovs-vsctl del-port br-int ' + vxlan_interface
print self.name, ': command:', command
(_, stdout, _) = self.ssh_conn.exec_command(command)
Delete a OVS bridge from a compute.
:return: True if success
"""
+ if self.test:
+ return
command = 'sudo ovs-vsctl del-br br-int'
print self.name, ': command:', command
(_, stdout, _) = self.ssh_conn.exec_command(command)
control_iface['net_id']=control_iface.pop('uuid')
#Get the brifge name
db_lock.acquire()
- result, content = db.get_table(FROM='nets', SELECT=('name','type', 'vlan'),WHERE={'uuid':control_iface['net_id']} )
+ result, content = db.get_table(FROM = 'nets',
+ SELECT = ('name','type', 'vlan', 'provider'),
+ WHERE = {'uuid':control_iface['net_id']})
db_lock.release()
if result < 0:
pass
if network['type']!='bridge_data' and network['type']!='bridge_man':
return -1, "Error at field netwoks: network uuid %s for control interface is not of type bridge_man or bridge_data" % control_iface['net_id']
resources['bridged-ifaces'].append(control_iface)
+ if network.get("provider") and network["provider"][0:3] == "OVS":
+ control_iface["type"] = "instance:ovs"
+ else:
+ control_iface["type"] = "instance:bridge"
+ if network.get("vlan"):
+ control_iface["vlan"] = network["vlan"]
else:
if network['type']!='data' and network['type']!='ptp':
return -1, "Error at field netwoks: network uuid %s for dataplane interface is not of type data or ptp" % control_iface['net_id']