| name | # | input | output | \\n\")\r\n\r\n input_paths = glob.glob(os.path.join(input_dir, '*inputs.png'))\r\n input_paths = sorted(input_paths)\r\n \r\n print('input path num: ', len(input_paths))\r\n num = 1\r\n for input_path in input_paths:\r\n index.write(\"
|---|---|---|---|
| %s | \\n\" % basename)\r\n index.write(\"---[%d]--- | \\n\" % num)\r\n num += 1\r\n index.write(\"\", \"\").replace(\" | \", \"\").strip()\n else:\n value = \"None\"\n\n content = '''---\ndate: {}\nlang: ja\nfeatured: false\ntype: news\n---\n{}\n'''.format(date, value)\n\n vol = file.split(\"/\")[-1].split(\"news\")[0].split(\".\")[0]\n dir = \"../content/news\"\n os.makedirs(dir, exist_ok=True)\n \n name = date + \"-\" + str(len(trs) - i).zfill(4)\n path = dir + \"/\" + name +\".md\"\n with open(path, mode='w') as f:\n f.write(content)","sub_path":"src/201_news.py","file_name":"201_news.py","file_ext":"py","file_size_in_byte":1333,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"528416141","text":"from openapi_server.models.original_sample import OriginalSample\nfrom openapi_server.models.original_samples import OriginalSamples\nfrom openapi_server.models.location import Location\nfrom openapi_server.models.attr import Attr\nfrom backbone_server.errors.missing_key_exception import MissingKeyException\n\nfrom backbone_server.location.fetch import LocationFetch\nfrom backbone_server.original_sample.fetch import OriginalSampleFetch\n\nfrom backbone_server.original_sample.edit import OriginalSampleEdit\n\nimport logging\n\nclass OriginalSamplesGetByTaxa():\n\n def __init__(self, conn):\n self._logger = logging.getLogger(__name__)\n self._connection = conn\n\n\n def get(self, taxa_id, start, count):\n with self._connection:\n with self._connection.cursor() as cursor:\n\n stmt = '''SELECT id FROM taxonomies WHERE id = %s'''\n cursor.execute(stmt, (taxa_id, ))\n vtaxa_id = None\n for tid in cursor:\n vtaxa_id = tid\n\n if not vtaxa_id:\n raise MissingKeyException(\"No taxa {}\".format(taxa_id))\n\n fields = '''SELECT os.id, study_name, sampling_event_id,\n days_in_culture, partner_species '''\n query_body = ''' FROM original_samples os\n LEFT JOIN sampling_events se ON se.id = os.sampling_event_id\n LEFT JOIN studies s ON s.id = os.study_id\n LEFT JOIN partner_species_identifiers psi ON psi.id = os.partner_species_id\n JOIN taxonomy_identifiers ti ON ti.partner_species_id = os.partner_species_id\n WHERE ti.taxonomy_id = %s'''\n args = (taxa_id,)\n\n count_args = args\n count_query = 'SELECT COUNT(os.id) ' + query_body\n\n query_body = query_body + ''' ORDER BY doc, study_name, os.id'''\n\n if not (start is None and count is None):\n query_body = query_body + ' LIMIT %s OFFSET %s'\n args = args + (count, start)\n\n original_samples = OriginalSamples(original_samples=[], count=0)\n\n stmt = fields + query_body\n\n cursor.execute(stmt, args)\n\n original_samples.original_samples, original_samples.sampling_events = OriginalSampleFetch.load_original_samples(cursor, True)\n\n if not (start is None and count is None):\n cursor.execute(count_query, count_args)\n original_samples.count = cursor.fetchone()[0]\n else:\n original_samples.count = len(original_samples.original_samples)\n\n original_samples.attr_types = []\n\n col_query = '''select distinct attr_type from original_sample_attrs sea\n JOIN attrs a ON a.id=sea.attr_id\n JOIN original_samples os ON os.id = sea.original_sample_id\n LEFT JOIN taxonomy_identifiers ti ON ti.partner_species_id = os.partner_species_id\n WHERE ti.taxonomy_id = %s'''\n\n cursor.execute(col_query, (taxa_id,))\n for (attr_type,) in cursor:\n original_samples.attr_types.append(attr_type)\n\n\n return original_samples\n","sub_path":"server/backbone_server/original_sample/get_by_taxa.py","file_name":"get_by_taxa.py","file_ext":"py","file_size_in_byte":3282,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"165296150","text":"fruit = []\r\nnumber = []\r\nwith open('fruit_inventory.txt','r') as f:\r\n for lines in f:\r\n line = lines.split()\r\n fruit_list = line[0]\r\n stock_level = line[1]\r\n fruit.append(fruit_list)\r\n fruit.sort()\r\n number.append(stock_level)\r\n print('fruit = ',fruit)\r\n print('number = ',number)\r\n f.close()\r\n\r\n","sub_path":"Labs/week07/lab07_file04.py","file_name":"lab07_file04.py","file_ext":"py","file_size_in_byte":350,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"455530296","text":"from json import load, loads\n\n\nMARKER_MAP = {\n \"{\": \"}\",\n \"[\": \"]\"\n}\n\n\ndef get_tests(test_path):\n inputs = {}\n for selector_path in test_path.visit(\"*.selector\"):\n input_path = selector_path.new(\n purebasename=selector_path.purebasename.split(\"_\")[0],\n ext=\"json\"\n )\n\n output_path = selector_path.new(ext=\"output\")\n\n if input_path not in inputs:\n with input_path.open(\"r\") as f:\n inputs[input_path] = load(f)\n\n with selector_path.open(\"r\") as selector_f:\n with output_path.open(\"r\") as output_f:\n yield (\n selector_f.read().strip(),\n inputs[input_path],\n read_output(output_f),\n selector_path.purebasename,\n )\n\n\ndef parse_output(output):\n marker = None\n collected = []\n collecting = \"\"\n\n for line in output.split(\"\\n\"):\n if not line:\n continue\n\n # int value?\n try:\n collected.append(int(line))\n continue\n except ValueError:\n pass\n\n # string\n if line[0] == \"\\\"\":\n collected.append(loads(line))\n continue\n\n # closing object or array\n if line[0] == marker:\n collecting += line\n collected.append(loads(collecting))\n collecting = \"\"\n marker = None\n continue\n\n # opening object or array\n if line[0] in \"[{\":\n marker = MARKER_MAP[line[0]]\n collecting += line\n continue\n\n # object or array body\n if marker:\n collecting += line\n continue\n\n # anything else\n collected.append(line)\n\n return collected\n\n\ndef items_equal(l1, l2):\n \"\"\"assert that two lists and their items are equal\n\n Taken from: http://stackoverflow.com/questions/12813633\n \"\"\"\n\n return len(l1) == len(l2) and sorted(l1) == sorted(l2)\n\n\ndef read_output(output_f):\n output = output_f.read().strip()\n\n try:\n output = loads(output)\n return output\n except ValueError:\n return parse_output(output)\n","sub_path":"tests/utils.py","file_name":"utils.py","file_ext":"py","file_size_in_byte":2190,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"509814878","text":"# Description:\n# Given a reference of a node in a connected undirected graph.\n# Return a deep copy (clone) of the graph.\n# Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.\n# Constraints:\n# 1 <= Node.val <= 100\n# Node.val is unique for each node.\n# Number of Nodes will not exceed 100.\n# There is no repeated edges and no self-loops in the graph.\n# The Graph is connected and all nodes can be visited starting from the given node.\n\nfrom typing import List\n\n# Definition for a Node.\nclass Node:\n def __init__(self, val = 0, neighbors = []):\n self.val = val\n self.neighbors = neighbors\n\n# Main Code\nclass Solution:\n\tdef cloneGraph(self, node: Node) -> Node:\n\n\t\t# dictionary to store created nodes\n\t\tcurrGraph = {}\n\n\t\t# helper function to iterate through nodes and create nodes\n\t\tdef nodeBuild(node, currGraph):\n\t\t\t# check for empty graph or no neighbors\n\t\t\tif(node == None):\n\t\t\t\treturn None\n\t\t\t# check for 1-node graph\n\t\t\tif(node.neighbors == []):\n\t\t\t\treturn Node(node.val)\n\n\t\t\t# otherwise, go through neighbors DFS\n\t\t\tnewNode = Node(node.val)\n\t\t\tcurrGraph[node.val] = newNode\n\n\t\t\tfor neighbor in node.neighbors:\n\t\t\t\tif(neighbor.val not in currGraph):\n\t\t\t\t\tnewerNode = nodeBuild(neighbor, currGraph)\n\t\t\t\tnewNode.neighbors.append(currGraph[neighbor.val])\n\n\t\t\treturn newNode\n\n\t\toutputGraph = nodeBuild(node, currGraph)\n\t\treturn outputGraph\n\n","sub_path":"Graphs/CloneGraph.py","file_name":"CloneGraph.py","file_ext":"py","file_size_in_byte":1390,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"270419678","text":"# -*- coding: UTF-8 -*-\n\"\"\"PyPoll Homework Challenge Solution.\"\"\"\n\n# Add our dependencies.\nimport csv\nimport os\n# Add a variable to load a file from a path.\nfile_to_load = os.path.join(\"Resources\", \"election_results.csv\")\n# Add a variable to save the file to a path.\nfile_to_save = os.path.join(\"Analysis\", \"election_results.txt\")\n\n# Initialize a total vote counter.\ntotal_votes = 0\n\n# Candidate Options and candidate votes.\ncandidate_options = []\ncandidate_votes = {}\n\n# 1: Create a county list and county votes dictionary.\ncounty_list =[]\ncounty_votes = {}\n\n# Track the winning candidate, vote count and percentage\nwinning_candidate = \"\"\nwinning_count = 0\nwinning_percentage = 0\n\n# 2: Track the largest county and county voter turnout.\nlargest_county = ''\ncounty_voter_turnout = 0\n#2.2 Tracks name of county with most votes, vote count for that county, and percentage of votes for that county\nc_w_most_votes = \"\"\nc_most_votes_count = 0\nc_votes_percentage = 0\n\n# Duplicate Checker Array (Will declare below in for loop)\nvoter_id_list = []\nvoter_id_dict = dict()\ndup_output = dict()\n\n\n# Read the csv and convert it into a list of dictionaries\nwith open(file_to_load) as election_data:\n reader = csv.reader(election_data)\n\n # Read the header\n header = next(reader)\n\n # For each row in the CSV file.\n for row in reader:\n #Duplicate voter ID detector\n # Create list of voter ids\n\n # Add to the total vote count\n total_votes = total_votes + 1\n # Get the candidate name from each row.\n candidate_name = row[2]\n\n # 3: Extract the\n # county name from each row.\n county_name = row[1]\n\n # Get the voter ID from each Row\n \n # If the candidate does not match any existing candidate add it to\n # the candidate list\n if candidate_name not in candidate_options:\n\n # Add the candidate name to the candidate list.\n candidate_options.append(candidate_name)\n\n # And begin tracking that candidate's voter count.\n candidate_votes[candidate_name] = 0\n\n # Add a vote to that candidate's count\n candidate_votes[candidate_name] += 1\n\n # 4a: Write an if statement that checks that the\n # county does not match any existing county in the county list.\n if county_name not in county_list: \n # 4b: Add the existing county to the list of counties.\n county_list.append(county_name)\n\n # 4c: Begin tracking the county's vote count.\n county_votes[county_name] = 0\n\n # 5: Add a vote to that county's vote count.\n county_votes[county_name] += 1\n \n\n \n \n\n# Save the results to our text file.\nwith open(file_to_save, \"w\") as txt_file:\n\n # Print the final vote count (to terminal)\n election_results = (\n f\"\\nElection Results\\n\"\n f\"-------------------------\\n\"\n f\"Total Votes: {total_votes:,}\\n\"\n f\"-------------------------\\n\\n\"\n f\"County Votes:\\n\")\n print(election_results, end=\"\")\n\n txt_file.write(election_results)\n\n # 6a: Write a for loop to get the county from the county dictionary.\n for county_name in county_votes:\n # 6b: Retrieve the county vote count.\n c_votes = county_votes.get(county_name)\n # 6c: Calculate the percentage of votes for the county.\n c_vote_percentage = (float(c_votes)/(float(total_votes)))*100\n # 6d: Print the county results to the terminal.\n county_results = (\n f'{county_name}: {c_vote_percentage:.1f}% ({c_votes:,} votes)\\n'\n )\n print(county_results)\n # 6e: Save the county votes to a text file.\n txt_file.write(county_results)\n # 6f: Write an if statement to determine the winning county and get its vote count.\n if c_votes > c_most_votes_count:\n c_most_votes_count = c_votes\n c_w_most_votes = county_name\n\n #7: Print the county with the largest turnout to the terminal.\n print(f\"The county with the most votes is {c_w_most_votes}.\\n\")\n\n #8: Save the county with the largest turnout to a text file.\n txt_file.write(\n f\"\\n-------------------------\\n\"\n f\"Largest County Turnout: {c_w_most_votes}\\n\"\n f\"-------------------------\\n\"\n )\n print(\n f\"\\n-------------------------\\n\"\n f'Candidate Results\\n'\n f\"-------------------------\\n\"\n )\n # Save the final candidate vote count to the text file.\n for candidate_name in candidate_votes:\n\n # Retrieve vote count and percentage\n votes = candidate_votes.get(candidate_name)\n vote_percentage = float(votes) / float(total_votes) * 100\n candidate_results = (\n f\"{candidate_name}: {vote_percentage:.1f}% ({votes:,})\\n\")\n\n # Print each candidate's voter count and percentage to the\n # terminal.\n print(candidate_results)\n # Save the candidate results to our text file.\n txt_file.write(candidate_results)\n\n # Determine winning vote count, winning percentage, and candidate.\n if (votes > winning_count) and (vote_percentage > winning_percentage):\n winning_count = votes\n winning_candidate = candidate_name\n winning_percentage = vote_percentage\n\n # Print the winning candidate (to terminal)\n winning_candidate_summary = (\n f\"-------------------------\\n\"\n f\"Winner: {winning_candidate}\\n\"\n f\"Winning Vote Count: {winning_count:,}\\n\"\n f\"Winning Percentage: {winning_percentage:.1f}%\\n\"\n f\"-------------------------\\n\")\n print(winning_candidate_summary)\n\n # Save the winning candidate's name to the text file\n txt_file.write(winning_candidate_summary)\n\n\n\n## TEST FOR DUPLICATES\n## NOTE: The code below (ln 180 - 193) tests for duplicate voter id numbers\n## and is commented out because it takes a very long time to run, so beware...\n## Read the csv and convert it into a list of dictionaries\n\n# with open(file_to_load) as election_data:\n# Read = csv.reader(election_data)\n\n# header = next(Read)\n\n# for row in Read:\n# voter_id = row[0]\n# if voter_id not in voter_id_list: \n# voter_id_list.append(voter_id)\n# voter_id_dict[voter_id] = 0\n# voter_id_dict[voter_id] +=1\n# if voter_id_dict[voter_id] > 1:\n# dup_output[voter_id]\n# print(dup_output)","sub_path":"PyPoll_Challenge.py","file_name":"PyPoll_Challenge.py","file_ext":"py","file_size_in_byte":6429,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"293832852","text":"import json\nfrom ahoy.dockerApi.containers import docker_containers_bp\nfrom ahoy.dockerApi import docker_client\nfrom flask import jsonify, request\nfrom docker.errors import APIError, ContainerError, InvalidArgument, NullResource\n\n\n@docker_containers_bp.route('/', methods=['GET','POST'])\ndef container_get():\n if request.method == \"POST\":\n try:\n container_id = json.loads(request.data.decode())['container_id'] or None\n return docker_client.containers.get(container_id=container_id).attrs\n except NullResource as err:\n return {'error': err.args[0]}\n\n return {'state':\"get\"}\n\n\n@docker_containers_bp.route('/list')\ndef docker_list():\n container_list = []\n for container in docker_client.containers.list(all=True):\n container_list.append(container.attrs)\n return jsonify(container_list)\n\n\n@docker_containers_bp.route('/run', methods=[\"POST\"])\ndef run_container():\n # ports format {'1900/udp': 1900, '32400/tcp': 32400}\n try:\n docker_client.containers.run( **json.loads(request.data.decode()) )\n return {\"status\":\"COntainer is created.\"}, 200\n\n except APIError as err :\n return {\"error\": f\"API Error: {err.explanation}\", },400\n\n except ContainerError as err:\n return {\"error\": f\"Container configration has error(s). Check container's logs.\"},400\n except InvalidArgument as err:\n return {\"error\": f\"{err}\" },400\n except Exception as e:\n return {\"error\": f\"{e}\" },400\n\n\n@docker_containers_bp.route('/remove', methods=[\"POST\"])\ndef remove_container():\n container_info = json.loads(request.data.decode())\n\n try:\n container = docker_client.containers.get(container_info['container_id'])\n container.remove(force=container_info['force'])\n return {\"state\": f\"{str(container.attrs['Name']).strip('/')} is removed\"}\n except APIError as err:\n return {\"msg\": str(err.explanation).split(':')[-1]},400\n except Exception as err:\n return {\"msg\":\"Something went wrong.\"}\n\n\n@docker_containers_bp.route('/start', methods=['POST'])\ndef container_start():\n\n if request.method == \"POST\":\n container_id = json.loads(request.data.decode())['container_id'] or None\n if (container_id):\n try:\n docker_client.containers.get(container_id).start()\n return {\"status\": f\"{container_id} is started.\"}\n except APIError as err:\n return {\"msg\": str(err.explanation).split(':')[-1]},400\n except Exception as err:\n return {\"msg\":\"Something went wrong.\"}\n\n return {'state':\"start\"}\n\n\n@docker_containers_bp.route('/stop', methods=['POST'])\ndef container_stop():\n\n if request.method == \"POST\":\n container_id = json.loads(request.data.decode())['container_id'] or None\n if (container_id):\n try:\n docker_client.containers.get(container_id).stop()\n return {\"status\": f\"{container_id} is stopped.\"}\n except APIError as err:\n return {\"msg\": str(err.explanation).split(':')[-1]},400\n except Exception as err:\n return {\"msg\":\"Something went wrong.\"}\n\n return {'state':\"stop\"}\n\n\n\n\n# attrs\n# id\n# image\n# labels\n# name\n# short_id\n# status\n# attach(**kwargs)\n# attach_socket(**kwargs)\n# diff()\n# exec_run(cmd, stdout=True, stderr=True, stdin=False, tty=False, privileged=False, user='', detach=False, stream=False, socket=False, environment=None, workdir=None, demux=False)\n# export(chunk_size=2097152)\n# get_archive(path, chunk_size=2097152, encode_stream=False)\n# kill(signal=None)\n# logs(**kwargs)\n# pause()\n# reload()\n# resize(height, width)\n# restart(**kwargs)\n#### start(**kwargs)\n#### stop(**kwargs)\n# stats(**kwargs)\n# top(**kwargs)\n# unpause()\n# update(**kwargs)\n# wait(**kwargs)\n\n\n\n########################################################################################################\n########################################################################################################\n########################################################################################################\n# attrs\n\n# id\n\n# The ID of the object.\n\n# image\n\n# The image of the container.\n\n# labels\n\n# The labels of a container as dictionary.\n\n# name\n\n# The name of the container.\n\n# short_id\n\n# The ID of the object, truncated to 10 characters.\n\n# status\n\n# The status of the container. For example, running, or exited. The raw representation of this object from the server.\n\n# attach(**kwargs)\n\n# Attach to this container.\n\n# logs() is a wrapper around this method, which you can use instead if you want to fetch/stream container output without first retrieving the entire backlog.\n# Parameters:\t\n\n# stdout (bool) – Include stdout.\n# stderr (bool) – Include stderr.\n# stream (bool) – Return container output progressively as an iterator of strings, rather than a single string.\n# logs (bool) – Include the container’s previous output.\n\n# Returns:\t\n\n# By default, the container’s output as a single string.\n\n# If stream=True, an iterator of output strings.\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# attach_socket(**kwargs)\n\n# Like attach(), but returns the underlying socket-like object for the HTTP request.\n# Parameters:\t\n\n# params (dict) – Dictionary of request parameters (e.g. stdout, stderr, stream).\n# ws (bool) – Use websockets instead of raw HTTP.\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# commit(repository=None, tag=None, **kwargs)\n\n# Commit a container to an image. Similar to the docker commit command.\n# Parameters:\t\n\n# repository (str) – The repository to push the image to\n# tag (str) – The tag to push\n# message (str) – A commit message\n# author (str) – The name of the author\n# changes (str) – Dockerfile instructions to apply while committing\n# conf (dict) –\n\n# The configuration for the container. See the Engine API documentation for full details.\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# diff()\n\n# Inspect changes on a container’s filesystem.\n# Returns:\t(str)\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# exec_run(cmd, stdout=True, stderr=True, stdin=False, tty=False, privileged=False, user='', detach=False, stream=False, socket=False, environment=None, workdir=None, demux=False)\n\n# Run a command inside this container. Similar to docker exec.\n# Parameters:\t\n\n# cmd (str or list) – Command to be executed\n# stdout (bool) – Attach to stdout. Default: True\n# stderr (bool) – Attach to stderr. Default: True\n# stdin (bool) – Attach to stdin. Default: False\n# tty (bool) – Allocate a pseudo-TTY. Default: False\n# privileged (bool) – Run as privileged.\n# user (str) – User to execute command as. Default: root\n# detach (bool) – If true, detach from the exec command. Default: False\n# stream (bool) – Stream response data. Default: False\n# socket (bool) – Return the connection socket to allow custom read/write operations. Default: False\n# environment (dict or list) – A dictionary or a list of strings in the following format [\"PASSWORD=xxx\"] or {\"PASSWORD\": \"xxx\"}.\n# workdir (str) – Path to working directory for this exec session\n# demux (bool) – Return stdout and stderr separately\n\n# Returns:\t\n\n# A tuple of (exit_code, output)\n\n# exit_code: (int):\n\n# Exit code for the executed command or None if either stream or socket is True.\n# output: (generator, bytes, or tuple):\n\n# If stream=True, a generator yielding response chunks. If socket=True, a socket object for the connection. If demux=True, a tuple of two bytes: stdout and stderr. A bytestring containing response data otherwise.\n\n# Return type:\t\n\n# (ExecResult)\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# export(chunk_size=2097152)\n\n# Export the contents of the container’s filesystem as a tar archive.\n# Parameters:\tchunk_size (int) – The number of bytes returned by each iteration of the generator. If None, data will be streamed as it is received. Default: 2 MB\n# Returns:\tThe filesystem tar archive\n# Return type:\t(str)\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# get_archive(path, chunk_size=2097152, encode_stream=False)\n\n# Retrieve a file or folder from the container in the form of a tar archive.\n# Parameters:\t\n\n# path (str) – Path to the file or folder to retrieve\n# chunk_size (int) – The number of bytes returned by each iteration of the generator. If None, data will be streamed as it is received. Default: 2 MB\n# encode_stream (bool) – Determines if data should be encoded (gzip-compressed) during transmission. Default: False\n\n# Returns:\t\n\n# First element is a raw tar data stream. Second element is a dict containing stat information on the specified path.\n# Return type:\t\n\n# (tuple)\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# Example\n\n# >>> f = open('./sh_bin.tar', 'wb')\n# >>> bits, stat = container.get_archive('/bin/sh')\n# >>> print(stat)\n# {'name': 'sh', 'size': 1075464, 'mode': 493,\n# 'mtime': '2018-10-01T15:37:48-07:00', 'linkTarget': ''}\n# >>> for chunk in bits:\n# ... f.write(chunk)\n# >>> f.close()\n\n# kill(signal=None)\n\n# Kill or send a signal to the container.\n# Parameters:\tsignal (str or int) – The signal to send. Defaults to SIGKILL\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# logs(**kwargs)\n\n# Get logs from this container. Similar to the docker logs command.\n\n# The stream parameter makes the logs function return a blocking generator you can iterate over to retrieve log output as it happens.\n# Parameters:\t\n\n# stdout (bool) – Get STDOUT. Default True\n# stderr (bool) – Get STDERR. Default True\n# stream (bool) – Stream the response. Default False\n# timestamps (bool) – Show timestamps. Default False\n# tail (str or int) – Output specified number of lines at the end of logs. Either an integer of number of lines or the string all. Default all\n# since (datetime or int) – Show logs since a given datetime or integer epoch (in seconds)\n# follow (bool) – Follow log output. Default False\n# until (datetime or int) – Show logs that occurred before the given datetime or integer epoch (in seconds)\n\n# Returns:\t\n\n# Logs from the container.\n# Return type:\t\n\n# (generator or str)\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# pause()\n\n# Pauses all processes within this container.\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# put_archive(path, data)\n\n# Insert a file or folder in this container using a tar archive as source.\n# Parameters:\t\n\n# path (str) – Path inside the container where the file(s) will be extracted. Must exist.\n# data (bytes) – tar data to be extracted\n\n# Returns:\t\n\n# True if the call succeeds.\n# Return type:\t\n\n# (bool)\n# Raises:\t\n\n# APIError If an error occurs.\n\n# reload()\n\n# Load this object from the server again and update attrs with the new data.\n\n# remove(**kwargs)\n\n# Remove this container. Similar to the docker rm command.\n# Parameters:\t\n\n# v (bool) – Remove the volumes associated with the container\n# link (bool) – Remove the specified link and not the underlying container\n# force (bool) – Force the removal of a running container (uses SIGKILL)\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# rename(name)\n\n# Rename this container. Similar to the docker rename command.\n# Parameters:\tname (str) – New name for the container\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# resize(height, width)\n\n# Resize the tty session.\n# Parameters:\t\n\n# height (int) – Height of tty session\n# width (int) – Width of tty session\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# restart(**kwargs)\n\n# Restart this container. Similar to the docker restart command.\n# Parameters:\ttimeout (int) – Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds.\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# start(**kwargs)\n\n# Start this container. Similar to the docker start command, but doesn’t support attach options.\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# stats(**kwargs)\n\n# Stream statistics for this container. Similar to the docker stats command.\n# Parameters:\t\n\n# decode (bool) – If set to true, stream will be decoded into dicts on the fly. Only applicable if stream is True. False by default.\n# stream (bool) – If set to false, only the current stats will be returned instead of a stream. True by default.\n\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# stop(**kwargs)\n\n# Stops a container. Similar to the docker stop command.\n# Parameters:\ttimeout (int) – Timeout in seconds to wait for the container to stop before sending a SIGKILL. Default: 10\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# top(**kwargs)\n\n# Display the running processes of the container.\n# Parameters:\tps_args (str) – An optional arguments passed to ps (e.g. aux)\n# Returns:\tThe output of the top\n# Return type:\t(str)\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# unpause()\n\n# Unpause all processes within the container.\n# Raises:\tdocker.errors.APIError – If the server returns an error.\n\n# update(**kwargs)\n\n# Update resource configuration of the containers.\n# Parameters:\t\n\n# blkio_weight (int) – Block IO (relative weight), between 10 and 1000\n# cpu_period (int) – Limit CPU CFS (Completely Fair Scheduler) period\n# cpu_quota (int) – Limit CPU CFS (Completely Fair Scheduler) quota\n# cpu_shares (int) – CPU shares (relative weight)\n# cpuset_cpus (str) – CPUs in which to allow execution\n# cpuset_mems (str) – MEMs in which to allow execution\n# mem_limit (int or str) – Memory limit\n# mem_reservation (int or str) – Memory soft limit\n# memswap_limit (int or str) – Total memory (memory + swap), -1 to disable swap\n# kernel_memory (int or str) – Kernel memory limit\n# restart_policy (dict) – Restart policy dictionary\n\n# Returns:\t\n\n# Dictionary containing a Warnings key.\n# Return type:\t\n\n# (dict)\n# Raises:\t\n\n# docker.errors.APIError – If the server returns an error.\n\n# wait(**kwargs)\n\n# Block until the container stops, then return its exit code. Similar to the docker wait command.\n# Parameters:\t\n\n# timeout (int) – Request timeout\n# condition (str) – Wait until a container state reaches the given condition, either not-running (default), next-exit, or removed\n\n# Returns:\t\n\n# The API’s response as a Python dictionary, including\n\n# the container’s exit code under the StatusCode attribute.\n\n# Return type:\t\n\n# (dict)\n# Raises:\t\n\n# requests.exceptions.ReadTimeout – If the timeout is exceeded.\n# docker.errors.APIError – If the server returns an error.\n\n","sub_path":"ahoy/dockerApi/containers/routes.py","file_name":"routes.py","file_ext":"py","file_size_in_byte":15993,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"285320209","text":"#pylint: disable-msg=E1101\n# -*- coding: iso-8859-1 -*-\n#\n# $Id: sasnCommands.py,v 1.3 2013/03/20 15:19:56 xjoaalm Exp $\n#\n# Copyright (c) Ericsson Espa�a S.A., 2012.\n# All rights reserved.\n#\n# This product or document is proprietary to and embodies the\n# confid;id+=1ential technology of Ericsson Espa�a S.A.\n# Possession, use, duplication or distribution of this product\n# or document is authorized only pursuant to a valid;id+=1 written\n# license from Ericsson Espa�a S.A\n#\n'''\nThis module contains a class to be used for encapsulating the commands\nthat can be executed in SASN\n'''\nimport copy, re\nimport os\nfrom sasnVersions import SASNVersions\nfrom execution_mode import ExecutionMode\nfrom command import Command, CommandLevel\nfrom NSTpyfw.utils.exception.framework import InvalidArgument, ArgumentNotPresent, InvalidLogFile\nfrom NSTpyfw.utils.sasn_paths import SASNPaths\n\n\"\"\"\nALL_COMMANDS = {\n \"command_name\": {\n \"com\": {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"command string\"\n }\n }\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"command string\"\n }\n }\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"command string\"\n }\n }\n }\n}\n\"\"\"\n\nALL_COMMANDS = {\n \"CHANGE_PART\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns partition set %1\"\n }\n }\n },\n \"PARTITION_CONFIGURATION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns partition show config\"\n }\n }\n },\n \"STOP_PART\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns partition stop\"\n }\n },\n \"com_available\": True\n },\n \"CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns cluster '%1' %2%3\"\n }\n }\n },\n \"ADD_TARGET\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"%1 %2 %3\"\n }\n }\n },\n\n \"SASN_START\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system boot start %1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SASN_STOP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system boot stop %1 %2\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SASN_RESTART\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system boot restart%1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SASN_STOP_ALL\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns stop%1%2\"\n }\n },\n \"com_available\": True\n },\n\n \"RD_START\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system rd-boot start %1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"RD_STOP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system rd-boot stop %1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"RD_RESTART\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system rd-boot restart%1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SHOW_PEER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 show peer\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"DIAM_APP_PARAM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 set application-param %2 %3\"\n }\n }\n },\n \"SHOW_STATUS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show status %1\"\n }\n },\n \"com_available\": True\n },\n \"SHOW_BOOT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show boot\"\n }\n },\n \"com_available\": True\n },\n \"SHOW_RD_BOOT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show rd-boot\"\n }\n },\n \"com_available\": True\n },\n \"LOAD_CFG_BCK\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard cluster load %1 local rd-backup force\"\n },\n SASNVersions().get_version_id(\"2012A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard load %1 local backup1 force\"\n }\n }\n },\n \"LOAD_CFG_MASTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard cluster load %1 force\"\n },\n SASNVersions().get_version_id(\"2012A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard load %1 force continue\"\n }\n }\n },\n \"LOAD_CFG_CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard cluster load %1 force %2\"\n },\n SASNVersions().get_version_id(\"2012A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard load %1 force continue\"\n }\n }\n },\n \"CHECK_DELTA\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns check-delta\"\n }\n },\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system check-delta %1\"\n }\n },\n \"com_available\": True\n },\n \"APPLY_CFG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard %1 apply %2 %3 %4 %5\"\n },\n SASNVersions().get_version_id(\"2012A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard apply %2 %3 %4 %5\"\n }\n }\n },\n \"LICENSE_INSTALL\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system license install %1\"\n }\n }\n },\n \"LICENSE_INSTALLED\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system license install %1\"\n }\n }\n },\n \"SHOW_SYS_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show config %1\"\n }\n },\n \"com_available\":[\n [\"(server|process|aggregated-qos|tcp|bearer|service|rating-group-control|\" + \\\n \"content-editor|content-filter|tcp-deferred-charging|\" + \\\n \"tcp-retransmitted-packets|charging-profile|qbau-reporting|gx|icap|gy|\" + \\\n \"rx|shaper|running|startup)\"]\n ]\n },\n \"SHOW_SYS_PERSISTENT_ROUTES\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show persistent-routes\"\n }\n },\n \"com_available\": True\n },\n \"SHOW_SYS_SESSION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show session%1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SHOW_SYS_STATS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show statistics %1\"\n }\n },\n \"com_available\":[\n [\"(server|process|aggregated-qos|tcp|bearer|service|rating-group-control|\" + \\\n \"content-editor|content-filter|tcp-deferred-charging|\" + \\\n \"tcp-retransmitted-packets|charging-profile|qbau-reporting|gx|icap|gy|\" + \\\n \"rx|shaper|dr-rest|dr-job|event-reporting-ebm)\"]\n ]\n },\n \"CLEAR_SYS_STATS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system clear statistics %1\"\n }\n },\n \"com_available\":[\n [\"(server|process|aggregated-qos|tcp|bearer|service|rating-group-control|\" + \\\n \"content-editor|content-filter|tcp-deferred-charging|\" + \\\n \"tcp-retransmitted-packets|charging-profile|qbau-reporting|gx|icap|gy|\" + \\\n \"rx|shaper|dr-rest|dr-job|event-reporting-ebm)\"]\n ]\n },\n \"DOMAIN_REPORTING_SYS_CMD\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system domain-reporting %1\"\n }\n }\n },\n \"HEALTH_CHECK\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns system health-check basic\"\n }\n },\n \"com_available\": False\n },\n \"CHECK_CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard cluster check %1\"\n }\n }\n },\n \"SHOW_PROC_CFG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns process show %1\"\n }\n },\n \"com_available\":[\n [\"(information|detail|ipc)\"]\n ]\n },\n \"START_STOP_PROCESS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns process %1%2\"\n }\n },\n \"com_available\":[\n [\"(start|stop)\"]\n ]\n },\n\n \"SET_PROCESS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns process set %1 %2\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n\n \"CHANGE_COREDUMP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns process set %1 coredump %2\"\n }\n },\n \"com_available\":[\n [\"pmain\", \"(on|off)\"],\n ]\n },\n \"MOD_SHOW_STAT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 show statistics\"\n }\n },\n \"com_available\":[\n [\"sml\"]\n ],\n },\n \"MOD_PLG_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 plugin %2 show %3\"\n }\n },\n \"com_available\":[\n [\"scm\", \"canalyzer\", \"(analyzers|cache|content-editor-matches|dbc|\" + \\\n \"dbc hosts|dbc rules|dbc servers|dbc timer|fields|\" + \\\n \"fields .+|flow-summary|flow-tree|flow-tree .+|\" + \\\n \"flows|flows .+|plugin|rule-matches|show statistics|\" + \\\n \"statistics all|plugin|protocols|version built-in|\" + \\\n \"version running)\"],\n [\"scm\", \"cfe\", \"(cache|cache verbose|sesssion|statistics)\"],\n [\"scm\", \"cfe profile .+\", \"cache\"],\n [\"scm\", \"relay shaper\", \"(session|statistics)\"],\n [\"scm\", \"relay$\", \"(deferred-charging-stats|dynamic-charging-statistics|\" + \\\n \"gargabe-collector|qbau-statistics|\" + \\\n \"rating-group-control-statistics|session|session all|\" + \\\n \"statistics queue|tcp-retransmit-stats|virtual-session)\"]\n ]\n },\n \"MOD_PLG_CLEAR\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 plugin %2 clear %3\"\n }\n },\n \"com_available\":[\n [\"scm\", \"canalyzer\", \"(content-editor-matches|dbc-shallow-rules)\"],\n [\"scm\", \"cfe\", \"statistics\"],\n [\"scm\", \"relay\", \"(deferred-charging-stats|dynamic-charging-statistics|\" + \\\n \"qbau-statistics|rating-group-control-statistics|\" + \\\n \"tcp-retransmit-stats)\"],\n [\"scm\", \"relay shaper\", \"statistics\"],\n ]\n },\n \"MOD_PLG_DELETE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 plugin %2 delete %3\"\n }\n },\n \"com_available\":[\n [\"scm\", \"cfe\", \"cache\"],\n [\"scm\", \"relay\", \"session all$\"],\n [\"scm\", \"canalyzer\", \"(rule-matches|all-flows)\"],\n ]\n },\n \"MOD_PLG_DELETE_PROFILE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 plugin %2 profile %3 delete %4\"\n }\n },\n \"com_available\":[\n [\"scm\", \"cfe\", \".*\", \"cache\"]\n ]\n },\n \"MOD_PLG_SET\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 plugin %2 set %3\"\n }\n },\n \"com_available\":[\n [\"scm\", \"canalyzer\", \"DNS config domain.*\"]\n ]\n },\n \"MOD_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"force_nssh\": True,\n \"command\": \"ns config %1 show%2\",\n }\n },\n \"com_available\":[\n [\".*\", \"application$\"],\n [\"broker\", \"(active|config|registry)\"],\n [\"^ha\", \"(config|process|redundancy|redundancy history|sync)\"],\n [\"probe\", \"status\"],\n [\"rdha\", \"(config|process|redundancy|redundancy history|sync)\"],\n [\"scm\", \"(control-class|replication|replication statistics|session .+)\"],\n [\"smg\", \"statistics\"],\n [\"tcp\", \"socket\"],\n [\"udr\", \"session all\"],\n [\"aocmgr\", \"session .*\"],\n [\"dataprobe\", \"status\"],\n [\"^probe\", \"status\"],\n [\"radiusproxy\", \"pools\"],\n [\"diamtr-.*\", \"(avps|categories|categories .+|debug|message|message queue|\" + \\\n \"peer|session|session .+|stat)\"],\n [\"rdvr\", \"redundancy\"],\n [\".*\", \"storage-area\"],\n [\"workflow\", \"running\"],\n [\"monitor\", \"information\"],\n [\"partition\", \"information\"],\n [\"vr\", \"(notification|process|redundancy|route|snmp)\"],\n ]\n\n },\n \"MOD_SHOW_NO_CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"force_nssh\": True,\n \"command\": \"ns config %1 show%2\",\n }\n },\n \"com_available\":[\n [\"tsmssr\", \"(status|config)\"],\n [\"rpcm\", \"status\"],\n [\"broker\", \"(vm-instance|status)\"]\n ]\n\n },\n \"MOD_CLEAR\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 clear %2\"\n }\n }\n },\n \"MOD_SET_NO_CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config %1 set %2%3\"\n }\n },\n \"com_available\":[\n [\"^ha\", \"redundancy manual\", \".*\"],\n [\"rdha\", \"redundancy manual\", \".*\"],\n ]\n },\n \"MOD_SET\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 set %2%3\"\n }\n },\n \"com_available\":[\n [\"broker\", \"(partition|partitions|probe)\", \".*\"],\n [\"^ha\", \"(process|redundancy|sync)\", \".*\"],\n [\"rdha\", \"(process|redundancy|redundancy manual|sync)\", \".*\"],\n [\"vr\", \"redundancy manual\", \".*\"],\n ]\n },\n \"MOD_SET_LOGGING\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns module set %1 logging %2\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"MOD_DELETE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 delete %2%3\"\n }\n },\n \"com_available\":[\n [\"^ha\", \"(process|sync|interface|platform-health-lockfile|subscriber)\", \".*\"],\n [\"rdha\", \"(process|sync|interface|platform-health-lockfile|subscriber)\", \".*\"]\n ]\n },\n \"XDR_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config udr plugin %1 set %2\"\n }\n }\n },\n \"SNMP_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns snmp show %1\"\n }\n },\n \"com_available\":[\n [\".*\"]\n ]\n },\n \"SNMP_MANUAL\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns snmp manual %1\"\n }\n },\n \"com_available\":[\n [\"(set|clear).*\"]\n ]\n },\n \"STATISTICS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns statistics show %1\"\n }\n },\n \"com_available\":[\n [\"information\"]\n ]\n },\n \"VAR_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns variable show value %1\"\n }\n }\n },\n \"SET_REDUNDANCY\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns part set 0 && ns config rdvr set redundancy manual %1\"\n }\n }\n },\n \"DEL_SHMEM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns management delete shmem %1\"\n }\n },\n \"com_available\":[\n [\"id\"]\n ]\n },\n \"SHOW_SHMEM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns management shmem show %1%2\"\n }\n },\n \"com_available\":[\n [\".+\"]\n ]\n },\n \"DUMP_SHMEM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns management shmem dump %1\"\n }\n },\n \"com_available\": True\n },\n \"DIAGNOSTIC\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns management diagnostic %1\"\n }\n },\n \"com_available\":[\n [\".+\"]\n ]\n },\n \"MEMDOMAIN\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns management memdomain %1%2\"\n }\n },\n \"com_available\": True\n },\n \"MANAGEMENT_BACKUP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns management backup\"\n }\n },\n \"com_available\": True\n },\n \"MANAGEMENT_CAPTURE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns management capture %1\"\n }\n },\n \"com_available\": True\n },\n \"MANAGEMENT_SET_BACKUP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns management set backup %1 %2\"\n }\n },\n \"com_available\": True\n },\n \"MANAGEMENT_TRACE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns management trace %1\"\n }\n },\n \"com_available\": True\n },\n \"MONITOR_ACTION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns monitor %1 %2 %3\"\n }\n },\n \"com_available\":[\n [\"show\", \"information\"]\n ]\n },\n \"RDMONITOR_ACTION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns rdmonitor %1 %2%3\"\n }\n },\n \"com_available\":[\n [\"show\", \"config\", \"\"]\n ]\n },\n \"SET_ANONYMOUS_SESSION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config scm plugin relay set session auto-msisdn true\"\n },\n SASNVersions().get_version_id(\"13B\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config scm plugin relay set session anonymous-sessions true\"\n }\n\n }\n },\n \"SOFTWARE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show software %1%2\"\n }\n },\n \"com_available\": True\n },\n \"VERSION\": {\n CommandLevel.com: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"display\",\n \"use_cluster\": False,\n \"command\": \"ns version\"\n }\n },\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns version\",\n \"force_nssh\": True\n }\n },\n \"com_available\": True\n },\n \"CFG_VALIDATE_HL\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns validate %1\",\n \"force_nssh\": True\n }\n },\n \"com_available\": True\n },\n \"CFG_COMMIT\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns commit %1\",\n \"force_nssh\": True\n }\n }\n },\n \"CHECK_COMMIT_STATUS\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns commit show status\"\n }\n },\n \"com_available\": True\n },\n \"COMMIT_CLEAR\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns commit clear\"\n }\n },\n \"com_available\": True\n },\n \"COMMIT_SET\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns commit set %1\"\n }\n },\n \"com_available\": [\n [\".*sequential.*\"]\n ]\n },\n \"COMMIT_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns commit show %1\"\n }\n },\n \"com_available\": [\n [\"(info|status)\"]\n ]\n },\n \"BROKER_CARDS\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns broker cards\"\n }\n },\n \"com_available\": True\n },\n \"BROKER_HOSTNAME\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns broker hostname %1\"\n }\n },\n \"com_available\": True\n },\n \"BROKER_B2B\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config broker b2b %1%2\",\n }\n },\n \"com_available\": False\n },\n \"RECOVER\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns recover%1\"\n }\n },\n \"com_available\": True\n },\n \"SINACTIVITY_CMD\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nsfw/bin/sinactivity %1\"\n }\n }\n },\n \"SHMSEARCH_CMD\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nsfw/bin/shmsearch %1\"\n }\n }\n },\n \"RST_DOMAIN_REPORTING_STATUS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config reporterEP report status reset\"\n }\n }\n },\n \"DOMAIN_REPORTING_REPORT_DOMAIN_JOB\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config reporterEP report domain job %1\"\n }\n }\n },\n \"LOG\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns log %1 %2\"\n }\n },\n \"com_available\": True\n },\n \"BROKER_FILE_TRANSFER\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns host set %1; ns copy %2 %3 %4\"\n }\n }\n },\n \"HOST\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns host set %1\"\n }\n }\n },\n \"COPY\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns copy %1 %2 %3\"\n }\n }\n },\n \"SASN_INSTALLATION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns system software install %1%2%3%4\"\n }\n },\n \"com_available\": True\n },\n \"SASN_ROLLBACK\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns system software rollback %1 %2%3%4\"\n }\n },\n \"com_available\": True\n },\n \"INSTALL_HEURISTICS\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns install-heuristics %1\"\n }\n },\n \"com_available\": True\n },\n \"UPDATE_HEURISTICS\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns update-heuristics %1\"\n }\n },\n \"com_available\": True\n },\n \"VALIDATE_HEURISTICS\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns validate-heuristics\"\n }\n },\n \"com_available\": True\n },\n \"APPLY_HEURISTICS\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns apply-heuristics\"\n }\n },\n \"com_available\": True\n },\n \"MIGRATION\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns migrate %1 outfile %2\"\n }\n },\n \"com_available\": True\n },\n \"SECURITY_CHANGE\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/tmp/hs %1 pass %2\"\n }\n }\n },\n \"RUN_CHANGE_ROOT_PASSWORD\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nstest/bin/run_change_root_password %1 %2 %3 %4 %5 %6\"\n }\n }\n },\n \"RUN_AND_CHECK_NS_COMMAND\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nstest/bin/run_and_check_ns_command %1 %2 %3 %4\"\n }\n }\n },\n \"RUN_AND_CHECK_SU_USER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nstest/bin/run_and_check_su %1 %2 %3 %4 %5 %6\"\n }\n }\n },\n \"CHANGE_ROOT_PASSWORD\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system security set pass root\"\n }\n }\n },\n \"CHECK_ROOT_PASSWORD\": {\n CommandLevel.nssh: {\n SASNVersions().get_version_id(\"14A\"): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"/opt/nstest/bin/check_su_root %1 %2 %3 %4\"\n }\n }\n },\n \"ICAP_SET_MODE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 set mode csv\"\n }\n }\n },\n \"ICAP_SET_SERVER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 set server icapserver%2\"\n }\n }\n },\n \"ICAP_SET_TRANSACTION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 set transaction%2\"\n }\n }\n },\n \"ICAP_SHOW_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config %1 show config verbose\"\n }\n }\n },\n \"PROBE_RESET\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns config probe reset %1\"\n }\n }\n },\n \"MODULE_SHOW_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns module show config\"\n }\n },\n \"com_available\": True\n },\n \"MONITOR_SHOW_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns monitor show config\"\n }\n },\n \"com_available\": True\n },\n \"PARTITION_SET\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns partition set %1\"\n }\n },\n \"com_available\": True\n },\n \"PARTITION_SHOW_CURRENT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns partition show current\"\n }\n },\n \"com_available\": True\n },\n \"PARTITION_SHOW_INFORMATION\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns partition show information\"\n }\n },\n },\n \"VARIABLE_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns variable show %1\"\n }\n },\n \"com_available\": True\n },\n \"SYSTEM_BOOT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system %1 %2%3\"\n }\n },\n \"com_available\": [\n [\"^boot\", \"auto\", \"(on|off)\"],\n [\"^boot\", \"recover\", \"\"],\n [\"rd-boot\", \"auto\", \"(on|off)\"],\n [\"rd-boot\", \"recover\", \"\"],\n ],\n },\n \"SYSTEM_SET_CONFIG\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system set config %1 %2\"\n }\n },\n \"com_available\": [\n [\"rollback-max\", \".*\"],\n ],\n },\n \"SYSTEM_SET_PDC\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"force_nssh\": True,\n \"command\": \"ns system set pdc %1%2\"\n }\n },\n \"com_available\": False\n },\n \"SYSTEM_SHOW\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show %1%2\"\n }\n },\n \"com_available\": [\n [\"pmd\", \"\"],\n [\"wizard\", \".*\"],\n [\"coredump\", \".*\"],\n ],\n },\n \"SYSTEM_WIZARD_CLUSTER\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system wizard cluster %1%2\"\n }\n },\n \"com_available\": True\n },\n \"CHECK_CONSISTENCY\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns check-consistency\"\n }\n },\n \"com_available\": True\n },\n \"MIGRATE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns migrate %1\"\n }\n },\n \"com_available\": True\n },\n \"CONFIG_RPFM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config rpfm %1\"\n }\n },\n \"com_available\": True\n },\n \"CONFIG_RPCM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns config rpcm %1 %2\"\n }\n },\n \"com_available\": True\n },\n \"CAT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns cat %1\"\n }\n },\n \"com_available\": True\n },\n \"ZCAT\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns zcat %1\"\n }\n },\n \"com_available\": True\n },\n \"DF\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns df\"\n }\n },\n \"com_available\": True\n },\n \"FREE\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns free\"\n }\n },\n \"com_available\": True\n },\n \"LS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns ls %1%2\"\n }\n },\n \"com_available\": True\n },\n \"PS\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns ps\"\n }\n },\n \"com_available\": True\n },\n \"TAIL\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns tail %1 %2\"\n }\n },\n \"com_available\": True\n },\n \"TOP\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns top%1\"\n }\n },\n \"com_available\": True\n },\n \"UPTIME\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns uptime\"\n }\n },\n \"com_available\": True\n },\n \"SOS_COMMAND\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"/opt/disk/service-pools/sasnpool/active/libexec/sos.sh %1\"\n }\n }\n },\n \"TSMSSR_CLEAN\": {\n CommandLevel.nssh: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"/opt/disk/service-pools/sasnpool/active/libexec/tsm.sh clean %1\"\n }\n }\n },\n \"RM\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": False,\n \"command\": \"ns rm %1\"\n }\n },\n \"com_available\": True\n },\n \"MEMORY_BENCHMARK\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns process show memory-benchmark %1 %2 %3\"\n }\n }\n },\n \"SASN_MEMORY\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"action\": \"execute\",\n \"use_cluster\": True,\n \"command\": \"ns system show memory info\"\n }\n }\n },\n#########################################\n## Folders and Paths\n#########################################\n \"CPUCHK_LOCAL_PATH\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"use_cluster\": False,\n \"command\": \"/opt/nstest/scripts/cpuchk\"\n }\n }\n },\n \"CPUCHK_REMOTE_PATH\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"use_cluster\": False,\n \"command\": \"/tmp/cpuchk/cpuchk\"\n }\n }\n },\n \"CPUCHK_COMMAND\": {\n CommandLevel.oracle: {\n SASNVersions().get_all_versions_id(): {\n \"use_cluster\": False,\n \"command\": \"%1%2\"\n }\n }\n },\n}\n\nclass SASNCommands(object):\n '''\n This module contains a class to be used for encapsulating the\n commands that can be executed in SASN\n '''\n __SSR_COMMANDS = 0\n __ORACLE_COMMANDS = 1\n __VSASN_COMMANDS = 2\n\n def __init__(self):\n \"\"\"\n Constructor for the class\n \"\"\"\n self._sasn_commands = ALL_COMMANDS\n self._sasn_version = None\n self.__execution_more = SASNCommands.__ORACLE_COMMANDS\n self.__command_type = CommandLevel.oracle\n ## END METHOD __init__()\n def __repr__(self):\n \"\"\"\n Return a string representation of this object, for debugging.\n\n @rtype: str\n \"\"\"\n out = '{SASNCommands'\n for i in (\"sasnCommands\", \"sasnVersion\"):\n out += ' %s=%s' % (i, repr(eval(\"self._\" + i)))\n out += '}'\n\n return out\n ## END METHOD __repr__( ... )\n def __initialize(self):\n \"\"\"\n This function initializes the class\n \"\"\"\n ## END METHOD __initialize\n def set_sasn_version(self, version ):\n \"\"\"\n Method used to set the version to be used while retrieving\n commads\n\n @param version: Version name\n @type version: str\n \"\"\"\n if 0 > SASNVersions().get_version_id(version):\n raise Exception(\"Not available version\")\n ## End If\n self._sasn_version = SASNVersions().get_version_id(version)\n SASNPaths().set_sasn_version(version)\n ## END METHOD set_sasn_version( version )\n def _set_execution_mode(self, execution_mode, command_type ):\n \"\"\"\n Function used to set execution mode to be used in\n while retrieving commands\n\n @param execution_mode: Execution mode\n @type execution_mode: str\n @param command_type: Type of commands that need to be sent:\n - B{com}: Commands will be sent via COM\n - B{nssh}: Commands will be sent via NSSH\n @type command_type: str\n \"\"\"\n if ExecutionMode().get_is_ssr(execution_mode):\n self.__execution_more = SASNCommands.__SSR_COMMANDS\n elif ExecutionMode().get_is_vsasn(execution_mode):\n self.__execution_more = SASNCommands.__VSASN_COMMANDS\n else:\n if command_type == CommandLevel.get_value(\"com\"):\n raise Exception(\"Command Type cannot be 'com' if the execution mode is not SSR\")\n ## End If\n self.__execution_more = SASNCommands.__ORACLE_COMMANDS\n ## End If\n self.__command_type = CommandLevel.get_value(command_type)\n ## END METHOD _set_execution_mode( ... )\n def __generate_command_path(self, path):\n \"\"\"\n Genearte a command or a string depending on the platform\n :param path:\n :return:\n \"\"\"\n if self.__execution_more != SASNCommands.__ORACLE_COMMANDS:\n _cmd = Command()\n _cmd.command = path\n return _cmd\n else:\n return path\n ## End If\n ## END METHOD __generate_command_path()\n def __retrieve_command(self, name, *args):\n \"\"\"\n Method that select the command needed by the caller\n\n @param name: Name of the command to be retrieved\n @type name: str\n @param args: List of arguments\n @type args: list\n\n @return: Depending on the execution mode the return will be a string\n or a tuple.\n If the execution mode is Oracle:\n Return a string with he command\n If the execution mode is SSR:\n Return a tuple with the following values:\n (type_of_command, use_or_not_ns_cluster, command)\n @rtype: str|(str,str,str)\n \"\"\"\n if None == self._sasn_version:\n raise Exception(\"SASN version need to be set first\")\n ## End If\n cmd = self._sasn_commands[name]\n result = copy.deepcopy(cmd)\n version = -1\n cmd_type = \"\"\n if result.get(CommandLevel.com) and self.__command_type == CommandLevel.com and\\\n self.__execution_more == SASNCommands.__SSR_COMMANDS:\n for key, _ in result[CommandLevel.com].iteritems():\n if version < key and self._sasn_version >= key:\n version = key\n cmd_type = CommandLevel.com\n ## End If\n ## End For\n ## End If\n\n if version == -1 and result.get(CommandLevel.nssh) and \\\n (self.__execution_more == SASNCommands.__SSR_COMMANDS or self.__execution_more == SASNCommands.__VSASN_COMMANDS):\n for key, _ in result[CommandLevel.nssh].iteritems():\n if version < key and self._sasn_version >= key:\n version = key\n cmd_type = CommandLevel.nssh\n ## End If\n ## End For\n ## End If\n if version == -1 and result.get(CommandLevel.oracle):\n for key, _ in result[CommandLevel.oracle].iteritems():\n if version < key and self._sasn_version >= key:\n version = key\n cmd_type = CommandLevel.oracle\n ## End If\n ## End For\n ## End If\n\n if -1 == version:\n raise Exception((\"The command[%s] do not exist for the version of SASN[%s]!\"%\n (name,SASNVersions().get_version_name(self._sasn_version))\n )\n )\n ## End If\n for arg_id, arg in enumerate(args):\n result[cmd_type][version][\"command\"] = result[cmd_type][version][\"command\"]\\\n .replace((\"%%%s\" % (arg_id+1)), str(arg) )\n ## End For\n if self.__execution_more != SASNCommands.__ORACLE_COMMANDS:\n com_available = False\n if result.get(\"com_available\"):\n if list != type(result[\"com_available\"]):\n com_available = True\n else:\n for cmd_list in result[\"com_available\"]:\n for param_idx, parameter in enumerate(cmd_list):\n if re.search( parameter, args[param_idx] ):\n com_available = True\n else:\n com_available = False\n break\n ## End If\n ## End For\n if com_available:\n break\n ## End If\n ## End For\n ## End If\n ## End If\n\n result_cmd = Command( result[cmd_type][version][\"command\"],\n result[cmd_type][version].get(\"action\"),\n result[cmd_type][version][\"use_cluster\"],\n cmd_type,\n com_available)\n return result_cmd\n else:\n return result[cmd_type][version][\"command\"]\n ## End If\n ## END METHOD retrieve_command(name)\n def retrieve_change_partition(self, number ):\n \"\"\"\n Function to retrieve the command to change partition\n\n @param number: Partition number to change to\n @type nunber: Integer\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CHANGE_PART\", number)\n ## End If\n ## END METHOD retrieve_change_partition( force )\n def retrieve_partition_configuration(self):\n \"\"\"\n Function to retrieve the command to see the partition configuration\n \"\"\"\n return self.__retrieve_command(\"PARTITION_CONFIGURATION\")\n ## END METHOD retrieve_partition_configuration()\n def retrieve_stop_partition(self):\n \"\"\"\n Function to retrieve the command to stop partition\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"STOP_PART\")\n ## END METHOD retrieve_stop_partition( force )\n def retrieve_cluster_command(self, command,\n target,\n partition = -1\n ):\n \"\"\"\n Function to wrap a command to a specific target\n and partition\n If no partition is needed then the value should be -1\n\n @param command: Command to be sent\n @type command: String\n @param target: Target platform or card\n @type target: String\n @param partition: Partiton where the command should be performed\n @type partition: Integer\n\n @rtype: String\n \"\"\"\n part = \"\"\n if str(-1) != str(partition):\n part = \" partition %s\" % partition\n ## End If\n if type(command) == Command:\n cmd = command.command\n else:\n cmd = command\n ## End If\n\n cmd = self.__retrieve_command(\"CLUSTER\", cmd,\n target,\n part)\n if type(command) == Command:\n command.command = cmd.command\n else:\n command = cmd\n ## End If\n\n return command\n\n ## END METHOD retrieve_cluster_command( ... )\n def retrieve_target_command(self, command,\n target,\n partition = -1\n ):\n \"\"\"\n Function to wrap a command to a specific target\n and partition\n If no partition is needed then the value should be -1\n\n @param command: Command to be sent\n @type command: String\n @param target: Target platform or card\n @type target: String\n @param partition: Partiton where the command should be performed\n @type partition: Integer\n\n @rtype: String\n \"\"\"\n part = \"\"\n if str(-1) != str(partition):\n part = \" %s\" % partition\n ## End If\n if type(command) == Command:\n cmd = command.command\n else:\n cmd = command\n ## End If\n\n cmd = self.__retrieve_command(\"ADD_TARGET\", cmd,\n target,\n part)\n if type(command) == Command:\n command.command = cmd.command\n else:\n command = cmd\n ## End If\n\n return command\n\n ## END METHOD retrieve_target_command( ... )\n\n def retrieve_cluster_sasn_start(self, force = True ):\n \"\"\"\n Function to retrieve the command to start SASN in all\n the cluster\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd = self.retrieve_sasn_start(force)\n return self.retrieve_cluster_command(cmd, \"all\")\n\n ## END METHOD retrieve_cluster_sasn_start( force )\n def retrieve_sasn_start(self, force = True ):\n \"\"\"\n Function to retrieve the command to start SASN\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n if force:\n return self.__retrieve_command(\"SASN_START\",\"force\")\n else:\n return self.__retrieve_command(\"SASN_START\",\"\")\n ## End If\n ## END METHOD retrieve_sasn_start( force )\n def retrieve_cluster_sasn_stop(self, abrupt = True, force = True ):\n \"\"\"\n Function to retrieve the command to stop SASN in all\n the cluster\n\n @param abrupt: Add abrupt to the command\n @type abrupt: Boolean\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd = self.retrieve_sasn_stop(abrupt, force)\n return self.retrieve_cluster_command(cmd, \"all\")\n\n ## End If\n ## END METHOD retrieve_cluster_sasn_stop( abrupt force )\n def retrieve_sasn_stop(self, abrupt = True, force = True ):\n \"\"\"\n Function to retrieve the command to stop SASN\n\n @param abrupt: Add abrupt to the command\n @type abrupt: Boolean\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd_abr = \"abrupt\" if abrupt else \"\"\n cmd_force = \"force\" if force else \"\"\n return self.__retrieve_command(\"SASN_STOP\", cmd_abr, cmd_force)\n\n ## End If\n ## END METHOD retrieve_cluster_sasn_stop( abrupt force )\n def retrieve_sasn_restart(self, force = True ):\n \"\"\"\n Function to retrieve the command to restart SASN\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n if force:\n return self.__retrieve_command(\"SASN_RESTART\",\" force\")\n else:\n return self.__retrieve_command(\"SASN_RESTART\",\"\")\n ## End If\n ## END METHOD retrieve_sasn_restart( force )\n def retrieve_cluster_rd_start(self, force = True ):\n \"\"\"\n Function to retrieve the command to start Radius Distributor\n in all the cluster\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd = self.retrieve_rd_start(force)\n return self.retrieve_cluster_command(cmd, \"all\")\n ## END METHOD retrieve_cluster_rd_start( force )\n def retrieve_rd_start(self, force = True ):\n \"\"\"\n Function to retrieve the command to start Radius Distributor\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd_force = \"force\" if force else \"\"\n return self.__retrieve_command(\"RD_START\", cmd_force)\n ## End If\n ## END METHOD retrieve_rd_start( force )\n def retrieve_cluster_rd_stop(self, force = True ):\n \"\"\"\n Function to retrieve the command to stop Radius Distributor\n in all the cluster\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd = self.retrieve_rd_stop(force)\n return self.retrieve_cluster_command(cmd, \"all\")\n\n ## End If\n ## END METHOD retrieve_cluster_rd_stop( abrupt, force )\n def retrieve_rd_stop(self, force = True ):\n \"\"\"\n Function to retrieve the command to stop Radius Distributor\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd_force = \"force\" if force else \"\"\n return self.__retrieve_command(\"RD_STOP\", cmd_force)\n\n ## End If\n ## END METHOD retrieve_rd_stop( abrupt, force )\n def retrieve_rd_restart(self, force = True ):\n \"\"\"\n Function to retrieve the command to restart Radius Distributor\n\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd_force = \" force\" if force else \"\"\n return self.__retrieve_command(\"RD_RESTART\", cmd_force)\n ## END METHOD retrieve_rd_restart( force )\n def retrieve_show_peer(self, server_name):\n \"\"\"\n Function to retrieve the command to show a peer information.\n For cluster evolution newer versions the partition argument\n will be ignored\n\n @param server_name: Name of the peer to check\n @type server_name: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"SHOW_PEER\", server_name)\n ## END METHOD retrieve_show_peer( abrupt, force )\n def retrieve_status(self, verbose = True):\n \"\"\"\n Function to retrieve the command to show status of SASN\n\n @param verbose: Set verbose output\n @type verbose: Boolean\n @rtype: String\n \"\"\"\n _verbose = \"verbose\" if verbose else \"\"\n return self.__retrieve_command(\"SHOW_STATUS\", _verbose)\n ## END METHOD retrieve_cluster_rd_stop( abrupt, force )\n def retrieve_show_boot(self):\n \"\"\"\n Function to retrieve the command to show system show boot data of SASN\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"SHOW_BOOT\")\n ## END METHOD retrieve_cluster_rd_stop( abrupt, force )\n def retrieve_show_rd_boot(self):\n \"\"\"\n Function to retrieve the command to show system show rd-boot data of SASN\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"SHOW_RD_BOOT\")\n ## END METHOD retrieve_cluster_rd_stop( abrupt, force )\n def retrieve_load_configuration_backup(self, config_file_path):\n \"\"\"\n Function to retrieve the command to load SASN configuration file\n into the Backup PPU\n\n @param config_file_path: Path to the HL file\n @type config_file_path: String\n @rtype: String\n \"\"\"\n\n return self.__retrieve_command(\"LOAD_CFG_BCK\", config_file_path)\n\n ## End If\n ## END METHOD retrieve_load_configuration_backup( config_file_path )\n def retrieve_load_configuration_master(self, config_file_path):\n \"\"\"\n Function to retrieve the command to load SASN configuration file\n into the Master PPU\n\n @param config_file_path: Path to the HL file\n @type config_file_path: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"LOAD_CFG_MASTER\", config_file_path)\n\n ## End If\n ## END METHOD retrieve_load_configuration_master( config_file_path )\n def retrieve_load_configuration_cluster(self, config_file_path,\n cnt = False):\n \"\"\"\n Function to retrieve the command to load SASN configuration file\n into the Master PPU\n\n @param config_file_path: Path to the HL file\n @type config_file_path: String\n @param cnt: Add continue to the command\n @type cnt: Boolean\n @rtype: String\n \"\"\"\n command = \"\"\n if cnt:\n command = \"continue\"\n ## End If\n\n return self.__retrieve_command(\"LOAD_CFG_CLUSTER\", config_file_path, command)\n ## END METHOD retrieve_load_configuration_cluster( config_file_path )\n def retrieve_check_delta(self, config_file_path = \"\"):\n \"\"\"\n Function to retrieve the command to check delta configuration on SASN\n\n @param config_file_path: Path to the HL file\n @type config_file_path: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CHECK_DELTA\", config_file_path)\n ## END METHOD retrieve_check_delta( config_file_path )\n def retrieve_apply_configuration(self, apply_mode = \"sequential\", cluster = False, \\\n p_timeout = 10, abrupt = True, rate = None,\\\n force = True, continue_apply = True):\n \"\"\"\n Function to retrieve the command to apply configuration to SASN\n\n @param cluster: Apply to all cluster\n @type cluster: Boolean\n @param apply_mode: Defines the mode to apply a config. Available values: parallel, local or sequential. Default value: sequential\n @type apply_mode: str\n @param p_timeout: Parallel timeout. When the apply_mode is set to \"parallel\", this value will be used as timeout.\n @type p_timeout: Integer\n @param abrupt: Do an abrupt apply\n @type abrupt: Boolean\n @param rate: If abrupt is false check this variable to see if\n a rate of session drop should be placed.\n @type rate: Integer\n @param force: Force apply\n @type force: Boolean\n @param continue_apply: Ignore errors\n @type continue_apply: Boolean\n @param local: Add local\n @type local: Boolean\n @rtype: String\n \"\"\"\n\n if cluster:\n _cluster = \"cluster\"\n else:\n _cluster = \"\"\n ## End If\n\n if apply_mode == \"parallel\":\n _sequential = \"parallel timeout %s\" % p_timeout\n elif apply_mode == \"local\":\n _sequential = \"local\"\n else:\n _sequential = \"sequential\"\n ## End If\n\n if abrupt:\n _abrupt = \"abrupt\"\n elif rate != None:\n _abrupt = \"rate %s\"% rate\n else:\n _abrupt = \"\"\n ## End If\n _force = \"force\" if force else \"\"\n _continue = \"continue\" if continue_apply else \"\"\n\n return self.__retrieve_command(\"APPLY_CFG\", _cluster, _sequential, \\\n _abrupt, _force, _continue)\n\n ## End If\n ## END METHOD retrieve_load_configuration_master( config_file_path )\n def retrieve_process_show(self,\n option = \"\",\n *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show process configuration\n\n @param option: Defines the process options that you want to retrieve\n @type options: str\n @rtype: String\n \"\"\"\n\n assert option in [\"config\", \"detail\", \"information\", \"ipc\"]\n value = option\n\n if len(args) > 0:\n for extra_parameter in args:\n value += \" \" + extra_parameter\n ## End If\n return self.__retrieve_command(\"SHOW_PROC_CFG\", value)\n\n ## END METHOD retrieve_load_configuration_master( config_file_path )\n\n def retrieve_set_process(self, process, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to activate or deactivate cores on a\n process\n\n @param process: Process name\n @type process: String\n @rtype: String\n \"\"\"\n extra_param = \"\"\n for param in args:\n extra_param += \" \" + param\n return self.__retrieve_command(\"SET_PROCESS\", process, extra_param)\n\n def retrieve_coredump_change(self, process, change_type = \"on\"):\n \"\"\"\n Function to retrieve the command to activate or deactivate cores on a\n process\n\n @param process: Process name\n @type process: String\n @param change_type: Values allowed( on, off ) to activate or deactivate\n CORE's into the process\n @type change_type: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CHANGE_COREDUMP\", process, change_type)\n\n def retrieve_show_module_stat(self, module_name):\n \"\"\"\n Function to retrieve the command to show probe status\n\n @param partition: Partition number\n @type partition: Integer\n @param module_name: Name of the module\n @type module_name: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"MOD_SHOW_STAT\", module_name)\n\n ## End If\n ## END METHOD retrieve_show_module_stat( partition )\n# def retrieve_show_module_plugin_stat(self, partition, module, plugin,\\\n# virtualSessions = False):\n# \"\"\"\n# Function to retrieve the command to show plugin status\n#\n# @param partition: Partition number\n# @type partition: Integer\n# @param module: Module name\n# @type module: String\n# @param plugin: Plugin name\n# @type plugin: String\n# @param virtualSessions: Get virtual session stat\n# @type virtualSessions: Boolean\n# @rtype: String\n# \"\"\"\n# return self.__retrieve_command(\"MOD_SHOW_STAT\", partition,\\\n# module, plugin,\\\n# (\"virtual-sessions\" if virtualSessions else \"\") )\n# ## End If\n# ## END METHOD retrieve_show_module_plugin_stat( partition, module, plugin,\n# ## virtualSessions )\n\n def retrieve_show_module_plugin(self, module, plugin, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show plugin status.\n\n The following option_stat are available:\n - For plugin relay:\n - \"rating_group\"\n - \"apr\"\n - \"qbau\"\n - \"deferred_charging\"\n - \"dynamic_charging\"\n - \"config\"\n - \"content_editor\"\n - \"garbage_collector\"\n - \"limits\"\n - \"statistics\"\n - \"session\"\n - \"virtual_class\"\n - \"virtual_session\"\n - \"tcp_retrasmit\"\n - \"topup_apns\"\n - \"shaper_session\"\n - \"statistics_queue\"\n - For plugin canalyzer:\n - \"rule_matches\"\n - \"extended_rule_hits_info\"\n - \"flow_summary\"\n - \"session_all\"\n - \"session_ip\": An IP should be provide as extra parameter (set at the first position of args)\n - \"session_id\" : An ID should be provide as extra parameter (set at the first position of args)\n - \"session_nai\" : An NAI should be provide as extra parameter (set at the first position of args)\n - \"session_imsi\" : An IMSI should be provide as extra parameter (set at the first position of args)\n - \"session_msid\" : An MSID should be provide as extra parameter (set at the first position of args)\n - \"p2p_cache\"\n - \"p2p_port_cache\"\n - \"p2p_group\"\n - \"p2p_pattern\"\n - \"p2p_detector\"\n - \"umc_report\"\n - \"umc_mk_report\"\n - \"dbc_rules\"\n - \"dbc_hosts\"\n - \"dbc_servers\"\n - \"dbc_timer\"\n - \"sig_running\"\n - \"sig_built\"\n - \"sig_protocol\"\n - \"detector_running\"\n - \"detector_built\"\n - \"dns_reporting_job_hosts\"\n - \"domain_reporting\"\n - \"domain_reporting_list\"\n - \"domain_reporting_jobs\"\n - \"rule_space_name\" : A rule space name should be provided as extra parameter (set at the first position of args)\n - \"pkt_mark\"\n - \"qos_information\"\n - \"routing_rules\"\n - \"analyzers\"\n - \"fields\"\n - \"flows\"\n - \"flow_tree\"\n - \"plugin\"\n - \"statistics_all\"\n - \"statistics_content_type\"\n - \"content_editor_matches\"\n - \"dpi_version\"\n - For plugin cfe:\n - \"cache\"\n - \"cache profile\"\n - \"profile\"\n - \"cache_plain\"\n - \"cache_verbose\"\n - \"profile_cache\"\n - \"statistics\"\n - \"session\"\n\n\n @param partition: Partition number\n @type partition: Integer\n @param module: Module name\n @type module: String\n @param plugin: Plugin name\n @type plugin: String\n @param option_stat: The option or stat to retrieve the information\n @type option_stat: str\n\n @rtype: String\n \"\"\"\n extra_value = \"\"\n if len(args) > 0:\n extra_value = args[0]\n\n dict_table_plugin = {\"sig_running\" : \"signatures\",\n \"sig_built\" : \"signatures\",\n \"sig_protocol\" : \"signatures\",\n \"detector_running\" : \"detectors\",\n \"detector_built\" : \"detectors\",\n \"sig_running\" : \"signatures\",\n \"qos_information\": \"pccrules\",\n \"pcc_rule\": \"pccrules\",\n \"pcc_rule_group\": \"pccrules\",\n \"pcc_rule_profile\": \"pccrules\",\n \"cache profile\": \"profile %s\" % extra_value,\n \"profile_cache\" : \"profile %s\" % extra_value,\n \"shaper_session\" : \"shaper\"\n }\n dict_table_option_stat = {\"rating_group\" : \"rating-group-control-statistics\",\n \"apr\" : \"apr-statistics\",\n \"qbau\" : \"qbau-statistics\",\n \"deferred_charging\" : \"deferred-charging-stats\",\n \"dynamic_charging\" : \"dynamic-charging-statistics\",\n \"config\" : \"config\",\n \"content_editor\" : \"content-editor-matches\",\n \"garbage_collector\" : \"garbage-collector\",\n \"limits\" : \"limits\",\n \"statistics\" : \"statistics\",\n \"session\" : \"session\",\n \"virtual_class\" : \"stat virtual-class\",\n \"virtual_session\" : \"virtual-session\",\n \"tcp_retrasmit\" : \"tcp-retransmit-stats\",\n \"topup_apns\" : \"topup-apns\",\n \"rule_matches\" : \"rule-matches\",\n \"extended_rule_hits_info\" : \"rule-matches extended-rule-hits-info\",\n \"flow_summary\" : \"flow-summary\",\n \"session_all\" : \"session all\",\n \"session_ip\" : \"session ip %s\" % extra_value,\n \"session_id\" : \"session id %s\" % extra_value,\n \"session_nai\" : \"session nai %s\" % extra_value,\n \"session_imsi\" : \"session imsi %s\" % extra_value,\n \"session_msid\" : \"session msid %s\" % extra_value,\n \"cfe_session\" : \"session %s\" % extra_value,\n \"cfe_session_all\" : \"session\",\n \"cfe_session_id\" : \"session id %s\" % extra_value,\n \"cfe_session_msisdn\" : \"session msisdn %s\" % extra_value,\n \"p2p_cache\" : \"p2p-cache\",\n \"p2p_port_cache\" : \"p2p-port-cache\",\n \"p2p_group\" : \"p2p-group-matches\",\n \"p2p_pattern\" : \"p2p-pattern-matches\",\n \"p2p_detector\" : \"p2p-detector-matches\",\n \"umc_report\" : \"umc-statistics\",\n \"umc_mk_report\" : \"umc-mk-statistics\",\n \"dbc_rules\" : \"dbc rules\",\n \"dbc_hosts\" : \"dbc hosts\",\n \"dbc_servers\" : \"dbc servers\",\n \"dbc_timer\" : \"dbc timer\",\n \"sig_running\" : \"version running\",\n \"sig_built\" : \"version built-in\",\n \"sig_protocol\" : \"protocols\",\n \"detector_running\" : \"version running\",\n \"detector_built\" : \"version built-in\",\n \"dns_reporting_job_hosts\" : \"dns-reporting-job %s hosts\" % extra_value,\n \"domain_reporting\" : \"domain-reporting statistics\",\n \"domain_reporting_jobs\": \"domain-reporting jobs\",\n \"domain_reporting_list\": \"domain-reporting list %s\" % extra_value,\n \"rule_space_name\" : \"rule-space %s\" % extra_value,\n \"pkt_mark\" : \"pkt-mark\",\n \"qos_information\": \"qos-information\",\n \"pcc_rule\": \"pcc-rule\",\n \"pcc_rule_group\": \"pcc-rule-group\",\n \"pcc_rule_profile\": \"pcc-rule-profile\",\n \"cache\": \"cache verbose\",\n \"cache profile\": \"cache verbose\",\n \"profile\": \"profile\",\n \"cache_plain\" : \"cache\",\n \"cache_verbose\": \"cache verbose\",\n \"profile_cache\": \"cache\",\n \"routing_rules\": \"routing-rules\",\n \"analyzers\" : \"analyzers\",\n \"fields\" : \"fields %s\" % extra_value,\n \"flows\" : \"flows %s\" % extra_value,\n \"flow_tree\" : \"flow-tree %s\" % extra_value,\n \"plugin\" : \"plugin\",\n \"statistics_all\" : \"statistics all\",\n \"shaper_session\" : \"session\",\n \"statistics_queue\" : \"statistics queue\",\n \"statistics_content_type\" : \"statistics content-type %s\" % extra_value,\n \"content_editor_matches\": \"content-editor-matches\",\n \"cdpi_version\": \"cdpi version\"}\n\n assert option_stat in dict_table_option_stat.keys(), \"Invalid option_stat [%s] will be found for pluging %s\" % (option_stat, plugin)\n\n if dict_table_plugin.get(option_stat):\n plugin += \" \" + dict_table_plugin.get(option_stat, \"\")\n value = dict_table_option_stat.get(option_stat)\n\n return self.__retrieve_command(\"MOD_PLG_SHOW\", module, plugin, value )\n ## End If\n ## END METHOD retrieve_show_module_plugin_stat( partition, module, plugin,\n ## * )\n def retrieve_show_module(self, module, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show\n from module\n\n Some extra parameter can be set using args (list of values) depending on the module:\n - \"session all\"\n - \"config\"\n - \"reconciliation\"\n - \"delete\"\n - \"redundancy\"\n - \"verbose\"\n - ...\n\n @param module: Module name\n @type module: String\n\n @rtype: String\n \"\"\"\n value = \"\"\n for option in args:\n value += \" \" + option\n\n no_cluster_options = {\"tsmssr\": [],\n \"rpcm\": [],\n \"broker\": [\"vm-instance\", \"status\"],\n }\n\n no_cluster = False\n if module in no_cluster_options.keys():\n if len(no_cluster_options[module]) > 0:\n for elem in args:\n if elem in no_cluster_options[module]:\n no_cluster = True\n break\n else:\n no_cluster = True\n\n\n if no_cluster:\n return self.__retrieve_command(\"MOD_SHOW_NO_CLUSTER\", module, value )\n else:\n return self.__retrieve_command(\"MOD_SHOW\", module, value )\n ## End If\n ## END METHOD retrieve_show_module( ... )\n\n def retrieve_clear_module(self, module, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to clear\n from module\n\n @param module: Module name\n @type module: String\n @rtype: String\n \"\"\"\n value = \"\"\n for option in args:\n value += \" \" + option\n ## End If\n return self.__retrieve_command(\"MOD_CLEAR\", module, value )\n ## End If\n ## END METHOD retrieve_clear_module( ... )\n def retrieve_show_set(self, module, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to set an option to the module.\n\n The options will depends the selected module.\n\n And it also depends of the option to add some extra parameters.\n\n @param partition: Partition number\n @type partition: Integer\n @param module: Module name\n @type module: String\n\n @rtype: String\n \"\"\"\n module_suffix_table = {\"redirect-agent\" : \"redirect-agent\"}\n\n value = \"\"\n for extra_param in args:\n value = \"%s %s\" % (value, extra_param)\n\n no_cluster_options = {\"ha\": [\"redundancy manual\", \"config-provisioning\", \"interface\",\n \"platform-health-lockfile\", \"subscriber \",\n \"redundancy exclude\", \"redundancy include\"],\n \"rdha\": [\"redundancy manual\", \"config-provisioning\",\n \"interface\", \"platform-health-lockfile\",\n \"subscriber \"],\n \"tsmssr\": [\"timeout pap\", \"timeout tssleep\", \"tsft_size\"],\n \"rpfm\": [\"alarm\"]\n }\n no_cluster = False\n if module in no_cluster_options.keys():\n if len(no_cluster_options[module]) > 0:\n if option in no_cluster_options[module]:\n no_cluster = True\n else:\n no_cluster = True\n\n if module_suffix_table.get(option):\n module += \" \" + module_suffix_table.get(option, \"\")\n option = \"\"\n\n if no_cluster:\n cmd = self.__retrieve_command(\"MOD_SET_NO_CLUSTER\", module, option, value )\n cmd.set_local(True)\n return cmd\n else:\n return self.__retrieve_command(\"MOD_SET\", module, option, value )\n ## End If\n\n ## End If\n\n ## End If\n ## END METHOD retrieve_show_set( ... )\n\n def retrieve_module_set_logging(self, module, level):\n \"\"\"\n Function to retrieve the command to set module logging\n\n @param module: Module name\n @type module: String\n @param level: The logging level to set\n @type level: int\n\n @param parameter: Extra parameters to be passed to the command\n @type parameter: String\n @rtype: String\n \"\"\"\n ## End If\n return self.__retrieve_command(\"MOD_SET_LOGGING\", \\\n module, \\\n level)\n ## End If\n ## END METHOD retrieve_module_set_logging( ... )\n\n def retrieve_show_delete(self, module, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to delete an option from the module.\n\n The options will depends the selected module.\n\n And it also depends of the option to add some extra parameters.\n\n @param partition: Partition number\n @type partition: Integer\n @param module: Module name\n @type module: String\n\n @rtype: String\n \"\"\"\n value = \"\"\n for extra_param in args:\n value += \" \" + extra_param\n\n return self.__retrieve_command(\"MOD_DELETE\", module, option, value )\n ## END METHOD retrieve_show_delete( ... )\n\n def retrieve_clear_module_plugin(self, module, plugin, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to clear\n from plugin\n\n The following option_stat are available:\n - For plugin relay:\n - \"virtual_class\"\n - \"qbau\"\n - \"statistics\"\n - \"content_editor\"\n - \"deferred_charging\"\n - \"tcp_retrasmit\"\n - \"dynamic_charging\"\n - \"rating_group\"\n\n - For plugin canalyzer:\n - \"session_all\"\n - \"umc_report\"\n - \"umc_mk_report\"\n - \"p2p_cache\"\n - \"p2p_port_cache\"\n - \"p2p_group\"\n - \"p2p_pattern\"\n - \"p2p_detector\"\n - \"domain_reporting\"\n - \"domain_reporting_list\"\n - \"dbc_shallow_rules\"\n - \"content_editor_matches\"\n\n @param module: Module name\n @type module: String\n @param plugin: Plugin name\n @type plugin: String\n @param option_stat: The option or stat to clear information\n @type option_stat: str\n @rtype: String\n \"\"\"\n\n dict_table_option_stat = {\n \"virtual_class\" : \"statistics virtual-class\",\n \"session_all\" : \"session all\",\n \"qbau\" : \"qbau-statistics\",\n \"statistics\" : \"statistics\",\n \"content_editor\" : \"content-editor-matches\",\n \"deferred_charging\" : \"deferred-charging-stats\",\n \"tcp_retrasmit\" : \"tcp-retransmit-stats\",\n \"dynamic_charging\" : \"dynamic-charging-statistics\",\n \"rating_group\" : \"rating-group-control-statistics\",\n \"umc_report\" : \"umc-statistics\",\n \"umc_mk_report\" : \"umc-mk-statistics\",\n \"p2p_cache\" : \"p2p-cache\",\n \"p2p_port_cache\" : \"p2p-port-cache\",\n \"p2p_group\" : \"p2p-group-matches\",\n \"p2p_pattern\" : \"p2p-pattern-matches\",\n \"p2p_detector\" : \"p2p-detector-matches\",\n \"domain_reporting\" : \"domain-reporting statistics\",\n \"domain_reporting_list\" : \"domain-reporting list\",\n \"dbc_shallow_rules\": \"dbc-shallow-rules\",\n \"content_editor_matches\": \"content-editor-matches\",\n \"session\": \"session\"}\n\n value = dict_table_option_stat.get(option_stat)\n\n return self.__retrieve_command(\"MOD_PLG_CLEAR\", module, plugin, value )\n ## End If\n ## END METHOD retrieve_clear_module_plugin( partition, module, plugin,\n ## virtualSessions )\n def retrieve_delete_module_plugin(self, module, plugin, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to delete\n from plugin\n\n @param module: Module name\n @type module: String\n @param plugin: Plugin name\n @type plugin: String\n @param option_stat: The option or stat to clear information\n @type option_stat: str\n\n @rtype: String\n \"\"\"\n\n extra_value = \"\"\n if len(args) > 0:\n extra_value = args[0]\n dict_table_option_stat = {\n \"rule_matches\" : \"rule-matches\",\n \"session_all\" : \"session all\",\n \"session_id\" : \"session %s\" % extra_value,\n \"all_flows\" : \"all-flows %s\" % extra_value,\n \"cache\" : \"cache\"}\n\n value = dict_table_option_stat.get(option_stat)\n if option_stat == \"session_all\" and kwargs.get(\"rate\") != None:\n value += \" rate %s\" % kwargs.get(\"rate\")\n return self.__retrieve_command(\"MOD_PLG_DELETE\", module, plugin, value )\n ## End If\n ## END METHOD retrieve_delete_module_plugin( partition, module, plugin,\n ## virtualSessions )\n\n def retrieve_delete_module_plugin_profile(self, module, plugin, profile, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to delete\n from plugin\n\n @param module: Module name\n @type module: String\n @param plugin: Plugin name\n @type plugin: String\n @param profile: Profile name\n @type profile: String\n @param option: The option to clear information\n @type option: str\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"MOD_PLG_DELETE_PROFILE\", module, plugin, profile, option)\n ## End If\n ## END METHOD retrieve_delete_module_plugin_profile( ... )\n\n def retrieve_set_module_plugin(self, module, plugin, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to set plugin\n\n @param module: Module name\n @type module: String\n @param plugin: Plugin name\n @type plugin: String\n @param option_stat: Availabe options: debug_internal_all, pkt_mark, domain_reporting\n @oaram option_stat: str\n\n @param enable: Enable/Disable a parameter in the plugin\n @type enable: Boolean\n @rtype: String\n \"\"\"\n value = \"\"\n if option_stat == \"debug_internal_all\":\n value = \"debug internal all\"\n\n elif option_stat == \"pkt_mark\":\n\n value = \"pkt-mark enable \"\n if kwargs.get(\"enable\"):\n value += \"on\"\n else:\n value += \"off\"\n ## End If\n elif option_stat == \"domain\":\n\n value = \"analyzer DNS config domain %s\" % kwargs.get(\"action\")\n ## End If\n elif option_stat == \"flow\":\n\n value = \"flow %s\" % kwargs.get(\"action\")\n ## End If\n elif option_stat == \"domain_reporting\":\n\n if kwargs.get(\"max_list_size\"):\n value = \"domain-reporting max-list-size %s\" % str(kwargs.get(\"max_list_size\"))\n else:\n raise Exception(\"Invalid arguments was found for domain_reporting options\")\n ## End If\n ## End If\n return self.__retrieve_command(\"MOD_PLG_SET\", module, plugin, value )\n ## End If\n ## END METHOD retrieve_set_module_plugin( partition, module, plugin,\n ## virtualSessions )\n def retrieve_xdr_configuration(self, xdr_type, option, reporting = False, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to retrieve\n XDR configuration\n\n @param xdr_type: XDR Type\n @type xdr_type: String\n @param option: The available options are: sequence_file, binary_filename or filename\n @type option: str\n @param reporting: This flag indicates which file pattern should be used to read the XDR files: charging (default) or reporting\n @type reporting: bool\n\n @rtype: String\n \"\"\"\n value = \"\"\n if reporting:\n value = \"reporting \"\n\n if option == \"sequence_file\":\n value += \"sequence filename %s\" % args[0]\n elif option == \"binary_filename\":\n value += \"filename binary %s\" % args[0]\n elif option == \"filename\":\n value += \"filename %s\" % args[0]\n elif option == \"rotation interval\":\n extra_options = str(kwargs.get(\"time\"))\n if kwargs.get(\"force\"):\n extra_options += \" force\"\n value += \"rotation-interval %s\" % extra_options\n ## End If\n return self.__retrieve_command(\"XDR_CONFIG\", \\\n xdr_type, value )\n ## End If\n ## END METHOD retrieve_xdr_configuration( partition, module, plugin,\n ## virtualSessions )\n def retrieve_snmp_show(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show commands\n on SNMP\n\n @param option: Option to retrieve\n @type option: str\n\n @rtype: String\n \"\"\"\n assert option in [\"config\", \"event\", \"information\", \"mib\", \"status\"], \"Invalid option was requested as snmp option.\"\n value = option\n\n ## End If\n return self.__retrieve_command(\"SNMP_SHOW\", \\\n value )\n ## End If\n ## END METHOD retrieve_snmp_show( status )\n def retrieve_snmp_manual(self, option,\n event_number,\n event_text = \"\",\n event_level = \"\"):\n \"\"\"\n Function to retrieve the command to execute manual\n commands on SNMP\n\n @param option: this string value could be set with: clear or set\n @type option: str\n\n @param event_number: Event number to be set or clear\n @type event_number: String\n @param event_text: Additional text for the event\n @type event_text: String\n @param event_level: Event level\n @type event_level: String\n @rtype: String\n \"\"\"\n value = \"\"\n if option == \"clear\":\n value = \"clear %s\" % (event_number)\n elif option == \"set\":\n value = \"set %s\" % (event_number)\n ## End If\n if event_text != \"\" and event_text is not None:\n value += \" \\\"%s\\\"\" % event_text\n ## End If\n if event_level != \"\":\n value += event_level\n ## End If\n return self.__retrieve_command(\"SNMP_MANUAL\", \\\n value )\n ## End If\n ## END METHOD retrieve_snmp_manual( ... )\n\n def retrieve_show_system_config(self, option = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show system configuration\n\n @param option: Defines the config option that you want to retrieve\n @type options: str\n @rtype: String\n \"\"\"\n\n assert option in [\"running\", \"startup\"]\n value = option\n return self.__retrieve_command(\"SHOW_SYS_CONFIG\", value)\n ## END METHOD retrieve_show_system_config( ... )\n\n def retrieve_show_system_persistent_routes(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show system persistent routes\n\n @rtype: String\n \"\"\"\n\n return self.__retrieve_command(\"SHOW_SYS_PERSISTENT_ROUTES\")\n ## END METHOD retrieve_show_system_persistent_routes( ... )\n\n def retrieve_show_system_session(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show system session\n\n @param option: Defines the session option that you want to retrieve\n @type options: str\n @rtype: String\n \"\"\"\n if len(args) > 0:\n value = \"\"\n for extra_parameter in args:\n value += \" \" + extra_parameter\n ## End If\n return self.__retrieve_command(\"SHOW_SYS_SESSION\", value)\n ## END METHOD retrieve_show_system_session( ... )\n\n def retrieve_show_system_stats(self, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show system\n statistics.\n\n The following options are available as option_stat:\n - \"server\"\n - \"process\"\n - \"bearer\"\n - \"service\"\n - \"gx\"\n - \"gy\"\n - \"rx\"\n - \"icap\"\n - \"ldap\"\n - \"process\"\n - \"qbau\"\n - \"shaper\"\n - \"aggregated_qos\"\n - \"content_filter\"\n - \"content_editor\"\n - \"tcp\"\n - \"tcp_deferred_charging\"\n - \"tcp_retransmitted_packets\"\n - \"charging_profile\"\n - \"rating_group_control\"\n - \"umc_report\"\n - \"umc_mk_report\"\n - \"pcc_rule_control\"\n - \"pcc_rule_qos\"\n - \"dr_rest\"\n - \"dr_job\"\n - \"event_reporting_ebm\"\n\n @param option_stat: One of the option showed above.\n @type option_stat: str\n\n @rtype: String\n \"\"\"\n\n\n dict_table_option_stat = {\n \"server\" : \"server\",\n \"process\" : \"process\",\n \"bearer\" : \"bearer\",\n \"service\" : \"service\",\n \"gx\" : \"gx\",\n \"gy\" : \"gy\",\n \"rx\" : \"rx\",\n \"icap\" : \"icap\",\n \"ldap\" : \"ldap\",\n \"process\" : \"process\",\n \"qbau\" : \"qbau-reporting\",\n \"shaper\" : \"shaper\",\n \"aggregated_qos\" : \"aggregated-qos\",\n \"content_filter\" : \"content-filter\",\n \"content_editor\" : \"content-editor\",\n \"tcp\" : \"tcp\",\n \"tcp_deferred_charging\" : \"tcp-deferred-charging\",\n \"tcp_retransmitted_packets\": \"tcp-retransmitted-packets\",\n \"charging_profile\" : \"charging-profile\",\n \"rating_group_control\": \"rating-group-control\",\n \"umc_report\" : \"umc-reporting\",\n \"umc_mk_report\" : \"umc-mk-reporting\",\n \"pcc_rule_control\" : \"pcc-rule-control\",\n \"pcc_rule_qos\" : \"pcc-rule-qos\",\n \"dr_rest\" : \"dr-rest\",\n \"dr_job\" : \"dr-job\",\n \"event_reporting_ebm\" : \"event-reporting-ebm\"}\n\n value = dict_table_option_stat.get(option_stat)\n\n return self.__retrieve_command(\"SHOW_SYS_STATS\", value )\n ## End If\n ## END METHOD retrieve_show_system_stats( ... )\n\n def retrieve_clear_system_statistics(self, module ):\n \"\"\"\n Function to retrieve the command to clear information\n from the statistics\n\n @param module: Name of the module to clear statistics\n @type module: String\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CLEAR_SYS_STATS\", module)\n ## End If\n ## END METHOD retrieve_snmp_show( status )\n\n def retrieve_domain_reporting_system_command(self, option_stat, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show ns system\n domain-reporting option\n \"\"\"\n\n extra_value = \"\"\n if len(args) > 0:\n extra_value = args[0]\n\n dict_table_option_stat = {\n \"jobs\" : \"list jobs\",\n \"clear\" : \"clear list\",\n \"status\" : \"show status server %s\" % extra_value,\n \"hosts\": \"show hosts job %s\" % extra_value,\n \"report\" : \"report filters job %s\" % extra_value,\n \"filters\" : \"show filters job %s\" % extra_value}\n\n value = dict_table_option_stat.get(option_stat)\n\n return self.__retrieve_command(\"DOMAIN_REPORTING_SYS_CMD\", value)\n ## END METHOD retrieve_snmp_show( status )\n\n def retrieve_health_check(self):\n \"\"\"\n Function to retrieve the command to check health\n\n @rtype: str\n \"\"\"\n cmd = self.__retrieve_command(\"HEALTH_CHECK\")\n if type(cmd) == Command:\n cmd.set_local(True)\n return cmd\n ## END METHOD retrieve_health_check()\n\n def retrieve_check_cluster(self, target):\n \"\"\"\n Function to retrieve the command to check cluster\n\n @param target: Target platform or card\n @type target: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CHECK_CLUSTER\", target)\n ## END METHOD retrieve_check_cluster()\n\n def retrieve_show_statistics(self ):\n \"\"\"\n Function to retrieve the command to show information\n from the statistics\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"STATISTICS\", \"information\")\n ## End If\n ## END METHOD retrieve_snmp_show( status )\n def retrieve_show_variable(self, name ):\n \"\"\"\n Function to retrieve the command to show a\n specific variable\n\n @param name: Name of the variable to show\n @type name: String\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"VAR_SHOW\",\n name)\n ## END METHOD retrieve_show_variable( ... )\n def retrieve_license_install(self,\n license_file ):\n \"\"\"\n Function to retrieve the command to install license\n file\n\n @param license_file: File path of the license file\n @type license_file: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"LICENSE_INSTALL\", license_file)\n ## END METHOD retrieve_license_install( ... )\n def retrieve_set_redundancy(self,\n master = False,\n slave = False,\n id = \"\" ):\n \"\"\"\n Function to retrieve the command to set redundancy.\n If both attributes are False set shmem to off\n\n @param master: Set as Master\n @type master: Boolean\n @param slave: Set as slave\n @type slave: Boolean\n @param id: If is different from \"\" will add the ID of the master\n @type id: String\n @rtype: String\n \"\"\"\n role = \"\"\n if master:\n role = \"master\"\n elif slave:\n role = \"slave\"\n else:\n role = \"off\"\n ## End If\n if id != \"\":\n role += \" id %s\" % id\n ## End If\n return self.__retrieve_command(\"SET_REDUNDANCY\", role)\n ## End If\n ## END METHOD retrieve_set_redundancy( ... )\n\n\n def retrieve_sinactivity_command(self, duration = True, \\\n inactivity = True,\n delete = False,\n extra_param = \"--seconds 1\"):\n \"\"\"\n Retrieve the command to enable/disable the testing mode described by feature.\n \"\"\"\n params = \"\"\n if duration:\n params += \" --duration\"\n if inactivity:\n params += \" --inactivity\"\n if delete:\n params += \" --delete\"\n\n params += \" \" + extra_param\n\n return self.__retrieve_command(\"SINACTIVITY_CMD\", params)\n\n\n ## END METHOD retrieve_sinactivity_command()\n def retrieve_shmsearch_cmd(self, ip_addr_list, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show the shared\n memory session IPs\n\n @param ip_addr_list: The output type. Available values: verbose or dump\n @type ip_addr_list: str\n\n @rtype: str\n \"\"\"\n param = \" \".join(ip_addr_list)\n\n return self.__retrieve_command(\"SHMSEARCH_CMD\", param)\n ## END METHOD retrieve_show_shmem( ... )\n\n def retrieve_show_shmem(self, option, output = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show the shared\n memory session IPs\n\n @param option: The option to show. Available values: all, local, id ID or ppu_name.\n @type option: Boolean\n @param output: The output type. Available values: verbose or dump\n @type output: str\n\n @rtype: String\n \"\"\"\n\n assert output in [\"\", \"verbose\", \"dump\"]\n if output != \"\":\n output = \" \" + output\n\n ## End If\n return self.__retrieve_command(\"SHOW_SHMEM\", option, output)\n ## End If\n ## END METHOD retrieve_show_shmem( ... )\n\n def retrieve_dump_shmem(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to dump the shared memory session IPs\n\n @param option: The option to show. Available values: all, id ID or local.\n @type option: str\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"DUMP_SHMEM\", option)\n ## END METHOD retrieve_dump_shmem( ... )\n\n def retrieve_delete_shmem(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to delete the shared\n memory or part of it\n\n @param option: The option to show. Available values: all, local, id ID or ipc.\n @type option: Boolean\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"DEL_SHMEM\", option)\n ## End If\n ## END METHOD retrieve_delete_shmem( ... )\n\n def retrieve_set_diagnostic(self, diagnostic_file, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to create a diagnostic file.\n\n @param diagnostic_file: Defines the diagnostic file to create\n @type diagnostic_file: str\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"DIAGNOSTIC\", diagnostic_file)\n ## END METHOD retrieve_set_diagnostic( ... )\n\n def retrieve_management_backup(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for management backup\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MANAGEMENT_BACKUP\")\n ## END METHOD retrieve_management_backup( ... )\n\n def retrieve_management_capture(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for management capture\n\n @param option: Capture option\n @type option: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MANAGEMENT_CAPTURE\", option)\n ## END METHOD retrieve_management_capture( ... )\n\n def retrieve_management_set_backup(self, option, value, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for\n\n @param option: Set backup option\n @type option: str\n @param value: Set backup value\n @type value: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MANAGEMENT_SET_BACKUP\", option, value)\n ## END METHOD retrieve_management_set_backup( ... )\n\n def retrieve_management_trace(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for\n\n @param option: Trace option\n @type option: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MANAGEMENT_TRACE\", option)\n ## END METHOD retrieve_management_trace( ... )\n\n def retrieve_monitor_action(self, action, option, target = \"\"):\n \"\"\"\n Function to retrieve the command to do an action\n over the monitor\n\n @param action: Action preformed\n @type action: str\n @param option: Option of the action\n @type option: str\n @param target: Target of the action\n @type target: String\n @rtype: String\n \"\"\"\n\n return self.__retrieve_command(\"MONITOR_ACTION\", action, option, target)\n ## END METHOD retrieve_monitor_action( ... )\n def retrieve_rdmonitor_action(self, action, option, target = \"\"):\n \"\"\"\n Function to retrieve the command to do an action\n over the rdmonitor\n\n @param action: Action preformed\n @type action: str\n @param option: Option of the action\n @type option: str\n @param target: Target of the action\n @type target: String\n @rtype: String\n \"\"\"\n if target != \"\":\n target = \" \" + target\n return self.__retrieve_command(\"RDMONITOR_ACTION\", action, option, target)\n\n ## END METHOD retrieve_rdmonitor_action( ... )\n\n def retrieve_set_anon_session(self):\n \"\"\"\n Function to retrieve the command set anonymous section\n \"\"\"\n return self.__retrieve_command(\"SET_ANONYMOUS_SESSION\")\n ## END METHOD retrieve_set_anon_session()\n\n def retrieve_sasn_ebm_directory(self):\n \"\"\"\n Function to retrieve the SASN etc directory\n \"\"\"\n path = SASNPaths().get_sasn_ebm_folder()\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_ebm_directory()\n\n def retrieve_sasn_pdc_file_name_pattern(self, option):\n \"\"\"\n Function to retrieve the SASN pdc report file name patterns: daily, monthly, archive\n \"\"\"\n valid_options = {\"daily\": SASNPaths().get_pdc_daily_report_file_pattern(), \\\n \"monthly\": SASNPaths().get_pdc_monthly_report_file_pattern(), \\\n \"archive\": SASNPaths().get_pdc_archive_report_file_pattern()}\n if not option in valid_options.keys():\n raise InvalidArgument('option')\n\n return self.__generate_command_path(valid_options[option])\n ## END METHOD retrieve_sasn_pdc_file_name_pattern()\n\n def retrieve_sasn_pdc_data_directory(self, option = \"\", service_role = False):\n \"\"\"\n Function to retrieve the SASN pdc data directories\n - /var/sans/pdc/\n - /var/sans/pdc/daily_output/\n - /var/sans/pdc/monthly_ouput/\n - /var/sans/pdc/pdc_archive/\n - /var/sans/pdc/log\n \"\"\"\n valid_options = {\"\": \"\", \"daily\": \"daily_output/\", \"monthly\": \"monthly_output/\", \"archive\": \"pdc_archive/\", \"log\": \"log/\"}\n if not option in valid_options.keys():\n raise InvalidArgument('option')\n\n subdir = valid_options[option]\n path = \"\"\n if service_role:\n path = SASNPaths().get_pdc_service_role_data_directory()\n else:\n path = SASNPaths().get_pdc_data_directory()\n ## End If\n path = os.path.join(path, subdir)\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_pdc_data_directory()\n\n def retrieve_stat_location(self, stat_type):\n \"\"\"\n Function to retrieve the path to statistics files\n @param stat_type: String to define the stat to retrieve the folder. Available stats: offline, uri_report or oss):\n @type stat_type: str\n\n @rtype: String\n \"\"\"\n path = \"\"\n if stat_type == \"offline\":\n path = SASNPaths().get_offline_stat_folder()\n elif stat_type == \"uri_report\":\n path = SASNPaths().get_uri_stat_folder()\n elif stat_type == \"oss\":\n path = SASNPaths().get_oss_stat_folder()\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_stat_location( ... )\n\n def retrieve_sasn_hl_file_path(self):\n \"\"\"\n Function to retrieve the HL config file path\n \"\"\"\n path = SASNPaths().get_sasn_hl_file()\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_hl_file_path()\n def retrieve_sasn_ll_file_path(self):\n \"\"\"\n Function to retrieve the LL config file path\n \"\"\"\n path = SASNPaths().get_sasn_ll_file()\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_ll_file_path()\n\n def retrieve_sasn_ebm_spec_xml_file(self):\n \"\"\"\n Function to retrieve the HL config file path\n \"\"\"\n path = os.path.split(SASNPaths().get_sasn_ebm_file())[-1]\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_ebm_spec_xml_file()\n\n def retrieve_testing_mode_path(self, feature):\n \"\"\"\n Retrieve the command to enable/disable the testing mode described by feature.\n \"\"\"\n if feature == \"bypass-radius-client-delta\":\n tm_file = \".bypass-radius-client-delta\"\n tm_path = SASNPaths().get_sasn_configuration_folder()\n tm_path = self.__generate_command_path(tm_path)\n else:\n raise Exception(\"Impossible to retrieve the testing mode path. Invalid feature %s\" % feature)\n ## End if\n if type(tm_path) == Command:\n tm_path.command += tm_file\n else:\n tm_path += tm_file\n ## End If\n return tm_path\n ## END METHOD retrieve_testing_mode_path()\n def retrieve_xdr_location(self):\n \"\"\"\n Function to retrieve the path to XDR files\n\n @rtype: String\n \"\"\"\n\n return self.__generate_command_path(SASNPaths().get_xdr_folder())\n ## END METHOD retrieve_ssr_xdr_location( )\n\n def retrieve_software(self, action, module = \"\"):\n \"\"\"\n Function to retrieve the software information\n\n @param action: The actio to perform. Available values: history or information\n @type action: str\n @param module: The module to retrive the action. Default value is an empty string.\n @type module: str\n\n @rtype: String\n \"\"\"\n if module != \"\":\n module = \" \" + module\n\n return self.__retrieve_command(\"SOFTWARE\", action, module)\n ## END METHOD retrieve_software( )\n def retrieve_heur_conf_file(self):\n \"\"\"\n Function to retrieve the file path and name of the\n heuristics configuration file\n\n\n @rtype: String\n \"\"\"\n return self.__generate_command_path(SASNPaths().get_heuristic_configuration_file())\n ## END METHOD retrieve_heur_conf_file( )\n def retrieve_diam_app_param_set(self, server_name, parameter,\n enable = None):\n \"\"\"\n Function to retrieve the command to set an application parameter\n for a Diameter server\n\n @param server_name: Name of the diameter server\n @type server_name: str\n @param parameter: Parameter to be set\n @type parameter: str\n @param enable: Enable or disable a parameter\n @type enable: Boolean\n @rtype: String\n \"\"\"\n action = \"\"\n if enable:\n action = \"on\"\n elif enable == False:\n action = \"off\"\n ## End If\n return self.__retrieve_command(\"DIAM_APP_PARAM\", server_name, parameter, \\\n action)\n ## END METHOD retrieve_diam_app_param_set( )\n\n def _retrieve_validate(self, file_name = \"\" ):\n \"\"\"\n Function to retrieve the command to validate a configuration\n\n @param file_name: Name of the HL to validate, only used if hl is True\n @type file_name: String\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CFG_VALIDATE_HL\", file_name)\n ## END METHOD retrieve_validate( ... )\n def _retrieve_commit(self, hl_file = \"\"):\n \"\"\"\n Function to retrieve the command to apply configuration to SASN\n\n @param hl_file: HL File path\n @type hl_file: String\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CFG_COMMIT\", hl_file)\n ## END METHOD retrieve_validate( force )\n def retrieve_commit_status(self):\n \"\"\"\n Function to retrieve the command to retrieve the status of the\n command commit\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"CHECK_COMMIT_STATUS\")\n\n ## End If\n ## END METHOD retrieve_check_delta( )\n def retrieve_commit_clear(self):\n \"\"\"\n Function to retrieve the command to clear commit settings\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"COMMIT_CLEAR\")\n ## END METHOD retrieve_commit_clear( ... )\n def retrieve_commit_set(self, option, timeout = 0, abrupt = False, rate = None, cont = False, ):\n \"\"\"\n Function to retrieve the command to do apply commit settings\n\n @rtype: String\n \"\"\"\n assert option in [\"sequential\", \"parallel\"]\n value = option\n if option == \"parallel\":\n value += \" timeout \" + str(timeout) + \" all-appvms\"\n if abrupt:\n value += \" abrupt\"\n elif rate:\n value += \" rate \" + str(rate)\n if cont:\n value += \" continue\"\n return self.__retrieve_command(\"COMMIT_SET\", value)\n ## END METHOD retrieve_commit_set(... )\n def retrieve_commit_show(self, option):\n \"\"\"\n Function to retrieve the command to do show commit settings\n\n @param option: Option\n @type options: str\n @rtype: String\n \"\"\"\n assert option in [\"info\", \"status\"]\n return self.__retrieve_command(\"COMMIT_SHOW\", option)\n ## END METHOD retrieve_commit_show( ... )\n def retrieve_broker_status(self):\n \"\"\"\n Function to retrieve the command to get the broker status\n @rtype: Command\n \"\"\"\n\n return self.retrieve_show_module(\"broker\", \"status\")\n ## END METHOD retrieve_broker_status()\n def retrieve_broker_b2b(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show\n from module\n\n Some extra parameter can be set using args (list of values) depending on the module:\n - \"interface\"\n - ...\n\n @param option: Command option: interface, role, slave, remove\n @type option: String\n\n @rtype: String\n \"\"\"\n value = \"\"\n for extra_args in args:\n value += \" \" + extra_args\n\n return self.__retrieve_command(\"BROKER_B2B\", option, value )\n ## End If\n ## END METHOD retrieve_broker_b2b( ... )\n\n def retrieve_broker_stats(self):\n \"\"\"\n Function to retrieve the command to get the broker stats\n @rtype: Command\n \"\"\"\n return self.retrieve_show_module(\"broker\", \"stats\")\n ## END METHOD retrieve_broker_stats()\n def retrieve_broker_cards(self):\n \"\"\"\n Function to retrieve the command to get the broker cards\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"BROKER_CARDS\")\n ## END METHOD retrieve_broker_cards()\n def retrieve_broker_hostname(self, hostname):\n \"\"\"\n Function to retrieve the command to get the broker cards\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"BROKER_HOSTNAME\", hostname)\n ## END METHOD retrieve_broker_hostname()\n def retrieve_binaries_folder(self, entity=\"application\"):\n \"\"\"\n Function to retrieve the path to the SASN binaries folder\n B{entity} can have the following options:\n application: Application Entity path\n control: Control Entity path\n @param entity: Entity type\n @type entity: str\n @rtype: Command\n \"\"\"\n if \"application\" == entity:\n path = SASNPaths().get_sasn_bin_folder()\n elif \"control\" == entity:\n path = SASNPaths().get_ce_sasn_bin_folder()\n else:\n raise InvalidArgument(\"entity\", \"\", \"application, control\", entity)\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_binaries_folder()\n def retrieve_modules_folder(self, entity = \"application\"):\n \"\"\"\n Function to retrieve the path to the SASN modules folder\n @param entity: Location of the modules:\n \"control\" In the Control Entity\n \"application\" In the Application Entity\n @rtype: Command\n \"\"\"\n if \"application\" == entity:\n path = SASNPaths().get_sasn_modules_folder()\n elif \"control\" == entity:\n path = SASNPaths().get_ce_sasn_modules_folder()\n else:\n raise InvalidArgument(\"entity\", \"\", \"application, control\", entity)\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_modules_folder()\n def retrieve_statistics_path(self):\n \"\"\"\n Function to retrieve the path to the statistics folder in SSR\n @rtype: String\n \"\"\"\n path = SASNPaths().get_statistics_folder()\n return self.__generate_command_path(path)\n ## END METHOD retrieve_statistics_path()\n def retrieve_sasn_installation_path(self, location = None):\n \"\"\"\n Retrieve the location where SASN is installed for Oracle\n \"\"\"\n if location in [\"rp_card\", \"control_entity\"]:\n path = SASNPaths().get_ce_sasn_folder()\n else:\n path = SASNPaths().get_sasn_folder()\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_sasn_installation_path()\n def retrieve_process_start_stop(self,\n option,\n process_name = \"\"):\n \"\"\"\n Function to retrieve the command to start or stop process\n\n @param option: Defines if the process should start or stop\n @type options: str\n @param process_name: Name of the process\n @type process_name: str\n @rtype: String\n \"\"\"\n option_with_argument = [\"start\", \"stop\"]\n available_options = option_with_argument + [\"broker-start\", \"broker-stop\"]\n if option not in available_options:\n raise InvalidArgument(\"option\",\n possible_values = available_options,\n current_value = option)\n ## End If\n if option in option_with_argument:\n if process_name is None or len(process_name) == 0:\n raise ArgumentNotPresent(\"process_name\")\n ## End If\n process_name = \" %s\" % process_name\n ## End If\n\n return self.__retrieve_command(\"START_STOP_PROCESS\", option, process_name)\n ## END METHOD retrieve_process_start_stop( .. )\n def retrieve_recover(self, target):\n \"\"\"\n Function to retrieve the command to get the broker cards\n @rtype: Command\n \"\"\"\n if target != \"\":\n target = \" \" + target\n ## End If\n return self.__retrieve_command(\"RECOVER\", target)\n ## END METHOD retrieve_recover()\n\n def retrieve_reset_domain_reporting_status(self):\n \"\"\"\n Function to retrieve the command to get the broker cards\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"RST_DOMAIN_REPORTING_STATUS\")\n ## END METHOD retrieve_reset_domain_reporting_status()\n def retrieve_domain_reporting_report_domain_job(self, id = \"all\"):\n \"\"\"\n Function to retrieve the command to get the report domain job command\n @rtype: Command\n \"\"\"\n if id.strip() == \"\":\n id = \"all\"\n elif id != \"all\":\n id = \"id \" + id\n return self.__retrieve_command(\"DOMAIN_REPORTING_REPORT_DOMAIN_JOB\", id)\n ## END METHOD retrieve_broker_cards()\n def retrieve_stop_all_sasn(self, abrupt = True, rate = None ):\n \"\"\"\n Function to retrieve the command to stop SASN\n\n @param abrupt: Add abrupt to the command\n @type abrupt: Boolean\n @param force: Apply force\n @type force: Boolean\n @rtype: String\n \"\"\"\n cmd_abr = \" abrupt\" if abrupt else \"\"\n cmd_rate = \" rate %s\" % rate if rate is not None else \"\"\n return self.__retrieve_command(\"SASN_STOP_ALL\", cmd_rate, cmd_abr)\n\n ## End If\n ## END METHOD retrieve_stop_all_sasn( abrupt force )\n def retrieve_log(self, target, msg):\n \"\"\"\n Function to retrieve the command to get the broker cards\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"LOG\", target, msg)\n ## END METHOD retrieve_log()\n def retrieve_broker_file_transfer(self, transfer_type,\n hostname,\n source_file,\n destination_file):\n \"\"\"\n Function to retrieve the command to transfer a file\n from or to another host\n @param transfer_type: Type of transfer {put, get}\n @type transfer_type: str\n @param hostname: Hostname to transfer from or to\n @type hostname: str\n @param source_file: Source file path\n @type source_file: str\n @param destination_file: Destination file path\n @type destination_file: str\n\n @rtype: Command\n \"\"\"\n available_transfer = [\"get\", \"put\"]\n if transfer_type not in available_transfer:\n raise Exception(\"Invalid transfer mode, the available ones are %s!\" % available_transfer)\n ## End If\n return self.__retrieve_command(\"BROKER_FILE_TRANSFER\",\n hostname,\n transfer_type,\n source_file,\n destination_file)\n ## END METHOD retrieve_broker_file_transfer(...)\n\n def retrieve_host(self, hostname):\n \"\"\"\n Function to retrieve the command to transfer a file\n from or to another host\n @param hostname: Hostname to transfer from or to\n @type hostname: str\n\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"HOST\",\n hostname)\n ## END METHOD retrieve_host(...)\n\n def retrieve_copy(self, transfer_type,\n source_file,\n destination_file):\n \"\"\"\n Function to retrieve the command to transfer a file\n from or to another host\n @param transfer_type: Type of transfer {put, get}\n @type transfer_type: str\n @param source_file: Source file path\n @type source_file: str\n @param destination_file: Destination file path\n @type destination_file: str\n\n @rtype: Command\n \"\"\"\n available_transfer = [\"get\", \"put\"]\n if transfer_type not in available_transfer:\n raise Exception(\"Invalid transfer mode, the available ones are %s!\" % available_transfer)\n ## End If\n return self.__retrieve_command(\"COPY\",\n transfer_type,\n source_file,\n destination_file)\n ## END METHOD retrieve_copy(...)\n\n def retrieve_installation(self, filename, *args):\n \"\"\"\n Function to retrieve the command to get the installation\n command\n extra arguments available:\n -B{force}: Force the installation\n -B{start}: Start\n -B{if-newer}: Install only if newer\n\n @param filename: Name of the file\n @type filename: str\n @rtype: Command\n \"\"\"\n force = \"\"\n start = \"\"\n newer = \"\"\n if \"force\" in args:\n force = \" force\"\n ## End If\n if \"start\" in args:\n start = \" start\"\n ## End If\n if \"if-newer\" in args:\n newer = \" if-newer\"\n ## End If\n return self.__retrieve_command(\"SASN_INSTALLATION\", filename, force, start, newer)\n ## END METHOD retrieve_log()\n def retrieve_migration(self, hlFile, comFile):\n \"\"\"\n Function to retrieve the command to migrate an HL file\n into a COM configuration file\n @param hlFile: HL File to be converted\n @type hlFile: str\n @param comFile: COM output file\n @type comFile: str\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"MIGRATION\", hlFile, comFile)\n ## END METHOD retrieve_log()\n def retrieve_rollback(self, dist_name, DID, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to get the installation\n command\n extra arguments available:\n -B{force}: Force the installation\n -B{CID=value}: Load a specific configuration after rollback\n\n @param dist_name: Name of the distribution to rollback\n @type dist_name: str\n @param DID: Distribution ID\n @type DID: int\n @rtype: Command\n \"\"\"\n force = \"\"\n load = \"\"\n if \"force\" in args or \"force\" in kwargs:\n force = \" force\"\n ## End If\n if \"CID\" in kwargs:\n load = \" load %s\" % kwargs[\"CID\"]\n ## End If\n return self.__retrieve_command(\"SASN_ROLLBACK\", dist_name, DID, force, load)\n ## END METHOD retrieve_rollback()\n def retrieve_install_heuristics(self, filepath):\n \"\"\"\n Function to retrieve the command to install a new heuristics\n package\n @param filepath: File path to the new package\n @type filepath: str\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"INSTALL_HEURISTICS\", filepath)\n ## END METHOD retrieve_install_heuristics()\n def retrieve_update_heuristics(self, filepath):\n \"\"\"\n Function to retrieve the command to update a new heuristics\n package\n @param filepath: File path to the new package\n @type filepath: str\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"UPDATE_HEURISTICS\", filepath)\n ## END METHOD retrieve_update_heuristics()\n def retrieve_validate_heuristics(self):\n \"\"\"\n Function to retrieve the command to validate the previously\n installed heuristics package\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"VALIDATE_HEURISTICS\")\n ## END METHOD retrieve_validate_heuristics()\n def retrieve_apply_heuristics(self):\n \"\"\"\n Function to retrieve the command to apply the previously\n installed heuristics package\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"APPLY_HEURISTICS\")\n ## END METHOD retrieve_validate_heuristics()\n def retrieve_security_change(self, action, *args):\n \"\"\"\n Function to retrieve the command to enable/disable\n or show the security\n @param action: Action to be performed:\n -B{set}: changes the configuration\n -B{show}: Show the current configuration\n @type action: str\n @param args: List with options:\n -B{enable}: Used with 'set' enables the security\n -B{disable}: Used with 'set' disable the security\n -B{default}: Set the default password \"root\" for root user\n @type args: list\n @rtype: Command\n \"\"\"\n extra_options = \"\"\n if \"set\" == action:\n if \"enable\" in args:\n extra_options = \"enable\"\n elif \"disable\" in args:\n extra_options = \"disable\"\n elif \"default\" in args:\n extra_options = \"default\"\n ## End If\n ## End If\n return self.__retrieve_command(\"SECURITY_CHANGE\", action, extra_options)\n ## END METHOD retrieve_security_change()\n def retrieve_check_root_password(self, *args, **kwargs):\n \"\"\"\n Function to check if the root password is correct\n \"\"\"\n return self.__retrieve_command(\"CHECK_ROOT_PASSWORD\", *args, **kwargs)\n ## END METHOD retrieve_change_centralized_password\n def retrieve_run_change_root_password(self, *args, **kwargs):\n \"\"\"\n Function to change the root password in a centralized way\n \"\"\"\n return self.__retrieve_command(\"RUN_CHANGE_ROOT_PASSWORD\", *args, **kwargs)\n ## END METHOD retrieve_change_centralized_password_\n def retrieve_change_root_password(self, *args, **kwargs):\n \"\"\"\n Function to execute a command to change the root password in a centralized way\n \"\"\"\n return self.__retrieve_command(\"CHANGE_ROOT_PASSWORD\", *args, **kwargs)\n ## END METHOD retrieve_change_root_password\n def retrieve_run_and_check_ns_command(self, *args, **kwargs):\n \"\"\"\n Function to execute the script perform_ns_command\n \"\"\"\n return self.__retrieve_command(\"RUN_AND_CHECK_NS_COMMAND\", *args, **kwargs)\n ## END METHOD retrieve_run_ns_command()\n def retrieve_run_and_check_su_user(self, *args, **kwargs):\n \"\"\"\n Function to execute the script run_and_check_su_user\n \"\"\"\n return self.__retrieve_command(\"RUN_AND_CHECK_SU_USER\", *args, **kwargs)\n ## END METHOD retrieve_run_and_check_su_user()\n def retrieve_icap_set_mode(self, server, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to set ICAP mode\n\n @param server: ICAP server\n @type server: str\n @rtype: str\n \"\"\"\n value = \"\"\n for option in args:\n value += \" \" + option\n ## End For\n return self.__retrieve_command(\"ICAP_SET_MODE\", server, value)\n ## End If\n ## END METHOD retrieve_icap_set_mode( ... )\n def retrieve_icap_set_server(self, server, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to set ICAP server option\n\n @param server: ICAP server\n @type server: str\n @rtype: str\n \"\"\"\n value = \"\"\n for option in args:\n value += \" \" + option\n ## End For\n return self.__retrieve_command(\"ICAP_SET_SERVER\", server, value)\n ## End If\n ## END METHOD retrieve_icap_set_server( ... )\n def retrieve_icap_set_transaction(self, server, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to set ICAP transaction option\n\n @param server: ICAP server\n @type server: str\n @rtype: str\n \"\"\"\n value = \"\"\n for option in args:\n value += \" \" + option\n ## End For\n return self.__retrieve_command(\"ICAP_SET_TRANSACTION\", server, value)\n ## End If\n ## END METHOD retrieve_icap_set_transaction( ... )\n def retrieve_icap_show_config(self, server, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show ICAP config\n\n @param server: ICAP server\n @type server: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"ICAP_SHOW_CONFIG\", server)\n ## End If\n ## END METHOD retrieve_icap_show_config( ... )\n def retrieve_probe_reset(self, link, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to reset probe\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"PROBE_RESET\", link)\n ## End If\n ## END METHOD retrieve_probe_reset( ... )\n\n def retrieve_module_show_config(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for module show config\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MODULE_SHOW_CONFIG\")\n ## End If\n ## END METHOD retrieve_module_show_config( ... )\n\n def retrieve_monitor_show_config(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for monitor show config\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"MONITOR_SHOW_CONFIG\")\n ## End If\n ## END METHOD retrieve_monitor_show_config( ... )\n def retrieve_partition_set(self, partition, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for partition set\n\n @param partition: Partition\n @type partition: int\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"PARTITION_SET\", partition)\n ## END METHOD retrieve_partition_set( ... )\n\n def retrieve_partition_show_current(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for partition set\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"PARTITION_SHOW_CURRENT\")\n ## END METHOD retrieve_partition_show_current( ... )\n def retrieve_partition_show_information(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for partition show information\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"PARTITION_SHOW_INFORMATION\")\n ## END METHOD retrieve_partition_show_information( ... )\n\n def retrieve_variable_show(self, variable, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for variable show\n\n @param variable: Variable\n @type variable: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"VARIABLE_SHOW\", variable)\n ## END METHOD retrieve_variable_show( ... )\n\n def retrieve_system_boot(self, module, option, value = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command for system boot\n\n @param module: Module\n @type module: str\n @param option: Option\n @type option: str\n @param value: Value\n @type value: str\n @rtype: str\n \"\"\"\n if value != \"\":\n value = \" \" + value\n return self.__retrieve_command(\"SYSTEM_BOOT\", module, option, value)\n ## END METHOD retrieve_system_boot( ... )\n\n def retrieve_system_set_config(self, option, value, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for system set config\n\n @param option: Option\n @type option: str\n @param value: Value\n @type value: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"SYSTEM_SET_CONFIG\", option, value)\n ## END METHOD retrieve_system_set_config( ... )\n\n def retrieve_system_set_pdc(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for system set pdc\n\n @param option: enable\n @type option: str\n @param value: dailyprocessing\n @type value: str\n @rtype: str\n \"\"\"\n options = {\"enable\": \"enable on\", \\\n \"disable\": \"enable off\"}\n assert option in options.keys(), \\\n \"retrieve_system_set_pdc: option %s not allowed. Available options: %s\" % (option, str(options))\n option = options[option]\n dailyprocessing = kwargs.get(\"dailyprocessing\", None)\n if dailyprocessing:\n dailyprocessing = \" dailyprocessing \" + str(dailyprocessing)\n else:\n dailyprocessing = \"\"\n\n return self.__retrieve_command(\"SYSTEM_SET_PDC\", option, dailyprocessing)\n ## END METHOD retrieve_system_set_pdc( ... )\n\n def retrieve_system_show(self, option, value = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command for system set config\n\n @param option: Option\n @type option: str\n @param value: Value\n @type value: str\n @rtype: str\n \"\"\"\n if value != \"\":\n value = \" \" + value\n return self.__retrieve_command(\"SYSTEM_SHOW\", option, value)\n ## END METHOD retrieve_system_show( ... )\n\n def retrieve_system_wizard_cluster(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for system wizard cluster\n\n @param option: Option\n @type option: str\n @rtype: str\n \"\"\"\n value = \"\"\n if len(args) > 0:\n for arg in args:\n value += \" \" + arg\n return self.__retrieve_command(\"SYSTEM_WIZARD_CLUSTER\", option, value)\n ## END METHOD retrieve_system_show( ... )\n\n def retrieve_version(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for version\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"VERSION\")\n ## END METHOD retrieve_system_show( ... )\n\n def retrieve_dpi_version(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for version\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"VERSION\")\n ## END METHOD retrieve_system_show( ... )\n\n def retrieve_check_consistency(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for check-consistency\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CHECK_CONSISTENCY\")\n ## END METHOD retrieve_check_consistency( ... )\n def retrieve_tmp_folder(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the tmp folder path\n\n @rtype: str\n \"\"\"\n path = \"/tmp/\"\n if \"control\" in args:\n if \"sasn\" in args:\n path = SASNPaths().get_ce_sasn_tmp_folder()\n ## End If\n elif \"application\" in args:\n if \"sasn\" in args:\n path = SASNPaths().get_sasn_tmp_folder()\n ## End If\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_tmp_folder( ... )\n\n\n def retrieve_migrate(self, options, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to for migrate\n\n @rtype: Command\n \"\"\"\n return self.__retrieve_command(\"MIGRATE\", options)\n ## END METHOD retrieve_migrate( ... )\n\n def retrieve_config_rpfm(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for config rpfm\n\n @param option: Option\n @type option: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CONFIG_RPFM\", option)\n ## END METHOD retrieve_config_rpfm( ... )\n\n def retrieve_config_rpcm(self, option, value, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for config rpcm\n\n @param option: Option\n @type option: str\n @param value: Value\n @type value: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CONFIG_RPCM\", option, value)\n ## END METHOD retrieve_config_rpcm( ... )\n\n def retrieve_cat(self, filename, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for cat\n\n @param filename: File name\n @type filename: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CAT\", filename)\n ## END METHOD retrieve_cat( ... )\n\n def retrieve_zcat(self, filename, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for zcat\n\n @param filename: File name\n @type filename: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"ZCAT\", filename)\n ## END METHOD retrieve_zcat( ... )\n\n def retrieve_df(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for df\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"DF\")\n ## END METHOD retrieve_df( ... )\n\n def retrieve_free(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for free\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"FREE\")\n ## END METHOD retrieve_free( ... )\n\n def retrieve_ls(self, directory, options = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command for ls\n\n @param directory: Directory\n @type directory: str\n @param options: Options\n @type options: str\n @rtype: str\n \"\"\"\n if options != \"\":\n options = options + \" \"\n return self.__retrieve_command(\"LS\", options, directory)\n ## END METHOD retrieve_ls( ... )\n\n def retrieve_ps(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for ps\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"PS\")\n ## END METHOD retrieve_ps( ... )\n\n def retrieve_tail(self, numlines, filename, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for tail\n\n @param numlines: Number of lines\n @type numlines: int\n @param filename: File name\n @type filename: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"TAIL\", numlines, filename)\n ## END METHOD retrieve_tail( ... )\n\n def retrieve_top(self, options = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command for top\n\n @param options: Options\n @type options: str\n @rtype: str\n \"\"\"\n if options != \"\":\n options = \" \" + options\n return self.__retrieve_command(\"TOP\", options)\n ## END METHOD retrieve_top( ... )\n def retrieve_rm(self, file_name = \"\", *args, **kwargs):\n \"\"\"\n Function to retrieve the command for ns rm\n\n @param file_name: file name\n @type file_name: str\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"RM\", file_name)\n ## END METHOD retrieve_rm( ... )\n def retrieve_uptime(self, *args, **kwargs):\n \"\"\"\n Function to retrieve the command for uptime\n\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"UPTIME\")\n ## END METHOD retrieve_uptime( ... )\n def retrieve_security_hack_filename(self):\n \"\"\"\n Function to retrieve the name of the file that do the hack\n @rtype: str\n \"\"\"\n path = SASNPaths().get_security_hack_filename()\n return self.__generate_command_path(path)\n ## END METHOD retrieve_security_hack_filename( ... )\n\n def retrieve_security_hack_injector_filepath(self, add_filename = True):\n \"\"\"\n Function to retrieve the command for uptime\n @param add_filename: If enables the filename will be added\n @type add_filename: bool\n @rtype: str\n \"\"\"\n path = SASNPaths().get_security_hack_injector()\n if add_filename:\n path = \"\".join([path, SASNPaths().get_security_hack_filename()])\n ## End If\n return self.__generate_command_path(path)\n ## END METHOD retrieve_security_hack_injector_filepath( ... )\n def retrieve_sos_command(self, action = \"start\"):\n \"\"\"\n Function to retrieve the command to stop/start/restart sos in the RP\n @param action: Action to be dne in SOS\n @type action: bool\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"SOS_COMMAND\", action)\n ## END METHOD retrieve_sos_command( ... )\n def retrieve_tsmssr_clean(self, to_clean = \"all\"):\n \"\"\"\n Function to retrieve the command clean the TSMSSR configuration\n @param to_clean: What should be cleaned\n - B{all} Clean everything\n - B{smartnic} Clean SmartNIC entries\n @type to_clean: str\n @rtype: str\n \"\"\"\n args = \"\"\n if \"smartnic\" == to_clean:\n args = \"-s\"\n ## End If\n return self.__retrieve_command(\"TSMSSR_CLEAN\", args)\n ## END METHOD retrieve_tsmssr_clean( ... )\n def retrieve_tsm_smaller_tables_file(self, enable = True):\n \"\"\"\n Function to retrieve the command clean the TSMSSR configuration\n @param to_clean: What should be cleaned\n - B{all} Clean everything\n - B{smartnic} Clean SmartNIC entries\n @type to_clean: str\n @rtype: str\n \"\"\"\n args = \"\"\n if enable:\n cmd_start = \"touch\"\n else:\n cmd_start = \"rm\"\n ## End If\n cmd = \" \".join([cmd_start, SASNPaths().get_tsm_small_table_file()])\n return self.__generate_command_path(cmd)\n ## END METHOD retrieve_tsm_smaller_tables_file( ... )\n def retrieve_cpuchk_local_path(self):\n \"\"\"\n Function to retrieve the local path where the script cpuchk is found\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CPUCHK_LOCAL_PATH\")\n ## END METHOD retrieve_security_hack_filename( ... )\n def retrieve_cpuchk_remote_path(self):\n \"\"\"\n Function to retrieve the remote path where the script cpuchk is found\n @rtype: str\n \"\"\"\n return self.__retrieve_command(\"CPUCHK_REMOTE_PATH\")\n ## END METHOD retrieve_security_hack_filename( ... )\n def retrieve_cpuchk_command(self,\n injector_time = None,\n alarm_time = None,\n log_delay = None,\n **kwargs):\n \"\"\"\n Function to retrieve the command to execute script cpuchk\n @param injector_time: Time in the injector\n @type injector_time: str\n @param alarm_time: Alarm time\n @type alarm_time: str\n @param log_delay: Log delay in micro seconds\n @type log_delay: str\n @rtype: str\n \"\"\"\n options = \"\"\n if injector_time is not None:\n options += \" --injector-time %s\" % injector_time\n ## End If\n if alarm_time is not None:\n options += \" --alarm %s\" % alarm_time\n ## End If\n if log_delay is not None:\n options += \" --logdelay %s\" % log_delay\n ## End If\n cmd_path = self.retrieve_cpuchk_remote_path()\n if isinstance(cmd_path, Command):\n cmd_path = cmd_path.get_command()\n ## End If\n return self.__retrieve_command(\"CPUCHK_COMMAND\",\n cmd_path,\n options)\n ## END METHOD retrieve_security_hack_filename( ... )\n def retrieve_set_canalyzer_config(self,\n parameter,\n value,\n **kwargs):\n \"\"\"\n Function to retrieve the command to execute script cpuchk\n @param parameter: Name parameter to change\n @type parameter: str\n @param value: Value of the parameter\n @type value: str\n @rtype: str\n \"\"\"\n options = \"\"\n if \"ignore-filter-ip-src\" in parameter:\n options = \"analyzer MASCS config %s\" % parameter\n if value:\n options += \" true\"\n else:\n options += \" false\"\n ## End If\n ## End If\n return self.__retrieve_command(\"MOD_PLG_SET\",\n \"scm\",\n \"canalyzer\",\n options)\n ## END METHOD retrieve_set_canalyzer_config( ... )\n def retrieve_management_memdomain(self, option, *args, **kwargs):\n \"\"\"\n Function to retrieve the command to show memdomain parameters\n from module\n\n Some extra parameter can be set using args (list of values) depending on the module:\n - \"cpu set\"\n - ...\n\n @param option: Command option: apply, cpualias all, cpualias foreground, set, huge-pages-total-2M\n @type option: String\n\n @rtype: String\n \"\"\"\n value = \"\"\n for extra_args in args:\n value += \" \" + extra_args\n\n return self.__retrieve_command(\"MEMDOMAIN\", option, value )\n ## End If\n ## END METHOD retrieve_management_memdomain( ... )\n def retrieve_memory_benchmark(self, process, allocation_type, size):\n \"\"\"\n Function to retrieve the command to show memory benchmark\n\n @param process: Name of SASN process\n @type process: str\n @param allocation_type: Type of memoy allocation (B{mmap} of B{malloc})\n @type allocation_type: str\n @param process: Size in MB to test\n @type process: int\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"MEMORY_BENCHMARK\", process, allocation_type, size)\n ## End If\n ## END METHOD retrieve_memory_benchmark( ... )\n def retrieve_memory(self):\n \"\"\"\n Function to retrieve the command to show memory of SASN\n\n @rtype: String\n \"\"\"\n return self.__retrieve_command(\"SASN_MEMORY\")\n ## END METHOD retrieve_memory()\n def retrieve_xml_file_path(self, add_name = True, validate = True ):\n \"\"\"\n Function to retrieve the path to the XML file\n with COM configuration\n\n @param add_name: Add the filename also\n @type add_name: Boolean\n @param validate: Retrieve XML validate file or the commit file\n @type validate: Boolean\n @rtype: String\n \"\"\"\n command = \"\"\n if add_name:\n command = self.retrieve_xml_filename(validate).command\n ## End If\n path = SASNPaths().get_xml_file_location()\n path += command\n return self.__generate_command_path(path)\n ## END METHOD retrieve_xml_filename( )\n def retrieve_xml_filename(self, validate = True ):\n \"\"\"\n Function to retrieve the name of the XML file\n with COM configuration\n\n @rtype: String\n \"\"\"\n filename = \"\"\n if validate:\n filename = SASNPaths().get_xml_validate_file_name()\n else:\n filename = SASNPaths().get_xml_commit_file_name()\n ## End If\n return self.__generate_command_path(filename)\n ## END METHOD retrieve_xml_filename( )\n\n def retrieve_log_location(self, domain, log_type):\n \"\"\"\n Function to retrieve the location of the logs from the different\n cards and the different applications\n The available domains are:\n -B{rp_card} Log from RP Card\n -B{ssc_card} Log from SSC Card\n -B{line_card} Log from Line Card\n The available log types are:\n -B{sasn_log} Logs from SASN\n -B{ssr_log} Logs from SSR\n -B{sasn_snmp} Logs of SNMP from SASN\n -B{persistent_log} Persistent log from the cards\n -B{startup_log} Startup log from the cards\n @param domain: Domain types are the\n @type domain: str\n @param log_type: Type of logs\n @type log_type: str\n @rtype: String\n \"\"\"\n available_domains = ['control_entity', 'application_entity', 'network_entity']\n available_types = ['sasn_log',\n 'sasn_snmp']\n\n if not domain in available_domains:\n raise InvalidArgument(\"domain\", possible_values=\"%s\" % available_domains, current_value = domain)\n #EndIf\n if not log_type in available_types:\n raise InvalidArgument(\"log_type\", possible_values=\"%s\" % available_types, current_value = log_type)\n #EndIf\n\n if domain in ['control_entity']:\n if log_type == 'sasn_log':\n path=SASNPaths().get_ce_sasn_messages_file()\n return self.__generate_command_path(path)\n elif log_type == 'sasn_snmp':\n path=SASNPaths().get_ce_sasn_snmp_file()\n return self.__generate_command_path(path)\n #EndIf\n #EndIf\n\n raise InvalidLogFile(domain, log_type)\n ## END METHOD retrieve_log_location( ... )\n## END CLASS SASNCommands\n\n","sub_path":"sds/back_test/ref/utils/sasnCommands.py","file_name":"sasnCommands.py","file_ext":"py","file_size_in_byte":173617,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"507739105","text":"'''\n\n新進測試\n\n'''\n\nprint('------------------------------------------------------------')\t#60個\nprint('準備工作')\n\nimport sqlite3\nimport time\n\ndef show_data_base_contents(db_filename, table_name, length):\n conn = sqlite3.connect(db_filename) # 建立資料庫連線\n sqlstr = 'SELECT * FROM {};'.format(table_name)#same\n sqlstr = 'SELECT * FROM %s' % table_name\n cursor = conn.execute(sqlstr)\n\n n = 0\n for row in cursor:\n print(row)\n n = n + 1\n #讀取 N 筆資料, 即跳出\n if n == length:\n break\n conn.close() # 關閉資料庫連線\n\ndef show_data_base_contents_all(db_filename, table_name):\n conn = sqlite3.connect(db_filename) # 建立資料庫連線\n sqlstr = 'SELECT * FROM {};'.format(table_name)#same\n sqlstr = 'SELECT * FROM %s' % table_name\n results = str(conn.execute(sqlstr).fetchall())\n print(results)\n conn.close() # 關閉資料庫連線\n\nprint('------------------------------------------------------------')\t#60個\n\nprint('新進測試')\n\ndb_filename = 'C:/_git/vcs/_1.data/______test_files2/db_' + time.strftime(\"%Y%m%d_%H%M%S\", time.localtime()) + '.a.qlite';\n\n\nmem_conn = sqlite3.connect(':memory:')\t# 建立資料庫連線, 記憶體\ndisk_conn = sqlite3.connect('example.db') # 建立資料庫連線, 磁碟\n\ncursor = mem_conn.cursor()\ncursor.execute(\"CREATE TABLE table01 (name_last, age)\")\n\nprint('目前共有修改資料次數 : ', mem_conn.total_changes)\n\nwho = \"David\"\nage = 18\n\ncursor.execute(\"INSERT INTO table01 VALUES (?, ?)\", (who, age))\n\nprint('目前共有修改資料次數 : ', mem_conn.total_changes)\n\ncursor.execute(\"INSERT INTO table01 VALUES (?, ?)\", (who, age))\ncursor.execute(\"INSERT INTO table01 VALUES (?, ?)\", (who, age))\ncursor.execute(\"INSERT INTO table01 VALUES (?, ?)\", (who, age))\nprint('目前共有修改資料次數 : ', mem_conn.total_changes)\n\ncursor.execute('''CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)''')\ncursor.execute(\"INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)\")\n\n\nmem_conn.commit()\n\ncursor.execute(\"SELECT * FROM table01\")\nprint(cursor.fetchall())\n\n#使用 backup 命令将内存数据库备份到磁盘数据库。\n\n# 备份内存数据库到磁盘数据库\nmem_conn.backup(disk_conn)\n\n'''\nbackup 覆蓋\nattach 附加\n'''\n\n'''\n# 将磁盘数据库附加到内存数据库中\nmem_conn.execute(\"ATTACH DATABASE 'example.db' AS disk_db\")\n\n# 执行插入命令将数据插入到磁盘数据库中\nmem_conn.execute(\"INSERT INTO disk_db.example_table VALUES (1, 'example')\")\n'''\n\n# 关闭数据库连接对象\nmem_conn.close()\ndisk_conn.close()\n\nprint('------------------------------------------------------------')\t#60個\n\ndb_filename = 'example.db'\ntable_name = 'table01'\nshow_data_base_contents_all(db_filename, table_name)\n\n\ntable_name = 'stocks'\nshow_data_base_contents_all(db_filename, table_name)\n\n\n\n\n\nprint('------------------------------------------------------------')\t#60個\nprint('測 executemany')\n\nimport sqlite3\nstocks = [('2006-01-05', 'BUY', 'RHAT', 100, 35.14),\n ('2006-03-28', 'BUY', 'IBM', 1000, 45.0),\n ('2006-04-06', 'SELL', 'IBM', 500, 53.0),\n ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)]\nconn = sqlite3.connect(\":memory:\")\nconn.execute(\"create table stocks (date text, buysell text, symb text, amount int, price real)\")\nconn.executemany(\"insert into stocks values (?, ?, ?, ?, ?)\", stocks) \ncur = conn.cursor()\n \nfor row in cur.execute('SELECT * FROM stocks ORDER BY price'):\n print(row)\n \n# Output:\n# ('2006-01-05', 'BUY', 'RHAT', 100, 35.14)\n# ('2006-03-28', 'BUY', 'IBM', 1000, 45.0)\n# ('2006-04-06', 'SELL', 'IBM', 500, 53.0)\n# ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)\n\n\ncur.execute('SELECT * FROM stocks ORDER BY price')\n\none_row_data = cur.fetchone()\nprint('fetchone', one_row_data)\n\nwhile one_row_data:\n one_row_data = cur.fetchone()\n print('fetchone', one_row_data)\n \n\nprint('------------------------------------------------------------')\t#60個\nprint('測試各種fetch')\n'''\nfetchone()\t#抓一行 tuple\nfetchmany(size=cursor.arraysize)\t#抓n行 list\nfetchall()\t#抓取剩下的全部 list\n\n'''\n\ndb_filename = 'ims_sql/db_ims.sqlite'\ndb_filename = 'C:/_git/vcs/_1.data/______test_files1/_db/gasoline.sqlite'\n#db_filename = 'db_20230703_113217.sqlite'\n\nprint('建立資料庫連線, 資料庫 : ' + db_filename)\nconn = sqlite3.connect(db_filename) # 建立資料庫連線\n\ncursor = conn.execute('SELECT * FROM prices;')\n\naaaa = cursor.fetchone()\nprint(type(aaaa))\nprint(aaaa)\n\naaaa = cursor.fetchone()\nprint(type(aaaa))\nprint(aaaa)\n\nbbbb = cursor.fetchmany(3)\nprint(type(bbbb))\nprint(bbbb)\n\ncccc = cursor.fetchall()\nprint(type(cccc))\n#print(cccc)\n\n\n\n\n\n\n\nconn.close() # 關閉資料庫連線\n\n\n\nprint('------------------------------------------------------------')\t#60個\nprint('xxxxx new 0717')\n\nconn = sqlite3.connect(\":memory:\")\ncursor = conn.cursor()\ncursor.execute(\"CREATE TABLE table01(key INTEGER PRIMARY KEY, task TEXT)\")\n\ntasks = (\n'give food to fish',\n'prepare group meeting',\n'fight with a zebra',\n)\n\nfor task in tasks:\n cursor.execute(\"INSERT INTO table01 VALUES(NULL, ?)\", (task,))\n\ncursor.execute(\"SELECT * FROM table01\")\nprint(cursor.fetchall())\n\n\n# Update a record, just for good measure.\ncursor.execute(\"UPDATE table01 SET task = 'learn italian' WHERE key = 1\")\n\n\ncursor.execute(\"SELECT * FROM table01\")\nprint(cursor.fetchall())\n\n\nkey_id = 2\ncursor.execute(\"SELECT * FROM table01 WHERE key=?\", (str(key_id),))\nkey, task = cursor.fetchone()\n\nprint(key)\nprint(task)\n\n\n\n\n\nprint(\"程式執行完畢!\")\n\n\n\n\n'''\n\n注意:不要使用%s 將字串插入 SQL 命令,因為它可能使你的程式容易受到 SQL 注入攻擊(請參閱 SQL 注入 )。\n\n'''\n","sub_path":"_4.python/sqlite/sqlite_新進測試2.py","file_name":"sqlite_新進測試2.py","file_ext":"py","file_size_in_byte":5764,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"583357900","text":"import pathlib\nimport transformers\nfrom my_module import path_manager as pm\nimport tensorflow as tf\nimport numpy as np\nimport pandas as pd\nimport statistics\n\nmodel_name = str(pm.get_abs_path(\n __file__, 'resources/BERT/BERT-base_mecab-ipadic-bpe-32k'))\ntokenizer = transformers.BertTokenizer.from_pretrained(model_name)\n\n\n# テキストのリストをtransformers用の入力データに変換\ndef to_features(texts, max_length):\n shape = (len(texts), max_length)\n # input_idsやattention_mask, token_type_idsの説明はglossaryに記載(cf. https://huggingface.co/transformers/glossary.html)\n input_ids = np.zeros(shape, dtype=\"int32\")\n attention_mask = np.zeros(shape, dtype=\"int32\")\n token_type_ids = np.zeros(shape, dtype=\"int32\")\n for i, text in enumerate(texts):\n encoded_dict = tokenizer.encode_plus(\n text, max_length=max_length, pad_to_max_length=True)\n input_ids[i] = encoded_dict[\"input_ids\"]\n attention_mask[i] = encoded_dict[\"attention_mask\"]\n token_type_ids[i] = encoded_dict[\"token_type_ids\"]\n return [input_ids, attention_mask, token_type_ids]\n\n\n# 単一テキストをクラス分類するモデルの構築\ndef build_model(model_name, num_classes, max_length):\n input_shape = (max_length, )\n input_ids = tf.keras.layers.Input(input_shape, dtype=tf.int32)\n attention_mask = tf.keras.layers.Input(input_shape, dtype=tf.int32)\n token_type_ids = tf.keras.layers.Input(input_shape, dtype=tf.int32)\n bert_model = transformers.TFBertModel.from_pretrained(model_name)\n last_hidden_state, pooler_output = bert_model(\n input_ids,\n attention_mask=attention_mask,\n token_type_ids=token_type_ids\n )\n output = tf.keras.layers.Dense(\n num_classes, activation=\"softmax\")(pooler_output)\n model = tf.keras.Model(\n inputs=[input_ids, attention_mask, token_type_ids], outputs=[output])\n optimizer = tf.keras.optimizers.Adam(\n learning_rate=3e-5, epsilon=1e-08, clipnorm=1.0)\n model.compile(optimizer=optimizer,\n loss=\"categorical_crossentropy\", metrics=[\"acc\"])\n return model\n\n\ndef train(train_texts, train_labels, model_name):\n\n num_classes = 2\n # max_length = 15\n max_length = 27\n batch_size = 10\n epochs = 3\n\n x_train = to_features(train_texts, max_length)\n y_train = tf.keras.utils.to_categorical(\n train_labels, num_classes=num_classes)\n model = build_model(model_name, num_classes=num_classes,\n max_length=max_length)\n\n # 訓練\n model.fit(\n x_train,\n y_train,\n batch_size=batch_size,\n epochs=epochs,\n )\n\n model.save_weights('resources/train/checkpoints/my_checkpoint')\n\n\ndef gen_model(boundary: float = 0.0):\n '''\n BERTモデルを生成します。\n\n Parameters\n ---\n boundary (float, optional): 学習に用いる極性値を決定する境界値\n '''\n # データフレームの読み込み\n df = pd.read_csv('sent_senti.csv')\n # 無極性のレビューを除去する。\n df = df[df['score'] != 0]\n # 感情値の絶対値が境界値以上の行を抽出\n df = df[abs(df['score']) >= boundary]\n train_texts = df['content'].values\n # 感情値が正の場合は1、負の場合は0\n train_labels = [1 if 0 < score else 0 for score in df['score'].values]\n # 学習を開始\n train(train_texts, train_labels, model_name)\n\n\ndef load_model():\n num_classes = 2\n # max_length = 15\n max_length = 27\n model = build_model(model_name, num_classes=num_classes,\n max_length=max_length)\n model.load_weights('resources/train/checkpoints/my_checkpoint')\n return model\n\n\nif __name__ == \"__main__\":\n # show_status_of_sentences()\n # gen_model(boundary=0.2)\n # model = load_model()\n # df = pd.read_csv('sent_senti.csv')\n # df = df[df['score'] != 0]\n # test_texts = df['content'].values[:100]\n # test_labels = [1 if 0 < score else -\n # 1 for score in df['score'].values][:100]\n # max_length = 27\n # # 予測\n # x_test = to_features(test_texts, max_length)\n # y_test = np.asarray(test_labels)\n # y_preda = model.predict(x_test)\n # y_pred = np.argmax(y_preda, axis=1)\n # print(\"Accuracy: %.5f\" % accuracy_score(y_test, y_pred))\n # model.evaluate()\n pass\n","sub_path":"tespy/gen_bert_model.py","file_name":"gen_bert_model.py","file_ext":"py","file_size_in_byte":4355,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"415902234","text":"#! /usr/bin/env python\n# Importing psycopg2 from python standard library\n\nimport psycopg2\n\nDBNAME = \"newsdata.article\"\n\n\ndef exer(cmd):\n dbm = psycopg2.connect(database=DBNAME)\n cr = dbm.cursor()\n cr.execute(cmd)\n resc = cr.fetchall()\n dbm.close()\n return resc\n\n# Question 1\n\n\ndef popular_author():\n cmd = \"\"\"select authors.name, count(*)\n as number from authors\n join articles\n on authors.id = articles.author\n join log\n on log.path like concat('/article/%',articles.slug)\n group by authors.name\n order by number\n desc limit 3; \"\"\"\n result = exer(cmd)\n counter = 1\n print(\"\\nBest Authors:\")\n for z in result:\n print(str(counter) + '.' + z[0] + '---' + str(z[1]) + \" views\")\n counter += 1\n\n# Question 2\n\nraw_input()\ndef famous_article():\n cmd = \"\"\"select articles.title, count(*)\n as number from articles\n join log\n on log.path like concat('/article/%',articles.slug)\n group by articles.title\n order by number\n desc limit 3;\"\"\"\n\n result = exer(cmd)\n counter = 1\n print(\"Best Articles:\")\n for z in result:\n numbers = str(counter) + '. \"'\n titles = z[0]\n views = '\" --- ' + str(z[1]) + \" views\"\n print(numbers + titles + views)\n counter += 1\n\n# Quesion 3\n\n\ndef error_ter():\n cmd = \"\"\"select tot.day,((errors.er*100)/tot.ers)as percent\n from ( select date_trunc('day', time) \"day\", count(*) as er from log\n where status like '404%' group by day) as errors\n join( select date_trunc('day',time) \"day\", count(*) as ers from log\n group by day) as tot on tot.day = errors.day\n where (((errors.er*100)/tot.ers)>1)\n order by percent desc;\"\"\"\n result = exer(cmd)\n print(\"\\nMaximum errors on:\")\n for z in result:\n dat = z[0].strftime('%B %d, %Y')\n err = str(z[1]) + \"%\" + \" errors\"\n print(dat + \"---\" + err)\n# here,functions are called\nfamous_article()\npopular_author()\nerror_ter()\nraw_input()\n","sub_path":"log_analysis.py","file_name":"log_analysis.py","file_ext":"py","file_size_in_byte":2093,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"510807372","text":"import subprocess \nfrom socket import *\nimport time\n\nif __name__ == '__main__':\n#All menus are going to be stored here\n\n tools= {\n 1: \"ping\",\n 2: \"hydra\",\n 3: \"GoBuster\",\n 4: \"john the ripper\",\n 5: \"Burpsuite\",\n 6: \"Port Scanner\",\n\n }\n\n hydra_options= {\n 1: \"SSH\",\n 2: \"HTTP-GET\",\n\n }\n \n\n yes_or_no= [\"1) Yes\",\n \"2) No\",\n ]\n\n\nfor number, tool in tools.items():\n print(str(number)+\" \" + tool)\n\noption=int(input(\"what tool would you like to use?\"))\n\n\n\n#All Fuctions will go here\n\n# ping a host function\ndef ping():\n host = str(input(\"what host would you like to ping?\"))\n subprocess.run('ping %s' %(host) , shell=True)\n\n# Hydra Bruteforce Function\ndef hydra():\n for number, optionselect in hydra_options.items():\n print(str(number)+ \" \" + optionselect)\n option= int(input(\"What are you trying to bruteforce? \"))\n\n if option == 1:\n print(\"SSH Selected\")\n user= str(input(\"what user are you tryng to bruteforce? \"))\n wordlist= str(input(\"specify your wordlist path \"))\n targetIP= str(input(\"What is the target IP \"))\n subprocess.run('hydra -l %s -P ' %(user) + wordlist + ' ' + targetIP +' ssh -t 4' , shell=True)\n\n# GoBuster Directoy Bruteforce Function \ndef gobuster():\n pass\n\n# John The Ripper Bruteforce Function\ndef john():\n pass\n\n# Burpsuite Open Function\ndef burp():\n pass\n\n# Stealth Port Scanner Function\ndef portscanner():\n target = input('Enter the host to be scanned: ')\n first_Port = int(input(\"What port would you like to start with? \"))\n last_Port = int(input(\"What is the ending port?\"))\n t_IP = gethostbyname(target)\n print ('Starting scan on host: ', t_IP)\n\n for i in range(first_Port, last_Port):\n s = socket(AF_INET, SOCK_STREAM)\n\n conn = s.connect_ex((t_IP, i))\n\n if(conn == 0):\n print ('Port %d: OPEN' % (i,))\n\n s.close()\n\n print(\"Scan finished\")\n\n\n\nif option == 1:\n ping()\n\nif option == 2:\n hydra()\n\nif option == 3:\n gobuster()\n\nif option == 4:\n john()\n\nif option == 5:\n burp()\n\nif option == 6:\n portscanner()\n \n","sub_path":"multi_tool.py","file_name":"multi_tool.py","file_ext":"py","file_size_in_byte":2202,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"563950402","text":"import unittest\n\nfrom werkzeug import exceptions\n\nfrom Python.src.constants import DATA_MODEL_ERROR\nfrom Python.src.preprocessor import Preprocessor\n\nresponse_type = '400 Bad Request: '\n\n\nclass TestPreprocessor(unittest.TestCase):\n def test_nlp_preprocessor_green(self):\n init_preprocessor = Preprocessor('test', 'en_core_web_sm')\n self.assertIsNotNone(init_preprocessor._nlp_pre_process())\n\n def test_nlp_preprocessor_no_text(self):\n init_preprocessor = Preprocessor(None, 'en_core_web_sm')\n with self.assertRaisesRegex(exceptions.BadRequest, response_type + DATA_MODEL_ERROR):\n init_preprocessor._nlp_pre_process()\n\n def test_nlp_preprocessor_no_model(self):\n init_preprocessor = Preprocessor('test', '')\n with self.assertRaisesRegex(exceptions.BadRequest, response_type + DATA_MODEL_ERROR):\n init_preprocessor._nlp_pre_process()\n","sub_path":"Python/test/preprocessor_text.py","file_name":"preprocessor_text.py","file_ext":"py","file_size_in_byte":905,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"294572385","text":"class Solution:\n def groupAnagrams(self, strs: List[str]) -> List[List[str]]:\n import collections\n\n res = collections.defaultdict(list)\n for word in strs:\n count = [0] * 26\n for c in word:\n count[ord(c) - ord('a')] += 1\n res[tuple(count)].append(word)\n\n return res.values()\n","sub_path":"Problems/049-group-anagrams/group-anagrams.py","file_name":"group-anagrams.py","file_ext":"py","file_size_in_byte":353,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"} +{"seq_id":"322239564","text":"'''\n当我们写一个参数比较多的函数时,如果有些参数在大多数情况下都是某个固定值,\n那么为了简化使用,就可以创建一个新函数,指定我们要使用的某个参数位固定值,\n这个新函数就是偏函数\n'''\n\ndef test(a,b,c,d=1):\n print(a+b+c+d)\n#\n# test(1,2,3)\n#\n#\n# def test2(a,b,c=1,d=2):\n# test(a,b,c,d)\n# test2(1,2,3)\n\n# 比较麻烦\n\nimport functools\nnewfunc=functools.partial(test,c=5)\nprint(newfunc,type(newfunc))\nnewfunc(1,3)\n#------------------------------ 场景-----------------------------\nnumStr=\"100010\"\n# result=int(numStr,base=2)\n# print(result)\n# 往后一段时间都需要把2进制字符串转换成10进制数据\nint2=functools.partial(int,base=2)\nprint(int2(numStr))","sub_path":"StudyPython/Python-函数-偏函数.py","file_name":"Python-函数-偏函数.py","file_ext":"py","file_size_in_byte":751,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"66"}