-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from OpenTelekomCloud/dcs
Dcs
- Loading branch information
Showing
41 changed files
with
4,199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
=================================================== | ||
Distributed Cache Service (DCS) command-line client | ||
=================================================== | ||
|
||
The DCS client is the command-line interface (CLI) for | ||
the Distributed Cache Service (DMS) API and its extensions. | ||
|
||
For help on a specific `dcs` command, enter: | ||
|
||
.. code-block:: console | ||
$ openstack dcs help SUBCOMMAND | ||
.. _dcs_instance: | ||
|
||
Instance operations | ||
------------------- | ||
|
||
.. autoprogram-cliff:: openstack.dcs.v1 | ||
:command: dcs instance * | ||
|
||
.. _dcs_stat: | ||
|
||
Statistics operations | ||
--------------------- | ||
|
||
.. autoprogram-cliff:: openstack.dcs.v1 | ||
:command: dcs stat * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
load_balancer.rst | ||
volume_backup.rst | ||
dms.rst | ||
dcs.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
DCS API | ||
======= | ||
|
||
.. automodule:: otcextensions.sdk.dcs.v1._proxy | ||
|
||
The Distributed Message Service Class | ||
------------------------------------- | ||
|
||
The dcs high-level interface is available through the ``dcs`` | ||
member of a :class:`~openstack.connection.Connection` object. The | ||
``dcs`` member will only be added if the | ||
``otcextensions.sdk.register_otc_extensions(conn)`` method is called. | ||
|
||
Instance Operations | ||
^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy | ||
|
||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.instances | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.create_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.get_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.find_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.delete_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.update_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.extend_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.start_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restart_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.stop_instance | ||
|
||
Statistics Operations | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy | ||
|
||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.statistics | ||
|
||
Backup Operations | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy | ||
|
||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.backup_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.backups | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.delete_instance_backup | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restore_instance | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.restore_records | ||
|
||
Instance Configuration Operations | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: otcextensions.sdk.dcs.v1._proxy.Proxy | ||
|
||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.instance_params | ||
.. automethod:: otcextensions.sdk.dcs.v1._proxy.Proxy.update_instance_params |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 logging | ||
|
||
from otcextensions import sdk | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
DEFAULT_API_VERSION = '1.0' | ||
API_VERSION_OPTION = 'os_dcs_api_version' | ||
API_NAME = "dcs" | ||
API_VERSIONS = { | ||
"1.0": "openstack.connection.Connection", | ||
"1": "openstack.connection.Connection", | ||
} | ||
|
||
|
||
def make_client(instance): | ||
"""Returns a DCS proxy""" | ||
|
||
conn = instance.sdk_connection | ||
|
||
if getattr(conn, 'dcs', None) is None: | ||
LOG.debug('OTC extensions are not registered. Do that now') | ||
sdk.register_otc_extensions(conn) | ||
|
||
LOG.debug('DCS client initialized using OpenStack OTC SDK: %s', | ||
conn.dcs) | ||
return conn.dcs | ||
|
||
|
||
def build_option_parser(parser): | ||
"""Hook to add global options""" | ||
return parser |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# 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. | ||
# | ||
'''DCS Backup v1 action implementations''' | ||
import logging | ||
|
||
from osc_lib import utils | ||
from osc_lib.command import command | ||
|
||
from otcextensions.common import sdk_utils | ||
|
||
from otcextensions.i18n import _ | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def _get_columns(item): | ||
column_map = { | ||
} | ||
return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) | ||
|
||
|
||
class ListBackup(command.Lister): | ||
_description = _('List backups of a single DCS instance') | ||
columns = ('id', 'name', 'progress', 'status', 'error_code') | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(ListBackup, self).get_parser(prog_name) | ||
parser.add_argument( | ||
'instance', | ||
metavar='<instance>', | ||
help=_('Name or ID of the instance') | ||
) | ||
parser.add_argument( | ||
'--limit', | ||
metavar='<limit>', | ||
type=int, | ||
help=_('Limit number of records to return.') | ||
) | ||
parser.add_argument( | ||
'--start', | ||
metavar='<start>', | ||
type=int, | ||
help=_('Start number for querying.') | ||
) | ||
parser.add_argument( | ||
'--from_time', | ||
metavar='<yyyyMMddHHmmss>', | ||
help=_('Start time of the period to be queried.') | ||
) | ||
parser.add_argument( | ||
'--to_time', | ||
metavar='<yyyyMMddHHmmss>', | ||
help=_('End time of the period to be queried.') | ||
) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
client = self.app.client_manager.dcs | ||
|
||
query = {} | ||
if parsed_args.limit: | ||
query['limit'] = parsed_args.limit | ||
if parsed_args.start: | ||
query['start'] = parsed_args.start | ||
if parsed_args.from_time: | ||
query['begin_time'] = parsed_args.from_time | ||
if parsed_args.to_time: | ||
query['end_time'] = parsed_args.to_time | ||
|
||
inst = client.find_instance(name_or_id=parsed_args.instance, | ||
ignore_missing=False) | ||
data = client.backups( | ||
instance={'id': inst.id}, | ||
**query | ||
) | ||
|
||
table = (self.columns, | ||
(utils.get_item_properties( | ||
s, self.columns, | ||
) for s in data)) | ||
return table | ||
|
||
|
||
class DeleteBackup(command.Command): | ||
_description = _('Delete DCS instance backup') | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(DeleteBackup, self).get_parser(prog_name) | ||
parser.add_argument( | ||
'instance', | ||
metavar='<instance>', | ||
help=_('ID of the instance.') | ||
) | ||
parser.add_argument( | ||
'backup', | ||
metavar='<backup>', | ||
nargs='+', | ||
help=_('ID of the instance backup to delete.') | ||
) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
|
||
if parsed_args.instance: | ||
client = self.app.client_manager.dcs | ||
inst = client.find_instance(name_or_id=parsed_args.instance, | ||
ignore_missing=False) | ||
for backup in parsed_args.backup: | ||
client.delete_instance_backup( | ||
backup=backup, | ||
instance_id=inst.id | ||
) | ||
|
||
|
||
class CreateBackup(command.ShowOne): | ||
_description = _('Create a backup of a DCS instance') | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(CreateBackup, self).get_parser(prog_name) | ||
parser.add_argument( | ||
'instance', | ||
metavar='<instance>', | ||
help=_('Name or ID of the DCS instance to take backup from.') | ||
) | ||
parser.add_argument( | ||
'--description', | ||
metavar='<description>', | ||
help=_('Description of the backup.') | ||
) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
|
||
client = self.app.client_manager.dcs | ||
|
||
attrs = {} | ||
|
||
if parsed_args.description: | ||
attrs['description'] = parsed_args.description | ||
|
||
inst = client.find_instance(name_or_id=parsed_args.instance, | ||
ignore_missing=False) | ||
|
||
obj = client.backup_instance( | ||
instance={'id': inst.id}, | ||
**attrs) | ||
|
||
display_columns, columns = _get_columns(obj) | ||
data = utils.get_item_properties(obj, columns) | ||
|
||
return (display_columns, data) |
Oops, something went wrong.