Debian Codegraph @

neutron_tempest_plugin/bgpvpn/services/bgpvpn_client.py

raw
1 # Copyright (c) 2015 Ericsson.
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 from tempest.lib.services.network import base
17
18 # This is the representation of the bgpvpn
19 # client of networking-bgpvpn
20
21 BGPVPN_OBJECT_PATH = '/bgpvpn/bgpvpns'
22 BGPVPN_RESOURCE_PATH = '/bgpvpn/bgpvpns/%s'
23 BGPVPN_NETWORK_ASSOCIATION_PATH = '/bgpvpn/bgpvpns/%s/network_associations'
24 BGPVPN_ROUTER_ASSOCIATION_PATH = '/bgpvpn/bgpvpns/%s/router_associations'
25 BGPVPN_PORT_ASSOCIATION_PATH = '/bgpvpn/bgpvpns/%s/port_associations'
26
27
28 class BgpvpnClient(base.BaseNetworkClient):
29
30 def create_bgpvpn(self, **kwargs):
31 uri = BGPVPN_OBJECT_PATH
32 post_data = {'bgpvpn': kwargs}
33 return self.create_resource(uri, post_data)
34
35 def delete_bgpvpn(self, bgpvpn_id):
36 uri = BGPVPN_RESOURCE_PATH % bgpvpn_id
37 return self.delete_resource(uri)
38
39 def show_bgpvpn(self, bgpvpn_id, **fields):
40 uri = BGPVPN_RESOURCE_PATH % bgpvpn_id
41 return self.show_resource(uri, **fields)
42
43 def list_bgpvpns(self, **filters):
44 uri = BGPVPN_OBJECT_PATH
45 return self.list_resources(uri, **filters)
46
47 def update_bgpvpn(self, bgpvpn_id, **kwargs):
48 uri = BGPVPN_RESOURCE_PATH % bgpvpn_id
49 post_data = {'bgpvpn': kwargs}
50 return self.update_resource(uri, post_data)
51
52 def create_network_association(self, bgpvpn_id, network_id):
53 uri = BGPVPN_NETWORK_ASSOCIATION_PATH % bgpvpn_id
54 post_data = {"network_association":
55 {"network_id": network_id}}
56 return self.create_resource(uri, post_data)
57
58 def delete_network_association(self, bgpvpn_id, association_id):
59 uri_pattern = BGPVPN_NETWORK_ASSOCIATION_PATH + "/%s"
60 uri = uri_pattern % (bgpvpn_id, association_id)
61 return self.delete_resource(uri)
62
63 def show_network_association(self, bgpvpn_id, association_id, **fields):
64 uri_pattern = BGPVPN_NETWORK_ASSOCIATION_PATH + "/%s"
65 uri = uri_pattern % (bgpvpn_id, association_id)
66 return self.show_resource(uri, **fields)
67
68 def list_network_associations(self, bgpvpn_id, **filters):
69 uri = BGPVPN_NETWORK_ASSOCIATION_PATH % bgpvpn_id
70 return self.list_resources(uri, **filters)
71
72 def create_router_association(self, bgpvpn_id, router_id):
73 uri = BGPVPN_ROUTER_ASSOCIATION_PATH % bgpvpn_id
74 post_data = {"router_association":
75 {"router_id": router_id}}
76 return self.create_resource(uri, post_data)
77
78 def delete_router_association(self, bgpvpn_id, association_id):
79 uri_pattern = BGPVPN_ROUTER_ASSOCIATION_PATH + "/%s"
80 uri = uri_pattern % (bgpvpn_id, association_id)
81 return self.delete_resource(uri)
82
83 def show_router_association(self, bgpvpn_id, association_id, **fields):
84 uri_pattern = BGPVPN_ROUTER_ASSOCIATION_PATH + "/%s"
85 uri = uri_pattern % (bgpvpn_id, association_id)
86 return self.show_resource(uri, **fields)
87
88 def list_router_associations(self, bgpvpn_id, **filters):
89 uri = BGPVPN_ROUTER_ASSOCIATION_PATH % bgpvpn_id
90 return self.list_resources(uri, **filters)
91
92 def create_port_association(self, bgpvpn_id, **kwargs):
93 uri = BGPVPN_PORT_ASSOCIATION_PATH % bgpvpn_id
94 post_data = {"port_association": kwargs}
95 return self.create_resource(uri, post_data)
96
97 def update_port_association(self, bgpvpn_id, association_id, **kwargs):
98 uri_pattern = BGPVPN_PORT_ASSOCIATION_PATH + "/%s"
99 uri = uri_pattern % (bgpvpn_id, association_id)
100 post_data = {"port_association": kwargs}
101 return self.update_resource(uri, post_data)
102
103 def delete_port_association(self, bgpvpn_id, association_id):
104 uri_pattern = BGPVPN_PORT_ASSOCIATION_PATH + "/%s"
105 uri = uri_pattern % (bgpvpn_id, association_id)
106 return self.delete_resource(uri)
107
108 def show_port_association(self, bgpvpn_id, association_id, **fields):
109 uri_pattern = BGPVPN_PORT_ASSOCIATION_PATH + "/%s"
110 uri = uri_pattern % (bgpvpn_id, association_id)
111 return self.show_resource(uri, **fields)
112
113 def list_port_associations(self, bgpvpn_id, **filters):
114 uri = BGPVPN_PORT_ASSOCIATION_PATH % bgpvpn_id
115 return self.list_resources(uri, **filters)