Merge lp:~rvb/maas/bug-1104215 into lp:~maas-committers/maas/trunk
Proposed by
Raphaël Badin
Status: | Merged |
---|---|
Approved by: | Raphaël Badin |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1426 |
Proposed branch: | lp:~rvb/maas/bug-1104215 |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
219 lines (+103/-3) 5 files modified
src/maas/settings.py (+5/-0) src/maasserver/api.py (+16/-2) src/maasserver/tests/test_api.py (+32/-1) src/maasserver/utils/__init__.py (+23/-0) src/maasserver/utils/tests/test_utils.py (+27/-0) |
To merge this branch: | bzr merge lp:~rvb/maas/bug-1104215 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+145588@code.launchpad.net |
Commit message
Detect if the connecting cluster is the local cluster by comparing its UUID with the local cluster UUID.
Description of the change
- We now support an external cluster to connect first (for instance if no cluster was installed alongside the region cluster). It will need to be accepted by an admin.
- No pre-imp for this but consensus was reached in the discussion on the bug's comments.
- This has been tested in the lab.
To post a comment you must log in.
Looks good.
[1]
+ if is_local_cluster: credentials( ) httplib. ACCEPTED)
+ return get_celery_
+ else:
+ return HttpResponse(
+ "Cluster registered. Awaiting admin approval.",
+ status=
The condition - if is_local_cluster - is a secondhand indicator for
what you should be testing here: that the nodegroup status is
ACCEPTED.
[2]
+ try: LOCAL_CLUSTER_ CONFIG) .read()
+ cluster_config = file(settings.
`file` is gone in Python 3.x. Use `open`.
[3]
+ except IOError:
+ # Cluster config file is not present.
+ return False
Be more specific here:
except IOError as error:
if error.errno == errno.ENOENT:
# Cluster config file is not present.
return False
else:
# Anything else is an error.
raise
[4]
+ match = re.search( 'CLUSTER_ UUID="( [^"]*)" ', cluster_config)
+ if match is not None:
+ return uuid == match.groups()[0]
I know you're probably well aware of this, but: euargh.
[5]
+ match = re.search( 'CLUSTER_ UUID="( [^"]*)" ', cluster_config)
Just in case someone comes along and removes the quotes, or changes
them to single quotes, or does either of those things in another part
of MAAS's code base, consider the following expression:
re.search(
"CLUSTER_ UUID=(? P<quote> [\"']?) ([^\"'] +)(?P=quote) ",
cluster_ config)