kubectl get pods -n moon
echo =========================================
-sleep 5
+sleep 10
kubectl create -n moon -f kubernetes/templates/moon_configuration.yaml
echo Waiting for jobs moonforming
- Fix a bug in core.py
- Update db_manager
+1.1.0
+-----
+- When adding a subject, check the existence of that user in the Keystone DB and
+ create it if necessary
# license which can be found in the file 'LICENSE' in this package distribution
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
-__version__ = "1.0.3"
+__version__ = "1.1.0"
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
from uuid import uuid4
-from oslo_log import log as logging
-from moon_utilities.security_functions import filter_input, enforce
+import logging
+from moon_utilities.security_functions import enforce
from moon_db.api.managers import Managers
-
LOG = logging.getLogger("moon.db.api.policy")
@enforce(("read", "write"), "perimeter")
def add_subject(self, user_id, policy_id, perimeter_id=None, value=None):
+ k_user = Managers.KeystoneManager.get_user_by_name(value.get('name'))
+ if not k_user['users']:
+ k_user = Managers.KeystoneManager.create_user(value)
if not perimeter_id:
- perimeter_id = uuid4().hex
- # TODO (asteroide): must check and add Keystone ID here
+ try:
+ perimeter_id = k_user['users'][0].get('id', uuid4().hex)
+ except IndexError:
+ k_user = Managers.KeystoneManager.get_user_by_name(
+ value.get('name'))
+ perimeter_id = uuid4().hex
+ value.update(k_user['users'][0])
return self.driver.set_subject(policy_id=policy_id, perimeter_id=perimeter_id, value=value)
@enforce(("read", "write"), "perimeter")
-----
- Fix a bug on the connection between interface and authz
+1.4.0
+-----
+- Add a waiting loop when the Keystone server is not currently available
+
#!/usr/bin/env bash
-VERSION=moon_utilities-1.3.4
+VERSION=moon_utilities-1.4.0
python3 setup.py sdist bdist_wheel
if [ "$1" = "upload" ]; then
twine upload dist/${VERSION}-py3-none-any.whl dist/${VERSION}-py3-none-any.whl.asc
twine upload dist/${VERSION}.tar.gz dist/${VERSION}.tar.gz.asc
+ rm -f ../moon_orchestrator/dist/moon_utilities*
+ rm -f ../moon_interface/dist/moon_utilities*
+ rm -f ../moon_manager/dist/moon_utilities*
+ rm -f ../moon_authz/dist/moon_utilities*
+ rm -f ../moon_wrapper/dist/moon_utilities*
fi
if [ "$1" = "copy" ]; then
mkdir -p ../moon_orchestrator/dist/ 2>/dev/null
+ rm -f ../moon_orchestrator/dist/moon_utilities*
cp -v dist/${VERSION}-py3-none-any.whl ../moon_orchestrator/dist/
mkdir -p ../moon_interface/dist/ 2>/dev/null
+ rm -f ../moon_interface/dist/moon_utilities*
cp -v dist/${VERSION}-py3-none-any.whl ../moon_interface/dist/
mkdir -p ../moon_manager/dist/ 2>/dev/null
+ rm -f ../moon_manager/dist/moon_utilities*
cp -v dist/${VERSION}-py3-none-any.whl ../moon_manager/dist/
mkdir -p ../moon_authz/dist/ 2>/dev/null
+ rm -f ../moon_authz/dist/moon_utilities*
cp -v dist/${VERSION}-py3-none-any.whl ../moon_authz/dist/
mkdir -p ../moon_wrapper/dist/ 2>/dev/null
+ rm -f ../moon_wrapper/dist/moon_utilities*
cp -v dist/${VERSION}-py3-none-any.whl ../moon_wrapper/dist/
fi
# license which can be found in the file 'LICENSE' in this package distribution
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
-__version__ = "1.3.4"
+__version__ = "1.4.0"
def login(user=None, password=None, domain=None, project=None, url=None):
+ start_time = time.time()
if not user:
user = keystone_config['user']
if not password:
}
}
- req = requests.post("{}/auth/tokens".format(url),
- json=data_auth, headers=headers,
- verify=keystone_config['certificate'])
-
- if req.status_code in (200, 201, 204):
- headers['X-Auth-Token'] = req.headers['X-Subject-Token']
- return headers
- LOG.error(req.text)
- raise exceptions.KeystoneError
+ while True:
+ req = requests.post("{}/auth/tokens".format(url),
+ json=data_auth, headers=headers,
+ verify=keystone_config['certificate'])
+
+ if req.status_code in (200, 201, 204):
+ headers['X-Auth-Token'] = req.headers['X-Subject-Token']
+ return headers
+ LOG.warning("Waiting for Keystone...")
+ if time.time() - start_time == 100:
+ LOG.error(req.text)
+ raise exceptions.KeystoneError
+ time.sleep(5)
def logout(headers, url=None):