summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--requirements.txt2
-rw-r--r--saharaclient/osc/v1/job_binaries.py100
-rw-r--r--saharaclient/tests/unit/osc/v1/test_job_binaries.py18
-rw-r--r--test-requirements.txt4
4 files changed, 112 insertions, 12 deletions
diff --git a/requirements.txt b/requirements.txt
index 492805e..630aae1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,7 +7,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
Babel!=2.4.0,>=2.3.4 # BSD
keystoneauth1>=3.3.0 # Apache-2.0
osc-lib>=1.8.0 # Apache-2.0
-oslo.log>=3.30.0 # Apache-2.0
+oslo.log>=3.36.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
diff --git a/saharaclient/osc/v1/job_binaries.py b/saharaclient/osc/v1/job_binaries.py
index 962b9c9..530d9c9 100644
--- a/saharaclient/osc/v1/job_binaries.py
+++ b/saharaclient/osc/v1/job_binaries.py
@@ -60,11 +60,17 @@ class CreateJobBinary(command.ShowOne):
metavar="<description>",
help="Description of the job binary"
)
- parser.add_argument(
+ 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',
@@ -72,11 +78,28 @@ class CreateJobBinary(command.ShowOne):
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',
@@ -122,20 +145,47 @@ class CreateJobBinary(command.ShowOne):
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 should be provided with password')
+ '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 entered '
- 'interactively with --password-prompt')
+ '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:
- extra = {
- 'user': parsed_args.username,
- 'password': parsed_args.password
- }
+ 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
@@ -290,11 +340,17 @@ class UpdateJobBinary(command.ShowOne):
metavar="<description>",
help='Description of the job binary'
)
- parser.add_argument(
+ 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',
@@ -302,11 +358,28 @@ class UpdateJobBinary(command.ShowOne):
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',
+ )
public = parser.add_mutually_exclusive_group()
public.add_argument(
'--public',
@@ -365,12 +438,21 @@ class UpdateJobBinary(command.ShowOne):
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)
extra = {}
if parsed_args.password:
extra['password'] = parsed_args.password
if parsed_args.username:
extra['user'] = parsed_args.username
+ if parsed_args.access_key:
+ extra['accesskey'] = parsed_args.access_key
+ if parsed_args.secret_key:
+ extra['secretkey'] = parsed_args.secret_key
+ if parsed_args.s3_endpoint:
+ extra['endpoint'] = parsed_args.s3_endpoint
if not extra:
extra = None
diff --git a/saharaclient/tests/unit/osc/v1/test_job_binaries.py b/saharaclient/tests/unit/osc/v1/test_job_binaries.py
index d01a03e..b4d18e0 100644
--- a/saharaclient/tests/unit/osc/v1/test_job_binaries.py
+++ b/saharaclient/tests/unit/osc/v1/test_job_binaries.py
@@ -14,6 +14,8 @@
# limitations under the License.
import mock
+from osc_lib.tests import utils as osc_u
+import testtools
from saharaclient.api import job_binaries as api_jb
from saharaclient.osc.v1 import job_binaries as osc_jb
@@ -96,6 +98,14 @@ class TestCreateJobBinary(TestJobBinaries):
self.jbi_mock.create.assert_called_once_with('job-binary', '')
+ def test_job_binary_create_mutual_exclusion(self):
+ arglist = ['job-binary', '--name', 'job-binary', '--access-key', 'ak',
+ '--secret-key', 'sk', '--url', 's3://abc/def',
+ '--password', 'pw']
+
+ with testtools.ExpectedException(osc_u.ParserException):
+ self.check_parser(self.cmd, arglist, mock.Mock())
+
class TestListJobBinaries(TestJobBinaries):
def setUp(self):
@@ -278,6 +288,14 @@ class TestUpdateJobBinary(TestJobBinaries):
self.jb_mock.update.assert_called_once_with(
'jb_id', {})
+ def test_job_binary_update_mutual_exclusion(self):
+ arglist = ['job-binary', '--name', 'job-binary', '--access-key', 'ak',
+ '--secret-key', 'sk', '--url', 's3://abc/def',
+ '--password', 'pw']
+
+ with testtools.ExpectedException(osc_u.ParserException):
+ self.check_parser(self.cmd, arglist, mock.Mock())
+
class TestDownloadJobBinary(TestJobBinaries):
def setUp(self):
diff --git a/test-requirements.txt b/test-requirements.txt
index 35b3e68..9e17266 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -7,9 +7,9 @@ hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
mock>=2.0.0 # BSD
openstackdocstheme>=1.17.0 # Apache-2.0
-oslotest>=1.10.0 # Apache-2.0
+oslotest>=3.2.0 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0
requests-mock>=1.1.0 # Apache-2.0
-sphinx>=1.6.2 # BSD
+sphinx!=1.6.6,>=1.6.2 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD