def test_stringify(self): img = imgmodel.RBDImage("demo", "openstack", "cthulu", "braanes", ["rbd.example.org"]) msg = str(img) self.assertEqual(msg.find("braanes"), -1) self.assertNotEqual(msg.find("***"), -1)
def test_rbd_image(self): img = imgmodel.RBDImage("demo", "openstack", "cthulu", "braanes", ["rbd.example.org"]) self.assertIsInstance(img, imgmodel.Image) self.assertEqual("demo", img.name) self.assertEqual("openstack", img.pool) self.assertEqual("cthulu", img.user) self.assertEqual("braanes", img.password) self.assertEqual(["rbd.example.org"], img.servers) self.assertEqual(imgmodel.FORMAT_RAW, img.format)
def get_model(self, connection): secret = None if CONF.libvirt.rbd_secret_uuid: secretobj = connection.secretLookupByUUIDString( CONF.libvirt.rbd_secret_uuid) secret = base64.b64encode(secretobj.value()) hosts, ports = self.driver.get_mon_addrs() servers = [str(':'.join(k)) for k in zip(hosts, ports)] return imgmodel.RBDImage(self.rbd_name, self.pool, self.rbd_user, secret, servers)
def setUp(self): super(VirtDiskVFSGuestFSTest, self).setUp() self.useFixture( fixtures.MonkeyPatch('nova.virt.disk.vfs.guestfs.guestfs', fakeguestfs)) self.qcowfile = imgmodel.LocalFileImage("/dummy.qcow2", imgmodel.FORMAT_QCOW2) self.rawfile = imgmodel.LocalFileImage("/dummy.img", imgmodel.FORMAT_RAW) self.lvmfile = imgmodel.LocalBlockImage("/dev/volgroup/myvol") self.rbdfile = imgmodel.RBDImage("myvol", "mypool", "cthulu", "arrrrrgh", ["server1:123", "server2:123"])
def get_model(self, connection): secret = None if CONF.libvirt.rbd_secret_uuid: secretobj = connection.secretLookupByUUIDString( CONF.libvirt.rbd_secret_uuid) secret = base64.b64encode(secretobj.value()) # Brackets are stripped from IPv6 addresses normally for libvirt XML, # but the servers list is for libguestfs, which needs the brackets # so the joined string is similar to '[::1]:6789' hosts, ports = self.driver.get_mon_addrs(strip_brackets=False) servers = [str(':'.join(k)) for k in zip(hosts, ports)] return imgmodel.RBDImage(self.rbd_name, self.driver.pool, self.driver.rbd_user, secret, servers)