Skip to content

Commit

Permalink
Merge pull request #203 from tdviet/vo-sites
Browse files Browse the repository at this point in the history
Add vo-list command
  • Loading branch information
tdviet authored Jul 4, 2024
2 parents 0f875de + 96ef652 commit af70cec
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
8 changes: 7 additions & 1 deletion docs/cheat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ Basic usages

$ fedcloud token list-vos

* List sites in EGI Federated Cloud:
* List sites in the EGI Federated Cloud:

::

$ fedcloud site list

* List all sites supporting a Virtual Organization in the EGI Federated Cloud:

::

$ fedcloud site list --vo vo.access.egi.eu

* Execute an OpenStack command:

::
Expand Down
12 changes: 11 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Basic usages
training.egi.eu
...

* List sites in EGI Federated Cloud
* List sites in the EGI Federated Cloud

::

Expand All @@ -53,6 +53,16 @@ Basic usages
CESGA
...

* List sites supporting a Virtual Organization in the EGI Federated Cloud

::

$ fedcloud site list --vo vo.access.egi.eu
BIFI
CENI
CESGA-CLOUD
...

* Execute an OpenStack command, e.g. list images in eosc-synergy.eu VO on IISAS-FedCloud site
(or other combination of site and VO you have access):

Expand Down
11 changes: 11 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ VOs and so on.
...


* **"fedcloud site list --vo <VO-name>"** : List all sites supporting a Virtual Organization

::

$ fedcloud site vo-list --vo vo.access.egi.eu
BIFI
CENI
CESGA-CLOUD
...


* **"fedcloud site show --site <SITE>"** : Show configuration of the corresponding site.

::
Expand Down
9 changes: 9 additions & 0 deletions fedcloudclient/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def wrapper(*args, **kwargs):
metavar="vo-name",
)

# Optional decorator for --vo
vo_params_optional = click.option(
"--vo",
help="Name of the VO",
required=False,
envvar="EGI_VO",
metavar="vo-name",
)


def site_vo_params(func):
"""
Expand Down
24 changes: 16 additions & 8 deletions fedcloudclient/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
all_site_params,
oidc_params,
site_vo_params,
vo_params_optional,
)
from fedcloudclient.shell import print_set_env_command

Expand Down Expand Up @@ -182,16 +183,22 @@ def delete_site_config(config_dir):
shutil.rmtree(config_dir, ignore_errors=True)


def list_sites():
def list_sites(vo=None):
"""
List of all sites IDs in site configurations
List all sites IDs in site configurations
Optionally list all sites supporting a Virtual Organization
:return: list of site IDs
"""
read_site_config()
result = []
for site_info in __site_config_data:
result.append(site_info["gocdb"])
if vo is None:
result.append(site_info["gocdb"])
else:
for vos in site_info["vos"]:
if vo == vos["name"]:
result.append(site_info["gocdb"])
return result


Expand Down Expand Up @@ -317,13 +324,14 @@ def save_config():


@site.command("list")
def list_():
@vo_params_optional
def list_(vo=None):
"""
List all sites
List all sites. If "--vo <name>" is provided, list only sites
supporting a Virtual Organization.
"""
read_site_config()
for site_info in __site_config_data:
print(site_info["gocdb"])
for site in list_sites(vo):
print(site)


@site.command()
Expand Down

0 comments on commit af70cec

Please sign in to comment.