Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Help Center/ Koo Command Line Interface/ Getting Started/ Step 4: View and Run Cloud Service Operation Commands

Step 4: View and Run Cloud Service Operation Commands

Updated on 2024-06-12 GMT+08:00

This section uses Windows as an example to describe how to use KooCLI. The methods for using the CLI in Linux and macOS are similar.

After the initialization is complete, you can query the cloud services supported by KooCLI and run operation commands. The following uses the Elastic Cloud Server (ECS) API for querying ECS details as an example to describe how to query and run a command.

  1. Query the operations of a cloud service.

    hcloud <service> --help

    As shown below, Available Operations lists the operations supported by ECS.

    hcloud ECS --help
    
    KooCLI(Koo Command Line Interface) Version 3.2.8 Copyright(C) 2020-2023 www.huaweicloud.com
    
    Usage:
      hcloud ECS <operation> --param1=value1 --param2=value2 ...
    
    Service:
      ECS
    
    Available Operations:
      AddServerGroupMember             MigrateServer                    NovaShowServerAction
      AssociateServerVirtualIp         NovaAssociateSecurityGroup       NovaShowServerGroup
      AttachServerVolume               NovaAttachInterface              NovaShowServerInterface
      BatchAddServerNics               NovaAttachVolume                 NovaShowServerMetadata
      ...
    NOTE:
    • During command execution, your authentication information will be used for requests, and the invocation of some APIs will incur charges.
    • Alternatively, you can query the operations supported by a cloud service on API Explorer.
    • To query the cloud services supported by KooCLI, run the hcloud --help command.
    NOTICE:

    If your KooCLI uses the offline mode, it automatically downloads the offline metadata package when executing commands for the first time. Once downloaded, the package will not be automatically updated. To invoke newly launched services in the offline mode, run the hcloud meta download command to update the offline metadata package, or run the hcloud configure set --cli-offline=false command to switch to the online mode.

  2. Query the help information about an operation.

    hcloud <service> <operation> --help

    Select NovaShowServer from the obtained ECS operation list to query the help information about the API. The API description, parameters, and parameter descriptions are displayed.

    hcloud ECS NovaShowServer --help
    
    KooCLI(Koo Command Line Interface) Version 3.2.8 Copyright(C) 2020-2023 www.huaweicloud.com
    
    Service:
      ECS
    
    Description:
    This API is used to query details about an ECS by ECS ID.
    
    Method:
      GET
    
    Params:
      --cli-region
        required    string  Region where the API can be called. If no region is specified in the command, cli-region in the current profile is used.
      --project_id
        required    string  path    Specifies the project ID. If no project ID is specified in the command, either the parent project ID of the specified region in the authentication information or cli-project-id in the current profile is used.
      --server_id
        required    string  path    Specifies the ECS ID.
      --OpenStack-API-Version
        optional    string  header  API with a microversion.

  3. Run the command to call the API and obtain the execution result.

    hcloud <service> <operation> [--param1=paramValue1 --param2=paramValue2 ...]

    After you enter cli-region (region), project_id (project ID), and server_id (ECS ID) and press Enter, the ECS information is returned.

    hcloud ECS NovaShowServer --cli-region="ap-southeast-1" --project_id="0dd8cb****************19b5a84546" --server_id="4f06****-****-****-****-****04dd856a"
    {
     "server": {
      "tenant_id": "0dd8cb****************19b5a84546",
      "metadata": {},
      "addresses": {
       "c865****-****-****-****-****efe7e8d8": [
        {
         "OS-EXT-IPS-MAC:mac_addr": "fa:**:**:**:**:**",
         "OS-EXT-IPS:type": "fixed",
         "addr": "192.***.*.**",
         "version": 4
        }
       ]
      },
      "OS-EXT-STS:task_state": null,
      "OS-DCF:diskConfig": "AUTO",
      "OS-EXT-AZ:availability_zone": "ap-southeast-1a",
      "links": [
       {
        "rel": "self",
        "href": "https://ecs.ap-southeast-1.myhuaweicloud.com/v2.1/0dd8cb****************19b5a84546/servers/4f06****-****-****-****-****04dd856a"
       },
       {
        "rel": "bookmark",
        "href": "https://ecs.ap-southeast-1.myhuaweicloud.com/0dd8cb****************19b5a84546/servers/4f06****-****-****-****-****04dd856a"
       }
      ],
      "OS-EXT-STS:power_state": 4,
      "id": "4f06****-****-****-****-****04dd856a",
      "os-extended-volumes:volumes_attached": [
       {
        "id": "aed9****-****-****-****-****0e3219cf"
       }
      ],
      "OS-EXT-SRV-ATTR:host": "51f41ce46********************************38b69b7aa4ea2a8",
      "image": {
       "links": [
        {
         "rel": "bookmark",
         "href": "https://ecs.ap-southeast-1.myhuaweicloud.com/0dd8cb****************19b5a84546/images/67f4****-****-****-****-****38539e09"
        }
       ],
       "id": "67f4****-****-****-****-****38539e09"
      },
      "OS-SRV-USG:terminated_at": null,
      "accessIPv4": "",
      "accessIPv6": "",
      "created": "2022-05-10T12:56:36Z",
      "hostId": "51f41ce46********************************38b69b7aa4ea2a8",
      "OS-EXT-SRV-ATTR:hypervisor_hostname": "cf199aabae********************************bed586126e6f57",
      "flavor": {
       "links": [
        {
         "rel": "bookmark",
         "href": "https://ecs.ap-southeast-1.myhuaweicloud.com/0dd8cb****************19b5a84546/flavors/s6.medium.2"
        }
       ],
       "id": "s6.medium.2"
      },
      "key_name": null,
      "security_groups": [
       {
        "name": "Sys-**********"
       }
      ],
      "OS-EXT-STS:vm_state": "stopped",
      "user_id": "b4d561****************346deaf79e",
      "OS-EXT-SRV-ATTR:instance_name": "instance-*******",
      "name": "ecs-****",
      "OS-SRV-USG:launched_at": "2022-05-10T12:56:53.000000",
      "updated": "2022-05-13T08:05:17Z",
      "status": "SHUTOFF"
     }
    }
    NOTE:
    • When using KooCLI to call APIs, you can obtain example CLI commands on API Explorer.
    • KooCLI automatically obtains the account ID and project ID of an IAM user based on the user authentication information during API calling. The user does not need to specify cli-region in the command if it has already been specified in the configuration information.
    • If a parameter value in the command is incorrect, an error message is displayed as follows:
      hcloud ECS ShowServer --project_id="0dd8cb****************19b5a84546" --cli-region="ap-southeast-1" --server_id="abc"
      {
        "error": {
          "message": "Instance[abc] could not be found.",
          "code": "Ecs.0114"
        }
      }
      For details, go to the API Error Center at 'https://console-intl.huaweicloud.com/apiexplorer/#/errorcenter?keyword=Ecs.0114&product=ECS'.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback