diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2018-03-07 16:16:11 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2018-03-07 16:18:31 +0800 |
commit | dcff4557e191f0ed925fd1306c7fca1a645b4654 (patch) | |
tree | ed4e88b667ed81a27a153609fa26d0b001cd80d3 /testapi | |
parent | 83cec09282cca292056a54b50d33f6a3d7e5b48c (diff) |
apply openstack import rule
Change-Id: I765a3aa64906cfa6d8f21ee7b7f2510d6c4ad7a2
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi')
-rw-r--r-- | testapi/testapi-client/testapiclient/httpClient.py | 1 | ||||
-rw-r--r-- | testapi/testapi-client/testapiclient/identity.py | 18 | ||||
-rw-r--r-- | testapi/testapi-client/testapiclient/main.py | 12 | ||||
-rw-r--r-- | testapi/testapi-client/testapiclient/pods.py | 24 | ||||
-rw-r--r-- | testapi/testapi-client/testapiclient/projects.py | 37 |
5 files changed, 47 insertions, 45 deletions
diff --git a/testapi/testapi-client/testapiclient/httpClient.py b/testapi/testapi-client/testapiclient/httpClient.py index 69d94a4..f8683b9 100644 --- a/testapi/testapi-client/testapiclient/httpClient.py +++ b/testapi/testapi-client/testapiclient/httpClient.py @@ -1,4 +1,5 @@ import json + import requests diff --git a/testapi/testapi-client/testapiclient/identity.py b/testapi/testapi-client/testapiclient/identity.py index d62ed7a..5456697 100644 --- a/testapi/testapi-client/testapiclient/identity.py +++ b/testapi/testapi-client/testapiclient/identity.py @@ -1,19 +1,21 @@ -import requests -from user import User -from config import Config -import urllib import functools +import urllib + +import requests + +from testapiclient import config +from testapiclient import user def _authenticate(username, password): session = requests.Session() hostname = '{}{}{}'.format( - Config.config.get("cas", "auth_url"), - urllib.quote(Config.config.get("api", "url")), - Config.config.get("cas", "signin_return")) + config.Config.config.get("cas", "auth_url"), + urllib.quote(config.Config.config.get("api", "url")), + config.Config.config.get("cas", "signin_return")) data = {'name': username, 'pass': password, 'form_id': 'user_login'} response = session.post(hostname, data) - User.session = session + user.User.session = session return response diff --git a/testapi/testapi-client/testapiclient/main.py b/testapi/testapi-client/testapiclient/main.py index 07dbeb8..0298e99 100644 --- a/testapi/testapi-client/testapiclient/main.py +++ b/testapi/testapi-client/testapiclient/main.py @@ -1,9 +1,11 @@ import sys -import requests -from user import User -from config import Config + from cliff.app import App from cliff.commandmanager import CommandManager +import requests + +from testapiclient import config +from testapiclient import user class TestAPIClient(App): @@ -15,9 +17,9 @@ class TestAPIClient(App): command_manager=CommandManager('testapi'), deferred_help=True, ) - User.session = requests.Session() + user.User.session = requests.Session() # Configure development or Production mode - Config.parse_conf() + config.Config.parse_conf() def initialize_app(self, argv): self.LOG.debug('initialize_app') diff --git a/testapi/testapi-client/testapiclient/pods.py b/testapi/testapi-client/testapiclient/pods.py index b73839e..64bb74d 100644 --- a/testapi/testapi-client/testapiclient/pods.py +++ b/testapi/testapi-client/testapiclient/pods.py @@ -1,14 +1,12 @@ import json -from testapiclient import identity from testapiclient import command +from testapiclient import config +from testapiclient import httpClient +from testapiclient import identity +from testapiclient import user -from config import Config -from httpClient import HTTPClient -from user import User - - -PODS_URL = Config.config.get("api", "url") + "/pods" +PODS_URL = config.Config.config.get("api", "url") + "/pods" class PodGet(command.Lister): @@ -22,7 +20,7 @@ class PodGet(command.Lister): return parser def take_action(self, parsed_args): - http_client = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() url = PODS_URL if(parsed_args.name): url = PODS_URL + "?name=" + parsed_args.name @@ -42,7 +40,7 @@ class PodGetOne(command.ShowOne): return parser def take_action(self, parsed_args): - http_client = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() pods = http_client.get(PODS_URL + "/" + parsed_args.name) print pods @@ -63,9 +61,9 @@ class PodCreate(command.Command): @identity.authenticate def take_action(self, parsed_args): - http_client = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() response = http_client.post(PODS_URL, - User.session, + user.User.session, parsed_args.pod) if response.status_code == 200: print "Pod has been successfully created!" @@ -86,6 +84,6 @@ class PodDelete(command.Command): @identity.authenticate def take_action(self, parsed_args): - http_client = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() print http_client.delete(PODS_URL + "/" + parsed_args.name, - User.session) + user.User.session) diff --git a/testapi/testapi-client/testapiclient/projects.py b/testapi/testapi-client/testapiclient/projects.py index 2e61369..cd55e74 100644 --- a/testapi/testapi-client/testapiclient/projects.py +++ b/testapi/testapi-client/testapiclient/projects.py @@ -1,13 +1,12 @@ import json from testapiclient import command +from testapiclient import config +from testapiclient import httpClient from testapiclient import identity +from testapiclient import user -from config import Config -from httpClient import HTTPClient -from user import User - -PROJECTS_URL = Config.config.get("api", "url") + "/projects" +PROJECTS_URL = config.Config.config.get("api", "url") + "/projects" class ProjectGet(command.Lister): @@ -20,11 +19,11 @@ class ProjectGet(command.Lister): return parser def take_action(self, parsed_args): - httpClient = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() url = PROJECTS_URL if parsed_args.name: url = url + "?name=" + parsed_args.name - projects = httpClient.get(url) + projects = http_client.get(url) print projects @@ -39,9 +38,9 @@ class ProjectGetOne(command.ShowOne): return parser def take_action(self, parsed_args): - httpClient = HTTPClient.get_Instance() + http_client = httpClient.HTTPClient.get_Instance() url = PROJECTS_URL + "/" + parsed_args.name - project = httpClient.get(url) + project = http_client.get(url) print project @@ -58,10 +57,10 @@ class ProjectCreate(command.Command): @identity.authenticate def take_action(self, parsed_args): - httpClient = HTTPClient.get_Instance() - response = httpClient.post(ProjectCreate.projects_url, - User.session, - parsed_args.project) + http_client = httpClient.HTTPClient.get_Instance() + response = http_client.post(ProjectCreate.projects_url, + user.User.session, + parsed_args.project) if response.status_code == 200: print "Project has been successfully created!" else: @@ -80,10 +79,10 @@ class ProjectDelete(command.Command): @identity.authenticate def take_action(self, parsed_args): - httpClient = HTTPClient.get_Instance() - projects = httpClient.delete( + http_client = httpClient.HTTPClient.get_Instance() + projects = http_client.delete( PROJECTS_URL + "/" + parsed_args.name, - User.session) + user.User.session) print projects @@ -104,9 +103,9 @@ class ProjectPut(command.Command): @identity.authenticate def take_action(self, parsed_args): - httpClient = HTTPClient.get_Instance() - projects = httpClient.put( + http_client = httpClient.HTTPClient.get_Instance() + projects = http_client.put( PROJECTS_URL + "/" + parsed_args.name, - User.session, + user.User.session, parsed_args.project) print projects |