4 # Copyright 2016 RIFT.IO Inc
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
22 from rift
.rwcal
.openstack
.openstack_drv
import OpenstackDriver
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
))
34 def verify(name
, min, count
):
36 raise Exception("only %d instances of %s found. Minimum is %d" % ( count
, name
, min))
37 print("found %d %s" % ( count
, name
))
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()))
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__
)
55 args
=tuple(sys
.argv
[1:6])
56 print("Using args \"%s\"" % ",".join(args
))
59 v3
= OpenstackDriver(*args
)
60 except Exception as e
:
61 print("\n\nunable to instantiate a endpoint: %s" % e
)
63 print("\n\n endpoint instantiated")
66 except Exception as e
:
67 print("\n\nendpoint verification failed: %s" % e
)
69 print("\n\nSUCCESS! openstack is working")
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