Compare commits

..

3 Commits

Author SHA1 Message Date
OpenDev Sysadmins
f53be19a16 OpenDev Migration Patch
This commit was bulk generated and pushed by the OpenDev sysadmins
as a part of the Git hosting and code review systems migration
detailed in these mailing list posts:

http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003603.html
http://lists.openstack.org/pipermail/openstack-discuss/2019-April/004920.html

Attempts have been made to correct repository namespaces and
hostnames based on simple pattern matching, but it's possible some
were updated incorrectly or missed entirely. Please reach out to us
via the contact information listed at https://opendev.org/ with any
questions you may have.
2019-04-19 19:41:50 +00:00
454d3af1b2 Update UPPER_CONSTRAINTS_FILE for stable/stein
Update the URL to the upper-constraints file to point to the redirect
rule on releases.openstack.org so that anyone working on this branch
will switch to the correct upper-constraints list automatically when
the requirements repository branches.

Until the requirements repository has as stable/stein branch, tests will
continue to use the upper-constraints list on master.

Change-Id: Ie28405202ca4dfc80060ddc0af6b0623a78e1c08
2019-03-18 14:51:58 +00:00
d89bcc232f Update .gitreview for stable/stein
Change-Id: I99d48367446651c53bd0afe7904513b29ea1ba83
2019-03-18 14:51:56 +00:00
20 changed files with 87 additions and 229 deletions

View File

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

View File

@@ -6,6 +6,5 @@
- openstack-python-jobs
- openstack-python35-jobs
- openstack-python36-jobs
- openstack-python37-jobs
- openstackclient-plugin-jobs
- publish-openstack-docs-pti

View File

@@ -25,10 +25,14 @@ OpenStack Client interface. Handles the REST calls and responses.
# E0202: An attribute inherited from %s hide this method
# pylint: disable=E0202
try:
import simplejson as json
except ImportError:
import json
import time
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import importutils
import requests
@@ -128,7 +132,7 @@ class HTTPClient(object):
def serialize(self, kwargs):
if kwargs.get('json') is not None:
kwargs['headers']['Content-Type'] = 'application/json'
kwargs['data'] = jsonutils.dumps(kwargs['json'])
kwargs['data'] = json.dumps(kwargs['json'])
try:
del kwargs['json']
except KeyError:

View File

@@ -24,7 +24,7 @@ places where actual behavior differs from the spec.
# W0102: Dangerous default value %s as argument
# pylint: disable=W0102
from oslo_serialization import jsonutils
import json
import requests
import six
@@ -58,7 +58,7 @@ class TestResponse(requests.Response):
# Fake the text attribute to streamline Response creation
text = data.get('text', "")
if isinstance(text, (dict, list)):
self._content = jsonutils.dumps(text)
self._content = json.dumps(text)
default_headers = {
"Content-Type": "application/json",
}

View File

@@ -12,13 +12,13 @@
from __future__ import print_function
import json
import os
import sys
import six
import uuid
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
import prettytable
@@ -138,7 +138,7 @@ def dict_prettyprint(val):
:param val: dict.
:return: formatted json string.
"""
return jsonutils.dumps(val, indent=2, sort_keys=True)
return json.dumps(val, indent=2, sort_keys=True)
def json_prettyprint(val):
@@ -147,8 +147,7 @@ def json_prettyprint(val):
:param val: json string.
:return: formatted json string.
"""
return val and jsonutils.dumps(jsonutils.loads(val),
indent=2, sort_keys=True)
return val and json.dumps(json.loads(val), indent=2, sort_keys=True)
def find_resource(manager, name_or_id, *args, **kwargs):

View File

@@ -12,10 +12,10 @@
"""Data protection V1 checkpoint action implementations"""
import json
from osc_lib.command import command
from osc_lib import utils as osc_utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from karborclient.common.apiclient import exceptions
from karborclient.i18n import _
@@ -28,7 +28,7 @@ def format_checkpoint(checkpoint_info):
checkpoint_info['protection_plan'] = "Name: %s\nId: %s" % (
plan['name'], plan['id'])
if 'resource_graph' in checkpoint_info:
checkpoint_info['resource_graph'] = jsonutils.dumps(jsonutils.loads(
checkpoint_info['resource_graph'] = json.dumps(json.loads(
checkpoint_info['resource_graph']), indent=2, sort_keys=True)
checkpoint_info.pop("links", None)

View File

@@ -12,7 +12,7 @@
"""Data protection V1 plan action implementations"""
from oslo_serialization import jsonutils
import json
from oslo_utils import uuidutils
from osc_lib.command import command
@@ -28,8 +28,7 @@ def format_plan(plan_info):
for key in ('resources', 'parameters'):
if key not in plan_info:
continue
plan_info[key] = jsonutils.dumps(plan_info[key],
indent=2, sort_keys=True)
plan_info[key] = json.dumps(plan_info[key], indent=2, sort_keys=True)
plan_info.pop("links", None)

View File

@@ -13,10 +13,10 @@
"""Data protection V1 protectables action implementations"""
import functools
import json
from osc_lib.command import command
from osc_lib import utils as osc_utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from karborclient.i18n import _
from karborclient import utils
@@ -136,8 +136,7 @@ class ListProtectableInstances(command.Lister):
column_headers = ['Id', 'Type', 'Name', 'Dependent resources',
'Extra info']
json_dumps = functools.partial(jsonutils.dumps,
indent=2, sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
formatters = {
"Extra info": json_dumps,
"Dependent resources": json_dumps,
@@ -187,8 +186,7 @@ class ShowProtectableInstance(command.ShowOne):
parsed_args.protectable_id,
search_opts=search_opts)
json_dumps = functools.partial(jsonutils.dumps,
indent=2, sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
instance._info.pop("links", None)
for key in ('extra_info', 'dependent_resources'):
if key not in instance._info:

View File

@@ -13,10 +13,10 @@
"""Data protection V1 provider action implementations"""
import functools
import json
from osc_lib.command import command
from osc_lib import utils as osc_utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from karborclient.i18n import _
@@ -96,8 +96,7 @@ class ShowProvider(command.ShowOne):
client = self.app.client_manager.data_protection
provider = osc_utils.find_resource(client.providers,
parsed_args.provider)
json_dumps = functools.partial(jsonutils.dumps,
indent=2, sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
provider._info.pop("links", None)
if 'extended_info_schema' in provider._info:
provider._info['extended_info_schema'] = json_dumps(

View File

@@ -13,8 +13,8 @@
"""Data protection V1 restore action implementations"""
import functools
import json
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from osc_lib.command import command
@@ -31,8 +31,8 @@ def format_restore(restore_info):
'resources_reason'):
if key not in restore_info:
continue
restore_info[key] = jsonutils.dumps(restore_info[key],
indent=2, sort_keys=True)
restore_info[key] = json.dumps(restore_info[key],
indent=2, sort_keys=True)
restore_info.pop("links", None)
@@ -98,9 +98,7 @@ class ListRestores(command.Lister):
column_headers = ['Id', 'Project id', 'Provider id', 'Checkpoint id',
'Restore target', 'Parameters', 'Status']
json_dumps = functools.partial(jsonutils.dumps,
indent=2,
sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
formatters = {
"Parameters": json_dumps,
}

View File

@@ -13,9 +13,9 @@
"""Data protection V1 scheduled_operations action implementations"""
import functools
import json
import six
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from osc_lib.command import command
@@ -30,8 +30,8 @@ def format_scheduledoperation(scheduledoperation_info):
for key in ('operation_definition', ):
if key not in scheduledoperation_info:
continue
scheduledoperation_info[key] = jsonutils.dumps(
scheduledoperation_info[key], indent=2, sort_keys=True)
scheduledoperation_info[key] = json.dumps(scheduledoperation_info[key],
indent=2, sort_keys=True)
scheduledoperation_info.pop("links", None)
@@ -118,9 +118,7 @@ class ListScheduledOperations(command.Lister):
column_headers = ['Id', 'Name', 'Operation Type', 'Trigger Id',
'Operation Definition']
json_dumps = functools.partial(jsonutils.dumps,
indent=2,
sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
formatters = {
"Operation Definition": json_dumps,
}

View File

@@ -13,13 +13,13 @@
"""Data protection V1 verification action implementations"""
import functools
import json
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from osc_lib.command import command
from osc_lib import utils as osc_utils
from oslo_log import log as logging
from karborclient.common.apiclient import exceptions
from karborclient.i18n import _
@@ -31,8 +31,8 @@ def format_verification(verification_info):
'resources_reason'):
if key not in verification_info:
continue
verification_info[key] = jsonutils.dumps(verification_info[key],
indent=2, sort_keys=True)
verification_info[key] = json.dumps(verification_info[key],
indent=2, sort_keys=True)
verification_info.pop("links", None)
@@ -98,9 +98,7 @@ class ListVerifications(command.Lister):
column_headers = ['Id', 'Project id', 'Provider id', 'Checkpoint id',
'Parameters', 'Status']
json_dumps = functools.partial(jsonutils.dumps,
indent=2,
sort_keys=True)
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
formatters = {
"Parameters": json_dumps,
}

View File

@@ -400,9 +400,9 @@ class KarborShell(object):
if args.api_timeout:
kwargs['timeout'] = args.api_timeout
self.cs = karbor_client.Client(api_version, endpoint, **kwargs)
client = karbor_client.Client(api_version, endpoint, **kwargs)
args.func(self.cs, args)
args.func(client, args)
def do_bash_completion(self, args):
"""Prints all of the commands and options to stdout."""

View File

@@ -12,8 +12,7 @@
# limitations under the License.
import copy
from oslo_serialization import jsonutils
import json
from karborclient.osc.v1 import checkpoints as osc_checkpoints
from karborclient.tests.unit.osc.v1 import fakes
@@ -33,7 +32,7 @@ CHECKPOINT_INFO = {
"type": "OS::Glance::Image",
"name": "cirros-0.3.4-x86_64-uec"}]
},
"resource_graph": jsonutils.dumps(
"resource_graph": json.dumps(
"[{'0x0': ['OS::Glance::Image', "
"'99777fdd-8a5b-45ab-ba2c-52420008103f', "
"'cirros-0.3.4-x86_64-uec']}, [[['0x0']]]]"
@@ -53,7 +52,7 @@ CHECKPOINT_INFO_2 = {
"type": "OS::Glance::Image",
"name": "cirros-0.3.4-x86_64-uec"}]
},
"resource_graph": jsonutils.dumps(
"resource_graph": json.dumps(
"[{'0x0': ['OS::Glance::Image', "
"'99777fdd-8a5b-45ab-ba2c-52420008103f', "
"'cirros-0.3.4-x86_64-uec']}, [[['0x0']]]]"

View File

@@ -12,8 +12,7 @@
# limitations under the License.
import copy
from oslo_serialization import jsonutils
import json
from karborclient.osc.v1 import restores as osc_restores
from karborclient.tests.unit.osc.v1 import fakes
@@ -70,7 +69,7 @@ class TestListRestores(TestRestores):
"cf56bd3e-97a7-4078-b6d5-f36246333fd9",
"dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
"",
jsonutils.dumps({}),
json.dumps({}),
"success")]
self.assertEqual(expected_data, list(data))

View File

@@ -12,8 +12,7 @@
# limitations under the License.
import copy
from oslo_serialization import jsonutils
import json
from karborclient.osc.v1 import verifications as osc_verifications
from karborclient.tests.unit.osc.v1 import fakes
@@ -68,7 +67,7 @@ class TestListVerifications(TestVerifications):
"e486a2f49695423ca9c47e589b948108",
"cf56bd3e-97a7-4078-b6d5-f36246333fd9",
"dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
jsonutils.dumps({}),
json.dumps({}),
"success")]
self.assertEqual(expected_data, list(data))

View File

@@ -37,13 +37,12 @@ class FakeClient(fakes.FakeClient, client.Client):
'project_id': PROJECT_ID,
}
client.Client.__init__(self, 'http://endpoint', **kwargs)
self.client = self.http_client
self.client = FakeHTTPClient(**kwargs)
class FakeHTTPClient(base_client.HTTPClient):
def __init__(self, endpoint, **kwargs):
super(FakeHTTPClient, self)
def __init__(self, **kwargs):
self.username = 'username'
self.password = 'password'
self.auth_url = 'auth_url'
@@ -51,9 +50,6 @@ class FakeHTTPClient(base_client.HTTPClient):
self.management_url = 'http://10.0.2.15:8776/v1/fake'
self.osapi_max_limit = 1000
self.marker = None
self.project_id = 'project_id'
self.auth_token = 'auth_token'
self.region_name = 'region_name'
def _cs_request(self, url, method, **kwargs):
# Check that certain things are called correctly
@@ -96,27 +92,3 @@ class FakeHTTPClient(base_client.HTTPClient):
"headers": headers,
})
return r, body
def json_request(self, method, url, **kwargs):
return self._cs_request(url, method, **kwargs)
def get_providers_1234_checkpoints(self, **kwargs):
return 200, {}, {"checkpoints": []}
def get_plans(self, **kwargs):
return 200, {}, {"plans": []}
def get_operation_logs(self, **kwargs):
return 200, {}, {"operation_logs": []}
def get_restores(self, **kwargs):
return 200, {}, {"restores": []}
def get_scheduled_operations(self, **kwargs):
return 200, {}, {"operations": []}
def get_triggers(self, **kwargs):
return 200, {}, {"triggers": []}
def get_verifications(self, **kwargs):
return 200, {}, {"verifications": []}

View File

@@ -1,137 +0,0 @@
# 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 fixtures
import mock
from karborclient import shell
from karborclient.tests.unit import base
from karborclient.tests.unit.v1 import fakes
FAKE_PROVIDER_ID = '1234'
FAKE_ENDPOINT = 'http://127.0.0.1/identity'
class ShellFixture(fixtures.Fixture):
def setUp(self):
super(ShellFixture, self).setUp()
self.shell = shell.KarborShell()
def tearDown(self):
# For some method like test_image_meta_bad_action we are
# testing a SystemExit to be thrown and object self.shell has
# no time to get instantiated which is OK in this case, so
# we make sure the method is there before launching it.
if hasattr(self.shell, 'cs'):
self.shell.cs.clear_callstack()
super(ShellFixture, self).tearDown()
class ShellTest(base.TestCaseShell):
FAKE_ENV = {
'OS_USERNAME': 'username',
'OS_PASSWORD': 'password',
'OS_TENANT_NAME': 'project_id',
'OS_AUTH_URL': 'http://no.where/v2.0',
'OS_AUTH_TOKEN': 'fake_token'
}
def setUp(self):
"""Run before each test."""
super(ShellTest, self).setUp()
for var in self.FAKE_ENV:
self.useFixture(fixtures.EnvironmentVariable(
var, self.FAKE_ENV[var]))
self.shell = self.useFixture(ShellFixture()).shell
get_endpoint = mock.MagicMock()
get_endpoint.return_value = FAKE_ENDPOINT
self.useFixture(fixtures.MonkeyPatch(
'keystoneauth1.identity.generic.token.Token.get_endpoint',
get_endpoint))
self.useFixture(fixtures.MonkeyPatch('karborclient.client.Client',
fakes.FakeClient))
self.useFixture(fixtures.MonkeyPatch(
'karborclient.common.http._construct_http_client',
fakes.FakeHTTPClient))
def run_command(self, cmd):
if not isinstance(cmd, list):
cmd = cmd.split()
self.shell.main(cmd)
def assert_called(self, method, url, body=None, **kwargs):
return self.shell.cs.assert_called(method, url, body, **kwargs)
def test_checkpoint_list_with_all_tenants(self):
self.run_command(
'checkpoint-list ' + FAKE_PROVIDER_ID + ' --all-tenants 1')
self.assert_called('GET',
'/providers/1234/'
'checkpoints?all_tenants=1')
def test_checkpoint_list_with_all(self):
self.run_command(
'checkpoint-list ' + FAKE_PROVIDER_ID + ' --all')
self.assert_called('GET',
'/providers/1234/'
'checkpoints?all_tenants=1')
def test_plan_list_with_all_tenants(self):
self.run_command('plan-list --all-tenants 1')
self.assert_called('GET', '/plans?all_tenants=1')
def test_plan_list_with_all(self):
self.run_command('plan-list --all')
self.assert_called('GET', '/plans?all_tenants=1')
def test_resotre_list_with_all_tenants(self):
self.run_command('restore-list --all-tenants 1')
self.assert_called('GET', '/restores?all_tenants=1')
def test_resotre_list_with_all(self):
self.run_command('restore-list --all')
self.assert_called('GET', '/restores?all_tenants=1')
def test_verification_list_with_all_tenants(self):
self.run_command('verification-list --all-tenants 1')
self.assert_called('GET', '/verifications?all_tenants=1')
def test_verification_list_with_all(self):
self.run_command('verification-list --all')
self.assert_called('GET', '/verifications?all_tenants=1')
def test_trigger_list_with_all_tenants(self):
self.run_command('trigger-list --all-tenants 1')
self.assert_called('GET', '/triggers?all_tenants=1')
def test_trigger_list_with_all(self):
self.run_command('trigger-list --all')
self.assert_called('GET', '/triggers?all_tenants=1')
def test_scheduledoperation_list_with_all_tenants(self):
self.run_command('scheduledoperation-list --all-tenants 1')
self.assert_called('GET', '/scheduled_operations?all_tenants=1')
def test_scheduledoperation_list_with_all(self):
self.run_command('scheduledoperation-list --all')
self.assert_called('GET', '/scheduled_operations?all_tenants=1')
def test_operationlog_list_with_all_tenants(self):
self.run_command('operationlog-list --all-tenants 1')
self.assert_called('GET', '/operation_logs?all_tenants=1')
def test_operationlog_list_with_all(self):
self.run_command('operationlog-list --all')
self.assert_called('GET', '/operation_logs?all_tenants=1')

View File

@@ -11,10 +11,10 @@
# under the License.
import argparse
import json
import os
from datetime import datetime
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from karborclient.common.apiclient import exceptions
@@ -31,6 +31,11 @@ from karborclient import utils as arg_utils
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--name',
metavar='<name>',
default=None,
@@ -281,6 +286,11 @@ def do_restore_create(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--status',
metavar='<status>',
default=None,
@@ -343,7 +353,7 @@ def do_restore_list(cs, args):
sortby_index = None
else:
sortby_index = 0
formatters = {"Parameters": lambda obj: jsonutils.dumps(
formatters = {"Parameters": lambda obj: json.dumps(
obj.parameters, indent=2, sort_keys=True)}
utils.print_list(restores, key_list, exclude_unavailable=True,
sortby_index=sortby_index, formatters=formatters)
@@ -406,6 +416,11 @@ def do_verification_create(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--status',
metavar='<status>',
default=None,
@@ -471,7 +486,7 @@ def do_verification_list(cs, args):
sortby_index = None
else:
sortby_index = 0
formatters = {"Parameters": lambda obj: jsonutils.dumps(
formatters = {"Parameters": lambda obj: json.dumps(
obj.parameters, indent=2, sort_keys=True)}
utils.print_list(verifications, key_list, exclude_unavailable=True,
sortby_index=sortby_index, formatters=formatters)
@@ -599,7 +614,7 @@ def do_protectable_list_instances(cs, args):
else:
sortby_index = 0
formatters = {"Dependent resources": lambda obj: jsonutils.dumps(
formatters = {"Dependent resources": lambda obj: json.dumps(
obj.dependent_resources, indent=2, sort_keys=True)}
utils.print_list(instances, key_list, exclude_unavailable=True,
sortby_index=sortby_index, formatters=formatters)
@@ -709,6 +724,11 @@ def do_checkpoint_create(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('provider_id',
metavar='<provider_id>',
help='ID of provider.')
@@ -897,6 +917,11 @@ def do_checkpoint_reset_state(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--name',
metavar='<name>',
default=None,
@@ -969,7 +994,7 @@ def do_trigger_list(cs, args):
else:
sortby_index = 0
formatters = {"Properties": lambda obj: jsonutils.dumps(
formatters = {"Properties": lambda obj: json.dumps(
obj.properties, indent=2, sort_keys=True)}
utils.print_list(triggers, key_list, exclude_unavailable=True,
sortby_index=sortby_index, formatters=formatters)
@@ -1048,6 +1073,11 @@ def do_trigger_delete(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--name',
metavar='<name>',
default=None,
@@ -1195,6 +1225,11 @@ def do_scheduledoperation_delete(cs, args):
const=1,
default=0,
help='Shows details for all tenants. Admin only.')
@utils.arg('--all_tenants',
nargs='?',
type=int,
const=1,
help=argparse.SUPPRESS)
@utils.arg('--status',
metavar='<status>',
default=None,

View File

@@ -10,7 +10,7 @@ setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/stein}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
whitelist_externals = rm
@@ -34,9 +34,7 @@ commands =
[testenv:docs]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html
[testenv:debug]