Coder Social home page Coder Social logo

contrail-api-cli's Introduction

Build Status Doc Status Coverage Status Join the chat at https://gitter.im/eonpatapon/contrail-api-cli

contrail-api-cli

Simple CLI program to browse Contrail API server

Installation

Python virtualenv

You can install contrail-api-cli inside a python virtualenv. First create the virtualenv and install contrail-api-cli with pip.

$ virtualenv contrail-api-cli-venv
$ source contrail-api-cli-venv/bin/activate
(contrail-api-cli-venv) $ pip install contrail-api-cli

Debian package

First you need to satisfy dependencies missing in Ubuntu Trusty. You can install them from newer distribution or from backports (eg. tcpcloud/extra)

  • python-pathlib
  • python-prompt-toolkit
  • python-wcwidth

When dependencies are satisfied, you can build package:

dpkg-buildpackage -uc -us

Then upload into your repository or install directly:

dpkg -i ../contrail-api-cli_*.deb

Usage

Run contrail-api-cli shell to start the cli. Use the -h option to see all supported options. By default it will try to connect to localhost on port 8082 with no authentication.

Type help to get the list of all available commands.

Here is a screen cast to see contrail-api-cli in action:

asciicast

Authentication

contrail-api-cli supports keystone (v2, v3) and Basic HTTP authentication mechanisms.

When running the contrail API server with --auth keystone you can login on port 8082 with keystone auth and on port 8095 with basic http auth.

Basic HTTP auth

contrail-api-cli --host localhost:8095 --os-auth-plugin http --os-username admin --os-password contrail123 shell

The username and password can be sourced from the environment variables OS_USERNAME, OS_PASSWORD.

The auth plugin default to http unless OS_AUTH_PLUGIN is set.

Kerberos auth

The easiest way is to source your openstack openrc file and run

contrail-api-cli --os-auth-plugin [v2password|v3password] shell

See contrail-api-cli --os-auth-plugin [v2password|v3password] --help for all options.

What if

virtualenv is missing

Install virtualenv

# pip install virtualenv

pip is missing

Install pip

# easy_install pip

contrail-api-cli's People

Contributors

adrian avatar eonpatapon avatar fdebonneval avatar fpytloun avatar gitter-badger avatar m-kostrzewa avatar

Stargazers

 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

contrail-api-cli's Issues

ImportError: cannot import name create_eventloop

after installation can't run it:
got these errors:

$ contrail-api-cli shell
Traceback (most recent call last):
  File "/home/pings/contrail-api-cli-venv/bin/contrail-api-cli", line 7, in <module>
    from contrail_api_cli.main import main
  File "/home/pings/contrail-api-cli-venv/local/lib/python2.7/site-packages/contrail_api_cli/main.py", line 12, in <module>
    from .manager import CommandManager
  File "/home/pings/contrail-api-cli-venv/local/lib/python2.7/site-packages/contrail_api_cli/manager.py", line 10, in <module>
    from .utils import Singleton
  File "/home/pings/contrail-api-cli-venv/local/lib/python2.7/site-packages/contrail_api_cli/utils.py", line 20, in <module>
    from prompt_toolkit.shortcuts import prompt, create_eventloop
ImportError: cannot import name create_eventloop

Installation Error on CentOS

Hello: I'm not sure this is the correct forum to raise an issue regarding installation errors

When following the install instructions on a CentOS machine, I get the following errors.

...
Download error on https://pypi.python.org/simple/pbr/: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:579) -- Some packages may not be found!
...
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pbr>=2.0.0')
...

Can anybody provide guidance?
Also, does this require a specific version of Python? My environment is defaulting to python 2.7.

Add "fsck" functionality

A very useful function is to have an "fsck" capability of the API:

  • remove truly orphaned objects
  • resolve inconsistencies
  • etc?

Thx :)

Fix RecursionError with Python3.6

Hi,
With Python3.6, I got this error (contrail-api-cli 0.3.0):

File "/usr/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
    [Previous line repeated 308 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

After gevent update, I found this warning:
MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Ple ase monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (/home/vagrant/env/lib/python3.6/site-packages/urllib3/util/__init__.py)', 'urllib3.util.ssl_ (/home/vagrant/env/lib/python3.6/site-p ackages/urllib3/util/ssl_.py)'].

Once those lines removed https://github.com/eonpatapon/contrail-api-cli/blob/master/contrail_api_cli/utils.py#L25-L26, my error was gone.

Could you integrate this fix ?

"edit" command with no arguments throws a TypeError

This is what happens when edit command is called without args:

admin@localhost:/> edit
Traceback (most recent call last):
  File "/home/kosiak/Dokumenty/capi/bin/contrail-api-cli", line 11, in <module>
    load_entry_point('contrail-api-cli==0.1.1', 'console_scripts', 'contrail-api-cli')()
  File "/home/kosiak/Dokumenty/capi/local/lib/python2.7/site-packages/contrail_api_cli-0.1.1-py2.7.egg/contrail_api_cli/main.py", line 91, in main
    result = subcmd(**subcmd_kwargs)
  File "/home/kosiak/Dokumenty/capi/local/lib/python2.7/site-packages/contrail_api_cli-0.1.1-py2.7.egg/contrail_api_cli/commands/shell.py", line 133, in __call__
    result = cmd.parse_and_call(*args)
  File "/home/kosiak/Dokumenty/capi/local/lib/python2.7/site-packages/contrail_api_cli-0.1.1-py2.7.egg/contrail_api_cli/command.py", line 249, in parse_and_call
    return self.__call__(**vars(args))
  File "/home/kosiak/Dokumenty/capi/local/lib/python2.7/site-packages/contrail_api_cli-0.1.1-py2.7.egg/contrail_api_cli/commands/edit.py", line 36, in __call__
    predicate=lambda r: isinstance(r, Resource))
  File "/home/kosiak/Dokumenty/capi/local/lib/python2.7/site-packages/contrail_api_cli-0.1.1-py2.7.egg/contrail_api_cli/command.py", line 158, in expand_paths
    paths = [Context().shell.current_path / res for res in paths]
  File "build/bdist.linux-x86_64/egg/pathlib.py", line 853, in __truediv__
  File "build/bdist.linux-x86_64/egg/pathlib.py", line 643, in _make_child
  File "build/bdist.linux-x86_64/egg/pathlib.py", line 605, in _parse_args
TypeError: argument should be a path or str object, not <type 'NoneType'>

DefaultStyle no longer available in prompt_toolkit.styles

Traceback (most recent call last):
  File "/home/anticimex/Envs/contrail-api-cli/bin/contrail-api-cli", line 9, in <module>
    load_entry_point('contrail-api-cli==0.1b1', 'console_scripts', 'contrail-api-cli')()
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/contrail_api_cli/main.py", line 11, in <module>
    from . import commands
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/contrail_api_cli/commands.py", line 28, in <module>
    from .style import PromptStyle
  File "/home/anticimex/Envs/contrail-api-cli/local/lib/python2.7/site-packages/contrail_api_cli/style.py", line 3, in <module>
    from prompt_toolkit.styles import DefaultStyle
ImportError: cannot import name DefaultStyle

Ref:
https://github.com/jonathanslenders/python-prompt-toolkit/blob/422aad8e0f90f1e2b9009b7f4aa60cbc1ff0a407/CHANGELOG#L85

Correct AS number is not reflected in the BGP peer after BGP peer router addition using contrail-api-cli

Issue :
Given BGP AS number for the BGP Peer is not updated properly.

When i add the BGP peer using contrail CLI, the BGP Peer AS number is modified to the local AS number instead of the given one.

/usr/bin/contrail-api-cli --ns contrail_api_cli.provision add-bgp-router --router-ip 192.168.122.230 --router-asn 64510 mitaka6

Here mitaka6 AS Number is 64510.

โŒ‚119% 2d [cloud@mitak5:~/devstack] stable/mitaka* ยฑ /usr/bin/contrail-api-cli --ns contrail_api_cli.provision list-bgp-router
[
{
"router_port": 179,
"router_asn": 64513,
"router_md5": [],
"router_ip": "192.168.122.185",
"router_address_families": [
"route-target",
"inet-vpn",
"e-vpn",
"erm-vpn",
"inet6-vpn"
],
"router_type": "contrail",
"router_name": "mitak5"
},
{
"router_port": 179,
"router_asn": 64513,
"router_md5": [],
"router_ip": "192.168.122.230",
"router_address_families": [
"route-target",
"inet-vpn",
"e-vpn",
"erm-vpn",
"inet6-vpn"
],
"router_type": "contrail",
"router_name": "mitaka6"
}
]

In this, it has been modified as 64513 (local AS number)

The log show, after the CREATE bgp router,
UPDATE is called with 64513 AS number.
Attached the log for reference.

  1. To resolve this issue, I have edited this object(using Contrail api cli) and updated the AS number.

Unable to run contrail-api-cli on Contrail 3.0

I'm facing the following error. '' TypeError: register_argparse_arguments() got an unexpected keyword argument 'default' '' when I run the following command in shell: contrail-api-cli or any argument it keeps throwing the same error.
Been stuck at this for hours now. Any help would be great.

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.