-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This would have not happened if unit tests were in place :-(
- Loading branch information
1 parent
d667d74
commit 350439c
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2021 Spanish National Research Council (CSIC) | ||
# | ||
# 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. | ||
|
||
from orpy.client import base | ||
from orpy import exceptions | ||
|
||
|
||
class Config(object): | ||
"""Get configured endpoints for the Orchestrator.""" | ||
|
||
def __init__(self, client): | ||
self.client = client | ||
|
||
def get(self): | ||
"""Get Configurted endpoints for the orchestrator. | ||
:return: Configured endpoints for the orchestrator. | ||
:rtype: orpy.client.base.OrchestratorConfiguration | ||
""" | ||
try: | ||
resp, body = self.client.get("./configuration") | ||
except exceptions.ClientException: | ||
raise exceptions.InvalidUrl(url=self.client.url) | ||
|
||
if resp.status_code == 200: | ||
body["url"] = self.client.url | ||
return base.OrchestratorInfo(body) | ||
else: | ||
raise exceptions.InvalidUrl(url=self.client.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2021 Spanish National Research Council (CSIC) | ||
# | ||
# 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. | ||
|
||
|
||
from cliff import show | ||
|
||
from orpy import utils | ||
|
||
|
||
class OrchestratorConfigShow(show.ShowOne): | ||
"""Show current orchestrator endpoints configured. | ||
Use this command to get the list of endpoints that the current orchrestator | ||
is using. | ||
""" | ||
|
||
auth_required = False | ||
|
||
def take_action(self, parsed_args): | ||
d = self.app.client.config.get().to_dict() | ||
for k, v in d.items(): | ||
if isinstance(v, dict): | ||
d[k] = utils.format_dict(v) | ||
return self.dict2columns(d) | ||
|