def test_ceph_related_queens(self):
     self.is_relation_made.return_value = True
     self.get_os_codename_package.return_value = "queens"
     service = 'mycinder'
     self.service_name.return_value = service
     self.assertEqual(
         contexts.CephSubordinateContext()(), {
             "cinder": {
                 "/etc/cinder/cinder.conf": {
                     "sections": {
                         service:
                         [('volume_backend_name', service),
                          ('volume_driver',
                           'cinder.volume.drivers.rbd.RBDDriver'),
                          ('rbd_pool', service), ('rbd_user', service),
                          ('rbd_secret_uuid', 'libvirt-uuid'),
                          ('rbd_ceph_conf',
                           '/var/lib/charm/mycinder/ceph.conf'),
                          ('report_discard_supported', True),
                          ('rbd_exclusive_cinder_pool', True),
                          ('rbd_flatten_volume_from_snapshot', False)]
                     }
                 }
             }
         })
 def test_ceph_explicit_backend_availability_zone(self):
     self.test_config.set('backend-availability-zone', 'special_az')
     self.is_relation_made.return_value = True
     self.get_os_codename_package.return_value = "pike"
     service = 'mycinder'
     self.service_name.return_value = service
     self.assertEqual(
         contexts.CephSubordinateContext()(), {
             "cinder": {
                 "/etc/cinder/cinder.conf": {
                     "sections": {
                         service:
                         [('volume_backend_name', service),
                          ('volume_driver',
                           'cinder.volume.drivers.rbd.RBDDriver'),
                          ('rbd_pool', service), ('rbd_user', service),
                          ('rbd_secret_uuid', 'libvirt-uuid'),
                          ('rbd_ceph_conf',
                           '/var/lib/charm/mycinder/ceph.conf'),
                          ('report_discard_supported', True),
                          ('rbd_exclusive_cinder_pool', True),
                          ('backend_availability_zone', 'special_az')]
                     }
                 }
             }
         })
 def test_ceph_explicit_pool_name_ec(self):
     self.test_config.set('rbd-pool-name', 'special_pool')
     self.test_config.set('pool-type', 'erasure-coded')
     self.is_relation_made.return_value = True
     self.get_os_codename_package.return_value = "mitaka"
     service = 'mycinder'
     self.service_name.return_value = service
     self.assertEqual(
         contexts.CephSubordinateContext()(), {
             "cinder": {
                 "/etc/cinder/cinder.conf": {
                     "sections": {
                         service: [('volume_backend_name', service),
                                   ('volume_driver',
                                    'cinder.volume.drivers.rbd.RBDDriver'),
                                   ('rbd_pool', 'special_pool-metadata'),
                                   ('rbd_user', service),
                                   ('rbd_secret_uuid', 'libvirt-uuid'),
                                   ('rbd_ceph_conf',
                                    '/var/lib/charm/mycinder/ceph.conf'),
                                   ('report_discard_supported', True)]
                     }
                 }
             }
         })
 def test_ceph_related_icehouse(self):
     self.is_relation_made.return_value = True
     self.get_os_codename_package.return_value = "icehouse"
     service = 'mycinder'
     self.service_name.return_value = service
     self.assertEqual(
         contexts.CephSubordinateContext()(), {
             "cinder": {
                 "/etc/cinder/cinder.conf": {
                     "sections": {
                         service: [('volume_backend_name', service),
                                   ('volume_driver',
                                    'cinder.volume.drivers.rbd.RBDDriver'),
                                   ('rbd_pool', service),
                                   ('rbd_user', service),
                                   ('rbd_secret_uuid', 'libvirt-uuid'),
                                   ('rbd_ceph_conf',
                                    '/var/lib/charm/mycinder/ceph.conf')]
                     }
                 }
             }
         })
 def test_ceph_not_related(self):
     self.is_relation_made.return_value = False
     self.assertEqual(contexts.CephSubordinateContext()(), {})