Exemple #1
0
 def handle_api_tm_hosts_create(self, http_context):
     mysql = MySQLConnector()
     if http_context.method == 'POST':
         host = {}
         host["name"] = http_context.json_body()['host_name']
         host["address"] = http_context.json_body()['host_address']
         host["description"] = http_context.json_body()['host_description']
         host["author"] = http_context.json_body()['host_author']
         host["project"] = http_context.json_body()['host_project']
         try:
             host["username"] = http_context.json_body()['project_username']
         except:
             host["username"] = ""
         try:
             host["password"] = http_context.json_body()['project_password']
         except:
             host["password"] = ""
         try:
             host["sshkey"] = http_context.json_body()['project_sshkey']
         except:
             host["sshkey"] = ""
         try:
             host["hophost"] = http_context.json_body()['host_hophost']
         except:
             pass
         result = mysql.insert("tm_hosts", host)
         return result
Exemple #2
0
 def handle_api_tm_projects_create(self, http_context):
     mysql = MySQLConnector()
     if http_context.method == 'POST':
         project = {}
         project["name"] = http_context.json_body()['project_name']
         project["description"] = http_context.json_body()['project_description']
         project["permission"] = http_context.json_body()['project_permission']
         project["author"] = http_context.json_body()['project_author']
         try:
             project["global_username"] = http_context.json_body()['project_global_username']
         except:
             project["global_username"] = ""
         try:
             project["global_password"] = http_context.json_body()['project_global_password']
         except:
             project["global_password"] = ""
         try:
             project["global_sshkey"] = http_context.json_body()['project_global_sshkey']
         except:
             project["global_sshkey"] = ""
         result = mysql.insert("tm_projects", project)
         return result