def test_pdcp_rpdcp(self): nodes = os.environ[var_name] with warnings.catch_warnings(): warnings.simplefilter("ignore") fname = os.tempnam() val = str(uuid.uuid1()) with open(fname, "w") as fd: fd.write(val) try: common.pdcp(nodes, None, fname, fname).communicate() out, err = common.pdsh(nodes, "cat " + fname).communicate() for node in iter_nodes(nodes): self.assertIn("{0}: {1}\n".format(node, val), out) finally: os.unlink(fname) common.rpdcp(nodes, None, fname, os.path.dirname(fname)).communicate() try: with open(fname) as fd: self.assertEqual(fd.read(), val) finally: os.unlink(fname) common.pdsh(nodes, "rm " + fname).communicate()
def distribute_conf(self): nodes = settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws') conf_file = self.config.get("conf_file") logger.info("Distributing %s.", conf_file) common.pdcp(nodes, '', conf_file, self.tmp_conf).communicate() common.pdsh(nodes, 'sudo mv /etc/ceph/ceph.conf /etc/ceph/ceph.conf.cbt.bak').communicate() common.pdsh(nodes, 'sudo ln -s %s /etc/ceph/ceph.conf' % self.tmp_conf).communicate()
def distribute_conf(self): nodes = settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws') conf_file = self.config.get("conf_file") print "Distributing %s." % conf_file common.pdcp(nodes, '', conf_file, self.tmp_conf).communicate() common.pdsh(nodes, 'sudo mv /etc/ceph/ceph.conf /etc/ceph/ceph.conf.cbt.bak').communicate() common.pdsh(nodes, 'sudo ln -s %s /etc/ceph/ceph.conf' % self.tmp_conf).communicate()
def distribute_conf(self): nodes = settings.getnodes("head", "clients", "osds", "mons", "rgws") conf_file = self.config.get("conf_file") print "Distributing %s." % conf_file common.pdcp(nodes, "", conf_file, self.tmp_conf).communicate() common.pdsh(nodes, "sudo mv /etc/ceph/ceph.conf /etc/ceph/ceph.conf.cbt.bak").communicate() common.pdsh(nodes, "sudo ln -s %s /etc/ceph/ceph.conf" % self.tmp_conf).communicate()
def distribute_conf(self): nodes = settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws') conf_file = self.config.get("conf_file") print "Distributing %s." % conf_file common.pdcp(nodes, '', conf_file, self.tmp_conf) common.pdsh(nodes, 'sudo mv /etc/ceph/ceph.conf /etc/ceph/ceph.conf.cbt.bak', True) common.pdsh(nodes, 'sudo ln -s %s /etc/ceph/ceph.conf' % self.tmp_conf)
def distribute_conf(self): nodes = settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs') conf_file = self.config.get("conf_file") logger.info("Distributing %s.", conf_file) common.pdsh(nodes, 'mkdir -p -m0755 /etc/ceph').communicate() common.pdcp(nodes, '', conf_file, self.tmp_conf).communicate() common.pdsh(nodes, 'sudo mv /etc/ceph/ceph.conf /etc/ceph/ceph.conf.cbt.bak').communicate() common.pdsh(nodes, 'sudo ln -s %s /etc/ceph/ceph.conf' % self.tmp_conf).communicate()
def make_mons(self): # Build and distribute the client keyring client_admin_dir = "%s/client.admin" % self.tmp_dir common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'rm -rf %s' % client_admin_dir).communicate() common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'mkdir -p %s' % client_admin_dir).communicate() keyring_fn = os.path.join(client_admin_dir, "keyring") common.pdsh(settings.getnodes('head'), '%s --create-keyring --gen-key --name=mon. %s --cap mon \'allow *\'' % (self.ceph_authtool_cmd, keyring_fn)).communicate() common.pdsh(settings.getnodes('head'), '%s --gen-key --name=client.admin --cap mon \'allow *\' --cap osd \'allow *\' --cap mds \'allow *\' --cap mgr \'allow *\' %s' % (self.ceph_authtool_cmd, keyring_fn)).communicate() common.rscp(settings.getnodes('head'), keyring_fn, '%s.tmp' % keyring_fn).communicate() common.pdcp(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), '', '%s.tmp' % keyring_fn, keyring_fn).communicate() common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'sudo mv %s %s.cbt.bak' % (self.client_keyring, self.client_keyring)).communicate() common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'sudo ln -s %s %s' % (keyring_fn, self.client_keyring)).communicate() common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'sudo mv %s %s.cbt.bak' % (self.client_secret, self.client_secret)).communicate() common.pdsh(settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws', 'mgrs'), 'sudo sh -c \'%s --print-key %s > %s\'' % (self.ceph_authtool_cmd, self.client_keyring, self.client_secret)).communicate() # Build the monmap, retrieve it, and distribute it mons = settings.getnodes('mons').split(',') cmd = 'monmaptool --create --clobber' monhosts = self.get_mon_hosts() logger.info(monhosts) for monhost, mons in monhosts.items(): for mon, addr in mons.items(): cmd = cmd + ' --add %s %s' % (mon, addr) cmd = cmd + ' --print %s' % self.monmap_fn common.pdsh(settings.getnodes('head'), cmd).communicate() common.rscp(settings.getnodes('head'), self.monmap_fn, '%s.tmp' % self.monmap_fn).communicate() common.pdcp(settings.getnodes('mons'), '', '%s.tmp' % self.monmap_fn, self.monmap_fn).communicate() # Build the ceph-mons user = settings.cluster.get('user') for monhost, mons in monhosts.items(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.items(): common.pdsh(monhost, 'sudo rm -rf %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'mkdir -p %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'sudo sh -c "ulimit -c unlimited && exec %s --mkfs -c %s -i %s --monmap=%s --keyring=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.monmap_fn, keyring_fn)).communicate() common.pdsh(monhost, 'cp %s %s/mon.%s/keyring' % (keyring_fn, self.tmp_dir, mon)).communicate() # Start the mons for monhost, mons in monhosts.items(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.items(): pidfile="%s/%s.pid" % (self.pid_dir, monhost) cmd = 'sudo sh -c "ulimit -n 16384 && ulimit -c unlimited && exec %s -c %s -i %s --keyring=%s --pid-file=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, keyring_fn, pidfile) if self.mon_valgrind: cmd = "%s %s" % (common.setup_valgrind(self.mon_valgrind, 'mon.%s' % monhost, self.tmp_dir), cmd) else: cmd = '%s %s' % (self.ceph_run_cmd, cmd) common.pdsh(monhost, 'sudo %s' % cmd).communicate()
def make_mons(self): # Build and distribute the keyring common.pdsh(settings.getnodes('head'), 'ceph-authtool --create-keyring --gen-key --name=mon. %s --cap mon \'allow *\'' % self.keyring_fn).communicate() common.pdsh(settings.getnodes('head'), 'ceph-authtool --gen-key --name=client.admin --set-uid=0 --cap mon \'allow *\' --cap osd \'allow *\' --cap mds allow %s' % self.keyring_fn).communicate() common.rscp(settings.getnodes('head'), self.keyring_fn, '%s.tmp' % self.keyring_fn).communicate() common.pdcp(settings.getnodes('mons', 'osds', 'rgws', 'mds'), '', '%s.tmp' % self.keyring_fn, self.keyring_fn).communicate() # Build the monmap, retrieve it, and distribute it mons = settings.getnodes('mons').split(',') cmd = 'monmaptool --create --clobber' monhosts = settings.cluster.get('mons') logger.info(monhosts) for monhost, mons in monhosts.iteritems(): for mon, addr in mons.iteritems(): cmd = cmd + ' --add %s %s' % (mon, addr) cmd = cmd + ' --print %s' % self.monmap_fn common.pdsh(settings.getnodes('head'), cmd).communicate() common.rscp(settings.getnodes('head'), self.monmap_fn, '%s.tmp' % self.monmap_fn).communicate() common.pdcp(settings.getnodes('mons'), '', '%s.tmp' % self.monmap_fn, self.monmap_fn).communicate() # Build the ceph-mons user = settings.cluster.get('user') for monhost, mons in monhosts.iteritems(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.iteritems(): common.pdsh(monhost, 'sudo rm -rf %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'mkdir -p %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'sudo sh -c "ulimit -c unlimited && exec %s --mkfs -c %s -i %s --monmap=%s --keyring=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.monmap_fn, self.keyring_fn)).communicate() common.pdsh(monhost, 'cp %s %s/mon.%s/keyring' % (self.keyring_fn, self.tmp_dir, mon)).communicate() # Start the mons for monhost, mons in monhosts.iteritems(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.iteritems(): pidfile="%s/%s.pid" % (self.pid_dir, monhost) cmd = 'sudo sh -c "ulimit -n 16384 && ulimit -c unlimited && exec %s -c %s -i %s --keyring=%s --pid-file=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.keyring_fn, pidfile) if self.mon_valgrind: cmd = "%s %s" % (common.setup_valgrind(self.mon_valgrind, 'mon.%s' % monhost, self.tmp_dir), cmd) else: cmd = '%s %s' % (self.ceph_run_cmd, cmd) common.pdsh(monhost, 'sudo %s' % cmd).communicate()
def make_mons(self): # Build and distribute the keyring common.pdsh(settings.getnodes('head'), 'ceph-authtool --create-keyring --gen-key --name=mon. %s --cap mon \'allow *\'' % self.keyring_fn).communicate() common.pdsh(settings.getnodes('head'), 'ceph-authtool --gen-key --name=client.admin --set-uid=0 --cap mon \'allow *\' --cap osd \'allow *\' --cap mds allow %s' % self.keyring_fn).communicate() common.rscp(settings.getnodes('head'), self.keyring_fn, '%s.tmp' % self.keyring_fn).communicate() common.pdcp(settings.getnodes('mons', 'osds', 'rgws', 'mds'), '', '%s.tmp' % self.keyring_fn, self.keyring_fn).communicate() # Build the monmap, retrieve it, and distribute it mons = settings.getnodes('mons').split(',') cmd = 'monmaptool --create --clobber' monhosts = settings.cluster.get('mons') print monhosts for monhost, mons in monhosts.iteritems(): for mon, addr in mons.iteritems(): cmd = cmd + ' --add %s %s' % (mon, addr) cmd = cmd + ' --print %s' % self.monmap_fn common.pdsh(settings.getnodes('head'), cmd).communicate() common.rscp(settings.getnodes('head'), self.monmap_fn, '%s.tmp' % self.monmap_fn).communicate() common.pdcp(settings.getnodes('mons'), '', '%s.tmp' % self.monmap_fn, self.monmap_fn).communicate() # Build the ceph-mons user = settings.cluster.get('user') for monhost, mons in monhosts.iteritems(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.iteritems(): common.pdsh(monhost, 'sudo rm -rf %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'mkdir -p %s/mon.%s' % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, 'sudo sh -c "ulimit -c unlimited && exec %s --mkfs -c %s -i %s --monmap=%s --keyring=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.monmap_fn, self.keyring_fn)).communicate() common.pdsh(monhost, 'cp %s %s/mon.%s/keyring' % (self.keyring_fn, self.tmp_dir, mon)).communicate() # Start the mons for monhost, mons in monhosts.iteritems(): if user: monhost = '%s@%s' % (user, monhost) for mon, addr in mons.iteritems(): pidfile="%s/%s.pid" % (self.pid_dir, monhost) cmd = 'sudo sh -c "ulimit -c unlimited && exec %s -c %s -i %s --keyring=%s --pid-file=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.keyring_fn, pidfile) if self.mon_valgrind: cmd = "%s %s" % (common.setup_valgrind(self.mon_valgrind, 'mon.%s' % monhost, self.tmp_dir), cmd) else: cmd = 'ceph-run %s' % cmd common.pdsh(monhost, 'sudo %s' % cmd).communicate()
def distribute_conf(self): nodes = settings.getnodes('head', 'clients', 'osds', 'mons', 'rgws') conf_file = self.config.get("conf_file") print "Distributing %s." % conf_file common.pdcp(nodes, '', conf_file, self.tmp_conf).communicate()
def make_mons(self): # Build and distribute the keyring common.pdsh( settings.getnodes("head"), "ceph-authtool --create-keyring --gen-key --name=mon. %s --cap mon 'allow *'" % self.keyring_fn, ).communicate() common.pdsh( settings.getnodes("head"), "ceph-authtool --gen-key --name=client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds allow %s" % self.keyring_fn, ).communicate() common.rscp(settings.getnodes("head"), self.keyring_fn, "%s.tmp" % self.keyring_fn).communicate() common.pdcp( settings.getnodes("mons", "osds", "rgws", "mds"), "", "%s.tmp" % self.keyring_fn, self.keyring_fn ).communicate() # Build the monmap, retrieve it, and distribute it mons = settings.getnodes("mons").split(",") cmd = "monmaptool --create --clobber" monhosts = settings.cluster.get("mons") print monhosts for monhost, mons in monhosts.iteritems(): for mon, addr in mons.iteritems(): cmd = cmd + " --add %s %s" % (mon, addr) cmd = cmd + " --print %s" % self.monmap_fn common.pdsh(settings.getnodes("head"), cmd).communicate() common.rscp(settings.getnodes("head"), self.monmap_fn, "%s.tmp" % self.monmap_fn).communicate() common.pdcp(settings.getnodes("mons"), "", "%s.tmp" % self.monmap_fn, self.monmap_fn).communicate() # Build the ceph-mons user = settings.cluster.get("user") for monhost, mons in monhosts.iteritems(): if user: monhost = "%s@%s" % (user, monhost) for mon, addr in mons.iteritems(): common.pdsh(monhost, "sudo rm -rf %s/mon.%s" % (self.tmp_dir, mon)).communicate() common.pdsh(monhost, "mkdir -p %s/mon.%s" % (self.tmp_dir, mon)).communicate() common.pdsh( monhost, 'sudo sh -c "ulimit -c unlimited && exec %s --mkfs -c %s -i %s --monmap=%s --keyring=%s"' % (self.ceph_mon_cmd, self.tmp_conf, mon, self.monmap_fn, self.keyring_fn), ).communicate() common.pdsh(monhost, "cp %s %s/mon.%s/keyring" % (self.keyring_fn, self.tmp_dir, mon)).communicate() # Start the mons for monhost, mons in monhosts.iteritems(): if user: monhost = "%s@%s" % (user, monhost) for mon, addr in mons.iteritems(): pidfile = "%s/%s.pid" % (self.pid_dir, monhost) cmd = 'sudo sh -c "ulimit -c unlimited && exec %s -c %s -i %s --keyring=%s --pid-file=%s"' % ( self.ceph_mon_cmd, self.tmp_conf, mon, self.keyring_fn, pidfile, ) if self.mon_valgrind: cmd = "%s %s" % (common.setup_valgrind(self.mon_valgrind, "mon.%s" % monhost, self.tmp_dir), cmd) else: cmd = "ceph-run %s" % cmd common.pdsh(monhost, "sudo %s" % cmd).communicate()