import clitool
import inspect
import mc_bin_client
+import memcacheConstants
import sys
-
+import os
def cmd_decorator(f):
"""Decorate a function with code to authenticate based on 1-3
.format(username, bucket))
sys.exit(1)
+ mc.hello("{} {}".format(os.path.split(sys.argv[0])[1],
+ os.getenv("EP_ENGINE_VERSION",
+ "unknown version")))
+
if kwargs.get('allBuckets', None):
buckets = mc.list_buckets()
for bucket in buckets:
self.s.connect_ex((host, port))
self.s.setblocking(0)
self.r=random.Random()
+ self.features = []
def close(self):
self.s.close()
def _cat(self, cmd, key, cas, val):
return self._doCmd(cmd, key, val, '', cas)
+ def hello(self, name):
+ return self._doCmd(memcacheConstants.CMD_HELLO, name,
+ struct.pack('>' + 'H' * len(self.features),
+ *self.features))
+
def append(self, key, value, cas=0):
return self._cat(memcacheConstants.CMD_APPEND, key, cas, value)
# Command constants
CMD_GET = 0
CMD_SET = 1
-CMD_SETQ = 0x11
CMD_ADD = 2
CMD_REPLACE = 3
CMD_DELETE = 4
-CMD_DELETEQ = 0x14
CMD_INCR = 5
CMD_DECR = 6
CMD_QUIT = 7
CMD_GETQ = 9
CMD_NOOP = 10
CMD_VERSION = 11
-CMD_STAT = 0x10
CMD_APPEND = 0x0e
CMD_PREPEND = 0x0f
+CMD_STAT = 0x10
+CMD_SETQ = 0x11
+CMD_DELETEQ = 0x14
CMD_VERBOSE = 0x1b
CMD_TOUCH = 0x1c
CMD_GAT = 0x1d
+CMD_HELLO = 0x1f
CMD_GET_REPLICA = 0x83
CMD_OBSERVE = 0x92
COMMAND_NAMES = dict(((globals()[k], k) for k in globals() if k.startswith("CMD_")))
+# Enableable features
+FEATURE_DATATYPE = 0x01
+FEATURE_TLS = 0x2
+FEATURE_TCPNODELAY = 0x03
+FEATURE_MUTATION_SEQNO = 0x04
+FEATURE_TCPDELAY = 0x05
+FEATURE_XATTR = 0x06
+FEATURE_XERROR = 0x07
+FEATURE_SELECT_BUCKET = 0x08
+FEATURE_COLLECTIONS = 0x09
+
# TAP_OPAQUE types
TAP_OPAQUE_ENABLE_AUTO_NACK = 0
TAP_OPAQUE_INITIAL_VBUCKET_STREAM = 1
#! /bin/sh
+export EP_ENGINE_VERSION="@EP_ENGINE_VERSION@"
+
CWD="`pwd`"
D0="`dirname "$0"`"
cd "$D0/../lib/python"