~shakhat/shaker/master

« back to all changes in this revision

Viewing changes to shaker/engine/deploy.py

  • Committer: Ilya Shakhat
  • Date: 2015-07-14 09:43:19 UTC
  • Revision ID: git-v1:1b7f6c035b2c8ff2435472a77c0d78fd7c57b45d
Allow to override instance IP via scenario

On a large stack Heat fails to return stack status in reasonable time.
The issue occurs if stack contains outputs section. This patch allows
to specify the source of instance IP not only via stack outputs, but
also via scenario.

Change-Id: I15f8faa3b2fb009b2a72cfe10f1c3ec445abe653

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
 
 
16
import functools
 
17
 
16
18
import jinja2
17
19
from oslo_config import cfg
18
20
from oslo_log import log as logging
87
89
    return result
88
90
 
89
91
 
90
 
def filter_agents(agents, stack_outputs):
 
92
def filter_agents(agents, stack_outputs, override=None):
91
93
    deployed_agents = {}
92
94
 
93
95
    # first pass, ignore non-deployed
94
96
    for agent in agents.values():
95
 
        stack_values = _get_stack_values(stack_outputs, agent['id'],
96
 
                                         ['ip', 'instance_name'])
97
 
        if not stack_values.get('instance_name'):
 
97
        stack_values = _get_stack_values(stack_outputs, agent['id'], ['ip'])
 
98
 
 
99
        if override:
 
100
            stack_values.update(override(agent))
 
101
 
 
102
        if not stack_values.get('ip'):
98
103
            LOG.info('Ignore non-deployed agent: %s', agent)
99
104
            continue
100
105
 
187
192
        # get info about deployed objects
188
193
        outputs = heat.get_stack_outputs(self.openstack_client.heat,
189
194
                                         stack['id'])
190
 
 
191
 
        return filter_agents(agents, outputs)
 
195
        override = self._get_override(specification.get('override'))
 
196
 
 
197
        return filter_agents(agents, outputs, override)
 
198
 
 
199
    def _get_override(self, override_spec):
 
200
        def override_ip(agent, ip_type):
 
201
            return dict(ip=nova.get_server_ip(
 
202
                self.openstack_client.nova, agent['id'], ip_type))
 
203
 
 
204
        if override_spec:
 
205
            if override_spec.get('ip'):
 
206
                return functools.partial(override_ip,
 
207
                                         ip_type=override_spec.get('ip'))
192
208
 
193
209
    def deploy(self, deployment, base_dir=None):
194
210
        agents = {}