@click.command(name="ns-alarm-create")
+@utils.require_hostname
@click.argument("name")
@click.option("--ns", prompt=True, help="NS instance id or name")
@click.option(
@click.command(name="alarm-show", short_help="show alarm details")
+@utils.require_hostname
@click.argument("uuid")
@click.pass_context
def alarm_show(ctx, uuid):
# List alarm
@click.command(name="alarm-list", short_help="list all alarms")
+@utils.require_hostname
@click.option(
"--ns_id", default=None, required=False, help="List out alarm for given ns id"
)
# Update alarm
@click.command(name="alarm-update", short_help="Update a alarm")
+@utils.require_hostname
@click.argument("uuid")
@click.option("--threshold", default=None, help="Alarm threshold")
@click.option("--is_enable", default=None, type=bool, help="enable or disable alarm")
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
@click.command(name="app-profile-create", short_help="creates an App Profile")
+@utils.require_hostname
@click.argument("name")
@click.option("--description", default="", help="human readable description")
@click.pass_context
@click.command(name="app-profile-delete", short_help="deletes an App Profile")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="app-profile-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="app-profile-show",
short_help="shows the details of an App Profile",
)
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
@click.command(name="app-profile-update", short_help="updates an App Profile")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the App Profile")
@click.option("--description", help="human readable description")
# under the License.
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
import yaml
@click.command(name="cluster-create", short_help="creates a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option("--node-count", "-n", prompt=True, type=int, help="number of nodes")
@click.option("--node-size", prompt=True, help="size of the worker nodes")
@click.command(name="cluster-delete", short_help="deletes a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="cluster-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="cluster-show",
short_help="shows the details of a K8s cluster",
)
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
@click.command(
name="cluster-edit", short_help="updates name or description of a K8s cluster"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the K8s cluster")
@click.option("--description", help="human readable description")
@click.command(
name="cluster-upgrade", short_help="changes the version of a K8s cluster"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--version", prompt=True, help="Kubernetes version")
@click.pass_context
@click.command(name="cluster-scale", short_help="scales a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option("--node-count", "-n", prompt=True, type=int, help="number of nodes")
@click.pass_context
@click.command(name="cluster-update", short_help="updates a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option("--version", help="Kubernetes version")
@click.option("--node-count", "-n", type=int, help="number of nodes")
@click.command(
name="cluster-get-credentials", short_help="gets kubeconfig of a K8s cluster"
)
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def cluster_get_credentials(ctx, name, **kwargs):
@click.command(
name="cluster-get-kubeconfig", short_help="gets kubeconfig of a K8s cluster"
)
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def cluster_get_kubeconfig(ctx, name, **kwargs):
@click.command(name="cluster-register", short_help="registers a K8s cluster to OSM")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--vim-account",
@click.command(name="cluster-deregister", short_help="deregisters a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
@click.command(
name="infra-config-profile-create", short_help="creates an Infra Config Profile"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--description", default="", help="human readable description")
@click.pass_context
@click.command(
name="infra-config-profile-delete", short_help="deletes an Infra Config Profile"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="infra-config-profile-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="infra-config-profile-show",
short_help="shows the details of an Infra Config Profile",
)
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
@click.command(
name="infra-config-profile-update", short_help="updates an Infra Config Profile"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the Infra Config Profile")
@click.option("--description", help="human readable description")
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
name="infra-controller-profile-create",
short_help="creates an Infra Controller Profile",
)
+@utils.require_hostname
@click.argument("name")
@click.option("--description", default="", help="human readable description")
@click.pass_context
name="infra-controller-profile-delete",
short_help="deletes an Infra Controller Profile",
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="infra-controller-profile-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="infra-controller-profile-show",
short_help="shows the details of an Infra Controller Profile",
)
+@utils.require_hostname
@click.argument("name")
@click.pass_context
@print_output.output_option
name="infra-controller-profile-update",
short_help="updates an Infra Controller Profile",
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the Infra Controller Profile")
@click.option("--description", help="human readable description")
@click.command(name="k8scluster-add", short_help="adds a K8s cluster to OSM")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--creds", prompt=True, help="credentials file, i.e. a valid `.kube/config` file"
@click.command(name="k8scluster-update", short_help="updates a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the K8s cluster")
@click.option("--creds", help="credentials file, i.e. a valid `.kube/config` file")
@click.command(name="k8scluster-delete", short_help="deletes a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="k8scluster-list")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="k8scluster-show", short_help="shows the details of a K8s cluster")
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.pass_context
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common.exceptions import ClientException
from osmclient.common import print_output
import logging
ignore_unknown_options=True,
),
)
+@utils.require_hostname
@click.argument(
"args",
nargs=-1,
@click.command(name="ksu-delete", short_help="deletes one or several KSU")
+@utils.require_hostname
@click.argument("ksus", type=str, nargs=-1, metavar="<KSU> [<KSU>...]")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="ksu-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
@click.command(name="ksu-show", short_help="shows the details of a KSU")
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
ignore_unknown_options=True,
),
)
+@utils.require_hostname
@click.argument(
"args",
nargs=-1,
name="ns-metric-export",
short_help="exports a metric to the internal OSM bus, which can be read by other apps",
)
+@utils.require_hostname
@click.option("--ns", prompt=True, help="NS instance id or name")
@click.option(
"--vnf", prompt=True, help="VNF name (VNF member index as declared in the NSD)"
@click.command(name="nsi-list", short_help="list all Network Slice Instances (NSI)")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(
name="netslice-instance-list", short_help="list all Network Slice Instances (NSI)"
)
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(
name="nsi-show", short_help="shows the content of a Network Slice Instance (NSI)"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.option(
name="netslice-instance-show",
short_help="shows the content of a Network Slice Instance (NSI)",
)
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.option(
@click.command(name="nsi-create", short_help="creates a new Network Slice Instance")
+@utils.require_hostname
@click.option("--nsi_name", prompt=True, help="name of the Network Slice Instance")
@click.option("--nst_name", prompt=True, help="name of the Network Slice Template")
@click.option(
@click.command(
name="netslice-instance-create", short_help="creates a new Network Slice Instance"
)
+@utils.require_hostname
@click.option("--nsi_name", prompt=True, help="name of the Network Slice Instance")
@click.option("--nst_name", prompt=True, help="name of the Network Slice Template")
@click.option(
@click.command(name="nsi-delete", short_help="deletes a Network Slice Instance (NSI)")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(
name="netslice-instance-delete", short_help="deletes a Network Slice Instance (NSI)"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
name="nsi-op-list",
short_help="shows the history of operations over a Network Slice Instance (NSI)",
)
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def nsi_op_list1(ctx, name):
name="netslice-instance-op-list",
short_help="shows the history of operations over a Network Slice Instance (NSI)",
)
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def nsi_op_list2(ctx, name):
name="nsi-op-show",
short_help="shows the info of an operation over a Network Slice Instance(NSI)",
)
+@utils.require_hostname
@click.argument("id")
@click.option(
"--filter",
name="netslice-instance-op-show",
short_help="shows the info of an operation over a Network Slice Instance(NSI)",
)
+@utils.require_hostname
@click.argument("id")
@click.option(
"--filter",
@click.command(name="nst-list", short_help="list all Network Slice Templates (NST)")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(
name="netslice-template-list", short_help="list all Network Slice Templates (NST)"
)
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(
name="nst-show", short_help="shows the content of a Network Slice Template (NST)"
)
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
name="netslice-template-show",
short_help="shows the content of a Network Slice Template (NST)",
)
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(
name="nst-create", short_help="creates a new Network Slice Template (NST)"
)
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
name="netslice-template-create",
short_help="creates a new Network Slice Template (NST)",
)
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
@click.command(name="nst-update", short_help="updates a Network Slice Template (NST)")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(
name="netslice-template-update", short_help="updates a Network Slice Template (NST)"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(name="nst-delete", short_help="deletes a Network Slice Template (NST)")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(
name="netslice-template-delete", short_help="deletes a Network Slice Template (NST)"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="vnfd-list", short_help="list all xNF packages (VNF, HNF, PNF)")
+@utils.require_hostname
@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)")
@click.option(
"--filter",
@click.command(name="vnfpkg-list", short_help="list all xNF packages (VNF, HNF, PNF)")
+@utils.require_hostname
@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)")
@click.option(
"--filter",
@click.command(name="nfpkg-list", short_help="list all xNF packages (VNF, HNF, PNF)")
+@utils.require_hostname
@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)")
@click.option(
"--filter",
@click.command(name="vnfd-show", short_help="shows the details of a NF package")
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="vnfpkg-show", short_help="shows the details of a NF package")
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="nfpkg-show", short_help="shows the details of a NF package")
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="vnfd-create", short_help="creates a new VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite", "overwrite", default=None, help="overwrite deprecated, use override"
@click.command(name="vnfpkg-create", short_help="creates a new VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
@click.command(name="nfpkg-create", short_help="creates a new NFpkg")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
@click.command(name="vnfd-update", short_help="updates a new VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(name="vnfpkg-update", short_help="updates a VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(name="nfpkg-update", short_help="updates a NFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content", default=None, help="filename with the NFpkg replacing the current one"
@click.command(name="vnfd-delete", short_help="deletes a VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="vnfpkg-delete", short_help="deletes a VNFD/VNFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="nfpkg-delete", short_help="deletes a NFpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="ns-list", short_help="list all NS instances")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="ns-show", short_help="shows the info of a NS instance")
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.option(
@click.command(name="ns-create", short_help="creates a new Network Service instance")
+@utils.require_hostname
@click.option("--ns_name", prompt=True, help="name of the NS instance")
@click.option("--nsd_name", prompt=True, help="name of the NS descriptor")
@click.option(
@click.command(name="ns-delete", short_help="deletes NS instances")
+@utils.require_hostname
@click.argument(
"names", nargs=-1, type=click.UNPROCESSED, callback=process_ns_multi_delete_params
)
@click.command(
name="ns-action", short_help="executes an action/primitive over a NS instance"
)
+@utils.require_hostname
@click.argument("ns_name")
@click.option(
"--vnf_name",
@click.command(
name="vnf-scale", short_help="executes a VNF scale (adding/removing VDUs)"
)
+@utils.require_hostname
@click.argument("ns_name")
@click.argument("vnf_name")
@click.option(
ignore_unknown_options=True,
),
)
+@utils.require_hostname
@click.argument("ns_name")
@click.argument(
"args",
ignore_unknown_options=True,
),
)
+@utils.require_hostname
@click.argument("vnf_name")
@click.argument(
"args",
@click.command(
name="ns-op-list", short_help="shows the history of operations over a NS instance"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--long", is_flag=True, help="get more details of the NS operation (date, )."
@click.command(name="ns-op-show", short_help="shows the info of a NS operation")
+@utils.require_hostname
@click.argument("id")
@click.option(
"--filter",
@click.command(name="ns-op-cancel", short_help="cancels an ongoing NS operation")
+@utils.require_hostname
@click.argument("id")
@click.option(
"--cancel_mode",
@click.command(name="nsd-list", short_help="list all NS packages")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="nspkg-list", short_help="list all NS packages")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="nsd-show", short_help="shows the details of a NS package")
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="nspkg-show", short_help="shows the details of a NS package")
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="nsd-create", short_help="creates a new NSD/NSpkg")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
@click.command(name="nspkg-create", short_help="creates a new NSD/NSpkg")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--overwrite",
@click.command(name="nsd-update", short_help="updates a NSD/NSpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(name="nspkg-update", short_help="updates a NSD/NSpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--content",
@click.command(name="nsd-delete", short_help="deletes a NSD/NSpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="nspkg-delete", short_help="deletes a NSD/NSpkg")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="nsconfig-list", short_help="list all NS Config Templates")
+@utils.require_hostname
@click.option(
"--nsd",
default=None,
@click.command(
name="nsconfig-show", short_help="shows the details of a Ns config template"
)
+@utils.require_hostname
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.argument("name")
@click.pass_context
@click.command(name="nsconfig-delete", short_help="deletes a Ns config template")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="nsconfig-create", short_help="creates a Ns config template")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--config_file",
@click.command(
name="nsconfig-update", short_help="update content of Ns config template"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the Ns config template")
@click.option(
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
@click.command(name="oka-add", short_help="adds an OSM Kubernetes Application (OKA)")
+@utils.require_hostname
@click.argument("name")
@click.argument("path")
@click.option(
@click.command(
name="oka-delete", short_help="deletes an OSM Kubernetes Application (OKA)"
)
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="oka-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="oka-show",
short_help="shows the details of an OKA",
)
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
@click.command(
name="oka-update", short_help="updates an OSM Kubernetes Application (OKA)"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the OSM Kubernetes Application (OKA)")
@click.option("--description", help="human readable description")
name="oka-update-content",
short_help="updates the content of an OKA",
)
+@utils.require_hostname
@click.argument("name")
@click.argument("path")
@click.pass_context
@click.command(name="version", short_help="shows client and server versions")
+@utils.require_hostname
@click.pass_context
def get_version(ctx):
"""shows client and server versions"""
# TODO: check if this command should be here. It is more related to nspkg and nfpkg
@click.command(name="upload-package", short_help="uploads a VNF package or NS package")
+@utils.require_hostname
@click.argument("filename")
@click.option(
"--skip-charm-build",
@click.command(name="pdu-list", short_help="list all Physical Deployment Units (PDU)")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(
name="pdu-show", short_help="shows the content of a Physical Deployment Unit (PDU)"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.option(
@click.command(
name="pdu-create", short_help="adds a new Physical Deployment Unit to the catalog"
)
+@utils.require_hostname
@click.option("--name", help="name of the Physical Deployment Unit")
@click.option("--pdu_type", help="type of PDU (e.g. router, firewall, FW001)")
@click.option(
@click.command(
name="pdu-update", short_help="updates a Physical Deployment Unit to the catalog"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the Physical Deployment Unit")
@click.option("--pdu_type", help="type of PDU (e.g. router, firewall, FW001)")
@click.command(name="pdu-delete", short_help="deletes a Physical Deployment Unit (PDU)")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
import click
import logging
from osmclient.common import print_output
+from osmclient.cli_commands import utils
logger = logging.getLogger("osmclient")
@click.command(name="profile-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
@click.command(name="attach-profile")
+@utils.require_hostname
@click.argument("profile")
@click.argument("cluster")
@click.option(
@click.command(name="detach-profile")
+@utils.require_hostname
@click.argument("profile")
@click.argument("cluster")
@click.option(
@click.command(name="role-create", short_help="creates a new role")
+@utils.require_hostname
@click.argument("name")
@click.option("--permissions", default=None, help="role permissions using a dictionary")
@click.pass_context
@click.command(name="role-update", short_help="updates a role")
+@utils.require_hostname
@click.argument("name")
@click.option("--set-name", default=None, help="change name of rle")
@click.option(
@click.command(name="role-delete", short_help="deletes a role")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def role_delete(ctx, name):
@click.command(name="role-list", short_help="list all roles")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="role-show", short_help="show specific role")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def role_show(ctx, name):
@click.command(name="project-create", short_help="creates a new project")
+@utils.require_hostname
@click.argument("name")
# @click.option('--description',
# default='no description',
@click.command(name="project-delete", short_help="deletes a project")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def project_delete(ctx, name):
@click.command(name="project-list", short_help="list all projects")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="project-show", short_help="shows the details of a project")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def project_show(ctx, name):
@click.command(
name="project-update", short_help="updates a project (only the name can be updated)"
)
+@utils.require_hostname
@click.argument("project")
@click.option("--name", default=None, help="new name for the project")
@click.option(
@click.command(name="user-create", short_help="creates a new user")
+@utils.require_hostname
@click.argument("username")
@click.option(
"--password",
@click.command(name="user-update", short_help="updates user information")
+@utils.require_hostname
@click.argument("username")
@click.option("--set-username", "set_username", default=None, help="change username")
@click.option("--email", "email", default=None, help="Change User's email address")
@click.command(name="user-delete", short_help="deletes a user")
+@utils.require_hostname
@click.argument("name")
# @click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
@click.pass_context
@click.command(name="user-list", short_help="list all users")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="user-show", short_help="shows the details of a user")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def user_show(ctx, name):
@click.command(name="user-reset-password", short_help="Resetting a user's password")
+@utils.require_hostname
@click.option("--email", "email", help="Email of the user")
@click.pass_context
def user_reset_password(ctx, email):
@click.command(name="repo-add", short_help="adds a repo to OSM")
+@utils.require_hostname
@click.argument("name")
@click.argument("uri")
@click.option(
@click.command(name="repo-update", short_help="updates a repo in OSM")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the repo")
@click.option("--uri", help="URI of the repo")
@click.command(name="repo-list")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="repo-show", short_help="shows the details of a repo")
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.pass_context
#######################################################################################
import click
-from osmclient.cli_commands import common
+from osmclient.cli_commands import common, utils
from osmclient.common import print_output
import logging
@click.command(
name="resource-profile-create", short_help="creates an Resource Profile to OSM"
)
+@utils.require_hostname
@click.argument("name")
@click.option("--description", default=None, help="human readable description")
@click.pass_context
@click.command(name="resource-profile-delete", short_help="deletes an Resource Profile")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="resource-profile-list")
+@utils.require_hostname
@click.option(
"--filter",
help="restricts the list to the items matching the filter",
name="resource-profile-show",
short_help="shows the details of an Resource Profile",
)
+@utils.require_hostname
@click.argument("name")
@print_output.output_option
@click.pass_context
@click.command(name="resource-profile-update", short_help="updates an Resource Profile")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the Resource Profile")
@click.option("--description", help="human readable description")
@click.command(name="sdnc-create", short_help="creates a new SDN controller")
+@utils.require_hostname
@click.option("--name", prompt=True, help="Name to create sdn controller")
@click.option("--type", prompt=True, help="SDN controller type")
@click.option(
@click.command(name="sdnc-update", short_help="updates an SDN controller")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the SDN controller")
@click.option("--description", default=None, help="human readable description")
@click.command(name="sdnc-delete", short_help="deletes an SDN controller")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="sdnc-list", short_help="list all SDN controllers")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="sdnc-show", short_help="shows the details of an SDN controller")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def sdnc_show(ctx, name):
name="subscription-create",
short_help="creates a new subscription to a specific event",
)
+@utils.require_hostname
@click.option(
"--event_type",
# type=click.Choice(['ns', 'nspkg', 'vnfpkg'], case_sensitive=False))
@click.command(name="subscription-delete", short_help="deletes a subscription")
+@utils.require_hostname
@click.option(
"--event_type",
# type=click.Choice(['ns', 'nspkg', 'vnfpkg'], case_sensitive=False))
@click.command(name="subscription-list", short_help="list all subscriptions")
+@utils.require_hostname
@click.option(
"--event_type",
# type=click.Choice(['ns', 'nspkg', 'vnfpkg'], case_sensitive=False))
@click.command(
name="subscription-show", short_help="shows the details of a subscription"
)
+@utils.require_hostname
@click.argument("subscription_id")
@click.option(
"--event_type",
# License for the specific language governing permissions and limitations
# under the License.
+import functools
import textwrap
import logging
import shutil
import yaml
+import click
from osmclient.common.exceptions import ClientException
logger = logging.getLogger("osmclient")
for k, v in cdict.items():
config[k] = v
return config
+
+
+def require_hostname(command):
+ @functools.wraps(command)
+ @click.pass_context
+ def wrapper(ctx, *args, **kwargs):
+ logger.debug("")
+ hostname = ctx.parent.params.get("hostname") if ctx.parent else None
+ if not hostname:
+ raise click.UsageError(
+ "This command requires --hostname or OSM_HOSTNAME to be set."
+ )
+ return ctx.invoke(command, *args, **kwargs)
+
+ return wrapper
@click.command(name="vca-add", short_help="adds a VCA (Juju controller) to OSM")
+# @utils.require_hostname
@click.argument("name")
@click.option(
"--endpoints",
@click.command(name="vca-update", short_help="updates a VCA")
+# @utils.require_hostname
@click.argument("name")
@click.option(
"--endpoints", help="Comma-separated list of IP or hostnames of the Juju controller"
@click.command(name="vca-delete", short_help="deletes a VCA")
+# @utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion from the DB (not recommended)"
@click.command(name="vca-list")
+# @utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="vca-show", short_help="shows the details of a VCA")
+# @utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.pass_context
@click.command(name="vim-create", short_help="creates a new VIM account")
+# @utils.require_hostname
@click.option("--name", required=True, help="Name to create datacenter")
@click.option("--user", default=None, help="VIM username")
@click.option("--password", default=None, help="VIM password")
@click.command(name="vim-update", short_help="updates a VIM account")
+# @utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the VIM account")
@click.option("--user", help="VIM username")
@click.command(name="vim-delete", short_help="deletes a VIM account")
+# @utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="vim-list", short_help="list all VIM accounts")
+# @utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="vim-show", short_help="shows the details of a VIM account")
+# @utils.require_hostname
@click.argument("name")
@click.option(
"--filter",
@click.command(name="vnf-list", short_help="list all NF instances")
+@utils.require_hostname
@click.option(
"--ns", default=None, help="NS instance id or name to restrict the NF list"
)
@click.command(name="nf-list", short_help="list all NF instances")
+@utils.require_hostname
@click.option(
"--ns", default=None, help="NS instance id or name to restrict the NF list"
)
@click.command(name="vnf-show", short_help="shows the info of a VNF instance")
+@utils.require_hostname
@click.argument("name")
@click.option("--literal", is_flag=True, help="print literally, no pretty table")
@click.option(
@click.command(name="wim-create", short_help="creates a new WIM account")
+@utils.require_hostname
@click.option("--name", prompt=True, help="Name for the WIM account")
@click.option("--user", help="WIM username")
@click.option("--password", help="WIM password")
@click.command(name="wim-update", short_help="updates a WIM account")
+@utils.require_hostname
@click.argument("name")
@click.option("--newname", help="New name for the WIM account")
@click.option("--user", help="WIM username")
@click.command(name="wim-delete", short_help="deletes a WIM account")
+@utils.require_hostname
@click.argument("name")
@click.option(
"--force", is_flag=True, help="forces the deletion bypassing pre-conditions"
@click.command(name="wim-list", short_help="list all WIM accounts")
+@utils.require_hostname
@click.option(
"--filter",
default=None,
@click.command(name="wim-show", short_help="shows the details of a WIM account")
+@utils.require_hostname
@click.argument("name")
@click.pass_context
def wim_show(ctx, name):
)
@click.option(
"--hostname",
- required=True,
envvar="OSM_HOSTNAME",
help="OSM NBI endpoint. " + "Also can set OSM_HOSTNAME in environment",
)
@click.pass_context
def cli_osm(ctx, **kwargs):
global logger
- # hostname is mandatory, so we pop it from kwargs
- hostname = kwargs.pop("hostname")
+ hostname = kwargs.pop("hostname", None)
kwargs = {k: v for k, v in kwargs.items() if v is not None}
ctx.obj = client.Client(version=1, host=hostname, **kwargs)
logger = logging.getLogger("osmclient")
self._headers = {}
self._token = None
self._url = None
+ if host is None:
+ # This is required to init a dummy Client for those click commands
+ # that do not require a host
+ host = "localhost"
if host.startswith("http://") or host.startswith("https://"):
self._url = host
else: