#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
  Provides info about a particular server.
"""

from usage import usage

import restclient
import simplejson
import subprocess
import sys

class Info:
    def __init__(self):
        self.debug = False

    def runCmd(self, cmd, server, port,
               user, password, opts):
        for (o, a) in opts:
            if o == '-d' or o == '--debug':
                self.debug = True

        rest = restclient.RestClient(server, port, {'debug':self.debug})
        opts = {'error_msg': 'server-info error'}

        data = rest.restCmd('GET', '/nodes/self',
                            user, password, opts)

        json = rest.getJson(data)

        for x in ['license', 'licenseValid', 'licenseValidUntil']:
            if x in json:
                del(json[x])
        if cmd == 'server-eshell':
            p = subprocess.call(['erl','-name','ctl@127.0.0.1',
                '-setcookie',json['otpCookie'],'-hidden','-remsh',json['otpNode']])
        else:
            print simplejson.dumps(json, sort_keys=True, indent=2)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
  Provides info about a particular server.
"""

from usage import usage

import restclient
import simplejson
import subprocess
import sys

from uuid import uuid1

class Info:
    def __init__(self):
        self.debug = False

    def runCmd(self, cmd, server, port,
               user, password, opts):
        for (o, a) in opts:
            if o == '-d' or o == '--debug':
                self.debug = True

        rest = restclient.RestClient(server, port, {'debug':self.debug})
        opts = {'error_msg': 'server-info error'}

        data = rest.restCmd('GET', '/nodes/self',
                            user, password, opts)

        json = rest.getJson(data)

        for x in ['license', 'licenseValid', 'licenseValidUntil']:
            if x in json:
                del(json[x])
        if cmd == 'server-eshell':
            name = 'ctl-%s' % str(uuid1())
            p = subprocess.call(['erl','-name',name,
                '-setcookie',json['otpCookie'],'-hidden','-remsh',json['otpNode']])
        else:
            print simplejson.dumps(json, sort_keys=True, indent=2)

Add uuid to remote shell node name.
Add uuid to remote shell node name.

With this change it's possible to attach several remote shells to the
same cluster. Previously there would be a name conflict.

Change-Id: Ic85f99c8a7c27a80b37ecad994c39557934c7f50
Reviewed-on: http://review.couchbase.org/12365
Tested-by: Aliaksey Artamonau <3c875bcfb3adf2a65b2ae7686ca921e6c9433147@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <340b8e09ca65cd3fc686427fcfed17e87eaf61e2@gmail.com>
