KVM frontend : Send slave connection parameters to master

parent e64ed370
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe, GenericSlapRecipe
import json import json
import zc.buildout import zc.buildout
class Recipe(GenericBaseRecipe): class Recipe(GenericSlapRecipe):
""" """
kvm frontend instance configuration. kvm frontend instance configuration.
""" """
...@@ -82,7 +82,7 @@ class Recipe(GenericBaseRecipe): ...@@ -82,7 +82,7 @@ class Recipe(GenericBaseRecipe):
proxy_table_content = json.dumps(proxy_table) proxy_table_content = json.dumps(proxy_table)
return proxy_table_content return proxy_table_content
def install(self): def _install(self):
# Check for mandatory field # Check for mandatory field
if self.options.get('domain', None) is None: if self.options.get('domain', None) is None:
raise zc.buildout.UserError('No domain name specified. Please define ' raise zc.buildout.UserError('No domain name specified. Please define '
...@@ -118,4 +118,14 @@ class Recipe(GenericBaseRecipe): ...@@ -118,4 +118,14 @@ class Recipe(GenericBaseRecipe):
self.substituteTemplate(self.getTemplateFilename('nodejs_run.in'), self.substituteTemplate(self.getTemplateFilename('nodejs_run.in'),
config)) config))
# Send connection parameters of slave instances
site_url = "https://%s:%s/" % (self.options['domain'], self.options['port'])
for slave in rewrite_rule_list:
self.setConnectionDict(
dict(url="%s%s" % (site_url, slave['resource']),
domainname=self.options['domain'],
port=self.options['port'],
resource=slave['resource']),
slave['reference'])
return [map_file, conf_file, runner_path] return [map_file, conf_file, runner_path]
...@@ -124,10 +124,13 @@ partition-id = $${slap-connection:partition-id} ...@@ -124,10 +124,13 @@ partition-id = $${slap-connection:partition-id}
name = SlaveFrontend name = SlaveFrontend
software-type = frontend software-type = frontend
slave = true slave = true
return = frontend_url config = host port
config-host = $${novnc-instance:ip}
config-port = $${novnc-instance:port}
return = url
[publish-kvm-connection-information] [publish-kvm-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
backend_url = https://[$${novnc-instance:ip}]:$${novnc-instance:port}/vnc_auto.html?host=[$${novnc-instance:ip}]&port=$${novnc-instance:port}&encrypt=1 backend_url = https://[$${novnc-instance:ip}]:$${novnc-instance:port}/vnc_auto.html?host=[$${novnc-instance:ip}]&port=$${novnc-instance:port}&encrypt=1
frontend_url = $${request-slave-frontend:frontend_url} frontend_url = $${request-slave-frontend:connection-url}
vnc_passwd = $${kvm-instance:passwd} vnc_passwd = $${kvm-instance:passwd}
...@@ -169,7 +169,7 @@ command = ...@@ -169,7 +169,7 @@ command =
[template-kvm] [template-kvm]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg url = ${:_profile_base_location_}/instance-kvm.cfg
md5sum = ce62abe1edabc78a4baa574a39d7faa0 md5sum = ef4b95334fd8b4608ec10595aba3df3d
output = ${buildout:directory}/template-kvm.cfg output = ${buildout:directory}/template-kvm.cfg
mode = 0644 mode = 0644
......
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