postservice/31-one-netmng: Mise à jour de la création et la mise à jour des réseaux

La syntaxe des templates de réseau a changer dans OpenNebula, il faut maintenant
créer un bloc "AR=[]", l'IP de fin de la place n'est plus utile il faut juste saisir
la taille de la plage.

fixes #12566 @3h
This commit is contained in:
Philippe Caseiro 2015-08-14 10:40:42 +02:00
parent 7c5ecd6ed0
commit 83eda7d01b
2 changed files with 19 additions and 16 deletions

View File

@ -32,7 +32,7 @@
<variable name='vnet_network_dns' type='ip' description='Adresse du serveur DNS'/>
<variable name='vnet_network_gw' type='ip' description='Passerelle du réseau'/>
<variable name='vnet_range_start' type='ip' description='Première IP de la plage (si nécessaire)'/>
<variable name='vnet_range_end' type='ip' description='Dernière IP de la plage (si nécessaire)'/>
<variable name='vnet_range_size' type='number' description='Taille du sous réseaux '/>
<variable name='vnet_vlan_tag' type='number' description='Numéro du VLAN'/>
<variable name='vnet_vlan_trunk' type='number' description="VLAN à transporter (trunk)" mode='expert'/>
@ -111,7 +111,7 @@
<target type='variable'>vnet_network_dns</target>
<target type='variable'>vnet_network_gw</target>
<target type='variable'>vnet_range_start</target>
<target type='variable'>vnet_range_end</target>
<target type='variable'>vnet_range_size</target>
<target type='variable'>vnet_vlan_tag</target>
<target type='variable'>vnet_vlan_trunk</target>
<target type='variable'>activer_multinode</target>
@ -135,7 +135,7 @@
<slave>vnet_network_mask</slave>
<slave>vnet_network_gw</slave>
<slave>vnet_range_start</slave>
<slave>vnet_range_end</slave>
<slave>vnet_range_size</slave>
<slave>vnet_vlan_tag</slave>
<slave>vnet_vlan_trunk</slave>
</group>
@ -168,7 +168,7 @@
<target type='variable'>vnet_network_mask</target>
<target type='variable'>vnet_network_gw</target>
<target type='variable'>vnet_range_start</target>
<target type='variable'>vnet_range_end</target>
<target type='variable'>vnet_range_size</target>
<target type='variable'>vnet_vlan_tag</target>
<target type='variable'>vnet_vlan_trunk</target>
<target type='variable'>l2_vnet_first_mac</target>

View File

@ -180,7 +180,7 @@ class OneNetwork():
return False
def update(self, one_client):
tmpl_file = self.create_template()
tmpl_file = self.create_template(True)
if one_client.update_network(tmpl_file, self.cluster, self.zone):
ihm.print_line("Virtual network {0} updated".format(self.zone))
return True
@ -211,21 +211,24 @@ class OneNetworkL3(OneNetwork):
self.vnet_mask = net_info[4]
self.vnet_gw = net_info[5]
self.vnet_rg_start = net_info[6]
self.vnet_rg_end = net_info[7]
self.vnet_rg_size = net_info[7]
self.vnet_dns = net_info[8]
self.vnet_trunk = net_info[9]
self.cluster = cluster
def create_template(self):
def create_template(self, update=False):
fd, tmp_path = mkstemp(prefix='oneVnet-')
template = open(tmp_path, 'w')
template.write('NAME = "{0}"\n'.format(self.zone))
if self.vnet_rg_start and self.vnet_rg_end:
template.write('TYPE = RANGED\n')
template.write('IP_START = {0}\n'.format(self.vnet_rg_start))
template.write('IP_END = {0}\n'.format(self.vnet_rg_end))
else:
template.write('TYPE = FIXED\n')
if (update is False):
if self.vnet_rg_start and self.vnet_rg_size:
template.write('AR=[\n')
template.write('TYPE = "IP4",\n')
template.write('IP = "{0}",\n'.format(self.vnet_rg_start))
template.write('SIZE = "{0}"\n'.format(self.vnet_rg_size))
template.write(']\n')
else:
template.write('TYPE = FIXED\n')
if self.vlan:
template.write('VLAN = yes\n')
@ -253,7 +256,7 @@ class OneNetworkL2(OneNetwork):
self.trunk = net_info[5]
self.cluster = cluster
def create_template(self):
def create_template(self,update=False):
fd, tmp_path = mkstemp(prefix='oneVnet-')
template = open(tmp_path, 'w')
template.write('NAME = "{0}"\n'.format(self.zone))
@ -287,7 +290,7 @@ def main():
vnet_dns = client.get_creole('vnet_network_dns')
vnet_gw = client.get_creole('vnet_network_gw')
vnet_rg_start = client.get_creole('vnet_range_start')
vnet_rg_end = client.get_creole('vnet_range_end')
vnet_rg_size = client.get_creole('vnet_range_size')
vnet_trunk = client.get_creole('vnet_vlan_trunk')
l2_vnet = client.get_creole('l2_vnets')
@ -309,7 +312,7 @@ def main():
info.append(vnet_mask[cpt])
info.append(vnet_gw[cpt])
info.append(vnet_rg_start[cpt])
info.append(vnet_rg_end[cpt])
info.append(vnet_rg_size[cpt])
info.append(vnet_dns[cpt])
info.append(vnet_trunk[cpt])
info.append(net_prefix)