Commit 4a818dba authored by Marco Mariani's avatar Marco Mariani

correctly assign slave instances

parent 3421a913
...@@ -123,20 +123,30 @@ class Recipe(object): ...@@ -123,20 +123,30 @@ class Recipe(object):
isSlave = options.get('slave', '').lower() in \ isSlave = options.get('slave', '').lower() in \
librecipe.GenericBaseRecipe.TRUE_VALUES librecipe.GenericBaseRecipe.TRUE_VALUES
self.instance = instance = request(software_url, software_type, self.instance = request(software_url, software_type,
name, partition_parameter_kw=partition_parameter_kw, name, partition_parameter_kw=partition_parameter_kw,
filter_kw=filter_kw, shared=isSlave) filter_kw=filter_kw, shared=isSlave)
self._raise_resource_not_ready = None
try:
# XXX what is the right way to get a global id?
options['instance_guid'] = self.instance.getId()
except slapmodule.ResourceNotReady as exc:
self._raise_resource_not_ready = exc
for param in return_parameters: for param in return_parameters:
try: try:
options['connection-%s' % param] = str( options['connection-%s' % param] = str(
instance.getConnectionParameter(param)) self.instance.getConnectionParameter(param))
except (slapmodule.NotFoundError, slapmodule.ServerError): except (slapmodule.NotFoundError, slapmodule.ServerError):
options['connection-%s' % param] = '' options['connection-%s' % param] = ''
if self.failed is None: if self.failed is None:
self.failed = param self.failed = param
def install(self): def install(self):
if self._raise_resource_not_ready:
raise slapmodule.ResourceNotReady(self._resource_not_ready)
if self.failed is not None: if self.failed is not None:
# Check instance status to know if instance has been deployed # Check instance status to know if instance has been deployed
try: try:
......
...@@ -94,7 +94,7 @@ context = key templateapache template-apache-php:output ...@@ -94,7 +94,7 @@ context = key templateapache template-apache-php:output
import-list = file parts template-parts:destination import-list = file parts template-parts:destination
file replicated template-replicated:destination file replicated template-replicated:destination
md5sum = 03aafcba5c626a4a1bd180d71007be1e md5sum = d96890f5cde5a6db3a71926002000082
mode = 0644 mode = 0644
......
...@@ -121,6 +121,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url} ...@@ -121,6 +121,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull
config-frequency = 30 * * * * config-frequency = 30 * * * *
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-2] [request-pull-backup-server-apache-2]
<= request-pbs-common <= request-pbs-common
...@@ -134,6 +136,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url} ...@@ -134,6 +136,8 @@ config-notify = ${request-pull-backup-server:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-apache-pull
config-frequency = 30 * * * * config-frequency = 30 * * * *
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-backup-1] [request-pull-backup-server-apache-backup-1]
...@@ -146,6 +150,8 @@ config-type = push ...@@ -146,6 +150,8 @@ config-type = push
config-server-key = ${request-apache-backup-1:connection-ssh-public-key} config-server-key = ${request-apache-backup-1:connection-ssh-public-key}
config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-1:config-notification-id} config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-1:config-notification-id}
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[request-pull-backup-server-apache-backup-2] [request-pull-backup-server-apache-backup-2]
<= request-pbs-common <= request-pbs-common
...@@ -157,6 +163,8 @@ config-type = push ...@@ -157,6 +163,8 @@ config-type = push
config-server-key = ${request-apache-backup-2:connection-ssh-public-key} config-server-key = ${request-apache-backup-2:connection-ssh-public-key}
config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-2:config-notification-id} config-on-notification = ${request-pull-backup-server:connection-feeds-url}${request-pull-backup-server-apache-2:config-notification-id}
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pull-backup-server:instance_guid}
[directory] [directory]
......
...@@ -51,7 +51,7 @@ mode = 0644 ...@@ -51,7 +51,7 @@ mode = 0644
[template-replicated] [template-replicated]
recipe = slapos.recipe.download recipe = slapos.recipe.download
url = ${:_profile_base_location_}/template-replicated.cfg url = ${:_profile_base_location_}/template-replicated.cfg
md5sum = 61780842ccda1600a102456b0da69ac9 md5sum = 140beeb9193e0580e42a6004b9e3821f
mode = 0644 mode = 0644
destination = ${buildout:directory}/template-replicated.cfg destination = ${buildout:directory}/template-replicated.cfg
......
...@@ -135,6 +135,8 @@ config-notify = ${request-pbs-{{namebase}}-{{id}}:connection-notification-url} ...@@ -135,6 +135,8 @@ config-notify = ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}
config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-pull config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-pull
config-title = Pulling from {{namebase}} config-title = Pulling from {{namebase}}
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
[request-pull-backup-server-{{namebase}}-backup-{{id}}] [request-pull-backup-server-{{namebase}}-backup-{{id}}]
<= request-pbs-common <= request-pbs-common
...@@ -149,6 +151,8 @@ config-notify = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-noti ...@@ -149,6 +151,8 @@ config-notify = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-noti
config-notification-id = ${request-{{namebase}}-pseudo-replicating-{{id}}:pbs-notification-id} config-notification-id = ${request-{{namebase}}-pseudo-replicating-{{id}}:pbs-notification-id}
config-title = Pushing to {{namebase}} backup {{id}} config-title = Pushing to {{namebase}} backup {{id}}
slave = true slave = true
sla = instance_guid
sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}
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