Make cbstats and cbepctl hello 06/75606/13
authorJames Harrison <00jamesh@gmail.com>
Thu, 23 Mar 2017 10:21:02 +0000 (10:21 +0000)
committerDave Rigby <daver@couchbase.com>
Fri, 31 Mar 2017 17:55:29 +0000 (17:55 +0000)
Change-Id: I797304de75220c661ea7a77b1fc8818e8b61340f
Reviewed-on: http://review.couchbase.org/75606
Tested-by: James Harrison <james.harrison@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
management/cli_auth_utils.py
management/mc_bin_client.py
management/memcacheConstants.py
wrapper/wrapper

index 49ba863..e81fb12 100644 (file)
@@ -3,8 +3,9 @@
 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
@@ -33,6 +34,10 @@ def cmd_decorator(f):
                        .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:
index 1ecea51..c4bf548 100644 (file)
@@ -64,6 +64,7 @@ class MemcachedClient(object):
             self.s.connect_ex((host, port))
         self.s.setblocking(0)
         self.r=random.Random()
+        self.features = []
 
     def close(self):
         self.s.close()
@@ -136,6 +137,11 @@ class MemcachedClient(object):
     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)
 
index 799fa03..3720596 100644 (file)
@@ -9,11 +9,9 @@ import struct
 # 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
@@ -21,12 +19,15 @@ CMD_FLUSH = 8
 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
 
@@ -112,6 +113,17 @@ ENGINE_PARAM_VBUCKET    = 5
 
 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
index 50a3faf..2c87ce3 100644 (file)
@@ -1,5 +1,7 @@
 #! /bin/sh
 
+export EP_ENGINE_VERSION="@EP_ENGINE_VERSION@"
+
 CWD="`pwd`"
 D0="`dirname "$0"`"
 cd "$D0/../lib/python"