Skip to content

Commit 60ef24a

Browse files
author
Joe Stubbs
committed
Merge commit '80a4bc7f846a31549a1a477b3f714846929eefea'
2 parents c9feb5a + 80a4bc7 commit 60ef24a

23 files changed

+1041
-367
lines changed

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Makefile for local development
2+
3+
4+
# Retrieves present working directory (./abaco) and sets :dev tag
5+
export abaco_path = ${PWD}
6+
export TAG = :dev
7+
8+
# Builds Docker images to run local-dev (abaco/core, abaco/prom, abaco/nginx, etc.)
9+
build:
10+
### Local Dev Images ###
11+
@docker pull abaco/core$$TAG
12+
@docker pull abaco/nginx$$TAG
13+
14+
### Database images ###
15+
@docker pull rabbitmq:3.5.3-management
16+
@docker pull redis
17+
@docker pull mongo
18+
19+
### In-Development Images ###
20+
@docker pull abaco/prom$$TAG
21+
@docker pull abaco/dashboard
22+
23+
# Starts up local environment (docker containers) in daemon mode
24+
deploy: build
25+
@docker-compose up -d
26+
27+
# Runs test suite against current repository
28+
test: deploy
29+
@./build_and_test.sh
30+
31+
# Builds a few sample Docker images
32+
samples:
33+
@docker build -t abaco_test -f samples/abaco_test/Dockerfile samples/abaco_test
34+
@docker build -t docker_ps -f samples/docker_ps/Dockerfile samples/docker_ps
35+
@docker build -t word_count -f samples/word_count/Dockerfile samples/word_count
36+
37+
# Creates every Docker image in samples folder
38+
all-samples:
39+
@for file in samples/*; do \
40+
if [[ "$$file" != "samples/README.md" ]]; then \
41+
docker build -t $$file -f $$file/Dockerfile $$file; \
42+
fi \
43+
done
44+
45+
# Cleanly remove docker images necessary for local-dev
46+
clean:
47+
@docker-compose down
48+
49+
# Removes/ends all active Docker containers
50+
force-clean:
51+
@docker rm -f `docker ps -aq`
52+
53+
# WARNING: Deletes all non-active Docker images
54+
prune:
55+
@docker system prune -a

abaco.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

actors/aga.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _token(self, data):
4141
logger.debug("top of _token")
4242
auth = requests.auth.HTTPBasicAuth(self.api_key, self.api_secret)
4343
logger.debug("about to make POST request for token; URL: {}; "
44-
"data: {}; auth: {}".format(self.token_url, data, auth))
44+
"data: {}; auth: {}:{}".format(self.token_url, data, self.api_key, self.api_secret))
4545
resp = requests.post(self.token_url, data=data, auth=auth,
4646
verify=self.verify)
4747
logger.debug("made request for token; rsp: {}".format(resp))
@@ -178,3 +178,13 @@ def delete(self, clientName):
178178
return {}
179179
except Exception as e:
180180
raise AgaveError('Error creating client: {}'.format(e))
181+
182+
def list(self):
183+
"""List all Agave OAuth2 clients."""
184+
auth = requests.auth.HTTPBasicAuth(self.parent.username, self.parent.password)
185+
try:
186+
rsp = requests.get(url='{}/clients/v2'.format(self.parent.api_server), auth=auth)
187+
rsp.raise_for_status()
188+
return rsp
189+
except Exception as e:
190+
raise AgaveError('Error listing clients: {}'.format(e))

actors/auth.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,23 @@ def check_nonce():
9494
g.api_server = get_api_server(g.tenant)
9595
logger.debug("tenant associated with nonce: {}".format(g.tenant))
9696
# get the actor_id base on the request path
97-
actor_id = get_db_id()
98-
logger.debug("db_id: {}".format(actor_id))
97+
actor_id, actor_identifier = get_db_id()
98+
logger.debug("db_id: {}; actor_identifier: {}".format(actor_id, actor_identifier))
9999
level = required_level(request)
100-
Nonce.check_and_redeem_nonce(actor_id, nonce_id, level)
100+
101+
# if the actor_identifier is an alias, then the nonce must be attached to that, so we must pass that in the
102+
# nonce check:
103+
if is_hashid(actor_identifier):
104+
Nonce.check_and_redeem_nonce(actor_id=actor_id, alias=None, nonce_id=nonce_id, level=level)
105+
else:
106+
alias_id = Alias.generate_alias_id(tenant=g.tenant, alias=actor_identifier)
107+
Nonce.check_and_redeem_nonce(actor_id=None, alias=alias_id, nonce_id=nonce_id, level=level)
101108
# if we were able to redeem the nonce, update auth context with the actor owner data:
102109
logger.debug("nonce valid and redeemed.")
103-
nonce = Nonce.get_nonce(actor_id, nonce_id)
110+
if is_hashid(actor_identifier):
111+
nonce = Nonce.get_nonce(actor_id=actor_id, alias=None, nonce_id=nonce_id)
112+
else:
113+
nonce = Nonce.get_nonce(actor_id=None, alias=alias_id, nonce_id=nonce_id)
104114
g.user = nonce.owner
105115
# update roles data with that stored on the nonce:
106116
g.roles = nonce.roles
@@ -137,7 +147,7 @@ def authorization():
137147
else:
138148
# every other route should have an actor identifier
139149
logger.debug("fetching db_id; rule: {}".format(request.url_rule.rule))
140-
db_id = get_db_id()
150+
db_id, _ = get_db_id()
141151
g.db_id = db_id
142152
logger.debug("db_id: {}".format(db_id))
143153

@@ -307,7 +317,7 @@ def check_permissions(user, identifier, level):
307317

308318

309319
def get_db_id():
310-
"""Get the db_id from the request path."""
320+
"""Get the db_id and actor_identifier from the request path."""
311321
# logger.debug("top of get_db_id. request.path: {}".format(request.path))
312322
path_split = request.path.split("/")
313323
if len(path_split) < 3:
@@ -327,7 +337,7 @@ def get_db_id():
327337
logger.error(msg)
328338
raise ResourceError(msg)
329339
logger.debug("actor_id: {}".format(actor_id))
330-
return Actor.get_dbid(g.tenant, actor_id)
340+
return Actor.get_dbid(g.tenant, actor_id), actor_identifier
331341

332342
def get_alias_id():
333343
"""Get the alias from the request path."""

actors/channels.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,14 @@ def __init__(self, name='default'):
8585
connection_type=RabbitConnection,
8686
uri=self.uri)
8787

88-
def put_cmd(self, actor_id, worker_ids, image, tenant, num=None, stop_existing=True):
88+
def put_cmd(self, actor_id, worker_id, image, tenant, stop_existing=True):
8989
"""Put a new command on the command channel."""
9090
msg = {'actor_id': actor_id,
91-
'worker_ids': worker_ids,
91+
'worker_id': worker_id,
9292
'image': image,
9393
'tenant': tenant,
9494
'stop_existing': stop_existing}
95-
if num:
96-
msg['num'] = num
95+
9796
self.put(msg)
9897

9998

actors/codes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
from agaveflask.logs import get_logger
44
logger = get_logger(__name__)
55

6+
SPAWNER_SETUP = 'SPAWNER SETUP'
7+
PULLING_IMAGE = 'PULLING IMAGE'
8+
CREATING_CONTAINER = 'CREATING CONTAINER'
9+
UPDATING_STORE = 'UPDATING STORE'
10+
#TODO: error include prior state ie ERROR previous STATE
11+
#TODO: comment about order of states
612
REQUESTED = 'REQUESTED'
13+
PROCESSING = 'PROCESSING'
714
COMPLETE = 'COMPLETE'
815
SUBMITTED = 'SUBMITTED'
916
READY = 'READY'

0 commit comments

Comments
 (0)