usacloud

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

README

Usacloud

Build Status

This project is work in progress!!

Overview

🐰usacloud is New CLI client for the SakuraCloud.
That means "Unofficial + sacloud".
Written by Go(golang) from scratch.

Key Features

Install

RHEL / CentOS
curl -fsSL https://usacloud.b.sakurastorage.jp/repos/setup-yum.sh | sh
Ubuntu / debian / bash on Windows
curl -fsSL https://usacloud.b.sakurastorage.jp/repos/setup-apt.sh | sh
Others
Manual install

Download binary file from Release page.

[OPTION] Enable bash-completion

$ eval "`curl -s -L https://usacloud.b.sakurastorage.jp/contrib/completion/bash/usacloud`"
# or
$ curl -s -L https://usacloud.b.sakurastorage.jp/contrib/completion/bash/usacloud >> ~/.bashrc

Usage

Setting API Keys
    # set API Key to environment variables
    $ export SAKURACLOUD_ACCESS_TOKEN=[YOUR_API_TOKEN]
    $ export SAKURACLOUD_ACCESS_TOKEN_SECRET=[YOUR_API_SECRET]

    # set default zone
    $ export SAKURACLOUD_DEFAULT_ZONE=tk1v
Usage
NAME:
   usacloud - Unofficial 'sacloud' - CLI client of the SakuraCloud

USAGE:
   usacloud [global options] command [command options] [arguments...]

VERSION:
   0.0.1, build xxxxxxx

COMMANDS:
     archive                          A manage commands of Archive
     auto-backup                      A manage commands of AutoBackup
     bill                             A manage commands of Bill
     bridge                           A manage commands of Bridge
     disk                             A manage commands of Disk
     dns                              A manage commands of DNS
     gslb                             A manage commands of GSLB
     icon                             A manage commands of Icon
     interface                        A manage commands of Interface
     internet                         A manage commands of Internet
     iso-image                        A manage commands of ISOImage
     license                          A manage commands of License
     object-storage, ojs              A manage commands of ObjectStorage
     packet-filter                    A manage commands of PacketFilter
     price, public-price              A manage commands of Price
     product-disk, disk-plan          A manage commands of ProductDisk
     product-internet, internet-plan  A manage commands of ProductInternet
     product-license, license-info    A manage commands of ProductLicense
     product-server, server-plan      A manage commands of ProductServer
     region                           A manage commands of Region
     server                           A manage commands of Server
     simple-monitor                   A manage commands of SimpleMonitor
     ssh-key                          A manage commands of SSHKey
     startup-script, note             A manage commands of StartupScript
     switch                           A manage commands of Switch
     web-accel                        A manage commands of WebAccel
     zone                             A manage commands of Zone
     help, h                          Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --format value, --output-format value                    Output format[table/json/csv/tsv] (default: table)
   --secret value, --sakuracloud-access-token-secret value  API Secret of SakuraCloud (default: none) [$SAKURACLOUD_ACCESS_TOKEN_SECRET]
   --token value, --sakuracloud-access-token value          API Token of SakuraCloud (default: none) [$SAKURACLOUD_ACCESS_TOKEN]
   --trace, --sakuracloud-trace-mode                        Flag of SakuraCloud debug-mode (default: false) [$SAKURACLOUD_TRACE_MODE]
   --zone value, --sakuracloud-default-zone value           Target zone of SakuraCloud (default: tk1a) [$SAKURACLOUD_ZONE]
   --help, -h                                               show help (default: false)
   --version, -v                                            print the version (default: false)

COPYRIGHT:
   Copyright (C) 2017 Kazumichi Yamamoto.
Examples: List/Find/Search resource
    # list all switches
    $ usacloud switch ls 
   
    # list switches with name "example"
    $ usacloud switch ls --name example
    
    # list switches order by Name(asc) and ID(desc)
    $ usacloud switch ls --sort Name --sort -ID
    
    # list switches with limit=5 and offset=2
    $ usacloud switch ls --max 5 --from 2
    
Examples: Basic CRUD
    # create switch
    $ usacloud switch create --name "Example" --desc "description" --tags "Tag1" --tags "Tag2"
     
    # show switch detail
    $ usacloud switch read [SwitchID]
   
    # update switch
    $ usacloud switch update --name "Example-update" [SwitchID]
    
    # delete switch
    $ usacloud switch delete [SwitchID]
    
Examples: Create Server
    # Build server from Public Archive(CentOS)
    $ usacloud server build \
             --name server01 \               # ServerName
             --os-type centos \              # OSType(use PublicArchive)
             --hostname server01 \           # for DiskEdit parameter
             --password "$YOUR_PASSWORD" \   # for DiskEdit parameter
             --ssh-key-mode generate \       # generate ssh-key
             --ssh-key-name key01 \          # generate ssh-key name
             --disable-pw-auth               # disable password auth

    # generated private-key is saved to ~/.ssh/sacloud_pkey_[ServerID]
Examples: Connect to server by SSH
    # connect to server by ssh using generated private-key(Not supported on Windows)
    $ usacloud server ssh [ServerID]
    
    # exec command on SSH(no-pty, support Windows)
    $ usacloud server ssh-exec cat /etc/passwd
    
    # upload/download by SSH(like scp)
    $ usacloud server scp local-file.txt [ServerID]:/home/ubuntu/remote-file.txt # local to remote
    $ usacloud server scp [ServerID]:/home/ubuntu/remote-file.txt local-file.txt # remote to local
    $ usacloud server scp -r local-dir [ServerID]:/home/ubuntu/remote-dir        # recursive
Examples: Upload/Download iso-image or archive by FTPS
    # upload iso-image
    $ usacloud iso-image create --name example --iso-file example.iso
    
    # download archive(Only MyArchive can be downloaded)
    $ usacloud archive download --file-destination example.img [MyArchiveID]
    
Examples: Billing(download csv)
    # list bill
    $ usacloud bill list
    
    # download bill-detail by CSV
    $ usacloud bill csv [BillID]

Examples: Object Storage
    # set API key of Object Storage(per bucket)
    $ export SACLOUD_OJS_ACCESS_KEY_ID="[YOUR_BUCKET_ACCESS_KEY]"
    $ export SACLOUD_OJS_SECRET_ACCESS_KEY="[YOUR_BUCKET_SECRET_KEY]"
    
    # list objects
    $ usacloud object-storage ls 
    $ usacloud object-storage ls dir1/dir2

    # download object to local(download remote.txt)
    $ usacloud object-storage get remote.txt           # output to os.StdOut
    $ usacloud object-storage get remote.txt local.txt # save as local file
    $ usacloud object-storage get -r remote/ local/    # download recursive

    # upload object
    $ usacloud object-storage put local.txt remote.txt
    $ usacloud object-storage put local.txt dir1/dir2/remote.txt
    $ usacloud object-storage put -r local/ remote/    # upload recursive
    
    # delete object
    $ usacloud object-storage del remote.txt
    $ usacloud object-storage del -r remote/           # delete recursive

Examples: Web Accelerator(purge cache)
    # purge cache on web-accel
    $ usacloud web-accel purge https://example.com https://foobar.com

Development

Build(includes src generate)
$ make build
Generate each command source
$ make gen
$ # or
$ make gen-force
Add new resource or command

Edit under the define package.

License

usacloud Copyright (C) 2017 Kazumichi Yamamoto.

This project is published under Apache 2.0 License.

Author

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL