Auto-detect public network
Change-Id: If527811f4757276b196988209b46e07794ed92d2
This commit is contained in:
@@ -12,6 +12,7 @@ oslo.i18n>=1.3.0 # Apache-2.0
|
||||
oslo.serialization>=1.2.0 # Apache-2.0
|
||||
oslo.utils>=1.2.0 # Apache-2.0
|
||||
python-keystoneclient>=1.0.0
|
||||
python-neutronclient>=2.3.6,<3
|
||||
python-novaclient>=2.18.0
|
||||
python-heatclient>=0.2.9
|
||||
PyYAML>=3.1.0
|
||||
|
||||
@@ -19,6 +19,7 @@ import jinja2
|
||||
|
||||
from shaker.engine import heat
|
||||
from shaker.engine import keystone
|
||||
from shaker.engine import neutron
|
||||
from shaker.engine import nova
|
||||
from shaker.engine import utils
|
||||
from shaker.openstack.common import log as logging
|
||||
@@ -39,6 +40,8 @@ class Deployment(object):
|
||||
self.keystone_client = keystone.create_keystone_client(keystone_kwargs)
|
||||
self.heat_client = heat.create_heat_client(self.keystone_client)
|
||||
self.nova_client = nova.create_nova_client(keystone_kwargs)
|
||||
self.neutron_client = neutron.create_neutron_client(
|
||||
self.keystone_client)
|
||||
|
||||
self.stack_name = 'shaker_%s' % uuid.uuid4()
|
||||
self.stack_deployed = False
|
||||
@@ -125,6 +128,17 @@ class Deployment(object):
|
||||
|
||||
return agents
|
||||
|
||||
def _fill_missing_template_parameters(self, template_parameters):
|
||||
template_parameters['private_net_name'] = 'net_%s' % uuid.uuid4()
|
||||
template_parameters['server_endpoint'] = self.server_endpoint
|
||||
|
||||
if not template_parameters.get('public_net'):
|
||||
ext_nets = self.neutron_client.list_networks(
|
||||
**{'router:external': True})['networks']
|
||||
if not ext_nets:
|
||||
raise Exception('No external networks found')
|
||||
template_parameters['public_net'] = ext_nets[0]['name']
|
||||
|
||||
def _deploy_from_hot(self, specification):
|
||||
vm_accommodation = specification['vm_accommodation']
|
||||
heat_template_name = specification['template']
|
||||
@@ -141,8 +155,7 @@ class Deployment(object):
|
||||
LOG.debug('Rendered template: %s', rendered_template)
|
||||
|
||||
# create stack by Heat
|
||||
template_parameters['private_net_name'] = 'net_%s' % uuid.uuid4()
|
||||
template_parameters['server_endpoint'] = self.server_endpoint
|
||||
self._fill_missing_template_parameters(template_parameters)
|
||||
|
||||
stack_params = {
|
||||
'stack_name': self.stack_name,
|
||||
|
||||
33
shaker/engine/neutron.py
Normal file
33
shaker/engine/neutron.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2015 Mirantis Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutronclient.neutron import client as neutron_client_pkg
|
||||
|
||||
from shaker.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
NEUTRON_CLIENT_VERSION = '2.0'
|
||||
|
||||
|
||||
def create_neutron_client(keystone_client):
|
||||
network_api_url = keystone_client.service_catalog.url_for(
|
||||
service_type='network')
|
||||
client = neutron_client_pkg.Client(NEUTRON_CLIENT_VERSION,
|
||||
endpoint_url=network_api_url,
|
||||
token=keystone_client.auth_token, )
|
||||
return client
|
||||
Reference in New Issue
Block a user