Code Monkey home page Code Monkey logo

jdcloud-cli's People

Contributors

jdcloud-apigateway avatar lidaobing avatar shijunlee avatar tanc009 avatar wdwqw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jdcloud-cli's Issues

jdc --help显示的sub-commands应描述所操作的资源。比如mps表示什么意思?可以是汉字。

$ jdc --help

sub-commands:
{mps,cps,rds,jke,vpc,xdata,mongodb,configure,streambus,ipanti,baseanti,datastar,redis,nc,monitor,iam,disk,cr,streamcomputer,sop,clouddnsservice,vm,oss}
mps 使用该子命令操作mps相关资源
cps 使用该子命令操作cps相关资源
rds 使用该子命令操作rds相关资源
jke 使用该子命令操作jke相关资源
vpc 使用该子命令操作vpc相关资源
xdata 使用该子命令操作xdata相关资源
mongodb 使用该子命令操作mongodb相关资源
configure 使用该子命令配置CLI
streambus 使用该子命令操作streambus相关资源
ipanti 使用该子命令操作ipanti相关资源
baseanti 使用该子命令操作baseanti相关资源
datastar 使用该子命令操作datastar相关资源
redis 使用该子命令操作redis相关资源
nc 使用该子命令操作nc相关资源
monitor 使用该子命令操作monitor相关资源
iam 使用该子命令操作iam相关资源
disk 使用该子命令操作disk相关资源
cr 使用该子命令操作cr相关资源
streamcomputer 使用该子命令操作streamcomputer相关资源
sop 使用该子命令操作sop相关资源
clouddnsservice 使用该子命令操作clouddnsservice相关资源
vm 使用该子命令操作vm相关资源
oss 使用该子命令操作oss相关资源
MichaeldeMacBook-Pro-2:~ myang

python3.6 报错,3.5没问题

jdc nc, then:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jdc", line 11, in
load_entry_point('jdcloud-cli==1.0.0', 'console_scripts', 'jdc')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jdcloud_cli-1.0.0-py3.6.egg/jdcloud_cli/jdc.py", line 98, in main
app.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jdcloud_cli-1.0.0-py3.6.egg/cement/core/foundation.py", line 905, in run
return_val = self.controller._dispatch()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jdcloud_cli-1.0.0-py3.6.egg/cement/ext/ext_argparse.py", line 935, in _dispatch
(contr.class.name, func_name)) # pragma: nocover
cement.core.exc.FrameworkError: Controller function does not exist NcController.default()

jdc nc exec-start Handshake status 404 Not Found

Traceback (most recent call last):
  File "/usr/local/bin/jdc", line 11, in <module>
    load_entry_point('jdcloud-cli==1.2.5', 'console_scripts', 'jdc')()
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/jdc.py", line 152, in main
    app.run()
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/cement/core/foundation.py", line 905, in run
    return_val = self.controller._dispatch()
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/cement/ext/ext_argparse.py", line 926, in _dispatch
    return func()
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/controllers/services/nc.py", line 602, in exec_start
    exec_start(self.app, 'nc', headers, region_id, self.app.pargs.containerId, self.app.pargs.execId)
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/controllers/websocket/exec_start_request.py", line 61, in exec_start
    request.invoke_shell(credential)
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/controllers/websocket/exec_start_request.py", line 47, in invoke_shell
    web_socket.invoke_shell(self.__url, self.__headers)
  File "/usr/local/lib/python3.6/site-packages/jdcloud_cli/controllers/websocket/websocket_gnu.py", line 43, in invoke_shell
    shell = websocket.create_connection(url, timeout=10, header=header)
  File "/usr/local/lib/python3.6/site-packages/websocket/_core.py", line 515, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.6/site-packages/websocket/_core.py", line 226, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "/usr/local/lib/python3.6/site-packages/websocket/_handshake.py", line 80, in handshake
    status, resp = _get_resp_headers(sock)
  File "/usr/local/lib/python3.6/site-packages/websocket/_handshake.py", line 165, in _get_resp_headers
    raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 404 Not Found

获取exec-id 没有问题。 但使用jdc 连接容器的时候,出现了这个错误。

jdc crash

$ jdc
Traceback (most recent call last):
File "/usr/local/bin/jdc", line 7, in
from jdcloud_cli.jdc import main
File "/usr/local/lib/python3.7/site-packages/jdcloud_cli/jdc.py", line 21, in
from jdcloud_cli.controllers.configure_controller import ConfigureController
File "/usr/local/lib/python3.7/site-packages/jdcloud_cli/controllers/configure_controller.py", line 68
print 'access-key is required.'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('access-key is required.')?

--input-json 和其它必选参数冲突

VM的创建实例接口,以json文件方式创建时,还必须输入必选参数--instanceSpec。两个参数冲突,使用--input-json参数时,最好不要强制再输入其它重复的必选参数。

vm create-instances命令中instance-spec是否应为可选参数?

如果instance-spec是必选参数,那如果有-input-json参数,以哪个参数的配置信息为准?

MichaeldeMacBook-Pro-2:~ myang$ jdc vm create-instances --help
usage: jdc vm create-instances [-h] [--region-id REGIONID] --instance-spec
INSTANCESPEC [--max-count MAXCOUNT]
[--client-token CLIENTTOKEN]
[--input-json INPUT_JSON] [--headers HEADERS]

jdc for python3 does not work

$ jdc
Traceback (most recent call last):
  File "/usr/local/bin/jdc", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/jdcloud_cli/jdc.py", line 98, in main
    app.run()
  File "/usr/local/lib/python3.7/site-packages/cement/core/foundation.py", line 905, in run
    return_val = self.controller._dispatch()
  File "/usr/local/lib/python3.7/site-packages/cement/ext/ext_argparse.py", line 935, in _dispatch
    (contr.__class__.__name__, func_name))      # pragma: nocover
cement.core.exc.FrameworkError: Controller function does not exist BaseController.default()

创建云主机使用--max-count参数报错。

不使用max-count参数能创建成功。
MichaeldeMacBook-Pro-2:~ myang$ jdc vm create-instances --instance-spec '{"systemDisk":{"deviceName":"vda","diskCategory":"cloud","cloudDiskSpec":{"diskSizeGB":40,"name":"jdcoe-test-wp-app02","az":"cn-east-2a","diskType":"ssd"},"autoDelete":true},"az":"cn-east-2a","name":"jdcoe-test-wp-app02","primaryNetworkInterface":{"networkInterface":{"subnetId":"subnet-wnmc6x55w2"}},"imageId":"img-vtc80pq9bn","charge":{"chargeMode":"postpaid_by_duration"},"instanceType":"c.n2.large"}' { "error": null, "result": { "instanceIds": [ "i-nnyd1qzuzx" ] }, "request_id": "bfr2vpm4d8u05owj2oo1ewnfvw4a3dku" }
使用--max-count参数报错。
MichaeldeMacBook-Pro-2:~ myang$ jdc vm create-instances --instance-spec '{"systemDisk":{"deviceName":"vda","diskCategory":"cloud","cloudDiskSpec":{"diskSizeGB":40,"name":"jdcoe-test-wp-app02","az":"cn-east-2a","diskType":"ssd"},"autoDelete":true},"az":"cn-east-2a","name":"jdcoe-test-wp-app02","primaryNetworkInterface":{"networkInterface":{"subnetId":"subnet-wnmc6x55w2"}},"imageId":"img-vtc80pq9bn","charge":{"chargeMode":"postpaid_by_duration"},"instanceType":"c.n2.large"}' --max-count 1 { "error": { "status": "INVALID_ARGUMENT", "message": "Invalid request body. Malformed parameter MaxCount", "code": 400 }, "result": null, "request_id": "026deb9b510e30c8d33805412e52646d" }

中文帮助需要排版支持

$ jdc vm create-instances --help
usage: jdc vm create-instances [-h] [--region-id REGIONID] --instance-spec
                               INSTANCESPEC [--max-count MAXCOUNT]
                               [--client-token CLIENTTOKEN]
                               [--input-json INPUT_JSON] [--headers HEADERS]

            创建一台或多台指定配置的云主机,创建模式分为三种:1.普通方式、2.使用高可用组、3.使用启动模板。三种方式创建云主机时参数的必传与非必传是不同的,具体请参考<a href="http://docs.jdcloud.com/virtual-machines/api/create_vm_sample">参数详细说明</a><br>; - 创建云主机需要通过实名认证; - 实例规格;     - 可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息。;     - 不能使用已下线、或已售馨的规格ID; - 镜像;     - Windows Server 2012 R2标准版 64位 中文版 SQL Server 2014 标准版 SP2内存需大于1GB;;     - Windows Server所有镜像CPU不可选超过64核CPU。;     - 可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息。;     - 选择的镜像必须支持选择的实例规格。可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimageconstraints">DescribeImageConstraints</a>接口获得指定镜像的实例规格限制信息。<br>; - 网络配置;     - 指定主网卡配置信息;         - 必须指定subnetId;         - 可以指定elasticIp规格来约束创建的弹性IP,带宽取值范围[1-100]Mbps,步进1Mbps;         - 可以指定主网卡的内网主IP(primaryIpAddress),此时maxCount只能为1;         - 安全组securityGroup需与子网Subnet在同一个私有网络VPC内;         - 一台云主机创建时必须指定一个安全组,至多指定5个安全组,如果没有指定安全组,默认使用默认安全组;         - 主网卡deviceIndex设置为1; - 存储;     - 系统盘;         - 磁盘分类,系统盘支持local或cloud;         - 磁盘大小;             - local:不能指定大小,默认为40GB;             - cloud:取值范围: 40-500GB,并且不能小于镜像的最小系统盘大小,如果没有指定,默认以镜像中的系统盘大小为准;         - 自动删除;             - 如果是local,默认自动删除,不能修改此属性;             - 如果是cloud类型的按配置计费的云硬盘,可以指定为True;     - 数据盘;         - 磁盘分类,数据盘仅支持cloud;         - 云硬盘类型可以选择ssd、premium-hdd;         - 磁盘大小;             - premium-hdd:范围[20,3000]GB,步长为10G;             - ssd:范围[20,1000]GB,步长为10G;         - 自动删除;             - 默认自动删除,如果是包年包月的数据盘或共享型数据盘,此参数不生效;             - 可以指定SnapshotId创建云硬盘;         - 可以从快照创建磁盘;     - local类型系统的云主机可以挂载8块云硬盘;     - cloud类型系统的云主机可以挂载7块云硬盘; - 计费;     - 弹性IP的计费模式,如果选择按用量类型可以单独设置,其它计费模式都以主机为准;     - 云硬盘的计费模式以主机为准; - 其他;     - 创建完成后,主机状态为running;     - 仅Linux系统云主机可以指定密钥;     - maxCount为最大努力,不保证一定能达到maxCount;     - 虚机的az会覆盖磁盘的az属性; - 密码;     - <a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>; 。

            示例: jdc vm create-instances  --instance-spec {"":""}


optional arguments:
  -h, --help            show this help message and exit
  --region-id REGIONID  (string) 地域ID
  --instance-spec INSTANCESPEC
                        (instanceSpec) 描述云主机配置;
  --max-count MAXCOUNT  (int) 购买云主机的数量;取值范围:[1,100],默认为1。;
  --client-token CLIENTTOKEN
                        (string) 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。;
  --input-json INPUT_JSON
                        (json) 以json字符串或文件绝对路径形式作为输入参数。
                        字符串方式举例:--input-json '{"field":"value"}';
                        文件格式举例:--input-json file:///xxxx.json
  --headers HEADERS     (json) 用户自定义Header,举例:'{"x-jdcloud-security-token":"abc","test":"123"}'

帮助断字有bug

$ jdc oss put-bucket -h
usage: jdc oss put-bucket [-h] [--region-id REGIONID] --bucketname BUCKETNAME
                          [--input-json INPUT_JSON]

创建bucket; 。 示例: jdc oss put-bucket --bucketname xxx

optional arguments:
  -h, --help            show this help message and exit
  --region-id REGIONID  (string) Region ID,例如:cn-north-1
  --bucketname BUCKETNAME
                        (string) bucket名字,例如:test-bucket
  --input-json INPUT_JSON
                        (json) 以json字符串或文件绝对路径形式作�
                        ��输入参数。字符串方式举例:--input-json
                        '{"field":"value"}';文件格式举例:--input-json
                        file:///xxxx.json

jdc monitor describe-alarm-contacts 执行不成功,信息为:"message": "this api is not allowed [gw]",

环境信息:

MichaeldeMacBook-Pro-2:~ myang$ jdc configure show-current
================= cn-east-2-monitor ================
access_key:  	xx
secret_key:  	xx
region_id:  	cn-east-2
endpoint:  	monitor.cn-east-2.jdcloud-api.com
scheme:  	https
timeout:  	20

能成功执行describe-alarms-by-id。

MichaeldeMacBook-Pro-2:~ myang$  jdc monitor describe-alarms-by-id --alarm-id=alarm_22f24539-fcea-4722-96e8-7247c52df160
{
    "error": null, 
    "result": {
        "alarm": {
            "status": 1, 
            "calculation": "avg", 
            "resourceId": "i-0vo7w5zg54", 
            "metric": "cpu_util", 
            "enabled": 1, 
            "period": 5, 
            "createTime": "2018-12-26T11:40:22+08:00", 
            "times": 1, 
            "contactGroups": null, 
            "tag": "", 
            "contactPersons": [
                "piaojinnan"
            ], 
            "serviceCode": "vm", 
            "threshold": 20, 
            "region": "cn-east-2", 
            "operation": ">", 
            "noticePeriod": 24, 
            "id": "alarm_22f24539-fcea-4722-96e8-7247c52df160", 
            "metricName": "CPU使用率"
        }
    }, 
    "request_id": "bghjqivd0qtgbk8hpf8epe1qkkpo0a7v"
}

但执行如下命令报错:

MichaeldeMacBook-Pro-2:~ myang$  jdc monitor describe-alarm-contacts   --alarm-id=alarm_22f24539-fcea-4722-96e8-7247c52df160
{
    "error": {
        "status": "HTTP_FORBIDDEN", 
        "message": "this api is not allowed [gw]", 
        "code": 403
    }, 
    "result": null, 
    "request_id": "bghjr7qoi7o6hcs02u7u6hoveodpvpmh"
}

jdc 帮助里边的自命令建议排序

$ jdc -h
...
    xdata               数据计算服务API
    mps                 媒体处理 API
    cps                 云物理服务器
    httpdns             京东云httpdns OpenAPI接口
    rds                 云数据库RDS
    ams                 京东云视频云应用管理平台接口(仅对授权用户使用)
    jke                 jke
    jdfusion            JDFusion
    ipanti              京东云IP高防相关接口
    mongodb             京东云数据库MongoDB接口
    configure           使用该子命令配置CLI
    streambus           JDCLOUD 流数据总线 API
    function            京东云function接口
    ias                 JDCloud IAS
    cdn                 JDCLOUD CDN Operation And Query API
    baseanti            京东云DDoS基础防护相关接口
    kms                 JDCLOUD 密钥管理服务(Key Management Service) API
    live                Live API
    datastar            知客相关API
    redis               京东云缓存Redis接口
    nc                  原生容器
    monitor             JCLOUD MONITOR API
    iam                 IAM API
    disk                云硬盘API
    cr                  容器镜像仓库
    streamcomputer      JDCLOUD流计算API
    sop                 敏感操作保护
    clouddnsservice     京东云解析OpenAPI接口
    vm                  云主机
    iothub              JCLOUD IoT Hub API
    oss                 云存储API
    vpc                 京东云VPC

jdc configure不支持自定义profile name

# jdc configure add --profile libingtest --access-key myak --secret-key mysk --region-id cn-north-1 --endpoint www.jdcloud-api.com --scheme https --timeout 20
Configure successfully!
# cat ~/.jdc/config 
[libingtest]
access_key = myak
secret_key = mysk
region_id = cn-north-1
endpoint = www.jdcloud-api.com
scheme = https
timeout = 20

current里为default:

# cat ~/.jdc/current 
default
# jdc nc describe-containers 
Please use `jdc configure add` command to add cli configure first.

手动更改为自定义profile name:

# vi ~/.jdc/current
:s/default/libingtest/g

仍然失败:

# jdc nc describe-containers 
Please use `jdc configure add` command to add cli configure first.

不自定义profile:

# jdc configure add --access-key myak --secret-key mysk --region-id cn-north-1 --endpoint www.jdcloud-api.com --scheme https --timeout 20
Configure successfully!

成功:

# jdc nc describe-containers
{
    "error": null, 
    "result": {
        "totalCount": 0, 
        "containers": null
    }, 
    "request_id": "bcv8c6whjcj2t6rmpf6fd9qqmqd50nvf"
}

python3: does not work with newest cement

$ pip3 install -U cement
Requirement already up-to-date: cement in /usr/local/lib/python3.7/site-packages (3.0.2)
$ python3  `which jdc`
Traceback (most recent call last):
  File "/usr/local/bin/jdc", line 7, in <module>
    from jdcloud_cli.jdc import main
  File "/usr/local/lib/python3.7/site-packages/jdcloud_cli/jdc.py", line 19, in <module>
    from cement.core.foundation import CementApp
ImportError: cannot import name 'CementApp' from 'cement.core.foundation' (/usr/local/lib/python3.7/site-packages/cement/core/foundation.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.