~shakhat/shaker/master

« back to all changes in this revision

Viewing changes to shaker/openstack/clients/nova.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 itertools
16
17
import re
17
18
import time
18
19
 
43
44
    return False
44
45
 
45
46
 
 
47
def get_server_ip(nova_client, server_name, ip_type):
 
48
    server = nova_client.servers.find(name=server_name)
 
49
    addresses = server.addresses
 
50
    ips = [v['addr'] for v in itertools.chain(*addresses.values())
 
51
           if v['OS-EXT-IPS:type'] == ip_type]
 
52
    if not ips:
 
53
        raise Exception('Could not get IP address of server: %s' % server_name)
 
54
    if len(ips) > 1:
 
55
        raise Exception('Server %s has more than one IP addresses: %s' %
 
56
                        (server_name, ips))
 
57
    return ips[0]
 
58
 
 
59
 
46
60
def check_server_console(nova_client, server_id, len_limit=100):
47
61
    console = nova_client.servers.get(server_id).get_console_output(len_limit)
48
62