本文整理汇总了Python中lib.remote.remote_util.RemoteMachineShellConnection.extract_remote_info方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteMachineShellConnection.extract_remote_info方法的具体用法?Python RemoteMachineShellConnection.extract_remote_info怎么用?Python RemoteMachineShellConnection.extract_remote_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.remote.remote_util.RemoteMachineShellConnection
的用法示例。
在下文中一共展示了RemoteMachineShellConnection.extract_remote_info方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def run(self):
remote_client = RemoteMachineShellConnection(self.server)
now = datetime.now()
day = now.day
month = now.month
year = now.year
hour = now.timetuple().tm_hour
minute = now.timetuple().tm_min
file_name = "%s-%s%s%s-%s%s-couch.tar.gz" % (self.server.ip, month, day, year, hour, minute)
print "Collecting data files from %s\n" % self.server.ip
remote_client.extract_remote_info()
data_path = self.__get_data_path(os_type=remote_client.info.type.lower())
output, error = remote_client.execute_command(
"tar -zcvf {0} '{1}' >/dev/null 2>&1".format(file_name, data_path)
)
print "\n".join(output)
print "\n".join(error)
user_path = "/home/"
if self.server.ssh_username == "root":
user_path = "/"
remote_path = "%s%s" % (user_path, self.server.ssh_username)
status = remote_client.file_exists(remote_path, file_name)
if not status:
raise Exception("%s doesn't exists on server" % file_name)
status = remote_client.get_file(remote_path, file_name, "%s/%s" % (self.path, file_name))
if not status:
raise Exception("Fail to download zipped logs from %s" % self.server.ip)
remote_client.execute_command("rm -f %s" % os.path.join(remote_path, file_name))
remote_client.disconnect()
示例2: convert_to_hostname
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def convert_to_hostname(self, servers_with_hostnames, username='Administrator', password='password'):
try:
hostname = []
for server in servers_with_hostnames:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
domain = ''.join(info.domain[0])
if not domain:
output = shell.execute_command_raw('nslookup %s' % info.hostname[0])
print output
self.fail("Domain is not defined, couchbase cannot be configured correctly. NOT A BUG. CONFIGURATION ISSUE")
hostname.append(info.hostname[0] + "." + domain)
master_rest = RestConnection(server)
current_hostname = master_rest.get_nodes_self().hostname
self.log.info("get_node_self function returned : {0}".format(current_hostname))
if server.ip in current_hostname:
self.log.info("Node {0} is referred via IP. Need to be referred with hostname. Changing the name of the node!!".format(server.ip))
version = RestConnection(server).get_nodes_self().version
if version.startswith("1.8.1") or version.startswith("2.0.0") or version.startswith("2.0.1"):
RemoteUtilHelper.use_hostname_for_server_settings(server)
master_rest.init_cluster()
else:
master_rest.init_cluster()
master_rest.rename_node(username=username, password=password, port='', hostname=hostname[-1])
else:
self.log.info("Node {0} already referred via hostname. No need to convert the name".format(server.ip))
finally:
shell.disconnect()
return hostname
示例3: create_and_restore_csv
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def create_and_restore_csv(self):
try:
self.__load_data()
shell_obj = RemoteMachineShellConnection(self.master)
self.log.info("Removing backup folder if already present")
info = shell_obj.extract_remote_info()
path = "/tmp/backup/"
if info.type.lower() == "windows":
path = "/cygdrive/c" + path
#TODO : Check for mac also
shell_obj.delete_files(path)
create_dir = "mkdir " + path
data_type = "csv:"
destination = path + "data.csv"
shell_obj.execute_command(create_dir)
source = "http://localhost:8091"
options = "-b default" + self.username_arg + self.password_arg
shell_obj.execute_cbtransfer(source, data_type + destination, options)
self.log.info("Created csv file @ %s" % destination)
source, destination = destination, source
options = "-B standard_bucket0" + self.username_arg + self.password_arg
self.log.info("Restoring data....!")
shell_obj.execute_cbtransfer(source, destination, options)
self.sleep(10)
self.log.info("Checking whether number of items loaded match with the number of items restored.")
rest = RestConnection(self.master)
itemCount = rest.get_bucket_json('standard_bucket0')['basicStats']['itemCount']
self.assertEqual(itemCount, self.num_items, msg="Number of items loaded do no match\
with the number of items restored. Number of items loaded is {0} \
but number of items restored is {1}".format(self.num_items, itemCount))
self.log.info("Number of items loaded = Number of items restored. Pass!!")
finally:
shell_obj.disconnect()
示例4: convert_to_hostname
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def convert_to_hostname(self, servers_with_hostnames):
try:
hostname = []
for server in servers_with_hostnames:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
domain = ''.join(info.domain[0])
hostname.append(info.hostname[0] + "." + domain)
master_rest = RestConnection(server)
var = master_rest.get_nodes_self().hostname
flag = True if server.ip in var else False
self.log.info("get_node_self function returned : {0}".format(var))
if flag:
self.log.info("Node {0} is referred via IP. Need to be referred with hostname. Changing the name of the node!!".format(server.ip))
version = RestConnection(server).get_nodes_self().version
if version.startswith("1.8.1") or version.startswith("2.0.0") or version.startswith("2.0.1"):
RemoteUtilHelper.use_hostname_for_server_settings(server)
obj = RestConnection(server)
obj.init_cluster()
else:
obj = RestConnection(server)
obj.init_cluster()
var = master_rest.rename_node(username='Administrator', password='password', port='', hostname=hostname[-1])
else:
self.log.info("Node {0} already referred via hostname. No need to convert the name".format(server.ip))
finally:
shell.disconnect()
return hostname
示例5: kill_erlang_service
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def kill_erlang_service(self, server):
remote_client = RemoteMachineShellConnection(server)
os_info = remote_client.extract_remote_info()
log.info("os_info : {0}", os_info)
if os_info.type.lower() == "windows":
remote_client.kill_erlang(os="windows")
else:
remote_client.kill_erlang()
remote_client.start_couchbase()
remote_client.disconnect()
# wait for restart and warmup on all node
self.sleep(self.wait_timeout * 2)
# wait till node is ready after warmup
ClusterOperationHelper.wait_for_ns_servers_or_assert([server], self, wait_if_warmup=True)
示例6: check_eventing_logs_for_panic
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def check_eventing_logs_for_panic(self):
self.generate_map_nodes_out_dist()
panic_str = "panic"
eventing_nodes = self.get_nodes_from_services_map(service_type="eventing", get_all_nodes=True)
if not eventing_nodes:
return None
for eventing_node in eventing_nodes:
shell = RemoteMachineShellConnection(eventing_node)
_, dir_name = RestConnection(eventing_node).diag_eval(
'filename:absname(element(2, application:get_env(ns_server,error_logger_mf_dir))).')
eventing_log = str(dir_name) + '/eventing.log*'
count, err = shell.execute_command("zgrep \"{0}\" {1} | wc -l".
format(panic_str, eventing_log))
if isinstance(count, list):
count = int(count[0])
else:
count = int(count)
if count > self.panic_count:
log.info("===== PANIC OBSERVED IN EVENTING LOGS ON SERVER {0}=====".format(eventing_node.ip))
panic_trace, _ = shell.execute_command("zgrep \"{0}\" {1}".
format(panic_str, eventing_log))
log.info("\n {0}".format(panic_trace))
self.panic_count = count
os_info = shell.extract_remote_info()
if os_info.type.lower() == "windows":
# This is a fixed path in all windows systems inside couchbase
dir_name_crash = 'c://CrashDumps'
else:
dir_name_crash = str(dir_name) + '/../crash/'
core_dump_count, err = shell.execute_command("ls {0}| wc -l".format(dir_name_crash))
if isinstance(core_dump_count, list):
core_dump_count = int(core_dump_count[0])
else:
core_dump_count = int(core_dump_count)
if core_dump_count > 0:
log.info("===== CORE DUMPS SEEN ON EVENTING NODES, SERVER {0} : {1} crashes seen =====".format(
eventing_node.ip, core_dump_count))
shell.disconnect()
示例7: machine_info
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
def machine_info(node):
shell = RemoteMachineShellConnection(node)
info = shell.extract_remote_info()
return {"type": info.type, "distribution": info.distribution_type,
"version": info.distribution_version, "ram": info.ram,
"cpu": info.cpu, "disk": info.disk, "hostname": info.hostname}
示例8: HostnameTests
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import extract_remote_info [as 别名]
class HostnameTests(BaseTestCase):
def setUp(self):
super(HostnameTests, self).setUp()
self.builds = self.input.param("builds", "2.2.0")
self.product = self.input.param('product', 'couchbase-server')
self.is_negative_test = self.input.param('is_negative_test', False)
self.error = self.input.param('error', '')
self.name = self.input.param('name', '')
def tearDown(self):
super(HostnameTests, self).tearDown()
for server in self.servers:
self.assertTrue(RestHelper(RestConnection(server)).is_ns_server_running(timeout_in_seconds=480),
msg="ns server is not running even after waiting for 6 minutes")
self.log.info("sleep for 10 seconds to give enough time for other nodes to restart")
self.sleep(10)
def install_builds(self, builds, servers=None):
params = {}
params['product'] = 'couchbase-server'
builds_list = builds.split(";")
st = 0
end = 1
if None in servers:
servers_to_install = self.servers
else:
servers_to_install = servers
for i in builds_list:
params['version'] = i
InstallerJob().sequential_install(servers_to_install[st:end], params)
st = st + 1
end = end + 1
self.sleep(20)
super(HostnameTests, self).setUp()
def rest_api_addNode(self):
hostnames = self.convert_to_hostname(self, self.servers[0:2])
master_rest = RestConnection(self.master)
master_rest.add_node(self.servers[1].rest_username, self.servers[1].rest_password, hostnames[1], self.servers[1].port)
#Now check whether the node which we added is still referred via hostname or not.
obj = RestConnection(self.servers[1])
var = obj.get_nodes_self().hostname
flag = True if self.servers[1].ip in var else False
self.assertEqual(flag, False, msg="Fail - Name of node {0} got converted to IP. Failing the test!!!".format(self.servers[1].ip))
self.log.info("Test Passed!!")
self.sleep(10)
#Cases 39 and 40 from hostname management test plan combined.
def rest_api_renameNode(self):
try:
self.shell = RemoteMachineShellConnection(self.master)
#com_inst_build = "cat /opt/couchbase/VERSION.txt"
#out = self.shell.execute_command(com_inst_build.format(com_inst_build))
self.install_builds(self.builds, self.servers[0:1])
if self.is_negative_test:
master_rest = RestConnection(self.master)
self.log.info("Renaming node {0} to {1}".format(self.master, self.name))
var = master_rest.rename_node(username=self.master.rest_username, password=self.master.rest_password,
port=self.master.port, hostname=self.name, is_negative_test=True)
out = var.pop()
self.assertEqual(out, self.error, msg="Fail to find correct error. The error should be {0}, but we got : {1}".format(self.error, out))
self.log.info("Got correct error - {0}....Passing the test".format(out))
else:
self.log.info("Node {0} is referred via IP. Changing the name of the node".format(self.servers[0:1]))
hostname = []
info = self.shell.extract_remote_info()
domain = ''.join(info.domain[0])
hostname.append(info.hostname[0] + "." + domain)
self.convert_to_hostname(self, self.servers[0:1])
self.log.info("Calling get_node_self() to check the status of node {0}".format(self.servers[0:1]))
obj = RestConnection(self.master)
var = obj.get_nodes_self().hostname
flag = True if self.master.ip in var else False
self.assertEqual(flag, False, msg="Fail - Node {0} is still referred via IP. Should\
have been referred via hostname. Failing the test!".format(self.master.ip))
self.log.info("Name of node {0} got converted to hostname. Proceeding......!".format(self.master.ip))
self.sleep(10)
self.log.info("Now changing name of node {0} from hostname to IP".format(self.master.ip))
var = obj.rename_node(username='Administrator', password='password', port='', hostname=self.master.ip)
self.log.info("Calling get_node_self() to check the status of the node {0}".format(self.master.ip))
var = obj.get_nodes_self().hostname
flag = True if self.master.ip in var else False
self.assertEqual(flag, True, msg="Fail - Node {0} is still referred via hostname. Should have been referred via IP. Failing the test!".format(self.master.ip))
self.log.info("Node {0} referred via IP. Pass !".format(self.master.ip))
finally:
self.shell.disconnect()
@staticmethod
def convert_to_hostname(self, servers_with_hostnames, username='Administrator', password='password'):
try:
hostname = []
for server in servers_with_hostnames:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
domain = ''.join(info.domain[0])
if not domain:
output = shell.execute_command_raw('nslookup %s' % info.hostname[0])
print output
#.........这里部分代码省略.........