Commit b4979a9a authored by Alain Takoudjou's avatar Alain Takoudjou

KVM: Allow to fully customize port when using nat

parent ba9edd4c
...@@ -47,8 +47,12 @@ class Recipe(GenericBaseRecipe): ...@@ -47,8 +47,12 @@ class Recipe(GenericBaseRecipe):
if not self.isTrueValue(self.options.get('use-tap')): if not self.isTrueValue(self.options.get('use-tap')):
# XXX This could be done using Jinja. # XXX This could be done using Jinja.
for port in self.options['nat-rules'].split(): for item in self.options['nat-rules'].split():
tunnel_port = int(port) + 10000 ports = item.split(':')
if len(ports) == 1:
tunnel_port = int(ports[0]) + 10000
else:
tunnel_port = int(ports[1])
tunnel_path = self.createExecutable( tunnel_path = self.createExecutable(
'%s-%s' % (self.options['6tunnel-wrapper-path'], tunnel_port), '%s-%s' % (self.options['6tunnel-wrapper-path'], tunnel_port),
self.substituteTemplate( self.substituteTemplate(
......
...@@ -86,7 +86,12 @@ if not os.path.exists(disk_path): ...@@ -86,7 +86,12 @@ if not os.path.exists(disk_path):
if use_tap == 'True': if use_tap == 'True':
qemu_network_parameter = 'tap,ifname=%%s,script=no,downscript=no' %% tap_interface qemu_network_parameter = 'tap,ifname=%%s,script=no,downscript=no' %% tap_interface
else: else:
qemu_network_parameter = 'user,' + ','.join('hostfwd=tcp:%%s:%%s-:%%s' %% (listen_ip, int(port) + 10000, port) for port in nat_rules.split()) qemu_network_parameter = 'user'
for item in nat_rules.split():
ports = item.split(':')
if len(ports) == 1:
ports.append(int(ports[0]) + 10000)
qemu_network_parameter += ',hostfwd=tcp:%%s:%%s-:%%s' %% (listen_ip, ports[1], ports[0])
kvm_argument_list = [qemu_path, kvm_argument_list = [qemu_path,
'-enable-kvm', '-net', 'nic,macaddr=%%s' %% mac_address, '-enable-kvm', '-net', 'nic,macaddr=%%s' %% mac_address,
......
...@@ -85,8 +85,9 @@ mac-address = $${create-mac:mac-address} ...@@ -85,8 +85,9 @@ mac-address = $${create-mac:mac-address}
runner-path = $${directory:services}/kvm runner-path = $${directory:services}/kvm
controller-path = $${directory:scripts}/kvm_controller controller-path = $${directory:scripts}/kvm_controller
ssh-port = 22222
use-tap = False use-tap = False
nat-rules = 22 80 443 nat-rules = 22:$${:ssh-port} 80:8080 443:4443
6tunnel-wrapper-path = $${directory:services}/6tunnel 6tunnel-wrapper-path = $${directory:services}/6tunnel
virtual-hard-drive-url = $${slap-parameter:virtual-hard-drive-url} virtual-hard-drive-url = $${slap-parameter:virtual-hard-drive-url}
...@@ -159,29 +160,11 @@ shell-path = ${dash:location}/bin/dash ...@@ -159,29 +160,11 @@ shell-path = ${dash:location}/bin/dash
6tunnel-path = ${6tunnel:location}/bin/6tunnel 6tunnel-path = ${6tunnel:location}/bin/6tunnel
[tunnel-ipv6-ssh] [tunnel-ipv6-ssh]
ipv6-port = 10022 ipv6-port = $${kvm-instance:ssh-port}
ipv4-port = 10022 ipv4-port = $${kvm-instance:ssh-port}
ipv6 = $${slap-network-information:global-ipv6} ipv6 = $${slap-network-information:global-ipv6}
ipv4 = $${slap-network-information:local-ipv4} ipv4 = $${slap-network-information:local-ipv4}
#[tunnel-ipv6-ssh]
#<= tunnel-ipv6-base
#ipv6-port = 22222
#ipv4-port = 10022
#runner-path = $${directory:services}/6tunnel-ssh
#[tunnel-ipv6-http]
#<= tunnel-ipv6-base
#ipv6-port = 80
#ipv4-port = 10080
#runner-path = $${directory:services}/6tunnel-http
#[tunnel-ipv6-https]
#<= tunnel-ipv6-base
#ipv6-port = 443
#ipv4-port = 10443
#runner-path = $${directory:services}/6tunnel-https
[tunnel-ipv6-keystone] [tunnel-ipv6-keystone]
<= tunnel-ipv4-to6 <= tunnel-ipv4-to6
ipv6-port = 5000 ipv6-port = 5000
......
...@@ -7,19 +7,6 @@ ...@@ -7,19 +7,6 @@
parts = parts =
certificate-authority certificate-authority
kvm-instance kvm-instance
tunnel-ipv6-ssh
tunnel-ipv6-http
tunnel-ipv6-https
tunnel-ipv6-keystone
tunnel-ipv6-keystone-admin
tunnel-ipv6-keystone-compute
tunnel-ipv6-novnc
tunnel-ipv6-glance
tunnel-ipv6-s3api
tunnel-ipv6-spice
tunnel-ipv6-novadb
tunnel-ipv6-rabbit
tunnel-ipv6-ec2
websockify-sighandler websockify-sighandler
kvm-promise kvm-promise
novnc-promise novnc-promise
...@@ -86,8 +73,9 @@ mac-address = $${create-mac:mac-address} ...@@ -86,8 +73,9 @@ mac-address = $${create-mac:mac-address}
runner-path = $${directory:services}/kvm runner-path = $${directory:services}/kvm
controller-path = $${directory:scripts}/kvm_controller controller-path = $${directory:scripts}/kvm_controller
ssh-port = 22222
use-tap = False use-tap = False
nat-rules = 22, 80, 443, 5000, 6080, 6082, 3333, 9292, 3306, 35357 nat-rules = 22:$${:ssh-port}, 80:8080, 443:4443, 5000:5000, 6080:6080, 6082:6082, 3333:3333, 9292:9292, 3306:3306, 35357:35357
6tunnel-wrapper-path = $${directory:services}/6tunnel 6tunnel-wrapper-path = $${directory:services}/6tunnel
virtual-hard-drive-url = $${slap-parameter:virtual-hard-drive-url} virtual-hard-drive-url = $${slap-parameter:virtual-hard-drive-url}
...@@ -112,83 +100,10 @@ shell-path = ${dash:location}/bin/dash ...@@ -112,83 +100,10 @@ shell-path = ${dash:location}/bin/dash
6tunnel-path = ${6tunnel:location}/bin/6tunnel 6tunnel-path = ${6tunnel:location}/bin/6tunnel
[tunnel-ipv6-ssh] [tunnel-ipv6-ssh]
<= tunnel-ipv6-base ipv6-port = $${kvm-instance:ssh-port}
ipv6-port = 22222 ipv4-port = $${kvm-instance:ssh-port}
ipv4-port = 10022 ipv6 = $${slap-network-information:global-ipv6}
runner-path = $${directory:services}/6tunnel-ssh ipv4 = $${slap-network-information:local-ipv4}
[tunnel-ipv6-http]
<= tunnel-ipv6-base
ipv6-port = 8080
ipv4-port = 10080
runner-path = $${directory:services}/6tunnel-http
[tunnel-ipv6-https]
<= tunnel-ipv6-base
ipv6-port = 4443
ipv4-port = 10443
runner-path = $${directory:services}/6tunnel-https
[tunnel-ipv6-keystone]
<= tunnel-ipv6-base
ipv6-port = 5000
ipv4-port = 15000
runner-path = $${directory:services}/6tunnel-keystone
[tunnel-ipv6-keystone-admin]
<= tunnel-ipv6-base
ipv6-port = 35357
ipv4-port = 45357
runner-path = $${directory:services}/6tunnel-keystone-admin
[tunnel-ipv6-keystone-compute]
<= tunnel-ipv6-base
ipv6-port = 8774
ipv4-port = 18774
runner-path = $${directory:services}/6tunnel-keystone-compute
[tunnel-ipv6-novnc]
<= tunnel-ipv6-base
ipv6-port = 6080
ipv4-port = 16080
runner-path = $${directory:services}/6tunnel-novnc
[tunnel-ipv6-glance]
<= tunnel-ipv6-base
ipv6-port = 9292
ipv4-port = 19292
runner-path = $${directory:services}/6tunnel-glance
[tunnel-ipv6-rabbit]
<= tunnel-ipv6-base
ipv6-port = 5672
ipv4-port = 15672
runner-path = $${directory:services}/6tunnel-rabbit
[tunnel-ipv6-spice]
<= tunnel-ipv6-base
ipv6-port = 6082
ipv4-port = 16082
runner-path = $${directory:services}/6tunnel-spice
[tunnel-ipv6-ec2]
<= tunnel-ipv6-base
ipv6-port = 8773
ipv4-port = 18773
runner-path = $${directory:services}/6tunnel-ec2
#I don't know if this is really usefull!!
[tunnel-ipv6-s3api]
<= tunnel-ipv6-base
ipv6-port = 3333
ipv4-port = 13333
runner-path = $${directory:services}/6tunnel-s3api
[tunnel-ipv6-novadb]
<= tunnel-ipv6-base
ipv6-port = 3306
ipv4-port = 13306
runner-path = $${directory:services}/6tunnel-novadb
[novnc-instance] [novnc-instance]
recipe = slapos.cookbook:novnc recipe = slapos.cookbook:novnc
......
...@@ -11,10 +11,17 @@ extends = ...@@ -11,10 +11,17 @@ extends =
../../component/noVNC/buildout.cfg ../../component/noVNC/buildout.cfg
../../component/openssl/buildout.cfg ../../component/openssl/buildout.cfg
../../stack/slapos.cfg ../../stack/slapos.cfg
../../component/git/buildout.cfg
parts = parts =
template template
eggs eggs
slapos.cookbook-repository
check-recipe
slapos-cookbook
develop =
${:parts-directory}/slapos.cookbook-repository
[eggs] [eggs]
recipe = z3c.recipe.scripts recipe = z3c.recipe.scripts
...@@ -28,14 +35,14 @@ eggs = ...@@ -28,14 +35,14 @@ eggs =
[template-openstack-main] [template-openstack-main]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-main.cfg url = ${:_profile_base_location_}/instance-main.cfg
md5sum = 527962a0384547e37998cf055196e073 md5sum = 1bf5ebf952369b4a99e82b51b5f08f71
output = ${buildout:directory}/template-openstack-main.cfg output = ${buildout:directory}/template-openstack-main.cfg
mode = 0644 mode = 0644
[template-openstack-compute] [template-openstack-compute]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-compute.cfg url = ${:_profile_base_location_}/instance-compute.cfg
md5sum = 4aa88cbefcb9f9bd175f31970e8f8c47 md5sum = 4fe2871f561b96cc458fe3f42eb9b442
output = ${buildout:directory}/template-openstack-compute.cfg output = ${buildout:directory}/template-openstack-compute.cfg
mode = 0644 mode = 0644
...@@ -62,6 +69,19 @@ md5sum = 73e5a796b8d27e20167f36732a1c9fad ...@@ -62,6 +69,19 @@ md5sum = 73e5a796b8d27e20167f36732a1c9fad
filename = ssh-configure.py.in filename = ssh-configure.py.in
md5sum = bcbeabd3cd8f19d71ec9209d9edfbbf8 md5sum = bcbeabd3cd8f19d71ec9209d9edfbbf8
[slapos.cookbook-repository]
recipe = slapos.recipe.build:gitclone
repository = http://git.erp5.org/repos/slapos.git
branch = openstack
git-executable = ${git:location}/bin/git
[check-recipe]
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command =
grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link;
[networkcache] [networkcache]
# signature certificates of the following uploaders. # signature certificates of the following uploaders.
# Romain Courteaud # Romain Courteaud
......
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 to comment