| Jeremy Mordkoff | 6f07e6f | 2016-09-07 18:56:51 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # |
| 4 | # Copyright 2016 RIFT.IO Inc |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | |
| 20 | import re |
| 21 | import sys |
| 22 | from rift.rwcal.openstack.openstack_drv import OpenstackDriver |
| 23 | |
| 24 | |
| 25 | |
| 26 | def test_openstack(drv): |
| 27 | print("checking endpoints") |
| 28 | for ep in [ 'compute', 'image', 'network', 'metering' ]: |
| 29 | url = drv.ks_drv.get_service_endpoint(ep, 'publicURL') |
| 30 | print("%s: %s" % ( ep, url)) |
| 31 | if re.search(url, '127.0.0'): |
| 32 | raise Exception("endpoint %s is using a loopback URL: %s" % ( ep, url)) |
| 33 | |
| 34 | def verify(name, min, count): |
| 35 | if count < min: |
| 36 | raise Exception("only %d instances of %s found. Minimum is %d" % ( count, name, min)) |
| 37 | print("found %d %s" % ( count, name )) |
| 38 | |
| 39 | verify("images" , 1, len(drv.glance_image_list())) |
| 40 | verify("flavors " , 1, len(drv.nova_flavor_list())) |
| 41 | verify("floating ips " , 1, len(drv.nova_floating_ip_list())) |
| 42 | verify("servers" , 0, len(drv.nova_server_list())) |
| 43 | verify("networks" , 1, len(drv.neutron_network_list())) |
| 44 | verify("subnets" , 1, len(drv.neutron_subnet_list())) |
| 45 | verify("ports" , 1, len(drv.neutron_port_list())) |
| 46 | #verify("ceilometers" , 1, len(drv.ceilo_meter_list())) |
| 47 | |
| 48 | |
| 49 | |
| 50 | if len(sys.argv) != 6: |
| 51 | print("ARGS are admin_user admin_password auth_url tenant_name mgmt_network_name") |
| 52 | print("e.g. %s pluto mypasswd http://10.95.4.2:5000/v3 demo private" % __file__ ) |
| 53 | sys.exit(1) |
| 54 | |
| 55 | args=tuple(sys.argv[1:6]) |
| 56 | print("Using args \"%s\"" % ",".join(args)) |
| 57 | |
| 58 | try: |
| 59 | v3 = OpenstackDriver(*args) |
| 60 | except Exception as e: |
| 61 | print("\n\nunable to instantiate a endpoint: %s" % e) |
| 62 | else: |
| 63 | print("\n\n endpoint instantiated") |
| 64 | try: |
| 65 | test_openstack(v3) |
| 66 | except Exception as e: |
| 67 | print("\n\nendpoint verification failed: %s" % e) |
| 68 | else: |
| 69 | print("\n\nSUCCESS! openstack is working") |
| 70 | sys.exit(0) |
| 71 | |
| 72 | |
| 73 | |
| 74 | sys.exit(1) |
| 75 | |
| 76 | |
| 77 | # need to check if any public urls are loopbacks |
| 78 | # need to check DNS is set up right |
| 79 | # neutron subnet-show private_subnet |
| 80 | # host repo.riftio.com 10.64.1.3 |
| 81 | |