[ $OPENVIM_VER_NUM -ge 4010 ] && DATABASE_TARGET_VER_NUM=8 #0.4.10 => 8
[ $OPENVIM_VER_NUM -ge 5001 ] && DATABASE_TARGET_VER_NUM=9 #0.5.1 => 9
[ $OPENVIM_VER_NUM -ge 5002 ] && DATABASE_TARGET_VER_NUM=10 #0.5.2 => 10
+[ $OPENVIM_VER_NUM -ge 5004 ] && DATABASE_TARGET_VER_NUM=11 #0.5.4 => 11
#TODO ... put next versions here
echo "ALTER TABLE ports CHANGE COLUMN type type ENUM('instance:bridge','instance:data','external') NOT NULL DEFAULT 'instance:bridge' AFTER status;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
echo "DELETE FROM schema_version WHERE version_int = '10';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
}
+
+function upgrade_to_11(){
+ echo " upgrade database from version 0.10 to version 0.11"
+ echo " Add gateway_ip colum to 'nets'"
+ echo "ALTER TABLE nets ADD COLUMN gateway_ip VARCHAR(64) NULL DEFAULT NULL AFTER dhcp_last_ip;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "INSERT INTO schema_version (version_int, version, openvim_ver, comments, date) VALUES (11, '0.11', '0.5.4', 'Add gateway_ip colum to nets', '2017-02-13');"| $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+}
+function downgrade_from_11(){
+ echo " downgrade database from version 0.11 to version 0.10"
+ echo " Delete gateway_ip colum from 'nets'"
+ echo "ALTER TABLE nets DROP COLUMN gateway_ip;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "DELETE FROM schema_version WHERE version_int = '11';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+}
#TODO ... put funtions here
else:
return False
- def launch_dhcp_server(self, vlan, ip_range, netmask, dhcp_path):
+ def launch_dhcp_server(self, vlan, ip_range, netmask, dhcp_path, gateway):
"""
Generate a linux bridge and attache the port to a OVS bridge
:param self:
:param ip_range: IP dhcp range
:param netmask: network netmask
:param dhcp_path: dhcp conf file path that live in namespace side
+ :param gateway: Gateway address for dhcp net
:return: True if success
"""
if not content:
command = 'sudo ip netns exec ' + net_namespace + ' /usr/sbin/dnsmasq --strict-order --except-interface=lo ' \
'--interface=' + interface + ' --bind-interfaces --dhcp-hostsdir=' + dhcp_path + \
- ' --dhcp-range ' + dhcp_range + ' --pid-file=' + pid_file + ' --dhcp-leasefile=' + leases_path + ' --listen-address ' + ip_range[0]
+ ' --dhcp-range ' + dhcp_range + ' --pid-file=' + pid_file + ' --dhcp-leasefile=' + leases_path + \
+ ' --listen-address ' + gateway
print self.name, ': command:', command
(_, stdout, _) = self.ssh_conn.exec_command(command)
dhcp_firt_ip = str(server_net['network']['dhcp_first_ip'])
dhcp_last_ip = str(server_net['network']['dhcp_last_ip'])
dhcp_cidr = str(server_net['network']['cidr'])
+ gateway = str(server_net['network']['gateway'])
vm_dhcp_ip = c2[0]["ip_address"]
config_dic['host_threads'][server['host_id']].insert_task("create-ovs-bridge-port", vlan)
set_mac_dhcp(vm_dhcp_ip, vlan, dhcp_firt_ip, dhcp_last_ip, dhcp_cidr, c2[0]['mac'])
http_controller = config_dic['http_threads'][threading.current_thread().name]
- http_controller.ovim.launch_dhcp_server(vlan, dhcp_firt_ip, dhcp_last_ip, dhcp_cidr)
+ http_controller.ovim.launch_dhcp_server(vlan, dhcp_firt_ip, dhcp_last_ip, dhcp_cidr, gateway)
#Start server
server['uuid'] = new_instance
network["dhcp_first_ip"] = str(ips[2])
if "dhcp_last_ip" not in network:
network["dhcp_last_ip"] = str(ips[-2])
+ if "gateway_ip" not in network:
+ network["gateway_ip"] = str(ips[1])
return True
else:
__author__="Alfonso Tierno"
__date__ ="$10-jul-2014 12:07:15$"
-__version__="0.5.3-r520"
+__version__="0.5.4-r521"
version_date="Jan 2017"
-database_version="0.10" #expected database schema version
+database_version="0.11" #expected database schema version
import httpserver
import auxiliary_functions as af
dhcp_host.ssh_connect()
return dhcp_host
- def launch_dhcp_server(self, vlan, first_ip, last_ip, cidr):
+ def launch_dhcp_server(self, vlan, first_ip, last_ip, cidr, gateway):
"""
Launch a dhcpserver base on dnsmasq attached to the net base on vlan id across the the openvim computes
:param vlan: vlan identifier
controller_host = self.get_dhcp_controller()
controller_host.create_linux_bridge(vlan)
controller_host.create_dhcp_interfaces(vlan, first_ip, dhcp_netmask)
- controller_host.launch_dhcp_server(vlan, ip_range, dhcp_netmask, dhcp_path)
+ controller_host.launch_dhcp_server(vlan, ip_range, dhcp_netmask, dhcp_path, gateway)