Debian Codegraph @

rally-jobs/plugins/test_vpn_status.py

raw
1 # Copyright 2015 Hewlett-Packard Development Company, L.P.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15
16 from rally.common import logging
17 from rally.task import scenario
18 from rally.task import types
19
20 import vpn_base
21
22 LOG = logging.getLogger(__name__)
23
24
25 class TestVpnStatusScenario(vpn_base.VpnBase):
26 @types.convert(image={"type": "glance_image"},
27 flavor={"type": "nova_flavor"})
28 @scenario.configure()
29 def check_vpn_status(self, **kwargs):
30 """Test VPN's status correctly after bringing router's status to
31 DOWN and back to ACTIVE state
32
33 1. Create 2 private networks, subnets and routers
34 2. Create public network, subnets and GW IPs on routers, if not present
35 3. Execute ip netns command and get the snat and qrouter namespaces
36 (assuming we use DVR)
37 4. Verify that there is a route between the router gateways by pinging
38 each other from their snat namespaces
39 5. Add security group rules for SSH and ICMP
40 6. Start a nova instance in each of the private networks
41 7. Create IKE and IPSEC policies
42 8. Create VPN service at each of the routers
43 9. Create IPSEC site connections at both endpoints
44 10. Bring both the private router's status to DOWN state
45 11. Verify that vpn-service and ipsec-site-connection is DOWN
46 12. Bring back the router's status to ACTIVE state
47 13. Verify the vpn-service and ipsec-site-connection is back to ACTIVE
48 14. Perform resource cleanup
49 """
50
51 try:
52 self.setup(**kwargs)
53 self.create_networks(**kwargs)
54 self.check_route()
55 self.ike_policy = self._create_ike_policy(**kwargs)
56 self.ipsec_policy = self._create_ipsec_policy(**kwargs)
57 self.create_vpn_services()
58 self.create_ipsec_site_connections(**kwargs)
59 self.assert_statuses(final_status='ACTIVE', **kwargs)
60 self.update_router(self.router_ids[0], admin_state_up=False)
61 self.update_router(self.router_ids[1], admin_state_up=False)
62 self.assert_statuses(final_status='DOWN', **kwargs)
63 self.update_router(self.router_ids[0], admin_state_up=True)
64 self.update_router(self.router_ids[1], admin_state_up=True)
65 self.assert_statuses(final_status='ACTIVE', **kwargs)
66 LOG.info("VPN STATUS TEST PASSED!")
67
68 finally:
69 self.cleanup()