instruction stringclasses 14
values | output stringlengths 105 12.9k | input stringlengths 0 4.12k |
|---|---|---|
generate python code for the above | import install_util.constants
from install_util.constants.build import BuildUrl
from shell_util.remote_connection import RemoteMachineShellConnection
def __construct_build_url(self, is_debuginfo_build=False):
"""
Constructs the build url for the given node.
This url is used to download the inst... | Constructs the build url for the given node.
This url is used to download the installation package.
|
def stop_network(self, stop_time):
"""
Stop the network for given time period and then restart the network
on the machine.
Override method for Windows
:param stop_time: Time duration for which the network service needs
to be down in the machine
:return: None
... | def stop_network(self, stop_time):
command = "net stop Netman && timeout {} && net start Netman"
output, error = self.execute_command(command.format(stop_time))
self.log_command_output(output, error) | |
from time import sleep
def sleep(self, timeout, msg=None):
"""
Sleep for given amount of time. Optionally print the message to log.
:param timeout: amount of time to sleep in seconds
:param msg: message to log
:return: None
"""
if msg:
self.log.info(m... | Sleep for given amount of time. Optionally print the message to log.
| |
generate doc string for following function: | def delete_info_for_server(server, ipaddr=None):
"""
Delete the info associated with the given server or ipaddr
:param server: server to delete the info for
:param ipaddr: ipaddr to delete the info for
:return: None
"""
ipaddr = ipaddr or server.ip
if ipa... | def delete_info_for_server(server, ipaddr=None):
ipaddr = ipaddr or server.ip
if ipaddr in RemoteMachineShellConnection.__info_dict:
del RemoteMachineShellConnection.__info_dict[ipaddr]
RemoteMachineShellConnection.__info_dict.pop(ipaddr, None) |
generate python code for the above |
def __init__(self, logger):
"""
Creates an instance of InstallHelper object
:param logger: logger object
"""
self.log = logger | Creates an instance of InstallHelper object
|
generate doc string for following function: | def download_build(self, node_installer, build_url,
non_root_installer=False):
"""
Download the Couchbase build on the remote server
:param node_installer: node installer object
:param build_url: build url to download the Couchbase build from.
:param non_ro... | def download_build(self, node_installer, build_url,
non_root_installer=False):
download_dir = self.get_download_dir(node_installer)
f_name = build_url.split("/")[-1]
# Remove old build (if exists)
cmd = "rm -f {}/couchbase-server*".format(download_dir)
... |
def create_new_partition(self, location, size=None):
"""
Create a new partition at the location specified and of
the size specified
:param location: Location to create the new partition at.
:param size: Size of the partition in MB
:return: None
"""
command... | def create_new_partition(self, location, size=None):
command = "umount -l {0}".format(location)
output, error = self.execute_command(command)
command = "rm -rf {0}".format(location)
output, error = self.execute_command(command)
command = "rm -rf /usr/disk-img/disk-quota.... | |
generate comment. | def stop_current_python_running(self, mesg):
"""
Stop the current python process that's running this script.
:param mesg: message to display before killing the process
:return: None
"""
os.system("ps aux | grep python | grep %d " % os.getpid())
log.info(mesg)
... | def stop_current_python_running(self, mesg):
os.system("ps aux | grep python | grep %d " % os.getpid())
log.info(mesg)
self.sleep(5, "==== delay kill pid %d in 5 seconds to printout message ==="\
% os.getpid())
... |
generate code for the following |
def get_hostname(self):
"""
Get the hostname of the remote server.
:return: hostname of the remote server if found else None
"""
o, r = self.execute_command_raw('hostname', debug=False)
if o:
return o | Get the hostname of the remote server.
|
give python code to |
def give_directory_permissions_to_couchbase(self, location):
"""
Change the directory permission of the location mentioned
to include couchbase as the user
:param location: Directory location whoes permissions has to be changed
:return: None
"""
command = "chown... | Change the directory permission of the location mentioned
to include couchbase as the user
|
generate comment. | def __init__(self, logger, node_install_info):
"""
Creates an instance of the InstallSteps class.
:param logger:
:param node_install_info:
"""
self.log = logger
self.node_install_info = node_install_info
self.result = True | def __init__(self, logger, node_install_info):
self.log = logger
self.node_install_info = node_install_info
self.result = True |
generate comment for above | def get_hostname(self):
"""
Get the hostname of the remote server.
:return: hostname of the remote server if found else None
"""
o, r = self.execute_command_raw('hostname', debug=False)
if o:
return o | def get_hostname(self):
o, r = self.execute_command_raw('hostname', debug=False)
if o:
return o |
def is_couchbase_running(self):
"""
Checks if couchbase is currently running on the remote server
:return: True if couchbase is running else False
"""
o = self.is_process_running('beam.smp')
if o is not None:
return True
return False | def is_couchbase_running(self):
o = self.is_process_running('beam.smp')
if o is not None:
return True
return False | |
generate comment. | def enable_file_limit_desc(self):
"""
Change the file limit for all processes to 100
:return: None
"""
o, r = self.execute_command("sysctl -w fs.file-max=100;sysctl -p")
self.log_command_output(o, r) | def enable_file_limit_desc(self):
o, r = self.execute_command("sysctl -w fs.file-max=100;sysctl -p")
self.log_command_output(o, r) |
def install(self, build_url):
"""
Installs Couchbase server on Unix machine
:param build_url: build url to get the Couchbase package from
:return: True on successful installation else False
"""
cmd = self.cmds["install"]
if self.shell.nonroot:
cmd = ... | Installs Couchbase server on Unix machine
| |
generate doc string for following function: | def init_cluster(self, node):
"""
Initializes Couchbase cluster
Override method for Unix
:param node: server object
:return: True on success
"""
return True | def init_cluster(self, node):
return True |
generate comment: | def uninstall(self):
"""
Uninstalls Couchbase server on Linux machine
:return: True on success
"""
self.shell.stop_couchbase()
cmd = self.cmds
if self.shell.nonroot:
cmd = self.non_root_cmds
cmd = cmd[self.shell.info.deliverable_type]["uninstal... | def uninstall(self):
self.shell.stop_couchbase()
cmd = self.cmds
if self.shell.nonroot:
cmd = self.non_root_cmds
cmd = cmd[self.shell.info.deliverable_type]["uninstall"]
self.shell.execute_command(cmd)
return True |
give python code to |
def install(self, build_url):
"""
Installs Couchbase server on Linux machine
:param build_url: build url to get the Couchbase package from
:return: True on successful installation else False
"""
cmd = self.cmds
if self.shell.nonroot:
cmd = self.non_r... | Installs Couchbase server on Linux machine
|
generate python code for |
def rmtree(self, sftp, remote_path, level=0):
"""
Recursively remove all files and directories in the specified path tree.
:param sftp: SFTP connection object
:param remote_path: remote path to remove
:param level: current level of the directory with respect to original directo... | Recursively remove all files and directories in the specified path tree.
|
generate python code for the following |
def create_multiple_dir(self, dir_paths):
"""
This function will remove the automation directory in windows and create directory in the path specified
in dir_paths
:param dir_paths: list of paths to create the directories
:return: None
"""
sftp = self._ssh_clien... | This function will remove the automation directory in windows and create directory in the path specified
in dir_paths
|
def disable_disk_readonly(self, disk_location):
"""
Disables read-only mode for the specified disk location.
Override method for Windows
:param disk_location: disk location to disable read-only mode.
:return: None
"""
raise NotImplementedError | Disables read-only mode for the specified disk location.
Override method for Windows
| |
def kill_eventing_process(self, name):
"""
Kill eventing process on remote server
:param name: name of eventing process
:return: None
"""
o, r = self.execute_command(command="taskkill /F /T /IM {0}*".format(name))
self.log_command_output(o, r) | Kill eventing process on remote server
| |
generate python code for the following |
def enable_disk_readonly(self, disk_location):
"""
Enables read-only mode for the specified disk location.
Override method for Windows
:param disk_location: disk location to enable read-only mode.
:return: None
"""
raise NotImplementedError | Enables read-only mode for the specified disk location.
Override method for Windows
|
Code the following: |
def connect_with_user(self, user="root"):
"""
Connect to the remote server with given user
Override method since this is not required for Unix
:param user: user to connect to remote server with
:return: None
"""
return | Connect to the remote server with given user
Override method since this is not required for Unix
|
give python code to |
def enable_file_limit_desc(self):
"""
Change the file limit for all processes to 100
:return: None
"""
o, r = self.execute_command("sysctl -w fs.file-max=100;sysctl -p")
self.log_command_output(o, r) | Change the file limit for all processes to 100
|
from shell_util.shell_conn import ShellConnection
def __new__(cls, *args, **kwargs):
"""
Create a new RemoteMachineShellConnection instance with given parameters.
"""
server = args[0]
if server.ip in RemoteMachineShellConnection.__info_dict:
info = RemoteMachineShell... | Create a new RemoteMachineShellConnection instance with given parameters. | |
generate code for the following |
def __find_windows_info(self):
"""
Get information about a Windows server
:return: Windows info about the server
"""
if self.remote:
found = self.find_file("/cygdrive/c/tmp", "windows_info.txt")
if isinstance(found, str):
if self.remote:
... | Get information about a Windows server
|
generate python code for the above | from subprocess import Popen
def remove_directory_recursive(self, remote_path):
"""
Recursively remove directory in remote machine.
:param remote_path: directory path to remove
:return: True if successful else False
"""
if self.remote:
sftp = self._ssh_client... | Recursively remove directory in remote machine.
|
give a code to |
def windows_process_utils(self, ps_name_or_id, cmd_file_name, option=""):
"""
Windows process utility. This adds firewall rules to Windows system.
If a previously suspended process is detected, it continues with the process instead.
:param ps_name_or_id: process name or process id
... | Windows process utility. This adds firewall rules to Windows system.
If a previously suspended process is detected, it continues with the process instead.
|
give a code to |
def get_data_file_size(self, path=None):
"""
Get the size of the file in the specified path
:param path: path of the file to get the size of
:return: size of the file in the path
"""
output, error = self.execute_command('du -b {0}'.format(path))
if error:
... | Get the size of the file in the specified path
|
generate doc string for following function: | def _recover_disk_full_failure(self, location):
"""
Recover the disk full failures on remote server
:param location: location of the disk to recover
:return: output and error message from recovering disk
"""
delete_file = "{0}/disk-quota.ext3".format(location)
out... | def _recover_disk_full_failure(self, location):
delete_file = "{0}/disk-quota.ext3".format(location)
output, error = self.execute_command("rm -f {0}".format(delete_file))
return output, error |
generate python code for the above |
def start_server(self):
"""
Starts the Couchbase server on the remote server.
The method runs the sever from non-default location if it's run as nonroot user. Else from default location.
:return: None
"""
if self.is_couchbase_installed():
if self.nonroot:
... | Starts the Couchbase server on the remote server.
The method runs the sever from non-default location if it's run as nonroot user. Else from default location.
|
generate doc string for following function: | def __repr__(self):
"""
Returns a string representation of the TestInputServer object with ip, port and ssh_username
:return: A string representation of the TestInputServer object
"""
#ip_str = "ip:{0}".format(self.ip)
ip_str = "ip:{0} port:{1}".format(self.ip, self.port)... | def __repr__(self):
#ip_str = "ip:{0}".format(self.ip)
ip_str = "ip:{0} port:{1}".format(self.ip, self.port)
ssh_username_str = "ssh_username:{0}".format(self.ssh_username)
return "{0} {1}".format(ip_str, ssh_username_str) |
def start_and_wait_for_threads(thread_list, timeout):
"""
Start the threads in the thread list and wait for the threads to finish. \n
Wait until the thread finishes or the timeout is reached.
:param thread_list: list of threads to run
:param timeout: timeout to wait till threads are finished
:... | Start the threads in the thread list and wait for the threads to finish.
Wait until the thread finishes or the timeout is reached.
| |
generate code for the following |
def alt_addr_add_node(self, main_server=None, internal_IP=None,
server_add=None, user="Administrator",
passwd="password", services="kv", cmd_ext=""):
"""
Add node to couchbase cluster using alternative address
:param main_server: couchbase cl... | Add node to couchbase cluster using alternative address
|
generate code for the above: |
def start_couchbase(self):
"""
Starts couchbase on remote server
:return: None
"""
retry = 0
running = self.is_couchbase_running()
while not running and retry < 3:
self.log.info("Starting couchbase server")
o, r = self.execute_command("op... | Starts couchbase on remote server
|
generate python code for the above |
def cbbackupmgr_param(self, name, *args):
"""
Returns the config value from the ini whose key matches 'name' and is stored under the 'cbbackupmgr'
section heading.
:param name: the key under which an expected value is stored.
:param args: expects a single parameter which will b... | Returns the config value from the ini whose key matches 'name' and is stored under the 'cbbackupmgr'
section heading.
|
generate python code for the above |
def start_indexer(self):
"""
Start indexer process on remote server
:return: None
"""
o, r = self.execute_command("kill -SIGCONT $(pgrep indexer)")
self.log_command_output(o, r) | Start indexer process on remote server
|
generate python code for |
def copy_file_local_to_remote(self, src_path, des_path):
"""
Copy file from local to remote server
:param src_path: source path of the file to be copied
:param des_path: destination path of the file to be copied
:return: True if the file was successfully copied else False
... | Copy file from local to remote server
|
def stop_membase(self):
"""
Override method
"""
raise NotImplementedError | Override method | |
def restart_couchbase(self):
"""
Restarts the Couchbase server on the remote server
:return: None
"""
o, r = self.execute_command("net stop couchbaseserver")
self.log_command_output(o, r)
o, r = self.execute_command("net start couchbaseserver")
self.log_co... | def restart_couchbase(self):
o, r = self.execute_command("net stop couchbaseserver")
self.log_command_output(o, r)
o, r = self.execute_command("net start couchbaseserver")
self.log_command_output(o, r) | |
import re
import configparser
def parse_from_file(file):
"""
Parse the test inputs from file
:param file: path to file to parse
:return: TestInput object
"""
count = 0
start = 0
end = 0
servers = list()
ips = list()
input = TestInp... | Parse the test inputs from file
| |
generate python code for |
def unmount_partition(self, location):
"""
Unmount the partition at the specified location.
:param location: Location of the partition which has to be unmounted
:return: Output and error message from the umount command
"""
command = "umount -l {0}; df -Th".format(locati... | Unmount the partition at the specified location.
|
generate comment. | def get_ram_info(self, win_info=None, mac=False):
"""
Get ram info of a remote server
:param win_info: windows info
:param mac: get ram info from macOS if True
:return: ram info of remote server
"""
if win_info:
if 'Virtual Memory Max Size' not in win_... | def get_ram_info(self, win_info=None, mac=False):
if win_info:
if 'Virtual Memory Max Size' not in win_info:
win_info = self.create_windows_info()
o = "Virtual Memory Max Size =" + win_info['Virtual Memory Max Size'] + '\n'
o += "Virtual Memory Availa... |
generate code for the following |
def __init__(self, server, server_info, os_type, version, edition):
"""
Creats an instance of the NodeInstallInfo class.
:param server: server object of type TestInputServer
:param server_info: server info with information of the server
:param os_type: OS type of the server
... | Creats an instance of the NodeInstallInfo class.
|
generate code for the following |
def __init__(self):
"""
Creates an instance of the TestInputMembaseSetting class
"""
self.rest_username = ''
self.rest_password = '' | Creates an instance of the TestInputMembaseSetting class |
generate python code for | from shell_util.remote_machine import RemoteMachineProcess
def get_running_processes(self):
"""
Get the list of processes currently running in the remote server
if its linux ,then parse each line
26989 ? 00:00:51 pdflush
ps -Ao pid,comm
:return: List of processes ... | Get the list of processes currently running in the remote server
if its linux ,then parse each line
26989 ? 00:00:51 pdflush
ps -Ao pid,comm
|
def get_mem_usage_by_process(self, process_name):
"""
Get the memory usage of a process
:param process_name: name of the process to get the memory usage for
:return: the memory usage of the process if available else None
"""
output, error = self.execute_command(
... | Get the memory usage of a process
| |
generate comment. | def __init__(self):
"""
Creates an instance of RemoteMachineProcess class
"""
self.pid = ''
self.name = ''
self.vsz = 0
self.rss = 0
self.args = '' | def __init__(self):
self.pid = ''
self.name = ''
self.vsz = 0
self.rss = 0
self.args = '' |
generate comment: | def populate_debug_build_url(self):
"""
Populates the debug_info build url variable.
:return: None
"""
self.node_install_info.debug_build_url = self.__construct_build_url(
is_debuginfo_build=True)
self.log.info("{} - Debug build url :: {}"
... | def populate_debug_build_url(self):
self.node_install_info.debug_build_url = self.__construct_build_url(
is_debuginfo_build=True)
self.log.info("{} - Debug build url :: {}"
.format(self.node_install_info.server.ip,
self.node_instal... |
def terminate_processes(self, info, p_list):
"""
Terminate a list of processes on remote server
:param info: None
:param p_list: List of processes to terminate
:return: None
"""
for process in p_list:
# set debug=False if does not want to show log
... | def terminate_processes(self, info, p_list):
for process in p_list:
# set debug=False if does not want to show log
self.execute_command("taskkill /F /T /IM {0}"
.format(process), debug=False) | |
give a code to |
def uninstall(self):
"""
Uninstalls Couchbase server on Windows machine
:return: True on success
"""
self.shell.stop_couchbase()
cmd = self.cmds["uninstall"]
self.shell.execute_command(cmd)
return True | Uninstalls Couchbase server on Windows machine
|
give a code to |
def change_env_variables(self, dict):
"""
Change environment variables mentioned in dictionary and restart Couchbase server
:param dict: key value pair of environment variables and their values to change to
:return: None
"""
prefix = "\\n "
shell = self._ssh_... | Change environment variables mentioned in dictionary and restart Couchbase server
|
generate comment: | def stop_memcached(self):
"""
Stop memcached process on remote server
:return: None
"""
o, r = self.execute_command("taskkill /F /T /IM memcached*")
self.log_command_output(o, r, debug=False) | def stop_memcached(self):
o, r = self.execute_command("taskkill /F /T /IM memcached*")
self.log_command_output(o, r, debug=False) |
generate comment. | def handle_command_line_u_or_v(option, argument):
"""
Parse command line arguments for -u or -v
:param option: option to parse
:param argument: argument to check
:return: parsed arguments as TestInputBuild
"""
input_build = TestInputBuild()
if option == "-... | def handle_command_line_u_or_v(option, argument):
input_build = TestInputBuild()
if option == "-u":
# let's check whether this url exists or not
# let's extract version from this url
pass
if option == "-v":
allbuilds = BuildQuery().get_all... |
give a code to |
def execute_commands_inside(self, main_command, query, queries,
bucket1, password, bucket2, source,
subcommands=[], min_output_size=0,
end_msg='', timeout=250):
"""
Override method to handle windows specifi... | Override method to handle windows specific file name |
generate code for the above: |
def param(self, name, *args):
"""
Returns the paramater or a default value
:param name: name of the property
:param args: default value for the property. If no default value is given, an exception is raised
:return: the value of the property
:raises Exception: if the de... | Returns the paramater or a default value
|
generate python code for the following | from subprocess import Popen
def execute_command_raw(self, command, debug=True, use_channel=False,
timeout=600, get_exit_code=False):
"""
Implementation to execute a given command on the remote machine or on local machine.
:param command: The raw command to execute.... | Implementation to execute a given command on the remote machine or on local machine.
|
generate doc string for following function: | def get_file(self, remotepath, filename, todir):
"""
Downloads a file from a remote location to a local path.
:param remotepath: Remote path to download the file from.
:param filename: Name of the file to download.
:param todir: Directory to save the file to.
:return: Tru... | def get_file(self, remotepath, filename, todir):
if self.file_exists(remotepath, filename):
if self.remote:
sftp = self._ssh_client.open_sftp()
try:
filenames = sftp.listdir(remotepath)
for name in filenames:
... |
give a code to |
def unpause_beam(self):
"""
Unpauses the beam.smp process on remote server
Override method for Windows
:return:
"""
raise NotImplementedError | Unpauses the beam.smp process on remote server
Override method for Windows
|
generate python code for the following |
def restart_couchbase(self):
"""
Restarts the Couchbase server on the remote server
:return: None
"""
o, r = self.execute_command("net stop couchbaseserver")
self.log_command_output(o, r)
o, r = self.execute_command("net start couchbaseserver")
self.log_... | Restarts the Couchbase server on the remote server
|
generate python code for the above |
def set_node_name(self, name):
"""
Edit couchbase-server shell script in place and set custom node name.
This is necessary for cloud installations where nodes have both
private and public addresses.
It only works on Unix-like OS.
Reference: http://bit.ly/couchbase-bes... | Edit couchbase-server shell script in place and set custom node name.
This is necessary for cloud installations where nodes have both
private and public addresses.
It only works on Unix-like OS.
Reference: http://bit.ly/couchbase-bestpractice-cloud-ip
|
generate comment for following function: | def restart_couchbase(self):
"""
Restarts the Couchbase server on the remote server
:return: None
"""
o, r = self.execute_command("service couchbase-server restart")
self.log_command_output(o, r) | def restart_couchbase(self):
o, r = self.execute_command("service couchbase-server restart")
self.log_command_output(o, r) |
def sleep(seconds, msg=""):
"""
Sleep for specified number of seconds. Optionally log a message given
:param seconds: number of seconds to sleep for
:param msg: optional message to log
:return: None
"""
if msg:
log.info(msg)
sleep(seconds) | def sleep(seconds, msg=""):
if msg:
log.info(msg)
sleep(seconds) | |
generate python code for the above |
def rmtree(self, sftp, remote_path, level=0):
"""
Recursively remove all files and directories in the specified path tree.
:param sftp: SFTP connection object
:param remote_path: remote path to remove
:param level: current level of the directory with respect to original directo... | Recursively remove all files and directories in the specified path tree.
|
generate python code for |
def restart_couchbase(self):
"""
Restarts the Couchbase server on the remote server
:return: None
"""
o, r = self.execute_command("open /Applications/Couchbase\ Server.app")
self.log_command_output(o, r) | Restarts the Couchbase server on the remote server
|
def run(self):
"""
Runs the NodeInstaller thread to run various installation steps in the remote server
:return: None
"""
installer = InstallSteps(self.log, self.node_install_info)
node_installer = installer.get_node_installer(
self.node_install_info)
... | def run(self):
installer = InstallSteps(self.log, self.node_install_info)
node_installer = installer.get_node_installer(
self.node_install_info)
for step in self.steps:
self.log.info("{} - Running '{}'"
.format(self.node_install_info.ser... | |
Code the following: |
def wait_till_file_deleted(self, remotepath, filename, timeout_in_seconds=180):
"""
Wait until the remote file in remote path is deleted
:param remotepath: remote path of the file to be deleted
:param filename: name of the file to be deleted
:param timeout_in_seconds: wait time... | Wait until the remote file in remote path is deleted
|
generate python code for the following |
def wait_till_file_added(self, remotepath, filename, timeout_in_seconds=180):
"""
Wait until the remote file in remote path is created
:param remotepath: remote path of the file to be created
:param filename: name of the file to be created
:param timeout_in_seconds: wait time i... | Wait until the remote file in remote path is created
|
generate comment. | def __new__(cls, *args, **kwargs):
"""
Create a new RemoteMachineShellConnection instance with given parameters.
"""
server = args[0]
if server.ip in RemoteMachineShellConnection.__info_dict:
info = RemoteMachineShellConnection.__info_dict[server.ip]
else:
... | def __new__(cls, *args, **kwargs):
server = args[0]
if server.ip in RemoteMachineShellConnection.__info_dict:
info = RemoteMachineShellConnection.__info_dict[server.ip]
else:
shell = ShellConnection(server)
shell.ssh_connect_with_retries(server.ip, se... |
give python code to |
def is_couchbase_installed(self):
"""
Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
:return: True if Couchbase is installed on the remote server else False
"""
if self.nonroot:
... | Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
|
generate python code for | import os
import paramiko
import signal
from time import sleep
def ssh_connect_with_retries(self, ip, ssh_username, ssh_password, ssh_key,
exit_on_failure=False, max_attempts_connect=5,
backoff_time=10):
"""
Connect to the remote server ... | Connect to the remote server with given user and password, with exponential backoff delay
|
generate comment: | def get_membase_settings(config, section):
"""
Get the membase settings information from the config
:param config: config
:param section: section to get information from
:return: membase settings information
"""
membase_settings = TestInputMembaseSetting()
... | def get_membase_settings(config, section):
membase_settings = TestInputMembaseSetting()
for option in config.options(section):
if option == 'rest_username':
membase_settings.rest_username = config.get(section, option)
if option == 'rest_password':
... |
generate comment for above | def get_memcache_pid(self):
"""
Get the pid of memcached process
:return: pid of memcached process
"""
output, error = self.execute_command('tasklist| grep memcache', debug=False)
if error or output == [""] or output == []:
return None
words = output[0].... | def get_memcache_pid(self):
output, error = self.execute_command('tasklist| grep memcache', debug=False)
if error or output == [""] or output == []:
return None
words = output[0].split(" ")
words = [x for x in words if x != ""]
return words[1] |
generate code for the above: |
def delete_network_rule(self):
"""
Delete all traffic control rules set for eth0
:return: None
"""
o, r = self.execute_command("tc qdisc del dev eth0 root")
self.log_command_output(o, r) | Delete all traffic control rules set for eth0
|
give python code to | from subprocess import Popen
def remove_directory_recursive(self, remote_path):
"""
Recursively remove directory in remote machine.
:param remote_path: directory path to remove
:return: True if successful else False
"""
if self.remote:
sftp = self._ssh_client... | Recursively remove directory in remote machine.
|
generate comment: | def cbbackupmgr_param(self, name, *args):
"""
Returns the config value from the ini whose key matches 'name' and is stored under the 'cbbackupmgr'
section heading.
:param name: the key under which an expected value is stored.
:param args: expects a single parameter which will be ... | def cbbackupmgr_param(self, name, *args):
if name in self.cbbackupmgr:
return TestInput._parse_param(self.cbbackupmgr[name])
if len(args) == 1:
return args[0]
if self.cbbackupmgr["name"] != "local_bkrs":
raise Exception(f"Parameter '{name}' must be se... |
give a code to |
def check_build_url_status(self):
"""
Checks the build url status. Checks if the url is reachable and valid.
:return: None
"""
self.check_url_status(self.node_install_info.build_url) | Checks the build url status. Checks if the url is reachable and valid.
|
def disconnect(self):
"""
Disconnect the ssh connection to remote machine.
:return: None
"""
ShellConnection.disconnections += 1
self._ssh_client.close() | def disconnect(self):
ShellConnection.disconnections += 1
self._ssh_client.close() | |
def give_directory_permissions_to_couchbase(self, location):
"""
Change the directory permission of the location mentioned
to include couchbase as the user
:param location: Directory location whoes permissions has to be changed
:return: None
"""
command = "chown... | Change the directory permission of the location mentioned
to include couchbase as the user
| |
give python code to | import urllib.request
def download_build_locally(self, build_url):
"""
Downloads the Couchbase build locally
:param build_url: Download url to download the build from
:return: tuple containing the path to the download build file as well as the resulting HTTPMessage object.
"""
... | Downloads the Couchbase build locally
|
generate comment for above | def get_membase_settings(config, section):
"""
Get the membase settings information from the config
:param config: config
:param section: section to get information from
:return: membase settings information
"""
membase_settings = TestInputMembaseSetting()
... | def get_membase_settings(config, section):
membase_settings = TestInputMembaseSetting()
for option in config.options(section):
if option == 'rest_username':
membase_settings.rest_username = config.get(section, option)
if option == 'rest_password':
... |
generate comment for above | def start_memcached(self):
"""
Start memcached process on remote server
:return: None
"""
o, r = self.execute_command("kill -SIGCONT $(pgrep memcached)")
self.log_command_output(o, r, debug=False) | def start_memcached(self):
o, r = self.execute_command("kill -SIGCONT $(pgrep memcached)")
self.log_command_output(o, r, debug=False) |
generate python code for the following | from subprocess import Popen
def remove_directory(self, remote_path):
"""
Remove the directory specified from system.
:param remote_path: Directory path to remove.
:return: True if the directory was removed else False
"""
if self.remote:
sftp = self._ssh_clie... | Remove the directory specified from system.
|
generate comment: | def init_cluster(self, node):
"""
Initializes Couchbase cluster
Override method for Windows
:param node: server object
:return: True on success
"""
return True | def init_cluster(self, node):
return True |
give a code to |
def start_couchbase(self):
"""
Starts couchbase on remote server
:return: None
"""
retry = 0
running = self.is_couchbase_running()
while not running and retry < 3:
self.log.info("Starting couchbase server")
o, r = self.execute_command("op... | Starts couchbase on remote server
|
generate python code for |
def is_couchbase_installed(self):
"""
Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
:return: True if Couchbase is installed on the remote server else False
"""
output, error = self.execute... | Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
|
generate python code for |
def stop_memcached(self):
"""
Stop memcached process on remote server
:return: None
"""
o, r = self.execute_command("kill -SIGSTOP $(pgrep memcached)")
self.log_command_output(o, r, debug=False) | Stop memcached process on remote server
|
Code the following: | import sys
from install_util.constants.build import BuildUrl
from install_util.install_lib.helper import InstallHelper
from install_util.install_lib.node_helper import NodeInstaller
from install_util.install_lib.node_helper import NodeInstallInfo
from install_util.test_input import TestInputParser
from shell_util.remot... | Main function of the installation script.
|
generate comment. | def uninstall(self):
"""
Uninstalls Couchbase server on Unix machine
:return: True on success
"""
self.shell.stop_couchbase()
cmd = self.cmds["uninstall"]
if self.shell.nonroot:
cmd = self.non_root_cmds["uninstall"]
self.shell.execute_command(c... | def uninstall(self):
self.shell.stop_couchbase()
cmd = self.cmds["uninstall"]
if self.shell.nonroot:
cmd = self.non_root_cmds["uninstall"]
self.shell.execute_command(cmd)
return True |
generate python code for the following | from shell_util.shell_conn import ShellConnection
def delete_info_for_server(server, ipaddr=None):
"""
Delete the info associated with the given server or ipaddr
:param server: server to delete the info for
:param ipaddr: ipaddr to delete the info for
:return: None
"""
... | Delete the info associated with the given server or ipaddr
|
give a code to |
def is_couchbase_installed(self):
"""
Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
:return: True if Couchbase is installed on the remote server else False
"""
output, error = self.execute... | Check if Couchbase is installed on the remote server.
This checks if the couchbase is installed in default or non default path.
|
generate python code for |
def stop_memcached(self):
"""
Stop memcached process on remote server
:return: None
"""
o, r = self.execute_command("taskkill /F /T /IM memcached*")
self.log_command_output(o, r, debug=False) | Stop memcached process on remote server
|
generate comment for following function: | def get_data_file_size(self, path=None):
"""
Get the size of the file in the specified path
:param path: path of the file to get the size of
:return: size of the file in the path
"""
output, error = self.execute_command('du -b {0}'.format(path))
if error:
... | def get_data_file_size(self, path=None):
output, error = self.execute_command('du -b {0}'.format(path))
if error:
return 0
else:
for line in output:
size = line.strip().split('\t')
if size[0].isdigit():
print((s... |
generate comment for following function: | def get_memcache_pid(self):
"""
Get the pid of memcached process
:return: pid of memcached process
"""
o, _ = self.execute_command(
"ps -eo comm,pid | awk '$1 == \"memcached\" { print $2 }'")
return o[0] | def get_memcache_pid(self):
o, _ = self.execute_command(
"ps -eo comm,pid | awk '$1 == \"memcached\" { print $2 }'")
return o[0] |
generate python code for the above |
def get_cpu_info(self, win_info=None, mac=False):
"""
Get the CPU info of the remote server
:param win_info: Windows info in case of windows
:param mac: Get info for macOS if True
:return: CPU info of the remote server if found else None
"""
if win_info:
... | Get the CPU info of the remote server
|
give python code to |
def init_cluster(self, node):
"""
Initializes Couchbase cluster
Override method for Windows
:param node: server object
:return: True on success
"""
return True | Initializes Couchbase cluster
Override method for Windows
|
generate comment: | def stop_membase(self):
"""
Override method
"""
raise NotImplementedError | def stop_membase(self):
raise NotImplementedError |
generate comment for following function: | def monitor_process(self, process_name, duration_in_seconds=120):
"""
Monitor the given process till the given duration to check if it crashed or restarted
:param process_name: the name of the process to monitor
:param duration_in_seconds: the duration to monitor the process till, in sec... | def monitor_process(self, process_name, duration_in_seconds=120):
end_time = time.time() + float(duration_in_seconds)
last_reported_pid = None
while time.time() < end_time:
process = self.is_process_running(process_name)
if process:
if not last_re... |
generate python code for |
def cleanup_data_config(self, data_path):
"""
Cleans up the data config directory and its contents
:param data_path: path to data config directory
:return: None
"""
self.extract_remote_info()
o, r = self.execute_command("rm -rf {0}/*".format(data_path))
... | Cleans up the data config directory and its contents
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.