summaryrefslogtreecommitdiff
path: root/saharaclient/osc/v2
diff options
context:
space:
mode:
Diffstat (limited to 'saharaclient/osc/v2')
-rw-r--r--saharaclient/osc/v2/cluster_templates.py149
-rw-r--r--saharaclient/osc/v2/clusters.py172
-rw-r--r--saharaclient/osc/v2/data_sources.py48
-rw-r--r--saharaclient/osc/v2/images.py62
-rw-r--r--saharaclient/osc/v2/job_binaries.py212
-rw-r--r--saharaclient/osc/v2/job_templates.py48
-rw-r--r--saharaclient/osc/v2/job_types.py54
-rw-r--r--saharaclient/osc/v2/jobs.py142
-rw-r--r--saharaclient/osc/v2/plugins.py40
9 files changed, 927 insertions, 0 deletions
diff --git a/saharaclient/osc/v2/cluster_templates.py b/saharaclient/osc/v2/cluster_templates.py
new file mode 100644
index 0000000..28ad648
--- /dev/null
+++ b/saharaclient/osc/v2/cluster_templates.py
@@ -0,0 +1,149 @@
+# Copyright (c) 2015 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 osc_lib import utils as osc_utils
+from oslo_log import log as logging
+
+from saharaclient.osc import utils
+from saharaclient.osc.v1 import cluster_templates as ct_v1
+
+
+def _format_ct_output(app, data):
+ data['node_groups'] = ct_v1._format_node_groups_list(data['node_groups'])
+ data['anti_affinity'] = osc_utils.format_list(data['anti_affinity'])
+
+
+class CreateClusterTemplate(ct_v1.CreateClusterTemplate):
+ """Creates cluster template"""
+
+ log = logging.getLogger(__name__ + ".CreateClusterTemplate")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_ct_output(self.app, data)
+ data = utils.prepare_data(data, ct_v1.CT_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ListClusterTemplates(ct_v1.ListClusterTemplates):
+ """Lists cluster templates"""
+
+ log = logging.getLogger(__name__ + ".ListClusterTemplates")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+ search_opts = {}
+ if parsed_args.plugin:
+ search_opts['plugin_name'] = parsed_args.plugin
+ if parsed_args.plugin_version:
+ search_opts['plugin_version'] = parsed_args.plugin_version
+
+ data = client.cluster_templates.list(search_opts=search_opts)
+
+ if parsed_args.name:
+ data = utils.get_by_name_substring(data, parsed_args.name)
+
+ if parsed_args.long:
+ columns = ('name', 'id', 'plugin_name', 'plugin_version',
+ 'node_groups', 'description')
+ column_headers = utils.prepare_column_headers(columns)
+
+ else:
+ columns = ('name', 'id', 'plugin_name', 'plugin_version')
+ column_headers = utils.prepare_column_headers(columns)
+
+ return (
+ column_headers,
+ (osc_utils.get_item_properties(
+ s,
+ columns,
+ formatters={
+ 'node_groups': ct_v1._format_node_groups_list
+ }
+ ) for s in data)
+ )
+
+
+class ShowClusterTemplate(ct_v1.ShowClusterTemplate):
+ """Display cluster template details"""
+
+ log = logging.getLogger(__name__ + ".ShowClusterTemplate")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = utils.get_resource(
+ client.cluster_templates, parsed_args.cluster_template).to_dict()
+
+ _format_ct_output(self.app, data)
+ data = utils.prepare_data(data, ct_v1.CT_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class DeleteClusterTemplate(ct_v1.DeleteClusterTemplate):
+ """Deletes cluster template"""
+
+ log = logging.getLogger(__name__ + ".DeleteClusterTemplate")
+
+
+class UpdateClusterTemplate(ct_v1.UpdateClusterTemplate):
+ """Updates cluster template"""
+
+ log = logging.getLogger(__name__ + ".UpdateClusterTemplate")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ ct_id = utils.get_resource_id(
+ client.cluster_templates, parsed_args.cluster_template)
+
+ data = self._take_action(client, parsed_args, ct_id)
+
+ _format_ct_output(self.app, data)
+ data = utils.prepare_data(data, ct_v1.CT_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ImportClusterTemplate(ct_v1.ImportClusterTemplate):
+ """Imports cluster template"""
+
+ log = logging.getLogger(__name__ + ".ImportClusterTemplate")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_ct_output(self.app, data)
+ data = utils.prepare_data(data, ct_v1.CT_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ExportClusterTemplate(ct_v1.ExportClusterTemplate):
+ """Export cluster template to JSON"""
+
+ log = logging.getLogger(__name__ + ".ExportClusterTemplate")
diff --git a/saharaclient/osc/v2/clusters.py b/saharaclient/osc/v2/clusters.py
new file mode 100644
index 0000000..40cb2cf
--- /dev/null
+++ b/saharaclient/osc/v2/clusters.py
@@ -0,0 +1,172 @@
+# Copyright (c) 2015 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 osc_lib import utils as osc_utils
+from oslo_log import log as logging
+
+from saharaclient.osc import utils
+from saharaclient.osc.v1 import clusters as c_v1
+
+
+def _format_cluster_output(app, data):
+ data['image'] = data.pop('default_image_id')
+ data['node_groups'] = c_v1._format_node_groups_list(data['node_groups'])
+ data['anti_affinity'] = osc_utils.format_list(data['anti_affinity'])
+
+
+class CreateCluster(c_v1.CreateCluster):
+ """Creates cluster"""
+
+ log = logging.getLogger(__name__ + ".CreateCluster")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ if parsed_args.count and parsed_args.count > 1:
+ clusters = []
+ for cluster in data['clusters']:
+ clusters.append(
+ utils.get_resource(client.clusters,
+ cluster['cluster']['id']))
+
+ if parsed_args.wait:
+ for cluster in clusters:
+ if not osc_utils.wait_for_status(
+ client.clusters.get, cluster.id):
+ self.log.error(
+ 'Error occurred during cluster creation: %s',
+ data['id'])
+
+ data = {}
+ for cluster in clusters:
+ data[cluster.name] = cluster.id
+
+ else:
+ if parsed_args.wait:
+ if not osc_utils.wait_for_status(
+ client.clusters.get, data['id']):
+ self.log.error(
+ 'Error occurred during cluster creation: %s',
+ data['id'])
+ data = client.clusters.get(data['id']).to_dict()
+ _format_cluster_output(self.app, data)
+ data = utils.prepare_data(data, c_v1.CLUSTER_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ListClusters(c_v1.ListClusters):
+ """Lists clusters"""
+
+ log = logging.getLogger(__name__ + ".ListClusters")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+ search_opts = {}
+ if parsed_args.plugin:
+ search_opts['plugin_name'] = parsed_args.plugin
+ if parsed_args.plugin_version:
+ search_opts['plugin_version'] = parsed_args.plugin_version
+
+ data = client.clusters.list(search_opts=search_opts)
+
+ if parsed_args.name:
+ data = utils.get_by_name_substring(data, parsed_args.name)
+
+ if parsed_args.long:
+ columns = ('name', 'id', 'plugin_name', 'plugin_version',
+ 'status', 'description', 'default_image_id')
+ column_headers = utils.prepare_column_headers(
+ columns, {'default_image_id': 'image'})
+ else:
+ columns = ('name', 'id', 'plugin_name', 'plugin_version',
+ 'status')
+ column_headers = utils.prepare_column_headers(
+ columns, {'default_image_id': 'image'})
+
+ return (
+ column_headers,
+ (osc_utils.get_item_properties(
+ s,
+ columns
+ ) for s in data)
+ )
+
+
+class ShowCluster(c_v1.ShowCluster):
+ """Display cluster details"""
+
+ log = logging.getLogger(__name__ + ".ShowCluster")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data, provision_steps = self._take_action(client, parsed_args)
+
+ _format_cluster_output(self.app, data)
+
+ data = self._show_cluster_info(data, provision_steps, parsed_args)
+ return data
+
+
+class DeleteCluster(c_v1.DeleteCluster):
+ """Deletes cluster"""
+
+ log = logging.getLogger(__name__ + ".DeleteCluster")
+
+
+class UpdateCluster(c_v1.UpdateCluster):
+ """Updates cluster"""
+
+ log = logging.getLogger(__name__ + ".UpdateCluster")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_cluster_output(self.app, data)
+ data = utils.prepare_data(data, c_v1.CLUSTER_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ScaleCluster(c_v1.ScaleCluster):
+ """Scales cluster"""
+
+ log = logging.getLogger(__name__ + ".ScaleCluster")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_cluster_output(self.app, data)
+ data = utils.prepare_data(data, c_v1.CLUSTER_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class VerificationUpdateCluster(c_v1.VerificationUpdateCluster):
+ """Updates cluster verifications"""
+
+ log = logging.getLogger(__name__ + ".VerificationUpdateCluster")
diff --git a/saharaclient/osc/v2/data_sources.py b/saharaclient/osc/v2/data_sources.py
new file mode 100644
index 0000000..c05793b
--- /dev/null
+++ b/saharaclient/osc/v2/data_sources.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2015 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 oslo_log import log as logging
+
+from saharaclient.osc.v1 import data_sources as ds_v1
+
+
+class CreateDataSource(ds_v1.CreateDataSource):
+ """Creates data source"""
+
+ log = logging.getLogger(__name__ + ".CreateDataSource")
+
+
+class ListDataSources(ds_v1.ListDataSources):
+ """Lists data sources"""
+
+ log = logging.getLogger(__name__ + ".ListDataSources")
+
+
+class ShowDataSource(ds_v1.ShowDataSource):
+ """Display data source details"""
+
+ log = logging.getLogger(__name__ + ".ShowDataSource")
+
+
+class DeleteDataSource(ds_v1.DeleteDataSource):
+ """Delete data source"""
+
+ log = logging.getLogger(__name__ + ".DeleteDataSource")
+
+
+class UpdateDataSource(ds_v1.UpdateDataSource):
+ """Update data source"""
+
+ log = logging.getLogger(__name__ + ".UpdateDataSource")
diff --git a/saharaclient/osc/v2/images.py b/saharaclient/osc/v2/images.py
new file mode 100644
index 0000000..ed4fe4e
--- /dev/null
+++ b/saharaclient/osc/v2/images.py
@@ -0,0 +1,62 @@
+# Copyright (c) 2015 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 oslo_log import log as logging
+
+from saharaclient.osc.v1 import images as images_v1
+
+IMAGE_FIELDS = ['name', 'id', 'username', 'tags', 'status', 'description']
+
+
+class ListImages(images_v1.ListImages):
+ """Lists registered images"""
+
+ log = logging.getLogger(__name__ + ".ListImages")
+
+
+class ShowImage(images_v1.ShowImage):
+ """Display image details"""
+
+ log = logging.getLogger(__name__ + ".ShowImage")
+
+
+class RegisterImage(images_v1.RegisterImage):
+ """Register an image"""
+
+ log = logging.getLogger(__name__ + ".RegisterImage")
+
+
+class UnregisterImage(images_v1.UnregisterImage):
+ """Unregister image(s)"""
+
+ log = logging.getLogger(__name__ + ".RegisterImage")
+
+
+class SetImageTags(images_v1.SetImageTags):
+ """Set image tags (Replace current image tags with provided ones)"""
+
+ log = logging.getLogger(__name__ + ".AddImageTags")
+
+
+class AddImageTags(images_v1.AddImageTags):
+ """Add image tags"""
+
+ log = logging.getLogger(__name__ + ".AddImageTags")
+
+
+class RemoveImageTags(images_v1.RemoveImageTags):
+ """Remove image tags"""
+
+ log = logging.getLogger(__name__ + ".RemoveImageTags")
diff --git a/saharaclient/osc/v2/job_binaries.py b/saharaclient/osc/v2/job_binaries.py
new file mode 100644
index 0000000..e1aa30b
--- /dev/null
+++ b/saharaclient/osc/v2/job_binaries.py
@@ -0,0 +1,212 @@
+# Copyright (c) 2015 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 osc_lib.command import command
+from osc_lib import exceptions
+from osc_lib import utils as osc_utils
+from oslo_log import log as logging
+from oslo_serialization import jsonutils
+
+from saharaclient.osc import utils
+from saharaclient.osc.v1 import job_binaries as jb_v1
+
+
+class CreateJobBinary(command.ShowOne):
+ """Creates job binary"""
+
+ log = logging.getLogger(__name__ + ".CreateJobBinary")
+
+ def get_parser(self, prog_name):
+ parser = super(CreateJobBinary, self).get_parser(prog_name)
+
+ parser.add_argument(
+ '--name',
+ metavar="<name>",
+ help="Name of the job binary [REQUIRED if JSON is not provided]",
+ )
+ creation_type = parser.add_mutually_exclusive_group()
+ creation_type.add_argument(
+ '--url',
+ metavar='<url>',
+ help='URL for the job binary [REQUIRED if JSON and file are '
+ 'not provided]'
+ )
+ parser.add_argument(
+ '--description',
+ metavar="<description>",
+ help="Description of the job binary"
+ )
+ username = parser.add_mutually_exclusive_group()
+ username.add_argument(
+ '--username',
+ metavar='<username>',
+ help='Username for accessing the job binary URL',
+ )
+ username.add_argument(
+ '--access-key',
+ metavar='<accesskey>',
+ help='S3 access key for accessing the job binary URL',
+ )
+ password = parser.add_mutually_exclusive_group()
+ password.add_argument(
+ '--password',
+ metavar='<password>',
+ help='Password for accessing the job binary URL',
+ )
+ password.add_argument(
+ '--secret-key',
+ metavar='<secretkey>',
+ help='S3 secret key for accessing the job binary URL',
+ )
+ password.add_argument(
+ '--password-prompt',
+ dest="password_prompt",
+ action="store_true",
+ help='Prompt interactively for password',
+ )
+ password.add_argument(
+ '--secret-key-prompt',
+ dest="secret_key_prompt",
+ action="store_true",
+ help='Prompt interactively for S3 secret key',
+ )
+ parser.add_argument(
+ '--s3-endpoint',
+ metavar='<endpoint>',
+ help='S3 endpoint for accessing the job binary URL (ignored if '
+ 'binary not in S3',
+ )
+ parser.add_argument(
+ '--public',
+ action='store_true',
+ default=False,
+ help='Make the job binary public',
+ )
+ parser.add_argument(
+ '--protected',
+ action='store_true',
+ default=False,
+ help='Make the job binary protected',
+ )
+ parser.add_argument(
+ '--json',
+ metavar='<filename>',
+ help='JSON representation of the job binary. Other '
+ 'arguments will not be taken into account if this one is '
+ 'provided'
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ if parsed_args.json:
+ blob = osc_utils.read_blob_file_contents(parsed_args.json)
+ try:
+ template = jsonutils.loads(blob)
+ except ValueError as e:
+ raise exceptions.CommandError(
+ 'An error occurred when reading '
+ 'template from file %s: %s' % (parsed_args.json, e))
+ data = client.job_binaries.create(**template).to_dict()
+ else:
+ if parsed_args.password_prompt:
+ parsed_args.password = osc_utils.get_password(
+ self.app.stdin, confirm=False)
+
+ if parsed_args.secret_key_prompt:
+ parsed_args.secret_key = osc_utils.get_password(
+ self.app.stdin, confirm=False)
+
+ if not parsed_args.password:
+ parsed_args.password = parsed_args.secret_key
+
+ if not parsed_args.username:
+ parsed_args.username = parsed_args.access_key
+
+ if parsed_args.password and not parsed_args.username:
+ raise exceptions.CommandError(
+ 'Username via --username, or S3 access key via '
+ '--access-key should be provided with password')
+
+ if parsed_args.username and not parsed_args.password:
+ raise exceptions.CommandError(
+ 'Password should be provided via --password or '
+ '--secret-key, or entered interactively with '
+ '--password-prompt or --secret-key-prompt')
+
+ if parsed_args.password and parsed_args.username:
+ if not parsed_args.url:
+ raise exceptions.CommandError(
+ 'URL must be provided via --url')
+ if parsed_args.url.startswith('s3'):
+ if not parsed_args.s3_endpoint:
+ raise exceptions.CommandError(
+ 'S3 job binaries need an endpoint provided via '
+ '--s3-endpoint')
+ extra = {
+ 'accesskey': parsed_args.username,
+ 'secretkey': parsed_args.password,
+ 'endpoint': parsed_args.s3_endpoint,
+ }
+
+ else:
+ extra = {
+ 'user': parsed_args.username,
+ 'password': parsed_args.password
+ }
+ else:
+ extra = None
+
+ data = client.job_binaries.create(
+ name=parsed_args.name, url=parsed_args.url,
+ description=parsed_args.description, extra=extra,
+ is_public=parsed_args.public,
+ is_protected=parsed_args.protected).to_dict()
+
+ data = utils.prepare_data(data, jb_v1.JOB_BINARY_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ListJobBinaries(jb_v1.ListJobBinaries):
+ """Lists job binaries"""
+
+ log = logging.getLogger(__name__ + ".ListJobBinaries")
+
+
+class ShowJobBinary(jb_v1.ShowJobBinary):
+ """Display job binary details"""
+
+ log = logging.getLogger(__name__ + ".ShowJobBinary")
+
+
+class DeleteJobBinary(jb_v1.DeleteJobBinary):
+ """Deletes job binary"""
+
+ log = logging.getLogger(__name__ + ".DeleteJobBinary")
+
+
+class UpdateJobBinary(jb_v1.UpdateJobBinary):
+ """Updates job binary"""
+
+ log = logging.getLogger(__name__ + ".UpdateJobBinary")
+
+
+class DownloadJobBinary(jb_v1.DownloadJobBinary):
+ """Downloads job binary"""
+
+ log = logging.getLogger(__name__ + ".DownloadJobBinary")
diff --git a/saharaclient/osc/v2/job_templates.py b/saharaclient/osc/v2/job_templates.py
new file mode 100644
index 0000000..ad85899
--- /dev/null
+++ b/saharaclient/osc/v2/job_templates.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2015 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 oslo_log import log as logging
+
+from saharaclient.osc.v1 import job_templates as jt_v1
+
+
+class CreateJobTemplate(jt_v1.CreateJobTemplate):
+ """Creates job template"""
+
+ log = logging.getLogger(__name__ + ".CreateJobTemplate")
+
+
+class ListJobTemplates(jt_v1.ListJobTemplates):
+ """Lists job templates"""
+
+ log = logging.getLogger(__name__ + ".ListJobTemplates")
+
+
+class ShowJobTemplate(jt_v1.ShowJobTemplate):
+ """Display job template details"""
+
+ log = logging.getLogger(__name__ + ".ShowJobTemplate")
+
+
+class DeleteJobTemplate(jt_v1.DeleteJobTemplate):
+ """Deletes job template"""
+
+ log = logging.getLogger(__name__ + ".DeleteJobTemplate")
+
+
+class UpdateJobTemplate(jt_v1.UpdateJobTemplate):
+ """Updates job template"""
+
+ log = logging.getLogger(__name__ + ".UpdateJobTemplate")
diff --git a/saharaclient/osc/v2/job_types.py b/saharaclient/osc/v2/job_types.py
new file mode 100644
index 0000000..1a22f8a
--- /dev/null
+++ b/saharaclient/osc/v2/job_types.py
@@ -0,0 +1,54 @@
+# Copyright (c) 2015 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 os import path
+import sys
+
+from oslo_log import log as logging
+from oslo_serialization import jsonutils
+
+from saharaclient.osc.v1 import job_types as jt_v1
+
+
+class ListJobTypes(jt_v1.ListJobTypes):
+ """Lists job types supported by plugins"""
+
+ log = logging.getLogger(__name__ + ".ListJobTypes")
+
+
+class GetJobTypeConfigs(jt_v1.GetJobTypeConfigs):
+ """Get job type configs"""
+
+ log = logging.getLogger(__name__ + ".GetJobTypeConfigs")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ if not parsed_args.file:
+ parsed_args.file = parsed_args.job_type
+
+ data = client.job_templates.get_configs(parsed_args.job_type).to_dict()
+
+ if path.exists(parsed_args.file):
+ self.log.error('File "%s" already exists. Choose another one with '
+ '--file argument.' % parsed_args.file)
+ else:
+ with open(parsed_args.file, 'w') as f:
+ jsonutils.dump(data, f, indent=4)
+ sys.stdout.write(
+ '"%(type)s" job configs were saved in "%(file)s"'
+ 'file' % {'type': parsed_args.job_type,
+ 'file': parsed_args.file})
diff --git a/saharaclient/osc/v2/jobs.py b/saharaclient/osc/v2/jobs.py
new file mode 100644
index 0000000..1ffe66f
--- /dev/null
+++ b/saharaclient/osc/v2/jobs.py
@@ -0,0 +1,142 @@
+# Copyright (c) 2015 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 sys
+
+from osc_lib import utils as osc_utils
+from oslo_log import log as logging
+
+from saharaclient.osc import utils
+from saharaclient.osc.v1 import jobs as jobs_v1
+
+
+def _format_job_output(app, data):
+ data['status'] = data['info']['status']
+ del data['info']
+
+
+class ExecuteJob(jobs_v1.ExecuteJob):
+ """Executes job"""
+
+ log = logging.getLogger(__name__ + ".ExecuteJob")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_job_output(self.app, data)
+ data = utils.prepare_data(data, jobs_v1.JOB_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class ListJobs(jobs_v1.ListJobs):
+ """Lists jobs"""
+
+ log = logging.getLogger(__name__ + ".ListJobs")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = client.jobs.list()
+
+ for job in data:
+ job.status = job.info['status']
+
+ if parsed_args.status:
+ data = [job for job in data
+ if job.info['status'] == parsed_args.status.replace(
+ '-', '').upper()]
+
+ if parsed_args.long:
+ columns = ('id', 'cluster id', 'job template id', 'status',
+ 'start time', 'end time')
+ column_headers = utils.prepare_column_headers(columns)
+
+ else:
+ columns = ('id', 'cluster id', 'job template id', 'status')
+ column_headers = utils.prepare_column_headers(columns)
+
+ return (
+ column_headers,
+ (osc_utils.get_item_properties(
+ s,
+ columns
+ ) for s in data)
+ )
+
+
+class ShowJob(jobs_v1.ShowJob):
+ """Display job details"""
+
+ log = logging.getLogger(__name__ + ".ShowJob")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = client.jobs.get(parsed_args.job).to_dict()
+
+ _format_job_output(self.app, data)
+ data = utils.prepare_data(data, jobs_v1.JOB_FIELDS)
+
+ return self.dict2columns(data)
+
+
+class DeleteJob(jobs_v1.DeleteJob):
+ """Deletes job"""
+
+ log = logging.getLogger(__name__ + ".DeleteJob")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+ for job_id in parsed_args.job:
+ client.jobs.delete(job_id)
+ sys.stdout.write(
+ 'Job "{job}" deletion has been started.\n'.format(job=job_id))
+
+ if parsed_args.wait:
+ for job_id in parsed_args.job:
+ wait_for_delete = utils.wait_for_delete(client.jobs, job_id)
+
+ if not wait_for_delete:
+ self.log.error(
+ 'Error occurred during job deleting: %s' %
+ job_id)
+ else:
+ sys.stdout.write(
+ 'Job "{job}" has been removed successfully.\n'.format(
+ job=job_id))
+
+
+class UpdateJob(jobs_v1.UpdateJob):
+ """Updates job"""
+
+ log = logging.getLogger(__name__ + ".UpdateJob")
+
+ def take_action(self, parsed_args):
+ self.log.debug("take_action(%s)", parsed_args)
+ client = self.app.client_manager.data_processing
+
+ data = self._take_action(client, parsed_args)
+
+ _format_job_output(self.app, data)
+ data = utils.prepare_data(data, jobs_v1.JOB_FIELDS)
+
+ return self.dict2columns(data)
diff --git a/saharaclient/osc/v2/plugins.py b/saharaclient/osc/v2/plugins.py
new file mode 100644
index 0000000..cf05512
--- /dev/null
+++ b/saharaclient/osc/v2/plugins.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2015 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 oslo_log import log as logging
+
+from saharaclient.osc.v1 import plugins as p_v1
+
+
+class ListPlugins(p_v1.ListPlugins):
+ """Lists plugins"""
+
+ log = logging.getLogger(__name__ + ".ListPlugins")
+
+
+class ShowPlugin(p_v1.ShowPlugin):
+ """Display plugin details"""
+
+ log = logging.getLogger(__name__ + ".ShowPlugin")
+
+
+class GetPluginConfigs(p_v1.GetPluginConfigs):
+ """Get plugin configs"""
+
+ log = logging.getLogger(__name__ + ".GetPluginConfigs")
+
+
+class UpdatePlugin(p_v1.UpdatePlugin):
+ log = logging.getLogger(__name__ + ".UpdatePlugin")