Giter VIP home page Giter VIP logo

gandi.cli's Introduction

Gandi CLI

Build Status Coverage Status Pip Version Python Version

⚠️ DEPRECATION notice:

Hello,

We have decided not to continue to maintain the CLI project. The existing project will remain as-is. Anyone interested in taking over and forking the project can let us know and we can inform our users and/or link to it.

If you have any questions, please feel free to contact our team.

Sincerely,

The Gandi.net team


Use $ gandi to easily create and manage web resources from the command line.

  • $ gandi domain to buy and manage your domain names
  • $ gandi paas to create and deploy your web applications
  • $ gandi vm to spin up and upgrade your virtual machines
  • $ gandi certificate to manage your ssl certificates
  • $ gandi to list all available commands
  • Detailed examples
  • All commands

Table of contents

Requirements

  • A compatible operating system (Linux, BSD, Mac OS X/Darwin, Windows)
  • Python 2.7/3.4/3.5/3.6/3.7/3.8
  • openssl
  • openssh
  • git

Recommended tools

Installation

Install with pip and virtualenv

$ virtualenv /some/directory/gandi.cli
$ source /some/directory/gandi.cli/bin/activate
$ pip install gandi.cli

Build from source

$ cd /path/to/the/repository
$ python setup.py install --user

From the Debian package

$ ln -sf packages/debian debian && debuild -us -uc -b && echo "Bisou"

Getting started

Using our classic (V4) website:

  1. To get started, you can create a free Gandi account and get your Gandi Handle
  2. Generate your Production API Token from the account admin section
  3. You may also want to top-up your prepaid account
  4. To manipulate VMs, you also need to purchase credits (you can use funds from your prepaid account)

Using our latest (V5) website:

  1. To get started, you can create a free Gandi account and get your Gandi username
  2. Generate your Production API Token from within the account Security section
  3. You may also want to top-up your prepaid account
  4. To manipulate VMs, you currently need to follow above steps to create an account on our classic (V4) website.

Then run the setup

$ gandi setup
> API Key: x134z5x4c5c          # copy-paste your api key
> Environment [production] :    # press enter for Production, the default
> SSH key [~/.ssh/id_rsa.pub] : # your SSH public key for hosting instances and servers

See the Advanced Usage section for more details on configuration.

Use cases

Registering a Domain Name

Gandi has been a domain name registrar since 1999. The oldest in France and one of the world's leading, Gandi is recognized for its No Bullshit™ trademark and approach to domain names.

You can now buy and manage domains in any of the 500+ TLD's that Gandi offers from the command line.

Learn more about Gandi Domains on the website.

1. Buy a domain using the interactive prompt

$ gandi domain create
> Domain: example.com      # enter the domain name here
> example.com is available
> Duration [1] : 1         # enter the duration in years

This will create a domain and use your default information for Ownership, Admin, Technical and Billing info.

2. Buy a domain in one line

$ gandi domain create --domain example.com --duration 1

3. Buy a domain with custom contacts

$ gandi domain create --domain example.com --duration 1 --owner XYZ123-GANDI --admin XYZ123-GANDI --tech XYZ123-GANDI --bill XYZ123-GANDI

You can use the information of Gandi handles associated to Contacts in your account to setup Owner, Admin, Technical and Billing info.

3. List your domains

$ gandi domain list

4. Get information about a domain

$ gandi domain info example.com

5. Manage NS records for your domains

Create a new record
$ gandi record create example.com --name www --type A --value 127.0.0.1

Add a new record to the domain's current zone file and activate it.

List your records
$ gandi record list example.com

List a domain's zone file records. You can use the --format parameter to change the output format to text or json.

Update one record
$ gandi record update example.com --record "@ 3600 IN A 127.0.0.1" --new-record "@ 3600 IN A 0.0.0.0"

This command is useful to update only one record at the time. The pattern to use is name TTL CLASS TYPE value.

You can easily check or copy-paste the values you need to replace using the --format text parameter:

$ gandi record list example.com --format text
Update many records
$ gandi record list example.com --format text > file.zone

Use this command to extract your zone records into a file called file.zone (or something else).

Simply edit the file to your liking and then update the entire zone file with it.

$ gandi record update example.com -f file.zone
Delete records
$ gandi record delete example.com --value 127.0.0.1

Delete all records that match the given parameters from a domain's zone file. In this example, if there were many records with '127.0.0.1' as their value, all of them would be deleted.

Creating a Virtual Machine

Gandi Server offers powerful Xen- and Linux-based virtual machines since 2007.

Virtual machines can be configured and upgraded on the fly to your liking. For example, you can start with 1GB of RAM, and run a command to add 2GB of RAM and 2 CPUs without even having to restart it.

Gandi Server measures consumption by the hour and uses a prepaid credit system. To learn more, check out the Gandi Server website.

1. Create and access a VM

$ gandi vm create
* root user will be created.
* SSH key authorization will be used.
* No password supplied for vm (required to enable emergency web console access).
* Configuration used: 1 cores, 256Mb memory, ip v4+v6, image Debian 8, hostname: temp1415183684, datacenter: LU

Create a virtual machine with the default configuration and a random hostname.

2. Upgrade a VM

$ gandi vm update temp1415183684 --memory 2048 --cores 2

Set the VM's RAM to 2GB and add a CPU core on the fly.

3. Create a custom VM

$ gandi vm create --datacenter US --hostname docker --cores 2 --memory 3072 --size 10240 --image "Ubuntu 14.04 64 bits LTS (HVM)" --run "curl -sSL https://get.docker.com/ubuntu/ | sh"
* root user will be created.
* SSH key authorization will be used.
* No password supplied for vm (required to enable emergency web console access).
* Configuration used: 2 cores, 3072Mb memory, ip v4+v6, image Ubuntu 14.04 64 bits LTS, hostname: docker, datacenter: LU

This command will setup the above VM, and install docker by running curl -sSL https://get.docker.com/ubuntu/ | sh after creation.

4. View your resources

$ gandi vm list

5. Get all the details about a VM

$ gandi vm info docker

Deploying a Web Application with Simple Hosting

Gandi Simple Hosting is a PaaS (Platform as a Service) offering fast code deployment and easy scaling, powering over 50,000 apps since its inception in 2012.

Instances can run apps in 4 languages (PHP, Python, Node.js and Ruby) along with one of 3 popular databases (MySQL, PostgreSQL and MongoDB) and operate on a managed platform with built-in http caching.

Plans cover all scales, from small to world-class projects. Check out the website for more information.

1. Create a Simple Hosting instance

$ gandi paas create --name myapp --type nodejspgsql --size S --datacenter FR --duration 1

2. Attach and push to your instance's git repository

Simple Hosting offers two "modes": the App mode, where an instance offers a single git repository (default.git) and the Sites mode, where you can have multiple git repositories per instance (one for each VHOST, for example www.myapp.com.git).

Node.js, Python and Ruby instances run in App mode, whereas PHP instances run in Sites mode by default. Note: If you create a wildcard VHOST for your PHP instance, the App mode will be activated.

Assuming you have local directory called app where you have placed your code base, you can use the following commands to create a git remote (called "gandi" by default) and push your code.

$ cd app
$ gandi paas attach myapp # App mode
$ gandi paas attach myapp --vhost www.myapp.com # Sites mode
$ git push gandi master

3. Deploy your code

Still inside the app folder, you can use the following command to start the deploy process, which will checkout your code, install dependencies and launch (or relaunch) the app process:

$ gandi deploy

Creating a SSL Certificate

Gandi SSL offers a range of SSL certificates to help you secure your projects.

You can order, obtain, update and revoke your certificates from the command line.

1. Find the right plan for you

$ gandi certificate plans

Our Standard, Pro and Business plans offer different validation methods and guarantees. Each plan supports all or some of these types of certificates: single address, wildcard and/or multiple subdomains.

To discover our offering and find the right certificate for your project, compare our plans and try our simulator.

Gandi CLI can choose the right certificate type for you depending on the number of domains (altnames) you supply at creation time. You only need to set it if you plan on adding more domains to the certificate in the future.

2. Create the Certificate

WARNING: This command is billable.

To request a certificate, you need to use a private key to generate and sign a CSR (Certificate Signing Request) that will be supplied to Gandi.

The create command will take care of this for you if you don't have them already, or you can supply your CSR directly.

Check out the examples below or our wiki for more information on how SSL certificates work.

To create a single domain Standard certificate:

$ gandi certificate create --cn "domain.tld"

For a wildcard Standard certificate:

$ gandi certificate create --cn "*.domain.tld"

For a multi domain Standard certificate:

$ gandi certificate create --cn "*.domain.tld" --altnames "host1.domain.tld" --altnames "host2.domain.tld"

You can also specify a plan type. For example, for a single domain Business certificate:

$ gandi certificate create --cn "domain.tld" --type "bus"

If you have a CSR (you can give the CSR content or the path):

$ gandi certificate create --csr /path/to/csr/file

3. Follow the Certificate create operation

$ gandi certificate follow <operation_id>

4. Get the Certificate

As soon as the operation is DONE, you can export the certificate.

$ gandi certificate export "domain.tld"

You can also retrieve intermediate certificates if needed.

$ gandi certificate export "domain.tld" --intermediate

Find information on how to use your certificate with different servers on our wiki.

Adding a Web Application vhost with SSL

Gandi allows you to associate a certificate with your vhost.

1. You already have the matching certificate at Gandi

Just create the vhost giving it the private key used to generate that certificate.

$ gandi vhost create domain.tld --paas "PaasName" \
    --ssl --private-key "domain.tld.key"

#### 2. You have the matching certificate but not at Gandi (or in another account)

Declare the hosted certificate.

$ gandi certstore create --pk "domain.tld.key" --crt "domain.tld.crt"

And then create the vhost.

$ gandi vhost create domain.tld --paas "PaasName" --ssl

3. You don't have any certificates but you plan to get one at Gandi

Create the certificate.

$ gandi certificate create --cn "domain.tld.key" --type std

And then create the vhost.

$ gandi vhost create domain.tld --paas "PaasName" \
    --ssl --private-key "domain.tld.key"

Creating a private VLAN

You can use Gandi CLI to create and setup your private VLANs. For more detailed information on how VLANs and networking in general works at Gandi, please check out our resources:

Create a VLAN

$ gandi vlan create --name my-vlan-in-lu --datacenter LU \
--subnet "192.168.1.0/24" --gateway 192.168.1.1

To create a VLAN you need to determine its name and datacenter.

You can also set the subnet at creation time, or a default subnet will be chosen for you. The gateway setting is also optional and you can update both of these settings at any moment.

$ gandi vlan update my-vlan-in-lu --gateway 192.168.1.254

Attach an existing VM to a VLAN

To add an existing VM to a VLAN, you can create a private network interface and attach it to the VM.

$ gandi ip create --vlan my-vlan-in-lu --attach my-existing-vm --ip 192.168.1.254

If you don't specify the IP you want to use, one will be chosen for you from the VLAN's subnet.

Create a "Private VM"

In fact there's no such thing as a "Private VM", but you can create a VM and only attach a private interface to it.

$ gandi vm create --hostname my-private-vm --vlan my-vlan-in-lu --ip 192.168.1.2

Please note that a private VM cannot be accessed through the emergency console. You'll need a public VM that also has a private interface on the same VLAN to gain access.

More options

$ gandi vlan --help

Use the --help flag for more VLAN management options.

Advanced Usage

All Commands

To list all available commands, type $ gandi --help

For extended instructions, check out the man page.

Build manpage

Install python-docutils and run:

$ rst2man --no-generator gandicli.man.rst > gandi.1.man

Then to read the manpage:

$ man ./gandi.1.man

Configuration

Run $ gandi setup to configure your settings (see Getting started)

Use $ gandi config to set and edit custom variables. The default variables are:

  • sshkey # path to your public ssh key
  • api.host # the URL of the API endpoint to use (i.e. OTE or Production)
  • api.key # the relevant API key for the chosen endpoint

Contributing

We <3 contributions! See CONTRIBUTING.md for contribution guidelines.

You can check the contributors list.

License / Copying

Copyright © 2014-2018 Gandi S.A.S

Gandi CLI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Gandi CLI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Gandi CLI. If not, see http://www.gnu.org/licenses/gpl.txt.

gandi.cli's People

Contributors

aamamou avatar aegiap avatar alxxxla avatar beorn- avatar demik avatar djoproject avatar dzen avatar engerim42 avatar flooweb214 avatar gdchamal avatar jpetazzo avatar jsonn avatar julienpalard avatar kalou avatar klnikita avatar koobs avatar mardiros avatar nilsthebest avatar ptitoliv avatar rdoursenaud avatar revi avatar romuald avatar sayoun avatar themimitoof avatar wdauchy avatar webcracy avatar yanndinendal avatar zaurky 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

gandi.cli's Issues

`gandi mail delete` fails

Deleting a mailbox fails with TypeError: delete() takes exactly 4 arguments (3 given):

$ gandi mail delete --help
Usage: gandi mail [OPTIONS] [email protected]

  Delete a mailbox.

Options:
  -f, --force  This is a dangerous option that will cause CLI to continue
               without prompting. (default=False).
  --help       Show this message and exit.
$ gandi mail delete [email protected]
Traceback (most recent call last):
  File "/usr/local/bin/gandi", line 9, in <module>
    load_entry_point('gandi.cli==0.11', 'console_scripts', 'gandi')()
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gandi/cli/__main__.py", line 8, in main
    cli(obj={})
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gandi/cli/core/cli.py", line 168, in invoke
    click.Group.invoke(self, ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
TypeError: delete() takes exactly 4 arguments (3 given)

Maybe a parsing issue in def delete?

Debian packaging needs unknown python debs

The Debian package builds cleanly on a Debian 7 but depends on 2 non-existing Debian packages:

  • python-click
  • python-yaml

Theses dependencies do not exist on my Debian 7 installation.

Regards

Gandi webacc delete --backend throws an error with --port option

When executing the following:

gandi webacc delete --backend 2001:4b98:dc2:43:216:3eff:fe2c:xxxx --port 80

I encountered the following error:

Traceback (most recent call last):
  File "/home/julien/Projects/gandi/15-ans/venv/bin/gandi", line 9, in <module>
    load_entry_point('gandi.cli==0.12', 'console_scripts', 'gandi')()
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/gandi.cli-0.12-py2.7.egg/gandi/cli/__main__.py", line 8, in main
    cli(obj={})
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/gandi.cli-0.12-py2.7.egg/gandi/cli/core/cli.py", line 168, in invoke
    click.Group.invoke(self, ctx)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/gandi.cli-0.12-py2.7.egg/gandi/cli/commands/webacc.py", line 183, in delete
    result = gandi.webacc.backend_remove(backend)
  File "/home/julien/Projects/gandi/15-ans/venv/local/lib/python2.7/site-packages/gandi.cli-0.12-py2.7.egg/gandi/cli/modules/webacc.py", line 131, in backend_remove
    (backend['ip'], backend['port']))
KeyError: 'port'

Error on install

I get an error after running:

$ apt-get install python-pip
$ pip install virtualenv
$ git clone https://github.com/Gandi/gandi.cli.git
$ virtualenv gandi.cli
$ pip install gandi.cli

The error is:

    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
    ext/_yaml.c:8:22: fatal error: pyconfig.h: No such file or directory
     #include "pyconfig.h"
                        ^
    compilation terminated.

Specify a custom config file

The values in ~/.config/gandi/config.yaml get overwritten (without warning) every time a command such as gandi create vm is run.
It should be possible to specify a custom config file when running such commands, to prevent unexpected changes to config.yaml and to allow easier context switching.

A better way might be, for example:

  • gandi create vm --config docker should look for ~/.config/gandi/docker.yaml, or
  • gandi create vm --config ~/path/to/test.yaml.

Method to set the reverse of an public IP

It would be useful to have a method in the ip namespace to set the reverse of a public IPv6 or IPv4.
Something like:

gandi ip update --reverse ns.chausette.org 1.2.3.4

As reverse name is the only element to modify in the ip object, the update method should have only one options (aside the mandatory --help).

Use a custom user with SSH

$gandi vm ssh <resource> currently uses the root user by default.

It would be nice to have an option to choose what user to login with, such as -u <username> or similar.

WDYT?

Add reverse name information in the IP information.

The list method for ip allow user to get the reverse name with the option --reverse, but the info method does not provide the information. I think the info output should have the the reverse name:

$ gandi ip info 1.2.3.4
ip         : 1.2.3.4
reverse    : ns.chaussette.org <---
state      : created
type       : public
vm         : server01
datacenter : LU

Better handle the error on disk attachment.

I tried to attach a disk to a VM and as the VM was in a bad state, the operation failed with the step error.

$ gandi disk attach sys_1425568864 myvm
Are you sure to attach disk 'sys_1425568864' to vm 'myvm' [y/N]: y
Attaching your disk(s).
Progress: [##############################################-----------------------] 66.67%  
00:00:19  Usage: gandi disk [OPTIONS] DISK VM

Error: step ERROR unknown, exiting

We should avoid printing a usage message in case of an operation in error.

More information:

$ cat /etc/debian_version 
8.0
$ gandi --version
Gandi CLI 0.12
$ dpkg -l gandicli
||/ Name                   Version          Architecture     Description
ii  gandicli               0.12             all              commandline client for Gandi.net

Unable to change vm_max_memory

We're currently unable to change a VM maximum memory limit

Meaning that creating a VM with the default 256Mib, we're unable to change it's memory past 2048Mib

We need:

  • an option to change the vm_max_memory
  • probably a interactive warning stating that this will reboot the VM (are you sure?)
  • probably an automatic option to upgrade it when updating memory beyond the current vm_max_memory

[Misfeature] Allow *not* ssh'ing after gandi vm create

While automatically connecting to the vm may seem useful for some use cases, one may want to execute some more commands before connecting (eg. creating and attaching some disks, adding zone entries…).

The connection should be optional or a parameter exposed to disable the automatic connection.

gandi paas create --vhosts causes "fatal: repository not found"

$ gandi paas create --name squirrels --type phpmysql --vhosts squirrels.gandi.xyz
Password:
Repeat for confirmation:
Creating your PaaS instance.
Progress: [############################################################################] 100.00%  00:01:38
Your PaaS instance squirrels has been created.
Cloning into 'squirrels.gandi.xyz'...
fatal: repository not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
An error has occured during git clone of instance.

gandi paas --help says --vhosts is supposed to be followed by a "List* of virtual hosts to be linked to the instance" so I don't know what a git error is doing there.

  • it wants a list, but the help text says --vhosts TEXT so it's not clear if the expected input is www.example.com or "www.example.com or ["www.example.com"] or "[www.example.com]" or what. I tried each of those formats and got the same error each time (the instance is still created, however).

Certificate Improvements

I think this CLI is a great way to increase your popularity among developers and tech-savvy people.

  • Add documentation on support for certificates (I didn't think it existed at first).
  • For extra usefulness, add a friendly, optional wrapper around the openssl command. So that a single command could generate the key (or use existing), create csr and order a certificate. All with a sane interface.

Updated to reflect support for certificates, at first I didn't know support existed (thanks soulshake).

explicit documentation or improve click usage

My fault. While moving to click, did not realize we need to call the docker client this way:
gandi docker -- run -i -t debian bash

To avoid click option parsing errors.
Still unclear to me if we have a clean way to support this with click while still understanding --vm, but if not I should at least update the documentation.

Add position of the disk when attaching it to a VM

TL;DR: add a param position in gandi disk attach which could be used in the hosting.vm.disk_attach API method.

The public API documentation for the option of the hosting.vm.disk_attach optional dict:
http://doc.rpc.gandi.net/hosting/reference_vm.html#VMDiskAttachOptions

Use case:
As a IaaS user, I am using a virtual machine and need to use another system disk (aka virtual disk with an associated kernel). I need to detach the current system disk and then attach the new disk to the VM. The new disk need to be attached in position 0 or I will need to rewrite the kernel boot param.

On my computer, the current help is:

$ gandi disk attach --help
Usage: gandi disk [OPTIONS] DISK VM

  Attach disk to vm.

  disk can be a disk name, or ID vm can be a vm name, or ID

Options:
  --bg, --background  Run command in background mode (default=False).
  -f, --force         This is a dangerous option that will cause CLI to
                      continue without prompting. (default=False).
  --help              Show this message and exit.

We could add a -p --position value : On which position do you want to attach the disk to the VM.

Bonus point if we could have the access method as a parameter of gandi disk attach also. Something like : -a --access ro|rw : Access method to the disk, ro is for read-only, rw is for read and write.

Context:

$ gandi --version
Gandi CLI 0.12
$ cat /etc/debian_version 
8.0
$ dpkg -l gandicli
||/ Name                   Version          Architecture
ii  gandicli               0.12             all

Add interfaces/vlan management

I just fell in love with your great API but when i wanted to add my newly created VM to my vlan... i didn't find a way :(

gandi domain create: Abort gracefully if domain is not available

Problems with gandi domain create:

  • Warning: Invoked legacy parameter callback message should not appear
  • Should exit cleanly if domain is not available
$ gandi domain create
Domain: squirrel.li
/usr/local/lib/python2.7/site-packages/click/core.py:767: Warning: Invoked legacy parameter callback "<function check_domain_available at 0x102282b18>".  The new signature for such callbacks starting with click 2.0 is (ctx, param, value).
  value, args = param.handle_parse_result(ctx, opts, args)
squirrel.li is not available
Duration [1]:
Usage: gandi domain [OPTIONS]

Error: Gandi API has returned an error: <Fault 150000: 'Error on object : OBJECT_APPLICATION (CAUSE_UNKNOWN) [Internal Server Error]'>

No configuration found, please use 'gandi setup' command

Hi,

I installed gandi.cli with pip and virtualenv on Mac OS X Yosemite (Beta 4). Then, i run through setup configuring, ote and production API Key.

Unfortunately, i got a "No configuration found" when i try to execute a cli command (i.e. gandi vm create)

Could you please help?
Thanks
Jérôme.

Add the FQDN host to add in your zone file in `paas info` and `vhost info` output

I have created a new vhost on a paas instance and choose --alter-zone to overide and activate my zone file. I want to start working on my website but I don't found the host to indicate in /etc/hosts with paas info and vhost info as it's the case for 'console' or 'git_server'.

It seems that the Gandi API don't give this information in api.paas.info, 'api.paas.list,api.paas.vhost.listorapi.paas.vhost.info`.

Security weakness in config file creation

I suggest that config.yaml (which contains the API key) should be created without read access for the world, whatever the user umask is. Yes, the directory is protected but I prefer to have belts and suspenders.

change default settings behaviour

I really like the short form of vm create - especially for my quick-vm-needs.
however, I believe we should refine the default value overriding/saving methods.

My default datacenter is set to US for latency reasons. If I need a temporary LU vm, I'll use the --datacenter switch. I'll probably forget to switch it back to US the next time.

I'd suggest:

  • continue saving a default value for some parameters when they do not have one
  • stop overriding default values, if the customer uses a --switch it is probably an exception
  • maybe adding a --save switch, or providing a more friendly gandi config command (especially to output current default values)

Add a filter to list virtual machines or disk per datacenter

summary

I would like a new parameter to gandi vm list command to get only the subset of VM running in a specific datacenter. Same thing for the gandi disk list.

current command

$ gandi vm list --help
Usage: gandi vm [OPTIONS]

  List virtual machines.

Options:
  --state TEXT     Filter results by state.
  --id             Display ids.
  --limit INTEGER  Limit number of results.  [default: 100]
  --help           Show this message and exit.

possible solution

$ gandi vm list --help
Usage: gandi vm [OPTIONS]

  List virtual machines.

Options:
  --state TEXT     Filter results by state.
  --id             Display ids.
  --limit INTEGER  Limit number of results.  [default: 100]
  --datacenter [FR|US|LU]  Filter by datacenter.
  --help           Show this message and exit.

more information

$ cat /etc/debian_version 
8.0
$ gandi --version
Gandi CLI 0.12
$ dpkg -l gandicli
||/ Name                   Version          Architecture     Description
ii  gandicli               0.12             all              commandline client for Gandi.net

Add kernel info on a gandi disk info.

In the 'disk' namespace, the info method does not show the potential kernel which could be associated with the virtual disk. Could we add it ?

$ gandi disk update --kernel "3.10-x86_64" sys_chaussette
Updating your disk.
Progress: [#############################] 100.00% 00:00:16

$ gandi disk info sys_chaussette
name : sys_chaussette
state : created
size : 3072
type : data
id : 1988888999999999
datacenter: FR
vm : chaussette

Warning on VM creation without password

When $ gandi vm create is ran without a password, we get this message:

/!\ Please be aware that you did not provide a password, some services like console will not be able to work.

It might be nicer instead to display the VM's config and other details such as:

  • root and admin users will be created
  • SSH key authorization will be used
  • No password was supplied (Warning: emergency console access from the web interface is disabled)

WDYT?

Install error with pip & virtualenv

System

OS OSX 10.10 (14A343f)
Python 2.7.6 system
Easy Install 3.6
Virtualenv 1.11.6
pip pip 1.5.6 from /Users/thibault/gandi/gandi.cli/lib/python2.7/site-packages (python 2.7)

Error

when I try to run the command pip install gandi.cli I got this output

Command /Users/thibault/gandi/gandi.cli/bin/python -c "import setuptools, tokenize;__file__='/Users/thibault/gandi/gandi.cli/build/pyyaml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/w4/xvgx5h5523j0sbjf17pfm4h00000gn/T/pip-jo4QW4-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/thibault/gandi/gandi.cli/include/site/python2.7 failed with error code 1 in /Users/thibault/gandi/gandi.cli/build/pyyaml
Storing debug log for failure in /Users/thibault/.pip/pip.log

Log file

complete terminal outpout
pip.log

Custom output for "info" commands

This applies to all namespaces with some info command (gandi vm info, gandi paas info, etc).

It would be very useful if users could 1) request only specific elements, and/or 2) get output in a structured format.

1) request only specific elements

Currently, I can only do this:

gandi paas info shine
name      : shine
type      : pythonmysql
size      : s
console   : [email protected]
ftp_server: sftp.dc1.gpaas.net
git_server: git.dc1.gpaas.net
vhost     : f75eccb375.test-url.ws
vhost     : shine.soulshake.net
datacenter: US

and I would like to be able to do something like this:

$ gandi paas info shine --vhost
vhost     : f75eccb375.test-url.ws
vhost     : shine.soulshake.net

2) get output in a structured format:

Currently, the output of a gandi vm info command, for example:

$ gandi vm info irc
hostname      : irc
state         : running
cores         : 1
memory        : 256
console       : 1
datacenter    : US
bandwidth     : 102400.0
ip4           : 173.246.105.94
ip6           : 2604:3400:dc1:43:216:3eff:febb:3cc0

label         : Ubuntu 14.04 64 bits
kernel_version: 3.10-x86_64
name          : sys_irc
size          : 3072

If I want to use the CLI in my scripts, I currently need to do some grep/cut/sed acrobatics, e.g.:
$ gandi vm info $vm_hostname | grep ^ip4 | cut -d: -f2 | sed "s/^ //"

It would be great if users could easily get this output into a Python dict (something like gandi vm info irc --json?), for example.

My dream is to be able to easily do things like this:

print(irc_info['ip4'])
173.246.105.94

Attach and detach disks to/from vm

This will require checking issue #22 for a coherent interface
There's a little work to do for a clean interaction between commands/(vm,disk), modules, and dependencies.

DynDNS-like

Hi

Currently, we can only add a new DNS record. Being able to remove and update them would permit to easily and dynamically manage an entry, like for a laptop. Is it planned ?

Add user validation on non refundable >X€ operations

Playing with the certificate command, I just spent €10 to buy a certificate for pouet.com

While it's not very disturbing for a temporary VM (a few cents if you delete it immediately) I believe we should add confirmation messages for higher cost operations. Pricing information would be a must but might be a little more difficult to implement right now.

Root SSH access is not available in all images

In some OS images, the SSH server is setup to only allow root connection with SSH public key. When a user create a VM (gandi vm create ...) without SSH public key but with a login, the root account is setup with this password, but the user cannot connect to the VM using SSH. Moreover the gandi vm create ... command cannot automatically SSH to the VM.

If the user use the --login and no --sshkey params in the CLI command, we could try to auto-SSH the VM after the creation of the VM with the login as parameter instead of using 'root' in all cases.

More charming hostname generator

At present, names are automatically generated for VMs and instances in the following format:

temp1415214477

Would any functionality be lost if we were to use a more creative naming scheme?
e.g. gandi vm delete temp\* ?

For inspiration, see names-generator.go.

Importing CLI as a module

I would like to leverage the default values, configuration files, existing benefits of our CLI and use it or parts of it as a python module.

My main frustration here is that most convenient functions (default values and configuration especially) are tightly coupled to the command/ module and its setup by the cores.

I don't have any idea right now. How can we achieve something usable there ?

Add more information about domain (date)

It would be nice if the domain information method will show the associated date : creation, renew, changed. Something like:

gandi domain info choucroute.net
owner       : AA1-GANDI
admin       : BB2-GANDI
bill        : CC3-GANDI
tech        : DD4-GANDI
fqdn        : choucroute.net
nameservers : ['a.dns.gandi.net', 'b.dns.gandi.net', 'c.dns.gandi.net']
services    : ['gandidns']
zone_id     : 424242
tags        : aliment
expires    : 2016-04-30 21:59:59
created    : 2006-04-07 14:57:34
changed   : 2015-03-30 22:07:01

Context:

$ gandi --version
Gandi CLI 0.12
$ cat /etc/debian_version 
8.0

Set a default path for git repos when a `git clone` is made

Add a 'default_path' in the config.yaml to clone repository into the directory indicated. When I used gandi vhost create if you forgot to change directory, the folder is created in the current directory. I would like have a default path which all repository are clone to use this command and change directory automaticaly after that :

[12-01-15 - 6:25:24] [alex@badam] :/home/alex 
$ gandi vhost create --vhost courgette.bhz.im --paas test
Creating a new vhost.
Your vhost courgette.bhz.im has been created.
Your have set /home/alex/dev/paas/ as the default git directory, would you like to clone this vhost in this repo ? [y/N] y
Clonage dans '/home/alex/dev/paas/courgette.bhz.im'...
warning: Vous semblez avoir cloné un dépôt vide.
Vérification de la connectivité... fait.
[12-01-15 - 6:26:16] [alex@badam] :/home/alex/dev/paas.courgette.bhz.im/
$ 

gandi.cli does not run on Mac OS 10.9.4

$ gandi --help
Traceback (most recent call last):
  File "/usr/local/bin/gandi", line 5, in <module>
from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: click<=3.1

Here is some PIP information:

$ pip freeze | grep click
click==3.1

[Feature request] Ability to delete a list of IP addresses

I tried to delete a bunch of private IP addresses by running

gandi ip delete --force $(gandi ip list --detached | awk '/ip/ {print $3}')

and encounter the following error:

Error: Got unexpected extra arguments (192.168.1.4 192.168.1.5 )

It would be great to be able to delete IP addresses by batch, don't you think ?

To bypass this limitation, I temporary use a bash for loop:

for i in $(gandi ip list --detached | awk '/ip/ {print $3}') ; do gandi ip delete --force $i ; done

Here is my current configuration

$ uname -a
Linux XXXXX 3.14-2-amd64 #1 SMP Debian 3.14.15-2 (2014-08-09) x86_64 GNU/Linux

$ gandi --version
Gandi CLI 0.12

Copyright: © 2014-2015 Gandi S.A.S.
License: GPL-3

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.