Compare commits

..

10 Commits

Author SHA1 Message Date
Jenkins
faf5c656af Merge "Add metadata parameter to checkpoint API" 2016-11-23 02:48:00 +00:00
chenying
fc425e741d Add a filter argument operation_definition for scheduledoperations API
Change-Id: I16c79491c51c341d692066c78611b218d0731435
2016-11-14 19:22:51 +08:00
Jenkins
74a382ecb6 Merge "Updated from global requirements" 2016-11-09 12:05:16 +00:00
Jenkins
59ef5ebda0 Merge "Make method import_versioned_module work" 2016-11-09 08:49:15 +00:00
OpenStack Proposal Bot
e273aa5b55 Updated from global requirements
Change-Id: Ie04ae794555e6266141ff4cdcca0121028685e0e
2016-11-09 04:23:47 +00:00
pawnesh.kumar
fae4ef7a03 Make method import_versioned_module work
Update function import_versioned_module in Oslo.utils 3.17.
This patch update to meet new version. For more information:
http://docs.openstack.org/developer/oslo.utils/history.html

Change-Id: I8b856c4a6a017fdc668326cb18c0b14d6d09ddc2
Closes-Bug: #1627313
2016-11-02 16:51:11 +05:30
Tony Xu
f3ca2e6944 Add Python 3.5 classifier and venv
Now that there is a passing gate job, we can claim
support for Python 3.5 in the classifier.
This patch also adds the convenience py35 venv.

Change-Id: I17e31b7c5218be7ad0b9d3cde9536522d77af24f
2016-10-26 00:09:04 +08:00
Jenkins
ac61ea3499 Merge "Add parameters field for protectable instances API" 2016-10-20 02:31:00 +00:00
chenying
49aae96f22 Add parameters field for protectable instances API
Scenario #1
User need a parameter for the region name to query resource
instances from different region endpoint.

Scenario #2
User uses the Protectable Instances API to query database
instances from the verdor's backup software. User must provide
some parameters about authentication to the restfull API of the
verdor's backup software.

A dict type parameter is needed for Protectable Instances API.
And it is optional.

blueprint instances-parameters

Change-Id: I9b5d2dc581edda23543f4b264c334bc429bcd3c3
2016-09-27 15:50:18 +08:00
chenying
7e81c138ec Add metadata parameter to checkpoint API
Change-Id: I86f6e6e8338e8256fec62a61275aeff8669b830c
2016-09-01 14:55:38 +08:00
12 changed files with 110 additions and 34 deletions

View File

@@ -2,4 +2,3 @@
host=review.openstack.org
port=29418
project=openstack/python-karborclient.git
defaultbranch=stable/newton

View File

@@ -9,10 +9,12 @@
# 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 karborclient.common import utils
from oslo_utils import importutils
def Client(version, *args, **kwargs):
module = utils.import_versioned_module(version, 'client')
module = importutils.import_versioned_module(
'karborclient', version, 'client'
)
client_class = getattr(module, 'Client')
return client_class(*args, **kwargs)

View File

@@ -19,7 +19,6 @@ import six
import uuid
from oslo_utils import encodeutils
from oslo_utils import importutils
import prettytable
@@ -49,13 +48,6 @@ def env(*vars, **kwargs):
return kwargs.get('default', '')
def import_versioned_module(version, submodule=None):
module = 'karborclient.v%s' % version
if submodule:
module = '.'.join((module, submodule))
return importutils.import_module(module)
def _print(pt, order):
if sys.version_info >= (3, 0):
print(pt.get_string(sortby=order))

View File

@@ -28,6 +28,8 @@ from keystoneclient import session as ksession
from oslo_log import handlers
from oslo_log import log as logging
from oslo_utils import encodeutils
from oslo_utils import importutils
import six
import six.moves.urllib.parse as urlparse
@@ -150,7 +152,9 @@ class KarborShell(object):
self.subcommands = {}
subparsers = parser.add_subparsers(metavar='<subcommand>')
submodule = utils.import_versioned_module(version, 'shell')
submodule = importutils.import_versioned_module(
'karborclient', version, 'shell'
)
self._find_actions(subparsers, submodule)
self._find_actions(subparsers, self)

View File

@@ -88,5 +88,5 @@ class CheckpointsTest(base.TestCaseShell):
'checkpoints'.format(
provider_id=FAKE_PROVIDER_ID),
data={
'checkpoint': {'plan_id': FAKE_PLAN_ID}},
'checkpoint': {'plan_id': FAKE_PLAN_ID, 'extra-info': None}},
headers={})

View File

@@ -26,8 +26,9 @@ class Checkpoint(base.Resource):
class CheckpointManager(base.ManagerWithFind):
resource_class = Checkpoint
def create(self, provider_id, plan_id):
body = {'checkpoint': {'plan_id': plan_id}}
def create(self, provider_id, plan_id, checkpoint_extra_info=None):
body = {'checkpoint': {'plan_id': plan_id,
'extra-info': checkpoint_extra_info}}
url = "/providers/{provider_id}/" \
"checkpoints" .format(provider_id=provider_id)
return self._create(url, body, 'checkpoint')

View File

@@ -77,14 +77,27 @@ class ProtectableManager(base.ManagerWithFind):
sort_dir=sort_dir, sort=sort)
return self._list(url, response_key='instances', obj_class=Instances)
def get_instance(self, type, id, session_id=None):
def get_instance(self, type, id, search_opts=None, session_id=None):
if session_id:
headers = {'X-Configuration-Session': session_id}
else:
headers = {}
url = "/protectables/{protectable_type}/" \
"instances/{protectable_id}".format(protectable_type=type,
protectable_id=id)
if search_opts is None:
search_opts = {}
query_params = {}
for key, val in search_opts.items():
if val:
query_params[key] = val
query_string = ""
if query_params:
params = sorted(query_params.items(), key=lambda x: x[0])
query_string = "?%s" % parse.urlencode(params)
url = ("/protectables/{protectable_type}/instances/"
"{protectable_id}{query_string}").format(
protectable_type=type, protectable_id=id,
query_string=query_string)
return self._get(url, response_key="instance", headers=headers)
def _build_instances_list_url(self, protectable_type,

View File

@@ -417,16 +417,28 @@ def do_protectable_show(cs, args):
utils.print_dict(protectable.to_dict())
@utils.arg('protectable_id',
metavar='<protectable_id>',
help='Protectable instance id.')
@utils.arg('protectable_type',
metavar='<protectable_type>',
help='Protectable type.')
@utils.arg('protectable_id',
metavar='<protectable_id>',
help='Protectable instance id.')
@utils.arg('--parameters',
type=str,
nargs='*',
metavar='<key=value>',
default=None,
help='Show a instance by parameters key and value pair. '
'Default=None.')
def do_protectable_show_instance(cs, args):
"""Shows instance details."""
search_opts = {
'parameters': (_extract_instances_parameters(args)
if args.parameters else None),
}
instance = cs.protectables.get_instance(args.protectable_type,
args.protectable_id)
args.protectable_id,
search_opts=search_opts)
utils.print_dict(instance.to_dict())
@@ -462,11 +474,20 @@ def do_protectable_show_instance(cs, args):
'form of <key>[:<asc|desc>]. '
'Valid keys: %s. '
'Default=None.') % ', '.join(base.SORT_KEY_VALUES)))
@utils.arg('--parameters',
type=str,
nargs='*',
metavar='<key=value>',
default=None,
help='List instances by parameters key and value pair. '
'Default=None.')
def do_protectable_list_instances(cs, args):
"""Lists all protectable instances."""
search_opts = {
'type': args.type,
'parameters': (_extract_instances_parameters(args)
if args.parameters else None),
}
if args.sort and (args.sort_key or args.sort_dir):
@@ -490,6 +511,19 @@ def do_protectable_list_instances(cs, args):
sortby_index=sortby_index)
def _extract_instances_parameters(args):
parameters = {}
for parameter in args.parameters:
if '=' in parameter:
(key, value) = parameter.split('=', 1)
else:
key = parameter
value = None
parameters[key] = value
return parameters
@utils.arg('provider_id',
metavar='<provider_id>',
help='Id of provider.')
@@ -565,12 +599,37 @@ def do_provider_list(cs, args):
@utils.arg('plan_id',
metavar='<plan_id>',
help='ID of plan.')
@utils.arg('--extra_info',
type=str,
nargs='*',
metavar='<key=value>',
default=None,
help='The extra info of a checkpoint.')
def do_checkpoint_create(cs, args):
"""Create a checkpoint."""
checkpoint = cs.checkpoints.create(args.provider_id, args.plan_id)
checkpoint_extra_info = None
if args.extra_info is not None:
checkpoint_extra_info = _extract_extra_info(args)
checkpoint = cs.checkpoints.create(args.provider_id, args.plan_id,
checkpoint_extra_info)
utils.print_dict(checkpoint.to_dict())
def _extract_extra_info(args):
checkpoint_extra_info = {}
for data in args.extra_info:
# unset doesn't require a val, so we have the if/else
if '=' in data:
(key, value) = data.split('=', 1)
else:
key = data
value = None
checkpoint_extra_info[key] = value
return checkpoint_extra_info
@utils.arg('provider_id',
metavar='<provider_id>',
help='ID of provider.')
@@ -625,7 +684,7 @@ def do_checkpoint_list(cs, args):
marker=args.marker, limit=args.limit, sort_key=args.sort_key,
sort_dir=args.sort_dir, sort=args.sort)
key_list = ['Id', 'Project id', 'Status', 'Protection plan']
key_list = ['Id', 'Project id', 'Status', 'Protection plan', 'Metadata']
if args.sort_key or args.sort_dir or args.sort:
sortby_index = None
@@ -858,6 +917,10 @@ def do_trigger_delete(cs, args):
metavar='<trigger_id>',
default=None,
help='Filters results by a trigger id. Default=None.')
@utils.arg('--operation_definition',
metavar='<operation_definition>',
default=None,
help='Filters results by the operation_definition. Default=None.')
@utils.arg('--marker',
metavar='<marker>',
default=None,
@@ -900,6 +963,7 @@ def do_scheduledoperation_list(cs, args):
'name': args.name,
'operation_type': args.operation_type,
'trigger_id': args.trigger_id,
'operation_definition': args.operation_definition,
}
if args.sort and (args.sort_key or args.sort_dir):

View File

@@ -1,13 +1,13 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=1.6 # Apache-2.0
PrettyTable<0.8,>=0.7 # BSD
python-keystoneclient!=2.1.0,>=2.0.0 # Apache-2.0
pbr>=1.8 # Apache-2.0
PrettyTable<0.8,>=0.7.1 # BSD
python-keystoneclient>=3.6.0 # Apache-2.0
requests>=2.10.0 # Apache-2.0
simplejson>=2.2.0 # MIT
Babel>=2.3.4 # BSD
six>=1.9.0 # MIT
oslo.utils>=3.16.0 # Apache-2.0
oslo.log>=1.14.0 # Apache-2.0
oslo.utils>=3.18.0 # Apache-2.0
oslo.log>=3.11.0 # Apache-2.0
oslo.i18n>=2.1.0 # Apache-2.0

View File

@@ -18,6 +18,7 @@ classifier =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
[global]
setup-hooks =

View File

@@ -4,10 +4,10 @@
hacking<0.11,>=0.10.2 # Apache-2.0
coverage>=3.6 # Apache-2.0
coverage>=4.0 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
sphinx!=1.3b1,<1.3,>=1.2.1 # BSD
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
sphinx!=1.3b1,<1.4,>=1.2.1 # BSD
oslosphinx>=4.7.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD

View File

@@ -1,6 +1,6 @@
[tox]
minversion = 1.6
envlist = py34,py27,pypy,pep8
envlist = py35,py34,py27,pypy,pep8
skipsdist = True
[testenv]