Merge "Fix pep8 issues"
This commit is contained in:
commit
08d3113166
@ -13,7 +13,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -139,9 +138,10 @@ class ResourceManager(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_json(response):
|
def get_json(response):
|
||||||
"""This method provided backward compatibility with old versions
|
"""Gets JSON representation of response.
|
||||||
of requests library.
|
|
||||||
|
|
||||||
|
This method provided backward compatibility with old versions
|
||||||
|
of requests library.
|
||||||
"""
|
"""
|
||||||
json_field_or_function = getattr(response, 'json', None)
|
json_field_or_function = getattr(response, 'json', None)
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from mistralclient.api import httpclient
|
from mistralclient.api import httpclient
|
||||||
from mistralclient.api.v1 import workbooks
|
|
||||||
from mistralclient.api.v1 import executions
|
from mistralclient.api.v1 import executions
|
||||||
from mistralclient.api.v1 import tasks
|
|
||||||
from mistralclient.api.v1 import listeners
|
from mistralclient.api.v1 import listeners
|
||||||
|
from mistralclient.api.v1 import tasks
|
||||||
|
from mistralclient.api.v1 import workbooks
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
@ -31,11 +31,11 @@ class Client(object):
|
|||||||
raise RuntimeError('Mistral url should be string')
|
raise RuntimeError('Mistral url should be string')
|
||||||
|
|
||||||
if auth_url:
|
if auth_url:
|
||||||
(mistral_url, auth_token, project_id, user_id) = \
|
(mistral_url, auth_token, project_id, user_id) = (
|
||||||
self.authenticate(mistral_url, username, api_key,
|
self.authenticate(mistral_url, username, api_key,
|
||||||
project_name, auth_url, project_id,
|
project_name, auth_url, project_id,
|
||||||
endpoint_type, service_type, auth_token,
|
endpoint_type, service_type, auth_token,
|
||||||
user_id)
|
user_id))
|
||||||
|
|
||||||
if not mistral_url:
|
if not mistral_url:
|
||||||
mistral_url = "http://localhost:8989/v1"
|
mistral_url = "http://localhost:8989/v1"
|
||||||
|
@ -38,7 +38,7 @@ class ListenerManager(base.ResourceManager):
|
|||||||
|
|
||||||
def update(self, workbook_name, id, webhook=None, description=None,
|
def update(self, workbook_name, id, webhook=None, description=None,
|
||||||
events=None):
|
events=None):
|
||||||
# TODO: need to describe what events is
|
# TODO(everyone): need to describe what events is
|
||||||
self._ensure_not_empty(workbook_name=workbook_name, id=id)
|
self._ensure_not_empty(workbook_name=workbook_name, id=id)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -31,8 +31,8 @@ class TaskManager(base.ResourceManager):
|
|||||||
|
|
||||||
if execution_id:
|
if execution_id:
|
||||||
if workbook_name:
|
if workbook_name:
|
||||||
uri = '/workbooks/%s/executions/%s/tasks/%s' % \
|
uri = ('/workbooks/%s/executions/%s/tasks/%s' %
|
||||||
(workbook_name, execution_id, id)
|
(workbook_name, execution_id, id))
|
||||||
else:
|
else:
|
||||||
uri = '/executions/%s/tasks/%s' % (execution_id, id)
|
uri = '/executions/%s/tasks/%s' % (execution_id, id)
|
||||||
else:
|
else:
|
||||||
@ -43,8 +43,8 @@ class TaskManager(base.ResourceManager):
|
|||||||
def list(self, workbook_name, execution_id):
|
def list(self, workbook_name, execution_id):
|
||||||
if execution_id:
|
if execution_id:
|
||||||
if workbook_name:
|
if workbook_name:
|
||||||
uri = '/workbooks/%s/executions/%s/tasks' % \
|
uri = ('/workbooks/%s/executions/%s/tasks' %
|
||||||
(workbook_name, execution_id)
|
(workbook_name, execution_id))
|
||||||
else:
|
else:
|
||||||
uri = '/executions/%s/tasks' % execution_id
|
uri = '/executions/%s/tasks' % execution_id
|
||||||
else:
|
else:
|
||||||
@ -57,8 +57,8 @@ class TaskManager(base.ResourceManager):
|
|||||||
|
|
||||||
if execution_id:
|
if execution_id:
|
||||||
if workbook_name:
|
if workbook_name:
|
||||||
uri = '/workbooks/%s/executions/%s/tasks/%s' % \
|
uri = ('/workbooks/%s/executions/%s/tasks/%s' %
|
||||||
(workbook_name, execution_id, id)
|
(workbook_name, execution_id, id))
|
||||||
else:
|
else:
|
||||||
uri = '/executions/%s/tasks/%s' % (execution_id, id)
|
uri = '/executions/%s/tasks/%s' % (execution_id, id)
|
||||||
else:
|
else:
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ import six
|
|||||||
from mistralclient.api import httpclient
|
from mistralclient.api import httpclient
|
||||||
from mistralclient.api.v2 import actions
|
from mistralclient.api.v2 import actions
|
||||||
from mistralclient.api.v2 import cron_triggers
|
from mistralclient.api.v2 import cron_triggers
|
||||||
from mistralclient.api.v2 import workbooks
|
|
||||||
from mistralclient.api.v2 import executions
|
from mistralclient.api.v2 import executions
|
||||||
from mistralclient.api.v2 import tasks
|
from mistralclient.api.v2 import tasks
|
||||||
|
from mistralclient.api.v2 import workbooks
|
||||||
from mistralclient.api.v2 import workflows
|
from mistralclient.api.v2 import workflows
|
||||||
|
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ class Client(object):
|
|||||||
raise RuntimeError('Mistral url should be string')
|
raise RuntimeError('Mistral url should be string')
|
||||||
|
|
||||||
if auth_url:
|
if auth_url:
|
||||||
(mistral_url, auth_token, project_id, user_id) = \
|
(mistral_url, auth_token, project_id, user_id) = (
|
||||||
self.authenticate(mistral_url, username, api_key,
|
self.authenticate(mistral_url, username, api_key,
|
||||||
project_name, auth_url, project_id,
|
project_name, auth_url, project_id,
|
||||||
endpoint_type, service_type, auth_token,
|
endpoint_type, service_type, auth_token,
|
||||||
user_id)
|
user_id))
|
||||||
|
|
||||||
if not mistral_url:
|
if not mistral_url:
|
||||||
mistral_url = "http://localhost:8989/v2"
|
mistral_url = "http://localhost:8989/v2"
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from cliff.command import Command as BaseCommand
|
from cliff import command
|
||||||
from cliff.lister import Lister as ListCommand
|
from cliff import lister
|
||||||
from cliff.show import ShowOne as ShowCommand
|
from cliff import show
|
||||||
|
|
||||||
from mistralclient.api.v1.executions import ExecutionManager
|
from mistralclient.api.v1 import executions as e
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ def format(execution=None):
|
|||||||
return (columns, data)
|
return (columns, data)
|
||||||
|
|
||||||
|
|
||||||
class List(ListCommand):
|
class List(lister.Lister):
|
||||||
"List all executions"
|
"List all executions"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -60,7 +60,7 @@ class List(ListCommand):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
data = [format(execution)[1] for execution
|
data = [format(execution)[1] for execution
|
||||||
in ExecutionManager(self.app.client)
|
in e.ExecutionManager(self.app.client)
|
||||||
.list(parsed_args.workbook)]
|
.list(parsed_args.workbook)]
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
@ -69,7 +69,7 @@ class List(ListCommand):
|
|||||||
return format()
|
return format()
|
||||||
|
|
||||||
|
|
||||||
class Get(ShowCommand):
|
class Get(show.ShowOne):
|
||||||
"Show specific execution"
|
"Show specific execution"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -84,13 +84,14 @@ class Get(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = ExecutionManager(self.app.client)\
|
execution = e.ExecutionManager(self.app.client).get(
|
||||||
.get(parsed_args.workbook, parsed_args.id)
|
parsed_args.workbook,
|
||||||
|
parsed_args.id)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
|
|
||||||
class Create(ShowCommand):
|
class Create(show.ShowOne):
|
||||||
"Create new execution"
|
"Create new execution"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -113,15 +114,15 @@ class Create(ShowCommand):
|
|||||||
except:
|
except:
|
||||||
ctx = open(parsed_args.context).read()
|
ctx = open(parsed_args.context).read()
|
||||||
|
|
||||||
execution = ExecutionManager(self.app.client)\
|
execution = e.ExecutionManager(self.app.client).create(
|
||||||
.create(parsed_args.workbook,
|
parsed_args.workbook,
|
||||||
parsed_args.task,
|
parsed_args.task,
|
||||||
ctx)
|
ctx)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
|
|
||||||
class Delete(BaseCommand):
|
class Delete(command.Command):
|
||||||
"Delete execution"
|
"Delete execution"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -136,11 +137,11 @@ class Delete(BaseCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
ExecutionManager(self.app.client)\
|
e.ExecutionManager(self.app.client).delete(
|
||||||
.delete(parsed_args.workbook, parsed_args.id)
|
parsed_args.workbook, parsed_args.id)
|
||||||
|
|
||||||
|
|
||||||
class Update(ShowCommand):
|
class Update(show.ShowOne):
|
||||||
"Update execution"
|
"Update execution"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -159,9 +160,9 @@ class Update(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = ExecutionManager(self.app.client)\
|
execution = e.ExecutionManager(self.app.client).update(
|
||||||
.update(parsed_args.workbook,
|
parsed_args.workbook,
|
||||||
parsed_args.id,
|
parsed_args.id,
|
||||||
parsed_args.state)
|
parsed_args.state)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from cliff.lister import Lister as ListCommand
|
from cliff import lister
|
||||||
from cliff.show import ShowOne as ShowCommand
|
from cliff import show
|
||||||
|
|
||||||
from mistralclient.api.v1.tasks import TaskManager
|
from mistralclient.api.v1 import tasks as t
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ def format(task=None):
|
|||||||
return (columns, data)
|
return (columns, data)
|
||||||
|
|
||||||
|
|
||||||
class List(ListCommand):
|
class List(lister.Lister):
|
||||||
"List all tasks"
|
"List all tasks"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -67,7 +67,7 @@ class List(ListCommand):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
data = [format(task)[1] for task
|
data = [format(task)[1] for task
|
||||||
in TaskManager(self.app.client)
|
in t.TaskManager(self.app.client)
|
||||||
.list(parsed_args.workbook,
|
.list(parsed_args.workbook,
|
||||||
parsed_args.execution)]
|
parsed_args.execution)]
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class List(ListCommand):
|
|||||||
return format()
|
return format()
|
||||||
|
|
||||||
|
|
||||||
class Get(ShowCommand):
|
class Get(show.ShowOne):
|
||||||
"Show specific task"
|
"Show specific task"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -94,15 +94,15 @@ class Get(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = TaskManager(self.app.client)\
|
execution = t.TaskManager(self.app.client).get(
|
||||||
.get(parsed_args.workbook,
|
parsed_args.workbook,
|
||||||
parsed_args.execution,
|
parsed_args.execution,
|
||||||
parsed_args.id)
|
parsed_args.id)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
|
|
||||||
class Update(ShowCommand):
|
class Update(show.ShowOne):
|
||||||
"Update task"
|
"Update task"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -124,9 +124,10 @@ class Update(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = TaskManager(self.app.client).update(parsed_args.workbook,
|
execution = t.TaskManager(self.app.client).update(
|
||||||
parsed_args.execution,
|
parsed_args.workbook,
|
||||||
parsed_args.id,
|
parsed_args.execution,
|
||||||
parsed_args.state)
|
parsed_args.id,
|
||||||
|
parsed_args.state)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from cliff.command import Command as BaseCommand
|
from cliff import command
|
||||||
from cliff.lister import Lister as ListCommand
|
from cliff import lister
|
||||||
from cliff.show import ShowOne as ShowCommand
|
from cliff import show
|
||||||
|
|
||||||
from mistralclient.api.v1.workbooks import WorkbookManager
|
from mistralclient.api.v1 import workbooks as w
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ def format(workbook=None):
|
|||||||
return (columns, data)
|
return (columns, data)
|
||||||
|
|
||||||
|
|
||||||
class List(ListCommand):
|
class List(lister.Lister):
|
||||||
"List all workbooks"
|
"List all workbooks"
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
data = [format(workbook)[1] for workbook
|
data = [format(workbook)[1] for workbook
|
||||||
in WorkbookManager(self.app.client).list()]
|
in w.WorkbookManager(self.app.client).list()]
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
return (format()[0], data)
|
return (format()[0], data)
|
||||||
@ -58,7 +58,7 @@ class List(ListCommand):
|
|||||||
return format()
|
return format()
|
||||||
|
|
||||||
|
|
||||||
class Get(ShowCommand):
|
class Get(show.ShowOne):
|
||||||
"Show specific workbook"
|
"Show specific workbook"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -69,12 +69,12 @@ class Get(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
workbook = WorkbookManager(self.app.client).get(parsed_args.name)
|
workbook = w.WorkbookManager(self.app.client).get(parsed_args.name)
|
||||||
|
|
||||||
return format(workbook)
|
return format(workbook)
|
||||||
|
|
||||||
|
|
||||||
class Create(ShowCommand):
|
class Create(show.ShowOne):
|
||||||
"Create new workbook"
|
"Create new workbook"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -100,20 +100,20 @@ class Create(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
workbook = WorkbookManager(self.app.client)\
|
workbook = w.WorkbookManager(self.app.client).create(
|
||||||
.create(parsed_args.name,
|
parsed_args.name,
|
||||||
parsed_args.description,
|
parsed_args.description,
|
||||||
str(parsed_args.tags).split(','))
|
str(parsed_args.tags).split(','))
|
||||||
|
|
||||||
if parsed_args.definition:
|
if parsed_args.definition:
|
||||||
WorkbookManager(self.app.client)\
|
w.WorkbookManager(self.app.client).upload_definition(
|
||||||
.upload_definition(parsed_args.name,
|
parsed_args.name,
|
||||||
parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
return format(workbook)
|
return format(workbook)
|
||||||
|
|
||||||
|
|
||||||
class Delete(BaseCommand):
|
class Delete(command.Command):
|
||||||
"Delete workbook"
|
"Delete workbook"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -125,10 +125,10 @@ class Delete(BaseCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
WorkbookManager(self.app.client).delete(parsed_args.name)
|
w.WorkbookManager(self.app.client).delete(parsed_args.name)
|
||||||
|
|
||||||
|
|
||||||
class Update(ShowCommand):
|
class Update(show.ShowOne):
|
||||||
"Update workbook"
|
"Update workbook"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -148,15 +148,15 @@ class Update(ShowCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
workbook = WorkbookManager(self.app.client)\
|
workbook = w.WorkbookManager(self.app.client).update(
|
||||||
.update(parsed_args.name,
|
parsed_args.name,
|
||||||
parsed_args.description,
|
parsed_args.description,
|
||||||
parsed_args.tags)
|
parsed_args.tags)
|
||||||
|
|
||||||
return format(workbook)
|
return format(workbook)
|
||||||
|
|
||||||
|
|
||||||
class UploadDefinition(BaseCommand):
|
class UploadDefinition(command.Command):
|
||||||
"Upload workbook definition"
|
"Upload workbook definition"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -172,12 +172,12 @@ class UploadDefinition(BaseCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
WorkbookManager(self.app.client)\
|
w.WorkbookManager(self.app.client).upload_definition(
|
||||||
.upload_definition(parsed_args.name,
|
parsed_args.name,
|
||||||
parsed_args.path.read())
|
parsed_args.path.read())
|
||||||
|
|
||||||
|
|
||||||
class GetDefinition(BaseCommand):
|
class GetDefinition(command.Command):
|
||||||
"Show workbook definition"
|
"Show workbook definition"
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -189,7 +189,7 @@ class GetDefinition(BaseCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
definition = WorkbookManager(self.app.client)\
|
definition = w.WorkbookManager(
|
||||||
.get_definition(parsed_args.name)
|
self.app.client).get_definition(parsed_args.name)
|
||||||
|
|
||||||
self.app.stdout.write(definition)
|
self.app.stdout.write(definition)
|
||||||
|
@ -115,8 +115,8 @@ class Create(base.MistralLister):
|
|||||||
return format
|
return format
|
||||||
|
|
||||||
def _get_resources(self, parsed_args):
|
def _get_resources(self, parsed_args):
|
||||||
return actions.ActionManager(self.app.client)\
|
return actions.ActionManager(self.app.client).create(
|
||||||
.create(parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
|
|
||||||
class Delete(command.Command):
|
class Delete(command.Command):
|
||||||
@ -151,8 +151,8 @@ class Update(base.MistralLister):
|
|||||||
return format
|
return format
|
||||||
|
|
||||||
def _get_resources(self, parsed_args):
|
def _get_resources(self, parsed_args):
|
||||||
return actions.ActionManager(self.app.client).\
|
return actions.ActionManager(self.app.client).update(
|
||||||
update(parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
|
|
||||||
class GetDefinition(command.Command):
|
class GetDefinition(command.Command):
|
||||||
@ -166,7 +166,7 @@ class GetDefinition(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
definition = actions.ActionManager(self.app.client)\
|
definition = actions.ActionManager(self.app.client).get(
|
||||||
.get(parsed_args.name).definition
|
parsed_args.name).definition
|
||||||
|
|
||||||
self.app.stdout.write(definition or "\n")
|
self.app.stdout.write(definition or "\n")
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
|
||||||
|
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
|
@ -35,23 +35,24 @@ def format(trigger=None, lister=False):
|
|||||||
'Name',
|
'Name',
|
||||||
'Pattern',
|
'Pattern',
|
||||||
'Workflow',
|
'Workflow',
|
||||||
# TODO (rakhmerov): Uncomment when passwords are handled properly.
|
# TODO(rakhmerov): Uncomment when passwords are handled properly.
|
||||||
# 'Workflow input',
|
# TODO(rakhmerov): Add 'Workflow input' column.
|
||||||
'Next execution time',
|
'Next execution time',
|
||||||
'Created at',
|
'Created at',
|
||||||
'Updated at'
|
'Updated at'
|
||||||
)
|
)
|
||||||
|
|
||||||
if trigger:
|
if trigger:
|
||||||
# wf_input = trigger.workflow_input if not lister \
|
# TODO(rakhmerov): Add following here:
|
||||||
# else base.cut(trigger.workflow_input)
|
# TODO(rakhmerov): wf_input = trigger.workflow_input if not lister
|
||||||
|
# TODO(rakhmerov:): else base.cut(trigger.workflow_input)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
trigger.name,
|
trigger.name,
|
||||||
trigger.pattern,
|
trigger.pattern,
|
||||||
trigger.workflow_name,
|
trigger.workflow_name,
|
||||||
# TODO (rakhmerov): Uncomment when passwords are handled properly.
|
# TODO(rakhmerov): Uncomment when passwords are handled properly.
|
||||||
# wf_input,
|
# TODo(rakhmerov): Add 'wf_input' here.
|
||||||
trigger.next_execution_time,
|
trigger.next_execution_time,
|
||||||
trigger.created_at,
|
trigger.created_at,
|
||||||
)
|
)
|
||||||
|
@ -71,8 +71,8 @@ class Get(show.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = executions.ExecutionManager(self.app.client)\
|
execution = executions.ExecutionManager(self.app.client).get(
|
||||||
.get(parsed_args.id)
|
parsed_args.id)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
@ -117,10 +117,10 @@ class Create(show.ShowOne):
|
|||||||
else:
|
else:
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
execution = executions.ExecutionManager(self.app.client)\
|
execution = executions.ExecutionManager(self.app.client).create(
|
||||||
.create(parsed_args.workflow_name,
|
parsed_args.workflow_name,
|
||||||
wf_input,
|
wf_input,
|
||||||
**params)
|
**params)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
@ -158,9 +158,9 @@ class Update(show.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = executions.ExecutionManager(self.app.client)\
|
execution = executions.ExecutionManager(self.app.client).update(
|
||||||
.update(parsed_args.id,
|
parsed_args.id,
|
||||||
parsed_args.state)
|
parsed_args.state)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
@ -176,8 +176,8 @@ class GetInput(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
ex_input = executions.ExecutionManager(self.app.client)\
|
ex_input = executions.ExecutionManager(self.app.client).get(
|
||||||
.get(parsed_args.id).input
|
parsed_args.id).input
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ex_input = json.loads(ex_input)
|
ex_input = json.loads(ex_input)
|
||||||
@ -199,8 +199,8 @@ class GetOutput(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
output = executions.ExecutionManager(self.app.client)\
|
output = executions.ExecutionManager(self.app.client).get(
|
||||||
.get(parsed_args.id).output
|
parsed_args.id).output
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = json.loads(output)
|
output = json.loads(output)
|
||||||
|
@ -71,8 +71,8 @@ class Get(show.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
execution = tasks.TaskManager(self.app.client)\
|
execution = tasks.TaskManager(self.app.client).get(
|
||||||
.get(parsed_args.id)
|
parsed_args.id)
|
||||||
|
|
||||||
return format(execution)
|
return format(execution)
|
||||||
|
|
||||||
@ -113,8 +113,8 @@ class GetOutput(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
output = tasks.TaskManager(self.app.client)\
|
output = tasks.TaskManager(self.app.client).get(
|
||||||
.get(parsed_args.id).output
|
parsed_args.id).output
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = json.loads(output)
|
output = json.loads(output)
|
||||||
@ -137,8 +137,8 @@ class GetResult(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
result = tasks.TaskManager(self.app.client)\
|
result = tasks.TaskManager(self.app.client).get(
|
||||||
.get(parsed_args.id).result
|
parsed_args.id).result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
@ -162,8 +162,8 @@ class GetInput(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
result = tasks.TaskManager(self.app.client)\
|
result = tasks.TaskManager(self.app.client).get(
|
||||||
.get(parsed_args.id).input
|
parsed_args.id).input
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
|
@ -97,8 +97,8 @@ class Create(show.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
workbook = workbooks.WorkbookManager(self.app.client)\
|
workbook = workbooks.WorkbookManager(self.app.client).create(
|
||||||
.create(parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
return format(workbook)
|
return format(workbook)
|
||||||
|
|
||||||
@ -132,8 +132,8 @@ class Update(show.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
workbook = workbooks.WorkbookManager(self.app.client)\
|
workbook = workbooks.WorkbookManager(self.app.client).update(
|
||||||
.update(parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
return format(workbook)
|
return format(workbook)
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class GetDefinition(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
definition = workbooks.WorkbookManager(self.app.client)\
|
definition = workbooks.WorkbookManager(self.app.client).get(
|
||||||
.get(parsed_args.name).definition
|
parsed_args.name).definition
|
||||||
|
|
||||||
self.app.stdout.write(definition or "\n")
|
self.app.stdout.write(definition or "\n")
|
||||||
|
@ -108,8 +108,8 @@ class Create(base.MistralLister):
|
|||||||
"definition file.")
|
"definition file.")
|
||||||
|
|
||||||
def _get_resources(self, parsed_args):
|
def _get_resources(self, parsed_args):
|
||||||
return workflows.WorkflowManager(self.app.client).\
|
return workflows.WorkflowManager(self.app.client).create(
|
||||||
create(parsed_args.definition.read())
|
parsed_args.definition.read())
|
||||||
|
|
||||||
|
|
||||||
class Delete(command.Command):
|
class Delete(command.Command):
|
||||||
@ -160,7 +160,7 @@ class GetDefinition(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
definition = workflows.WorkflowManager(self.app.client)\
|
definition = workflows.WorkflowManager(self.app.client).get(
|
||||||
.get(parsed_args.name).definition
|
parsed_args.name).definition
|
||||||
|
|
||||||
self.app.stdout.write(definition or "\n")
|
self.app.stdout.write(definition or "\n")
|
||||||
|
@ -21,23 +21,21 @@ Command-line interface to the Mistral APIs
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from mistralclient.openstack.common.cliutils import env
|
|
||||||
|
|
||||||
from mistralclient.api import client
|
from mistralclient.api import client
|
||||||
|
|
||||||
import mistralclient.commands.v1.workbooks
|
|
||||||
import mistralclient.commands.v1.executions
|
import mistralclient.commands.v1.executions
|
||||||
import mistralclient.commands.v1.tasks
|
import mistralclient.commands.v1.tasks
|
||||||
|
import mistralclient.commands.v1.workbooks
|
||||||
import mistralclient.commands.v2.actions
|
import mistralclient.commands.v2.actions
|
||||||
import mistralclient.commands.v2.cron_triggers
|
import mistralclient.commands.v2.cron_triggers
|
||||||
import mistralclient.commands.v2.executions
|
import mistralclient.commands.v2.executions
|
||||||
import mistralclient.commands.v2.tasks
|
import mistralclient.commands.v2.tasks
|
||||||
import mistralclient.commands.v2.workbooks
|
import mistralclient.commands.v2.workbooks
|
||||||
import mistralclient.commands.v2.workflows
|
import mistralclient.commands.v2.workflows
|
||||||
|
from mistralclient.openstack.common import cliutils as c
|
||||||
|
|
||||||
from cliff import app
|
from cliff import app
|
||||||
from cliff import help
|
|
||||||
from cliff import commandmanager
|
from cliff import commandmanager
|
||||||
|
from cliff import help
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
@ -126,49 +124,50 @@ class MistralShell(app.App):
|
|||||||
'--os-mistral-url',
|
'--os-mistral-url',
|
||||||
action='store',
|
action='store',
|
||||||
dest='mistral_url',
|
dest='mistral_url',
|
||||||
default=env('OS_MISTRAL_URL', default='http://localhost:8989/v2'),
|
default=c.env('OS_MISTRAL_URL',
|
||||||
|
default='http://localhost:8989/v2'),
|
||||||
help='Mistral API host (Env: OS_MISTRAL_URL)'
|
help='Mistral API host (Env: OS_MISTRAL_URL)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-username',
|
'--os-username',
|
||||||
action='store',
|
action='store',
|
||||||
dest='username',
|
dest='username',
|
||||||
default=env('OS_USERNAME', default='admin'),
|
default=c.env('OS_USERNAME', default='admin'),
|
||||||
help='Authentication username (Env: OS_USERNAME)'
|
help='Authentication username (Env: OS_USERNAME)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-password',
|
'--os-password',
|
||||||
action='store',
|
action='store',
|
||||||
dest='password',
|
dest='password',
|
||||||
default=env('OS_PASSWORD', default='openstack'),
|
default=c.env('OS_PASSWORD', default='openstack'),
|
||||||
help='Authentication password (Env: OS_PASSWORD)'
|
help='Authentication password (Env: OS_PASSWORD)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-tenant-id',
|
'--os-tenant-id',
|
||||||
action='store',
|
action='store',
|
||||||
dest='tenant_id',
|
dest='tenant_id',
|
||||||
default=env('OS_TENANT_ID'),
|
default=c.env('OS_TENANT_ID'),
|
||||||
help='Authentication tenant identifier (Env: OS_TENANT_ID)'
|
help='Authentication tenant identifier (Env: OS_TENANT_ID)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-tenant-name',
|
'--os-tenant-name',
|
||||||
action='store',
|
action='store',
|
||||||
dest='tenant_name',
|
dest='tenant_name',
|
||||||
default=env('OS_TENANT_NAME', 'Default'),
|
default=c.env('OS_TENANT_NAME', 'Default'),
|
||||||
help='Authentication tenant name (Env: OS_TENANT_NAME)'
|
help='Authentication tenant name (Env: OS_TENANT_NAME)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-auth-token',
|
'--os-auth-token',
|
||||||
action='store',
|
action='store',
|
||||||
dest='token',
|
dest='token',
|
||||||
default=env('OS_AUTH_TOKEN'),
|
default=c.env('OS_AUTH_TOKEN'),
|
||||||
help='Authentication token (Env: OS_AUTH_TOKEN)'
|
help='Authentication token (Env: OS_AUTH_TOKEN)'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-auth-url',
|
'--os-auth-url',
|
||||||
action='store',
|
action='store',
|
||||||
dest='auth_url',
|
dest='auth_url',
|
||||||
default=env('OS_AUTH_URL'),
|
default=c.env('OS_AUTH_URL'),
|
||||||
help='Authentication URL (Env: OS_AUTH_URL)'
|
help='Authentication URL (Env: OS_AUTH_URL)'
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
@ -14,10 +14,9 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tempest_lib.cli import base
|
|
||||||
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
from tempest import test
|
from tempest import test
|
||||||
|
from tempest_lib.cli import base
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
|
@ -1,8 +1,22 @@
|
|||||||
|
# Copyright (c) 2014 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import testtools
|
|
||||||
|
|
||||||
from tempest import clients
|
from tempest import clients
|
||||||
from tempest.common import rest_client
|
from tempest.common import rest_client
|
||||||
|
import testtools
|
||||||
|
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
from mistralclient.api.v1 import client as mclient
|
from mistralclient.api.v1 import client as mclient
|
||||||
@ -71,8 +85,8 @@ class MistralBase(testtools.TestCase):
|
|||||||
def assert_item_in_list(self, items, **props):
|
def assert_item_in_list(self, items, **props):
|
||||||
def _matches(item, **props):
|
def _matches(item, **props):
|
||||||
for prop_name, prop_val in props.iteritems():
|
for prop_name, prop_val in props.iteritems():
|
||||||
v = item[prop_name] if isinstance(item, dict) \
|
v = item[prop_name] if isinstance(item, dict) else getattr(
|
||||||
else getattr(item, prop_name)
|
item, prop_name)
|
||||||
|
|
||||||
if v != prop_val:
|
if v != prop_val:
|
||||||
return False
|
return False
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
# Copyright (c) 2014 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
from base import MistralBase
|
from base import MistralBase
|
||||||
|
|
||||||
|
|
||||||
@ -35,8 +49,8 @@ class Workbooks(MistralURLDefine):
|
|||||||
|
|
||||||
def test_upload_get_definition(self):
|
def test_upload_get_definition(self):
|
||||||
self.mistral_client.workbooks.upload_definition("wb", self.definition)
|
self.mistral_client.workbooks.upload_definition("wb", self.definition)
|
||||||
received_definition = \
|
received_definition = (self.mistral_client.
|
||||||
self.mistral_client.workbooks.get_definition("wb")
|
workbooks.get_definition("wb"))
|
||||||
|
|
||||||
self.assertEqual(self.definition, received_definition)
|
self.assertEqual(self.definition, received_definition)
|
||||||
|
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest2
|
|
||||||
import mock
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
class FakeResponse(object):
|
class FakeResponse(object):
|
||||||
"""Fake response for testing Mistral Client."""
|
"""Fake response for testing Mistral Client."""
|
||||||
@ -35,8 +36,8 @@ class BaseClientTest(unittest2.TestCase):
|
|||||||
if isinstance(content, dict):
|
if isinstance(content, dict):
|
||||||
content = json.dumps(content)
|
content = json.dumps(content)
|
||||||
|
|
||||||
self._client.http_client.get = \
|
self._client.http_client.get = mock.MagicMock(
|
||||||
mock.MagicMock(return_value=FakeResponse(status_code, content))
|
return_value=FakeResponse(status_code, content))
|
||||||
|
|
||||||
return self._client.http_client.get
|
return self._client.http_client.get
|
||||||
|
|
||||||
@ -44,8 +45,8 @@ class BaseClientTest(unittest2.TestCase):
|
|||||||
if isinstance(content, dict):
|
if isinstance(content, dict):
|
||||||
content = json.dumps(content)
|
content = json.dumps(content)
|
||||||
|
|
||||||
self._client.http_client.post = \
|
self._client.http_client.post = mock.MagicMock(
|
||||||
mock.MagicMock(return_value=FakeResponse(status_code, content))
|
return_value=FakeResponse(status_code, content))
|
||||||
|
|
||||||
return self._client.http_client.post
|
return self._client.http_client.post
|
||||||
|
|
||||||
@ -53,14 +54,14 @@ class BaseClientTest(unittest2.TestCase):
|
|||||||
if isinstance(content, dict):
|
if isinstance(content, dict):
|
||||||
content = json.dumps(content)
|
content = json.dumps(content)
|
||||||
|
|
||||||
self._client.http_client.put = \
|
self._client.http_client.put = mock.MagicMock(
|
||||||
mock.MagicMock(return_value=FakeResponse(status_code, content))
|
return_value=FakeResponse(status_code, content))
|
||||||
|
|
||||||
return self._client.http_client.put
|
return self._client.http_client.put
|
||||||
|
|
||||||
def mock_http_delete(self, status_code=204):
|
def mock_http_delete(self, status_code=204):
|
||||||
self._client.http_client.delete = \
|
self._client.http_client.delete = mock.MagicMock(
|
||||||
mock.MagicMock(return_value=FakeResponse(status_code))
|
return_value=FakeResponse(status_code))
|
||||||
|
|
||||||
return self._client.http_client.delete
|
return self._client.http_client.delete
|
||||||
|
|
||||||
|
@ -14,15 +14,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import mock
|
||||||
import pkg_resources as pkg
|
import pkg_resources as pkg
|
||||||
|
|
||||||
import mock
|
from mistralclient.api.v1 import executions as e
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
from mistralclient.commands.v1 import executions
|
from mistralclient.commands.v1 import executions
|
||||||
from mistralclient.api.v1.executions import Execution
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
EXECUTION = Execution(mock, {
|
EXECUTION = e.Execution(mock, {
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'workbook_name': 'some',
|
'workbook_name': 'some',
|
||||||
'task': 'else',
|
'task': 'else',
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from mistralclient.api.v1 import tasks as t
|
||||||
|
from mistralclient.commands.v1 import tasks
|
||||||
from mistralclient.tests.unit import base
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
from mistralclient.commands.v1 import tasks
|
TASK = t.Task(mock, {
|
||||||
from mistralclient.api.v1.tasks import Task
|
|
||||||
|
|
||||||
TASK = Task(mock, {
|
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'workbook_name': 'some',
|
'workbook_name': 'some',
|
||||||
'execution_id': 'thing',
|
'execution_id': 'thing',
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from mistralclient.api.v1 import workbooks as w
|
||||||
|
from mistralclient.commands.v1 import workbooks
|
||||||
from mistralclient.tests.unit import base
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
from mistralclient.commands.v1 import workbooks
|
WORKBOOK = w.Workbook(mock, {
|
||||||
from mistralclient.api.v1.workbooks import Workbook
|
|
||||||
|
|
||||||
WORKBOOK = Workbook(mock, {
|
|
||||||
'name': 'a',
|
'name': 'a',
|
||||||
'description': 'some',
|
'description': 'some',
|
||||||
'tags': ['a', 'b']
|
'tags': ['a', 'b']
|
||||||
|
@ -12,13 +12,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest2
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.tests.unit.v1 import base
|
import unittest2
|
||||||
from mistralclient.api.v1.executions import Execution
|
|
||||||
|
|
||||||
# TODO: Later we need additional tests verifying all the errors etc.
|
from mistralclient.api.v1 import executions as e
|
||||||
|
from mistralclient.tests.unit.v1 import base
|
||||||
|
|
||||||
|
# TODO(everyone): Later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
EXECS = [
|
EXECS = [
|
||||||
{
|
{
|
||||||
@ -55,7 +56,7 @@ class TestExecutions(base.BaseClientV1Test):
|
|||||||
EXECS[0]['context'])
|
EXECS[0]['context'])
|
||||||
|
|
||||||
self.assertIsNotNone(ex)
|
self.assertIsNotNone(ex)
|
||||||
self.assertDictEqual(Execution(self.executions, EXECS[0]).__dict__,
|
self.assertDictEqual(e.Execution(self.executions, EXECS[0]).__dict__,
|
||||||
ex.__dict__)
|
ex.__dict__)
|
||||||
|
|
||||||
arg_body = mock.call_args[0][1]
|
arg_body = mock.call_args[0][1]
|
||||||
@ -105,7 +106,7 @@ class TestExecutions(base.BaseClientV1Test):
|
|||||||
EXECS[0]['state'])
|
EXECS[0]['state'])
|
||||||
|
|
||||||
self.assertIsNotNone(ex)
|
self.assertIsNotNone(ex)
|
||||||
self.assertEqual(Execution(self.executions, EXECS[0]).__dict__,
|
self.assertEqual(e.Execution(self.executions, EXECS[0]).__dict__,
|
||||||
ex.__dict__)
|
ex.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (EXECS[0]['workbook_name'], EXECS[0]['id']),
|
URL_TEMPLATE_ID % (EXECS[0]['workbook_name'], EXECS[0]['id']),
|
||||||
@ -119,7 +120,7 @@ class TestExecutions(base.BaseClientV1Test):
|
|||||||
self.assertEqual(1, len(executions))
|
self.assertEqual(1, len(executions))
|
||||||
ex = executions[0]
|
ex = executions[0]
|
||||||
|
|
||||||
self.assertEqual(Execution(self.executions, EXECS[0]).__dict__,
|
self.assertEqual(e.Execution(self.executions, EXECS[0]).__dict__,
|
||||||
ex.__dict__)
|
ex.__dict__)
|
||||||
mock.assert_called_once_with(URL_TEMPLATE % EXECS[0]['workbook_name'])
|
mock.assert_called_once_with(URL_TEMPLATE % EXECS[0]['workbook_name'])
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ class TestExecutions(base.BaseClientV1Test):
|
|||||||
|
|
||||||
ex = self.executions.get(EXECS[0]['workbook_name'], EXECS[0]['id'])
|
ex = self.executions.get(EXECS[0]['workbook_name'], EXECS[0]['id'])
|
||||||
|
|
||||||
self.assertEqual(Execution(self.executions, EXECS[0]).__dict__,
|
self.assertEqual(e.Execution(self.executions, EXECS[0]).__dict__,
|
||||||
ex.__dict__)
|
ex.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (EXECS[0]['workbook_name'], EXECS[0]['id']))
|
URL_TEMPLATE_ID % (EXECS[0]['workbook_name'], EXECS[0]['id']))
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from mistralclient.api.v1 import listeners as l
|
||||||
from mistralclient.tests.unit.v1 import base
|
from mistralclient.tests.unit.v1 import base
|
||||||
from mistralclient.api.v1.listeners import Listener
|
|
||||||
|
|
||||||
# TODO: later we need additional tests verifying all the errors etc.
|
# TODO(everyone): later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
LISTENERS = [
|
LISTENERS = [
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ class TestListeners(base.BaseClientV1Test):
|
|||||||
LISTENERS[0]['description'])
|
LISTENERS[0]['description'])
|
||||||
|
|
||||||
self.assertIsNotNone(lsnr)
|
self.assertIsNotNone(lsnr)
|
||||||
self.assertEqual(Listener(self.listeners, LISTENERS[0]).__dict__,
|
self.assertEqual(l.Listener(self.listeners, LISTENERS[0]).__dict__,
|
||||||
lsnr.__dict__)
|
lsnr.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE % (LISTENERS[0]['workbook_name']),
|
URL_TEMPLATE % (LISTENERS[0]['workbook_name']),
|
||||||
@ -69,7 +69,7 @@ class TestListeners(base.BaseClientV1Test):
|
|||||||
LISTENERS[0]['description'])
|
LISTENERS[0]['description'])
|
||||||
|
|
||||||
self.assertIsNotNone(lsnr)
|
self.assertIsNotNone(lsnr)
|
||||||
self.assertEqual(Listener(self.listeners, LISTENERS[0]).__dict__,
|
self.assertEqual(l.Listener(self.listeners, LISTENERS[0]).__dict__,
|
||||||
lsnr.__dict__)
|
lsnr.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (LISTENERS[0]['workbook_name'],
|
URL_TEMPLATE_ID % (LISTENERS[0]['workbook_name'],
|
||||||
@ -84,7 +84,7 @@ class TestListeners(base.BaseClientV1Test):
|
|||||||
self.assertEqual(1, len(listeners))
|
self.assertEqual(1, len(listeners))
|
||||||
lsnr = listeners[0]
|
lsnr = listeners[0]
|
||||||
|
|
||||||
self.assertEqual(Listener(self.listeners, LISTENERS[0]).__dict__,
|
self.assertEqual(l.Listener(self.listeners, LISTENERS[0]).__dict__,
|
||||||
lsnr.__dict__)
|
lsnr.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE % (LISTENERS[0]['workbook_name']))
|
URL_TEMPLATE % (LISTENERS[0]['workbook_name']))
|
||||||
@ -95,7 +95,7 @@ class TestListeners(base.BaseClientV1Test):
|
|||||||
lsnr = self.listeners.get(LISTENERS[0]['workbook_name'],
|
lsnr = self.listeners.get(LISTENERS[0]['workbook_name'],
|
||||||
LISTENERS[0]['id'])
|
LISTENERS[0]['id'])
|
||||||
|
|
||||||
self.assertEqual(Listener(self.listeners, LISTENERS[0]).__dict__,
|
self.assertEqual(l.Listener(self.listeners, LISTENERS[0]).__dict__,
|
||||||
lsnr.__dict__)
|
lsnr.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (LISTENERS[0]['workbook_name'],
|
URL_TEMPLATE_ID % (LISTENERS[0]['workbook_name'],
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from mistralclient.api.v1 import tasks as t
|
||||||
from mistralclient.tests.unit.v1 import base
|
from mistralclient.tests.unit.v1 import base
|
||||||
from mistralclient.api.v1.tasks import Task
|
|
||||||
|
|
||||||
# TODO: later we need additional tests verifying all the errors etc.
|
# TODO(everyone): later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
TASKS = [
|
TASKS = [
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ class TestTasks(base.BaseClientV1Test):
|
|||||||
TASKS[0]['state'])
|
TASKS[0]['state'])
|
||||||
|
|
||||||
self.assertIsNotNone(task)
|
self.assertIsNotNone(task)
|
||||||
self.assertEqual(Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
self.assertEqual(t.Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (TASKS[0]['workbook_name'],
|
URL_TEMPLATE_ID % (TASKS[0]['workbook_name'],
|
||||||
TASKS[0]['execution_id'],
|
TASKS[0]['execution_id'],
|
||||||
@ -65,7 +65,7 @@ class TestTasks(base.BaseClientV1Test):
|
|||||||
self.assertEqual(1, len(tasks))
|
self.assertEqual(1, len(tasks))
|
||||||
task = tasks[0]
|
task = tasks[0]
|
||||||
|
|
||||||
self.assertEqual(Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
self.assertEqual(t.Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE % (TASKS[0]['workbook_name'],
|
URL_TEMPLATE % (TASKS[0]['workbook_name'],
|
||||||
TASKS[0]['execution_id']))
|
TASKS[0]['execution_id']))
|
||||||
@ -77,7 +77,7 @@ class TestTasks(base.BaseClientV1Test):
|
|||||||
TASKS[0]['execution_id'],
|
TASKS[0]['execution_id'],
|
||||||
TASKS[0]['id'])
|
TASKS[0]['id'])
|
||||||
|
|
||||||
self.assertEqual(Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
self.assertEqual(t.Task(self.tasks, TASKS[0]).__dict__, task.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_ID % (TASKS[0]['workbook_name'],
|
URL_TEMPLATE_ID % (TASKS[0]['workbook_name'],
|
||||||
TASKS[0]['execution_id'],
|
TASKS[0]['execution_id'],
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from mistralclient.api.v1 import workbooks as w
|
||||||
from mistralclient.tests.unit.v1 import base
|
from mistralclient.tests.unit.v1 import base
|
||||||
from mistralclient.api.v1.workbooks import Workbook
|
|
||||||
|
|
||||||
# TODO: later we need additional tests verifying all the errors etc.
|
# TODO(everyone): later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
WORKBOOKS = [
|
WORKBOOKS = [
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ class TestWorkbooks(base.BaseClientV1Test):
|
|||||||
WORKBOOKS[0]['tags'])
|
WORKBOOKS[0]['tags'])
|
||||||
|
|
||||||
self.assertIsNotNone(wb)
|
self.assertIsNotNone(wb)
|
||||||
self.assertEqual(Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
self.assertEqual(w.Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
||||||
wb.__dict__)
|
wb.__dict__)
|
||||||
mock.assert_called_once_with(URL_TEMPLATE, json.dumps(WORKBOOKS[0]))
|
mock.assert_called_once_with(URL_TEMPLATE, json.dumps(WORKBOOKS[0]))
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class TestWorkbooks(base.BaseClientV1Test):
|
|||||||
WORKBOOKS[0]['tags'])
|
WORKBOOKS[0]['tags'])
|
||||||
|
|
||||||
self.assertIsNotNone(wb)
|
self.assertIsNotNone(wb)
|
||||||
self.assertEqual(Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
self.assertEqual(w.Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
||||||
wb.__dict__)
|
wb.__dict__)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
URL_TEMPLATE_NAME % WORKBOOKS[0]['name'],
|
URL_TEMPLATE_NAME % WORKBOOKS[0]['name'],
|
||||||
@ -92,7 +92,7 @@ class TestWorkbooks(base.BaseClientV1Test):
|
|||||||
self.assertEqual(1, len(workbooks))
|
self.assertEqual(1, len(workbooks))
|
||||||
wb = workbooks[0]
|
wb = workbooks[0]
|
||||||
|
|
||||||
self.assertEqual(Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
self.assertEqual(w.Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
||||||
wb.__dict__)
|
wb.__dict__)
|
||||||
mock.assert_called_once_with(URL_TEMPLATE)
|
mock.assert_called_once_with(URL_TEMPLATE)
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class TestWorkbooks(base.BaseClientV1Test):
|
|||||||
wb = self.workbooks.get(WORKBOOKS[0]['name'])
|
wb = self.workbooks.get(WORKBOOKS[0]['name'])
|
||||||
|
|
||||||
self.assertIsNotNone(wb)
|
self.assertIsNotNone(wb)
|
||||||
self.assertEqual(Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
self.assertEqual(w.Workbook(self.workbooks, WORKBOOKS[0]).__dict__,
|
||||||
wb.__dict__)
|
wb.__dict__)
|
||||||
mock.assert_called_once_with(URL_TEMPLATE_NAME % WORKBOOKS[0]['name'])
|
mock.assert_called_once_with(URL_TEMPLATE_NAME % WORKBOOKS[0]['name'])
|
||||||
|
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
|
|
||||||
from mistralclient.commands.v2 import actions as action_cmd
|
|
||||||
from mistralclient.api.v2 import actions
|
from mistralclient.api.v2 import actions
|
||||||
|
from mistralclient.commands.v2 import actions as action_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
ACTION_DICT = {
|
ACTION_DICT = {
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
|
|
||||||
from mistralclient.commands.v2 import cron_triggers as cron_triggers_cmd
|
|
||||||
from mistralclient.api.v2 import cron_triggers
|
from mistralclient.api.v2 import cron_triggers
|
||||||
|
from mistralclient.commands.v2 import cron_triggers as cron_triggers_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
TRIGGER_DICT = {
|
TRIGGER_DICT = {
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import mock
|
||||||
import pkg_resources as pkg
|
import pkg_resources as pkg
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
from mistralclient.commands.v2 import executions as execution_cmd
|
|
||||||
from mistralclient.api.v2 import executions
|
from mistralclient.api.v2 import executions
|
||||||
|
from mistralclient.commands.v2 import executions as execution_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
EXECUTION = executions.Execution(mock, {
|
EXECUTION = executions.Execution(mock, {
|
||||||
'id': '123',
|
'id': '123',
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
|
|
||||||
from mistralclient.commands.v2 import tasks as task_cmd
|
|
||||||
from mistralclient.api.v2 import tasks
|
from mistralclient.api.v2 import tasks
|
||||||
|
from mistralclient.commands.v2 import tasks as task_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
TASK_DICT = {
|
TASK_DICT = {
|
||||||
'id': '123',
|
'id': '123',
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
|
|
||||||
from mistralclient.commands.v2 import workbooks as workbook_cmd
|
|
||||||
from mistralclient.api.v2 import workbooks
|
from mistralclient.api.v2 import workbooks
|
||||||
|
from mistralclient.commands.v2 import workbooks as workbook_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
WORKBOOK_DICT = {
|
WORKBOOK_DICT = {
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mistralclient.tests.unit import base
|
|
||||||
|
|
||||||
from mistralclient.commands.v2 import workflows as workflow_cmd
|
|
||||||
from mistralclient.api.v2 import workflows
|
from mistralclient.api.v2 import workflows
|
||||||
|
from mistralclient.commands.v2 import workflows as workflow_cmd
|
||||||
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
WORKFLOW_DICT = {
|
WORKFLOW_DICT = {
|
||||||
|
@ -12,13 +12,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest2
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.tests.unit.v2 import base
|
import unittest2
|
||||||
from mistralclient.api.v2 import executions
|
|
||||||
|
|
||||||
# TODO: Later we need additional tests verifying all the errors etc.
|
from mistralclient.api.v2 import executions
|
||||||
|
from mistralclient.tests.unit.v2 import base
|
||||||
|
|
||||||
|
# TODO(everyone): Later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
EXEC = {
|
EXEC = {
|
||||||
'id': "123",
|
'id': "123",
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.tests.unit.v2 import base
|
|
||||||
from mistralclient.api.v2 import tasks
|
from mistralclient.api.v2 import tasks
|
||||||
|
from mistralclient.tests.unit.v2 import base
|
||||||
|
|
||||||
# TODO: later we need additional tests verifying all the errors etc.
|
# TODO(everyone): later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
TASK = {
|
TASK = {
|
||||||
'id': "1",
|
'id': "1",
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mistralclient.tests.unit.v2 import base
|
|
||||||
from mistralclient.api.v2 import workbooks
|
from mistralclient.api.v2 import workbooks
|
||||||
|
from mistralclient.tests.unit.v2 import base
|
||||||
|
|
||||||
# TODO: later we need additional tests verifying all the errors etc.
|
# TODO(everyone): later we need additional tests verifying all the errors etc.
|
||||||
|
|
||||||
|
|
||||||
WB_DEF = """
|
WB_DEF = """
|
||||||
|
3
tox.ini
3
tox.ini
@ -38,7 +38,8 @@ setenv = VIRTUAL_ENV={envdir}
|
|||||||
commands = bash tools/lintstack.sh
|
commands = bash tools/lintstack.sh
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
|
#H201 no 'except:' at least use 'except Exception:'
|
||||||
show-source = true
|
show-source = true
|
||||||
ignore = H803,H305,H405,H904,H101,H102,H201,H302,H306,H307
|
ignore = H201
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
||||||
|
Loading…
Reference in New Issue
Block a user