本文整理汇总了Python中lib.remote.remote_util.RemoteMachineShellConnection.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteMachineShellConnection.disconnect方法的具体用法?Python RemoteMachineShellConnection.disconnect怎么用?Python RemoteMachineShellConnection.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.remote.remote_util.RemoteMachineShellConnection
的用法示例。
在下文中一共展示了RemoteMachineShellConnection.disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [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 disconnect [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
示例3: convert_to_hostname
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [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
示例4: _save_snapshot
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def _save_snapshot(self, server, bucket, file_base=None):
"""Save data files to a snapshot"""
src_data_path = os.path.dirname(server.data_path or
testconstants.COUCHBASE_DATA_PATH)
dest_data_path = "{0}-snapshots".format(src_data_path)
self.log.info("server={0}, src_data_path={1}, dest_data_path={2}"
.format(server.ip, src_data_path, dest_data_path))
shell = RemoteMachineShellConnection(server)
build_name, short_version, full_version = \
shell.find_build_version("/opt/couchbase/", "VERSION.txt", "cb")
dest_file = self._build_tar_name(bucket, full_version, file_base)
self._exec_and_log(shell, "mkdir -p {0}".format(dest_data_path))
# save as gzip file, if file exsits, overwrite
# TODO: multiple buckets
zip_cmd = "cd {0}; tar -cvzf {1}/{2} {3} {3}-data _*"\
.format(src_data_path, dest_data_path, dest_file, bucket)
self._exec_and_log(shell, zip_cmd)
shell.disconnect()
return True
示例5: run
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [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
min = now.timetuple().tm_min
file_name = "%s-%s%s%s-%s%s-diag.zip" % (self.server.ip,
month, day, year, hour, min)
print "Collecting logs from %s\n" % self.server.ip
output, error = remote_client.execute_cbcollect_info(file_name)
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 status:
print "Downloading zipped logs from %s" % self.server.ip
else:
raise Exception("Fail to download zipped logs from %s"
% self.server.ip)
remote_client.disconnect()
示例6: run
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def run(self):
file_name = "%s-%s-diag.zip" % (self.server.ip, time_stamp())
if not self.local:
from lib.remote.remote_util import RemoteMachineShellConnection
remote_client = RemoteMachineShellConnection(self.server)
print "Collecting logs from %s\n" % self.server.ip
output, error = remote_client.execute_cbcollect_info(file_name)
print "\n".join(output)
print "\n".join(error)
user_path = "/home/"
if remote_client.info.distribution_type.lower() == "mac":
user_path = "/Users/"
else:
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 status:
print "Downloading zipped logs from %s" % self.server.ip
else:
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()
示例7: create_and_restore_csv
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [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()
示例8: set_ep_compaction
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def set_ep_compaction(self, comp_ratio):
"""Set up ep_engine side compaction ratio"""
for server in self.input.servers:
shell = RemoteMachineShellConnection(server)
cmd = "/opt/couchbase/bin/cbepctl localhost:11210 "\
"set flush_param db_frag_threshold {0}".format(comp_ratio)
self._exec_and_log(shell, cmd)
shell.disconnect()
示例9: stop_measure_sched_delay
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def stop_measure_sched_delay(self):
for server in self.servers:
shell = RemoteMachineShellConnection(server)
cmd = "killall -9 -r .*measure-sched-delays"
output, error = shell.execute_command(cmd)
shell.log_command_output(output, error)
shell.disconnect()
self.log.info("measure-sched-delays was stopped on {0}".format(server.ip))
示例10: fetch_logs
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def fetch_logs(self):
for server in self.servers:
shell = RemoteMachineShellConnection(server)
files = shell.list_files(self.path + "/")
files = [file for file in files if file["file"].startswith("sched-delay")]
for file in files:
shell.copy_file_remote_to_local(file["path"] + file["file"], os.getcwd() + "/" + file["file"])
self.log.info("copied {0} from {1}".format([file["file"] for file in files] , server.ip))
shell.disconnect()
示例11: reboot_server
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def reboot_server(self, server):
remote_client = RemoteMachineShellConnection(server)
remote_client.reboot_node()
remote_client.disconnect()
# wait for restart and warmup on all node
self.sleep(self.wait_timeout * 5)
# disable firewall on these nodes
self.stop_firewall_on_node(server)
# wait till node is ready after warmup
ClusterOperationHelper.wait_for_ns_servers_or_assert([server], self, wait_if_warmup=True)
示例12: set_ep_param
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def set_ep_param(self, type, param, value):
"""
Set ep-engine specific param, using cbepctl
type: paramter type, e.g: flush_param, tap_param, etc
"""
bucket = Bucket(name=self.buckets[0], authType="sasl", saslPassword="")
for server in self.input.servers:
shell = RemoteMachineShellConnection(server)
shell.execute_cbepctl(bucket,
"", "set %s" % type, param, value)
shell.disconnect()
示例13: set_up_proxy
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def set_up_proxy(self, bucket=None):
"""Set up and start Moxi"""
if self.input.moxis:
self.log.info("setting up proxy")
bucket = bucket or self.param('bucket', 'default')
shell = RemoteMachineShellConnection(self.input.moxis[0])
shell.start_moxi(self.input.servers[0].ip, bucket,
self.input.moxis[0].port)
shell.disconnect()
示例14: load_sample_buckets
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [as 别名]
def load_sample_buckets(self, bucketName="beer-sample" ):
"""
Load the specified sample bucket in Couchbase
"""
#self.cluster.bucket_delete(server=self.master, bucket="default")
server = self.master
shell = RemoteMachineShellConnection(server)
shell.execute_command("""curl -v -u Administrator:password \
-X POST http://{0}:8091/sampleBuckets/install \
-d '["{1}"]'""".format(server.ip, bucketName))
self.sleep(30)
shell.disconnect()
示例15: kill_erlang_service
# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import disconnect [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)