1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Resource class and its manager for fixed IPs in Compute API v2
18 """
19
20 from yakumo import base
21 from yakumo import mapper
22
23
24 ATTRIBUTE_MAPPING = [
25 ('ip', '', mapper.Noop),
26 ]
27
28
30 """Resource class for fixed IPs in Compute API v2"""
31
32
34 """Manager class for fixed IPs in Compute API v2"""
35
36 resource_class = Resource
37 service_type = 'compute'
38 _attr_mapping = ATTRIBUTE_MAPPING
39 _hidden_methods = ["create", "list", "update"]
40 _id_attr = 'ip'
41 _json_resource_key = 'fixed_ip'
42 _url_resource_path = '/os-fixed-ips'
43
44 - def get(self, ip=None):
45 """
46 Get information for fixed IP
47
48 @keyword ip: Fixed IP (required)
49 @type ip: str
50 @return: Information of the fixed IP
51 @rtype: str
52 """
53 ret = self._http.get(self._url_resource_path, ip)
54 return ret.get('fixed_ip')
55
57 """
58 Reserve a fixed IP
59
60 @keyword ip: Fixed IP (required)
61 @type ip: str
62 @rtype: None
63 """
64 self._http.post(self._url_resource_path, ip, 'action',
65 data=dict(reserve=None))
66
68 """
69 Release a fixed IP
70
71 @keyword ip: Fixed IP (required)
72 @type ip: str
73 @rtype: None
74 """
75 self._http.post(self._url_resource_path, ip, 'action',
76 data=dict(unreserve=None))
77