@@ -193,6 +193,65 @@ def create_services(attrs=None, count=2):
193193 return services
194194
195195
196+ class FakeCapability (object ):
197+ """Fake capability."""
198+
199+ @staticmethod
200+ def create_one_capability (attrs = None ):
201+ """Create a fake volume backend capability.
202+
203+ :param Dictionary attrs:
204+ A dictionary with all attributes of the Capabilities.
205+ :return:
206+ A FakeResource object with capability name and attrs.
207+ """
208+ # Set default attribute
209+ capability_info = {
210+ "namespace" : "OS::Storage::Capabilities::fake" ,
211+ "vendor_name" : "OpenStack" ,
212+ "volume_backend_name" : "lvmdriver-1" ,
213+ "pool_name" : "pool" ,
214+ "driver_version" : "2.0.0" ,
215+ "storage_protocol" : "iSCSI" ,
216+ "display_name" : "Capabilities of Cinder LVM driver" ,
217+ "description" : "Blah, blah." ,
218+ "visibility" : "public" ,
219+ "replication_targets" : [],
220+ "properties" : {
221+ "compression" : {
222+ "title" : "Compression" ,
223+ "description" : "Enables compression." ,
224+ "type" : "boolean"
225+ },
226+ "qos" : {
227+ "title" : "QoS" ,
228+ "description" : "Enables QoS." ,
229+ "type" : "boolean"
230+ },
231+ "replication" : {
232+ "title" : "Replication" ,
233+ "description" : "Enables replication." ,
234+ "type" : "boolean"
235+ },
236+ "thin_provisioning" : {
237+ "title" : "Thin Provisioning" ,
238+ "description" : "Sets thin provisioning." ,
239+ "type" : "boolean"
240+ }
241+ }
242+ }
243+
244+ # Overwrite default attributes if there are some attributes set
245+ capability_info .update (attrs or {})
246+
247+ capability = fakes .FakeResource (
248+ None ,
249+ capability_info ,
250+ loaded = True )
251+
252+ return capability
253+
254+
196255class FakeVolumeClient (object ):
197256
198257 def __init__ (self , ** kwargs ):
@@ -233,6 +292,8 @@ def __init__(self, **kwargs):
233292 self .cgsnapshots .resource_class = fakes .FakeResource (None , {})
234293 self .auth_token = kwargs ['token' ]
235294 self .management_url = kwargs ['endpoint' ]
295+ self .capabilities = mock .Mock ()
296+ self .capabilities .resource_class = fakes .FakeResource (None , {})
236297
237298
238299class TestVolume (utils .TestCommand ):
0 commit comments