Package yakumo :: Package nova :: Package v2 :: Module interface_attachment
[hide private]
[frames] | no frames]

Source Code for Module yakumo.nova.v2.interface_attachment

 1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>. 
 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  """ 
17  Resource class and its manager for interface attachment in Compute API v2 
18  """ 
19   
20  from yakumo import base 
21  from yakumo.constant import UNDEF 
22  from yakumo import mapper 
23  from yakumo import utils 
24   
25   
26  ATTRIBUTE_MAPPING = [ 
27      ('port', 'port_id', mapper.Resource('port')), 
28      ('id', 'port_id', mapper.Resource('port')), 
29      ('network', 'net_id', mapper.Resource('network')), 
30      ('mac_addr', 'mac_addr', mapper.Noop), 
31      ('fixed_ips', 'fixed_ips', mapper.Noop), 
32      ('status', 'port_state', mapper.Noop), 
33  ] 
34   
35   
36 -class Resource(base.Resource):
37 """Resource class for interface attachment in Compute API v2""" 38
39 - def detach(self):
40 """ 41 Detach a interface 42 43 @rtype: None 44 """ 45 super(Resource, self).delete()
46 47
48 -class Manager(base.SubManager):
49 """Manager class for interface attachment in Compute API v2""" 50 51 resource_class = Resource 52 service_type = 'compute' 53 _attr_mapping = ATTRIBUTE_MAPPING 54 _hidden_methods = ["create", "update", "delete"] 55 _json_resource_key = 'interfaceAttachment' 56 _json_resources_key = 'interfaceAttachments' 57 _url_resource_path = '/servers/%s/os-interface' 58
59 - def attach(self, port=UNDEF, network=UNDEF, fixed_ips=UNDEF):
60 """Attach a interface 61 62 @keyword port: Port 63 @type port: yakumo.neutron.v2.port.Resource 64 @keyword network: Network 65 @type network: yakumo.neutron.v2.network.Resource 66 @keyword fixed_ips: list of fixed ips (required if network= exists) 67 @type fixed_ips: [yakumo.neutron.v2.fixed_ip.Resource] 68 @return: Interface attachment 69 @rtype: yakumo.nova.v2.interface_attachment.Resource 70 """ 71 return super(Manager, self).create(port=port, 72 network=network, 73 fixed_ips=fixed_ips)
74