• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >云计算 > UcloudClient,icloud

UcloudClient,icloud

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含icloud,icloud官网,icloud登陆,www.icloud.com,icloud邮箱登陆等服务器相关知识,网友希望可以进行参考

UcloudClient,icloud


Ucloud Python SDK and Command-Line Tool

UcloudClient is a python sdk and a command-line client for Ucloud that brings
the command set for Uhost, Unet, Umon APIs together in a single shell with a
uniform command structure.
welcome to contribute to this tools.
feel free to contact me if you find any bugs or have good advices.

一、设计理念

这个项目包含python sdk 和 命令行工具,覆盖了UHOST,UNET,UMON这三大资源管理.SDK设计上也是按前面三大资源来做区分.
由于一直有研究openstack,发现它的命令行做得很不错,所以这里命令行则是参考了openstack 命令行工具的资源管理命令。

1.1 SDK方法归类

现在有host,net,mon三种资源:
基本上每种资源都有以下五个操作:

1.1.1 uhost具体方法:
['attach_disk', 'create', 'create_image', 'create_snapshot', 'delete_image', 'detach_disk', 'get', 'get_image', 'get_price', 'get_vnc', 'list_snapshot', 'modify_name', 'modify_tag', 'reboot', 'reinstall', 'reset_password', 'resize', 'start', 'stop', 'terminate']
1.1.2 unet具体方法:
'eip_bandwidth_modify', 'eip_bind', 'eip_create', 'eip_get', 'eip_price_get', 'eip_release', 'eip_unbind', 'eip_update', 'eip_weight_modify', 'sec_creat', 'sec_delete', 'sec_get', 'sec_grant', 'sec_reource_get', 'sec_update', 'vip_allocate', 'vip_get', 'vip_release']
1.1.3 umon具体方法:
['metric_get']
1.2 命令行操作分类:

在命令行下,也是按资源分类,然后再到资源操作,具体可以留意下面的命令行操作帮助。另外,命令行增加下面的功能:

二、SDK的安装与使用:

本项目已经打包好放到python社区的软件仓库里面了,可以通过pip或者easy_install 来进行安装。
本项目基于python2.7版本进行开发,同时也考虑python3的兼容,但没做python3的兼容测试。
本项目有了第三方的依赖包,安装时会自动进行依赖安装,依赖如下:

PrettyTable>=0.7,<0.8
six>=1.9.0

软件链接:https://pypi.python.org/pypi/ucloudclient

2.1 直接通过pip(或者easy_install)安装:
#pip install ucloudclient
2.2 SDK使用样例:
from ucloudclient.client import Client as uclient
client = uclient(base_url, public_key, private_key)
uhosts = client.uhost.get(region="us-west-01")
print uhosts

output:

{
    u'Action': u'DescribeUHostInstanceResponse',
    u'TotalCount': 1,
    u'RetCode': 0,
    u'UHostSet': [
        {
            u'Remark': u'',
            u'Tag': u'Default',
            u'Name': u'yan-1',
            u'State': u'Running',
            u'IPSet': [
                {
                    u'IP': u'10.11.1.126',
                    u'Type': u'Private'
                },
                {
                    u'IPId': u'eip-yci4qr',
                    u'IP': u'107.150.97.103',
                    u'Bandwidth': 2,
                    u'Type': u'International'
                }
            ],
            u'DiskSet': [
                {
                    u'Type': u'Boot',
                    u'Drive': u'/dev/sda',
                    u'DiskId': u'ce3b1751-d837-4949-9c73-29368b7fe820',
                    u'Size': 20
                }
            ],
            u'CPU': 1,
            u'OsName': u'Ubuntu14.0464\u4f4d',
            u'BasicImageId': u'uimage-nhwrqn',
            u'ImageId': u'ce3b1751-d837-4949-9c73-29368b7fe820',
            u'ExpireTime': 1429632272,
            u'UHostType': u'Normal',
            u'UHostId': u'uhost-4dmzop',
            u'NetworkState': u'Connected',
            u'ChargeType': u'Month',
            u'Memory': 2048,
            u'OsType': u'Linux',
            u'CreateTime': 1426953872,
            u'BasicImageName': u'Ubuntu14.0464\u4f4d'
        }
    ]
}

2.3 在linux环境下的命令行使用:

使用之前,先编辑下uclud.rc文件,然后导入环境变量,接下来的命令就不用输入你的认证信息了.

hyphendeMacBook-Air:ucloud-python-sdk hyphen$ cat ucloud.rc 
export UCLOUD_REGION="cn-north-03"
export UCLOUD_URL="https://api.ucloud.cn"
export UCLOUD_PUBKEY="asdf"
export UCLOUD_PRIKEY="asdf"
export PS1='[\u@\h \W(ucloud)]\$ '

hyphendeMacBook-Air:ucloud-python-sdk hyphen$ source ucloud.rc

命令帮助:

(.venv)hyphendeMacBook-Air:ucloud-python-sdk hyphen$ $ ucloud help

usage: ucloud [--debug] [--timing] <subcommand> ...

Command line interface for ucloud

Positional arguments:
  <subcommand>
    uhost-attach-disk        attach a disk to a host
    uhost-create             boot a host
    uhost-create-image       create an image from a given host
    uhost-create-snapshot    create a snapshot from a host
    uhost-delete-image       delete an image by id
    uhost-detach-disk        attach a disk to a host
    uhost-get-price          get price of given type of host/s
    uhost-get-vnc            get a host's vnc connection information
    uhost-image-list         list all images
    uhost-image-show         show image details
    uhost-list               list uhosts
    uhost-list-snapshot      list snapshots of an instance
    uhost-modify-name        modify a host's name
    uhost-modify-tag         modify a host's tag
    uhost-reboot             reboot a host
    uhost-reinstall          reinstall a host
    uhost-reset-password     reset a host's password
    uhost-resize             resize a host
    uhost-show               show detail of a host
    uhost-start              start a host
    uhost-stop               stop a host
    uhost-terminate          terminate a host
    umon-metric-get          get metic data
    unet-eip-bandwidth-modify
                             modify bandwidth of a given eip
    unet-eip-bind            bind ip to given resource
    unet-eip-create          create an eip
    unet-eip-list            list eip
    unet-eip-price-get       get eip price
    unet-eip-release         release an eip
    unet-eip-show            show eip details info
    unet-eip-unbind          unbind ip to given resource
    unet-eip-update          update an eip
    unet-eip-weight-modify   modify weight of a given eip
    unet-sec-create          create security group
    unet-sec-delete          delete given security group
    unet-sec-grant           grant given security group to specified resource
    unet-sec-list            get security group info.you can filte by reource
                             id or resource type.
    unet-sec-resource-get    get resource attached to given security group
    unet-sec-show            get security group details info.
    unet-sec-update          update security group
    unet-vip-allocate        allocate a vip
    unet-vip-list            list vip
    unet-vip-release         release a vip
    bash-completion          Prints all of the commands and options to stdout
                             so that the ucloud.bash_completion script doesn't
                             have to hard code them.
    help                     Display help about this program or one of its
                             subcommands.

Optional arguments:
  --debug                    Print debugging output
  --timing                   Print call timing info

See "ucloud help COMMAND" for help on a specific command.

命令样例:

hyphendeMacBook-Air:ucloud-python-sdk hyphen$ ucloud uhost-show uhost-4dmzop

+----------------+------------------------------------------------------------------+
| Property     
  


 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • UcloudClient,icloud

相关文章

  • 相似度计算map-reduce实现思路,计算map-reduce思路
  • Hadoop之——搭建ZooKeeper服务器集群,hadoopzookeeper
  • 家,我日夜思念的名字,我回来了,
  • request.getScheme()的使用方法,request.getscheme
  • CDH5 hadoop-hive-habse单机版配置,hadoophivehbase
  • OpenStack Magnum 项目简介,openstackmagnum
  • hadoop-common源码分析之-WritableUtils,hadoopcommon源码
  • Spark RDD API扩展开发(1),sparkrdd
  • CentOS 下面解决libvirt版本过低、升级冲突问题,centoslibvirt
  • 每日定时导入hive数据仓库的自动化脚本,hive数据仓库脚本

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • 云计算容器服务该何去何从,容器该何去何从
    • Hadoop 1.x的Shuffle源码分析之2,hadoopshuffle
    • hive sql,hive
    • MyEclipse字体和保护色设置,myeclipse保护色
    • Nodejs课堂笔记-第六课 在DynamoDB中如何创建表,nodejsdynamodb
    • 谈谈自己对随机森林(Random Forest)的一点理解以及代码注释~,randomforest
    • Hadoop之——Flume笔记,hadoopflume
    • CentOS6.5系统下Hadoop2.6.0完全分布式环境安装与配置信息介绍,centos6.5hadoop2.6
    • spark-OutOfMemory:GC overhead limit exceeded 解决,timelimitexceeded
    • Hadoop新版和旧版中InputSplit大小的区别,hadoopinputsplit

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有