Skip to content

Commit

Permalink
asadm changes (#14)
Browse files Browse the repository at this point in the history
Asadm maintenance

* TOOLS-792 : Include rackaware config in ascollectinfo.log
* Removed unused code from logcontroller
* log-analyser stanza(info, statistics and config) modified to use constants
* TOOLS-798 : Fixed tools package 3.11.0.1 which breaks Nagios/Ganglia script
* asinfo output function modified to avoid unnecessary splitting and joining
* TOOLS-764 : Fix write-dup-res histogram to avoid showing 100%+ in some of the buckets
* Tools-775: Fix Object size access histogram
* TOOLS-755 : Add warning if alumni list doesn't match services list
* TOOLS-806: (asadm) Modify TLS connectivity to check alternate subject names while tls-name matching
* TOOLS-807: (asadm) asadm should not throw TLS related import errors for non-TLS connection
* Add Rackaware-mode column 'info network'
* Fix loglatency output to show proper units
  • Loading branch information
hbpatre authored and citrusraj committed Feb 6, 2017
1 parent 2343989 commit 907deab
Show file tree
Hide file tree
Showing 54 changed files with 992 additions and 461 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
22 changes: 20 additions & 2 deletions asadm-deps/deb/pyOpenSSL/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

PYMODULE=pyOpenSSL
Expand All @@ -24,13 +39,16 @@ if ! command_exists pip ; then
apt-get install -y python-setuptools

echo Installing pip
easy_install pip
apt-get install python-pip

if ! command_exists pip ; then
echo "Error while installing pip. Please install pip and run this installation again."
exit 1
fi
fi

echo Installing build-essential libssl-dev libffi-dev
apt-get install build-essential libssl-dev libffi-dev

echo Installing ${PYMODULE}
pip install ${PYMODULE} --upgrade
pip install --upgrade ${PYMODULE}
15 changes: 15 additions & 0 deletions asadm-deps/deb/zip/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

command_exists () {
Expand Down
15 changes: 15 additions & 0 deletions asadm-deps/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

if [ $EUID -ne 0 ]; then
Expand Down
15 changes: 15 additions & 0 deletions asadm-deps/mac/pyOpenSSL/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

PYMODULE=pyOpenSSL
Expand Down
15 changes: 15 additions & 0 deletions asadm-deps/mac/zip/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

command_exists () {
Expand Down
20 changes: 19 additions & 1 deletion asadm-deps/rpm/pyOpenSSL/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

PYMODULE=pyOpenSSL
Expand Down Expand Up @@ -36,5 +51,8 @@ if ! command_exists ${pip_command} ; then
exit 1
fi
fi
echo Installing gcc libffi-devel python-devel openssl-devel
yum install gcc libffi-devel python-devel openssl-devel

echo Installing ${PYMODULE}
${pip_command} install ${PYMODULE} --upgrade
${pip_command} install --upgrade ${PYMODULE}
15 changes: 15 additions & 0 deletions asadm-deps/rpm/zip/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env bash

# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################

command_exists () {
Expand Down
41 changes: 25 additions & 16 deletions asadm.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/env python

# Copyright 2013-2016 Aerospike, Inc.
# Copyright 2013-2017 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import readline
import cmd
import getpass
import shlex
Expand Down Expand Up @@ -50,12 +49,14 @@ def __init__(self, seed, telnet, user=None, password=None, use_services=True, lo
except Exception as ctrle:
print terminal.fg_red() + "Exception while creating controller: " + str(ctrle) + terminal.fg_clear()
self.do_exit('')
exit(0)
exit(1)

try:
readline.read_history_file(ADMINHIST)
except Exception:
readline.write_history_file(ADMINHIST)
if not execute_only_mode:
import readline
try:
readline.read_history_file(ADMINHIST)
except Exception:
readline.write_history_file(ADMINHIST)

self.prompt = "Admin> "
if self.use_rawinput:
Expand All @@ -73,11 +74,15 @@ def __init__(self, seed, telnet, user=None, password=None, use_services=True, lo
if log_path:
self.intro += terminal.fg_red() + ">>>>> -l not specified -f ignored. Running in normal asadm mode. Use -l for log analyser mode !! <<<<< \n" + terminal.fg_clear()
log_path = ""
self.intro += str(self.ctrl.cluster) + "\n"
cluster_visibility_error_nodes = self.ctrl.cluster.getClusterVisibilityErrorNodes()
if cluster_visibility_error_nodes:
self.intro += terminal.fg_red() + "Cluster Visibility error (Please check services list): %s"%(", ".join(cluster_visibility_error_nodes)) + terminal.fg_clear() + "\n"
if not execute_only_mode:
self.intro += str(self.ctrl.cluster) + "\n"
cluster_visibility_error_nodes = self.ctrl.cluster.getVisibilityErrorNodes()
if cluster_visibility_error_nodes:
self.intro += terminal.fg_red() + "Cluster Visibility error (Please check services list): %s"%(", ".join(cluster_visibility_error_nodes)) + terminal.fg_clear() + "\n"

cluster_down_nodes = self.ctrl.cluster.getDownNodes()
if cluster_down_nodes:
self.intro += terminal.fg_red() + "Extra nodes in alumni list: %s"%(", ".join(cluster_down_nodes)) + terminal.fg_clear() + "\n"

if not self.ctrl.cluster.getLiveNodes():
if execute_only_mode:
Expand Down Expand Up @@ -128,6 +133,7 @@ def cleanLine(self, line):

def precmd(self, line, max_commands_to_print_header=1, command_index_to_print_from=1):
lines = None

try:
lines = self.cleanLine(line)

Expand Down Expand Up @@ -278,6 +284,7 @@ def close(self):
# Other
def do_exit(self, line):
self.close()
import readline
readline.write_history_file(ADMINHIST)
print "\nConfig files location: " + str(ADMINHOME)
return True
Expand Down Expand Up @@ -338,7 +345,7 @@ def parse_tls_input(cli_args):
cipher_suite=cli_args.cipher_suite, cert_blacklist=cli_args.cert_blacklist,
crl_check=cli_args.crl_check, crl_check_all=cli_args.crl_check_all).ctx
except Exception as e:
print terminal.fg_red() + "Wrong TLS inputs: " + str(e) + terminal.fg_clear()
print terminal.fg_red() + "SSLContext creation Exception: " + str(e) + terminal.fg_clear()
exit(1)


Expand Down Expand Up @@ -431,7 +438,7 @@ def main():
parser.add_argument("--tls_protocols"
, dest="protocols"
, help="Set the TLS protocol selection criteria. This format is the same as Apache's SSLProtocol documented "
"at https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol"
"at https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol . "
"If not specified the asadm will use '-all +TLSv1.2' if has support for TLSv1.2,"
"otherwise it will be '-all +TLSv1'.")
parser.add_argument("--tls_cipher_suite"
Expand Down Expand Up @@ -553,7 +560,7 @@ def main():
parser.add_option("--tls_protocols"
, dest="protocols"
, help="Set the TLS protocol selection criteria. This format is the same as Apache's SSLProtocol documented "
"at https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol"
"at https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol . "
"If not specified the asadm will use '-all +TLSv1.2' if has support for TLSv1.2,"
"otherwise it will be '-all +TLSv1'.")
parser.add_option("--tls_cipher_suite"
Expand Down Expand Up @@ -642,7 +649,9 @@ def main():
execute_only_mode = True

ssl_context = parse_tls_input(cli_args)
readline.set_completer_delims(' \t\n;')
if not execute_only_mode:
import readline
readline.set_completer_delims(' \t\n;')
shell = AerospikeShell(seed, telnet, user=user, password=password, use_services=use_services, log_path=log_path,
log_analyser=log_analyser, ssl_context=ssl_context, only_connect_seed=only_connect_seed, execute_only_mode=execute_only_mode)

Expand Down
2 changes: 1 addition & 1 deletion lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
18 changes: 13 additions & 5 deletions lib/assocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -16,9 +16,14 @@
from lib.info import authenticate, info
import socket
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from OpenSSL import SSL

try:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from OpenSSL import SSL
HAVE_PYOPENSSL = True
except ImportError:
HAVE_PYOPENSSL = False

class ASSocket:
def __init__(self, node, ip, port, pool_size=3):
Expand All @@ -30,7 +35,10 @@ def __init__(self, node, ip, port, pool_size=3):

def _wrap_socket(self, sock, ctx):
if ctx:
sock = SSL.Connection(ctx, sock)
if HAVE_PYOPENSSL:
sock = SSL.Connection(ctx, sock)
else:
raise ImportError("No module named pyOpenSSL")

return sock

Expand Down
Loading

0 comments on commit 907deab

Please sign in to comment.