@@ -172,30 +172,64 @@ def create_one_port(attrs={}, methods={}):
172172 :param Dictionary methods:
173173 A dictionary with all methods
174174 :return:
175- A FakeResource object, with id, name, admin_state_up,
176- status, tenant_id
175+ A FakeResource object, with id, name, etc.
177176 """
177+
178178 # Set default attributes.
179179 port_attrs = {
180+ 'admin_state_up' : True ,
181+ 'allowed_address_pairs' : [{}],
182+ 'binding:host_id' : 'binding-host-id-' + uuid .uuid4 ().hex ,
183+ 'binding:profile' : {},
184+ 'binding:vif_details' : {},
185+ 'binding:vif_type' : 'ovs' ,
186+ 'binding:vnic_type' : 'normal' ,
187+ 'device_id' : 'device-id-' + uuid .uuid4 ().hex ,
188+ 'device_owner' : 'compute:nova' ,
189+ 'dns_assignment' : [{}],
190+ 'dns_name' : 'dns-name-' + uuid .uuid4 ().hex ,
191+ 'extra_dhcp_opts' : [{}],
192+ 'fixed_ips' : [{}],
180193 'id' : 'port-id-' + uuid .uuid4 ().hex ,
194+ 'mac_address' : 'fa:16:3e:a9:4e:72' ,
181195 'name' : 'port-name-' + uuid .uuid4 ().hex ,
196+ 'network_id' : 'network-id-' + uuid .uuid4 ().hex ,
197+ 'port_security_enabled' : True ,
198+ 'security_groups' : [],
182199 'status' : 'ACTIVE' ,
183- 'admin_state_up' : True ,
184200 'tenant_id' : 'project-id-' + uuid .uuid4 ().hex ,
185201 }
186202
187203 # Overwrite default attributes.
188204 port_attrs .update (attrs )
189205
190206 # Set default methods.
191- port_methods = {}
207+ port_methods = {
208+ 'keys' : ['admin_state_up' , 'allowed_address_pairs' ,
209+ 'binding:host_id' , 'binding:profile' ,
210+ 'binding:vif_details' , 'binding:vif_type' ,
211+ 'binding:vnic_type' , 'device_id' , 'device_owner' ,
212+ 'dns_assignment' , 'dns_name' , 'extra_dhcp_opts' ,
213+ 'fixed_ips' , 'id' , 'mac_address' , 'name' ,
214+ 'network_id' , 'port_security_enabled' ,
215+ 'security_groups' , 'status' , 'tenant_id' ],
216+ }
192217
193218 # Overwrite default methods.
194219 port_methods .update (methods )
195220
196221 port = fakes .FakeResource (info = copy .deepcopy (port_attrs ),
197222 methods = copy .deepcopy (port_methods ),
198223 loaded = True )
224+
225+ # Set attributes with special mappings.
226+ port .project_id = port_attrs ['tenant_id' ]
227+ port .binding_host_id = port_attrs ['binding:host_id' ]
228+ port .binding_profile = port_attrs ['binding:profile' ]
229+ port .binding_vif_details = port_attrs ['binding:vif_details' ]
230+ port .binding_vif_type = port_attrs ['binding:vif_type' ]
231+ port .binding_vnic_type = port_attrs ['binding:vnic_type' ]
232+
199233 return port
200234
201235 @staticmethod
0 commit comments