Esempio n. 1
0
    def _update_gluster_vols_dict(self, context):
        """Update dict of gluster vols that are used/unused."""

        shares = self.db.share_get_all(context)

        # Store the gluster volumes in dict thats helpful to track
        # (push and pop) in future. {gluster_export: gluster_addr, ...}
        # gluster_export is of form hostname:/volname which is unique
        # enough to be used as a key.
        self.gluster_unused_vols_dict = {}
        self.gluster_used_vols_dict = {}

        for gv in self.configuration.glusterfs_targets:
            gaddr = glusterfs.GlusterAddress(gv)
            exp_locn_gv = gaddr.export

            # Assume its unused to begin with.
            self.gluster_unused_vols_dict.update({exp_locn_gv: gaddr})

            for s in shares:
                exp_locn_share = s.get('export_location', None)
                if exp_locn_share == exp_locn_gv:
                    # gluster volume is in use, move it to used list.
                    self.gluster_used_vols_dict.update({exp_locn_gv: gaddr})
                    self.gluster_unused_vols_dict.pop(exp_locn_gv)
                    break
Esempio n. 2
0
 def test_gluster_address_init(self):
     self._gluster_address = glusterfs.GlusterAddress(
         '[email protected]:/testvol')
     self.assertEqual(self._gluster_address.remote_user,
                      gluster_address_attrs['remote_user'])
     self.assertEqual(self._gluster_address.host,
                      gluster_address_attrs['host'])
     self.assertEqual(self._gluster_address.volume,
                      gluster_address_attrs['volume'])
     self.assertEqual(self._gluster_address.qualified,
                      gluster_address_attrs['qualified'])
     self.assertEqual(self._gluster_address.export,
                      gluster_address_attrs['export'])
Esempio n. 3
0
 def test_gluster_address_make_gluster_args_remote(self):
     self._gluster_address = glusterfs.GlusterAddress(
         '[email protected]:/testvol')
     ret = self._gluster_address.make_gluster_args(*self._gluster_args)
     self.assertEqual(len(ret), 2)
     self.assertEqual(len(ret[0]), 3)
     # python 2.6 compat thingy
     check_output = lambda cmd:\
         subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).\
             communicate()[0]
     # shell unescaping thru echo(1)
     self.assertEqual(check_output('echo ' + ' '.join(ret[0]),)[:-1],
                      'ssh [email protected] gluster ' +
                         ' '.join(self._gluster_args))
     self.assertEqual(ret[1], {})
Esempio n. 4
0
 def test_gluster_address_make_gluster_args_local(self):
     self._gluster_address = glusterfs.GlusterAddress(
         '127.0.0.1:/testvol')
     ret = self._gluster_address.make_gluster_args(*self._gluster_args)
     self.assertEqual(ret, (('gluster',) + self._gluster_args,
                            {'run_as_root': True}))