Skip to content

Commit

Permalink
Include missing files
Browse files Browse the repository at this point in the history
This would have not happened if unit tests were in place :-(
  • Loading branch information
alvarolopez committed Mar 5, 2021
1 parent d667d74 commit 350439c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
42 changes: 42 additions & 0 deletions orpy/client/config.py
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)
38 changes: 38 additions & 0 deletions orpy/cmd/config.py
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)

0 comments on commit 350439c

Please sign in to comment.