Commit 897382a9 authored by Filippos Giannakos's avatar Filippos Giannakos

Fix imports in vlmc tool

parent 4ab3ce85
......@@ -37,15 +37,15 @@
from xseg.xseg_api import *
from xseg.xprotocol import *
from ctypes import CFUNCTYPE, cast, c_void_p, addressof, string_at, memmove, \
create_string_buffer, pointer, sizeof, POINTER, c_char_p, c_char, byref
create_string_buffer, pointer, sizeof, POINTER, c_char_p, c_char, byref, \
c_uint32, c_uint64
cb_null_ptrtype = CFUNCTYPE(None, uint32_t)
import os, sys, subprocess, argparse, time, psutil, signal, errno
from subprocess import call, check_call, Popen, PIPE
from collections import namedtuple
import struct
import binascii
import ctypes
from struct import unpack
from binascii import hexlify
#archipelago peer roles. Order matters!
roles = ['blockerb', 'blockerm', 'mapperd', 'vlmcd']
......@@ -60,6 +60,7 @@ PID_SUFFIX='.pid'
DEFAULTS='/etc/default/archipelago'
VLMC_LOCK_FILE='vlmc.lock'
ARCHIP_PREFIX='archip_'
CEPH_CONF_FILE='/etc/ceph/ceph.conf'
#system defaults
PIDFILE_PATH="/var/run/archipelago"
......@@ -84,17 +85,17 @@ available_storage = {'files': FILE_BLOCKER, 'rados': RADOS_BLOCKER}
XSEGBD_START=0
XSEGBD_END=199
VPORT_START=200
VPORT_END=399
BPORT=500
MPORT=501
MBPORT=502
VTOOL=503
#RESERVED 511
XSEGBD_END=499
VPORT_START=500
VPORT_END=999
BPORT=1000
MPORT=1001
MBPORT=1002
VTOOL=1003
#RESERVED 1023
#default config
SPEC="segdev:xsegbd:512:5120:12"
SPEC="segdev:xsegbd:1024:5120:12"
NR_OPS_BLOCKERB=""
NR_OPS_BLOCKERM=""
......@@ -959,7 +960,7 @@ def vlmc_list(args):
for o in oi :
name = o.key
if name.startswith(ARCHIP_PREFIX) and not name.endswith('_lock'):
print name.lstrip(ARCHIP_PREFIX)
print name[len(ARCHIP_PREFIX):]
elif STORAGE == "files":
raise Error("Vlmc list not supported for files yet")
else:
......@@ -1197,30 +1198,35 @@ def vlmc_mapinfo(args):
if STORAGE == "rados":
import rados
cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
cluster = rados.Rados(conffile=CEPH_CONF_FILE)
cluster.connect()
ioctx = cluster.open_ioctx(RADOS_POOL_MAPS)
BLOCKSIZE = 4*1024*1024
mapdata = ioctx.read(ARCHIP_PREFIX + name, length=BLOCKSIZE)
try:
mapdata = ioctx.read(ARCHIP_PREFIX + name, length=BLOCKSIZE)
except Exception:
raise Error("Cannot read map data")
if not mapdata:
raise Error("Cannot read map data")
pos = 0
size_uint32t = ctypes.sizeof(ctypes.c_uint32)
version = struct.unpack("<L", mapdata[pos:pos+size_uint32t])[0]
size_uint32t = sizeof(c_uint32)
version = unpack("<L", mapdata[pos:pos+size_uint32t])[0]
pos += size_uint32t
size_uint64t = ctypes.sizeof(ctypes.c_uint64)
size = struct.unpack("Q", mapdata[pos:pos+size_uint64t])[0]
size_uint64t = sizeof(c_uint64)
size = unpack("Q", mapdata[pos:pos+size_uint64t])[0]
pos += size_uint64t
blocks = size / BLOCKSIZE
nr_exists = 0
print ""
print "Volume: " + name
print "Version: " + str(version)
print "Size: " + str(size)
for i in range(blocks):
exists = bool(struct.unpack("B", mapdata[pos:pos+1])[0])
exists = bool(unpack("B", mapdata[pos:pos+1])[0])
if exists:
nr_exists += 1
pos += 1
block = binascii.hexlify(mapdata[pos:pos+32])
block = hexlify(mapdata[pos:pos+32])
pos += 32
if args.verbose:
print block, exists
......@@ -1369,9 +1375,6 @@ if __name__ == "__main__":
args.func(args)
sys.exit(0)
except Error as e:
if os.environ['TERM']:
print red(e)
else:
print e
print red(e)
sys.exit(-1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment