Convert cgtsclient from setuptools to pbr. Add tox.

Primary reason for this change was to update the spec and setup files
from basic setuptools to use pbr
This allows the autogenerated  /usr/bin/system file to directly call the
main method without using pkg-resources.
This will provide a performance improvement of .5 seconds per CLI call,
once the other pkg_resources issues are resolved

Second reason for this change was to wire in the tox unit tests.  This
also includes pep8, pylint and coverage.
Currently pep8 does not perform the 80 char limit check
Currently pylint still reports some issues

This should not affect the RPM names being generated or otherwise affect
patching or upgrades.

Change-Id: I9f14c9216fdcc63930a4b2849102b58442706144
This commit is contained in:
Al Bailey 2018-03-26 10:49:48 -05:00 committed by Jack Ding
parent 7da2cf5582
commit d7330d0f44
102 changed files with 910 additions and 702 deletions

View File

@ -32,10 +32,16 @@ Contains SDK files for %{name} package
%prep
%autosetup -n %{name}-%{version} -S git
# Remove bundled egg-info
rm -rf *.egg-info
%build
export PBR_VERSION=%{version}
%{__python} setup.py build
%install
export PBR_VERSION=%{version}
%{__python} setup.py install --root=$RPM_BUILD_ROOT \
--install-lib=%{pythonroot} \
--prefix=/usr \
@ -59,10 +65,8 @@ rm -rf $RPM_BUILD_ROOT
%doc LICENSE
%{local_bindir}/*
%{local_etc_bash_completiond}/*
%dir %{pythonroot}/cgtsclient
%{pythonroot}/cgtsclient/*
%dir %{pythonroot}/cgtsclient-%{version}.0-py2.7.egg-info
%{pythonroot}/cgtsclient-%{version}.0-py2.7.egg-info/*
%{pythonroot}/cgtsclient
%{pythonroot}/cgtsclient-%{version}*.egg-info
%files sdk
/usr/share/remote-clients/python-wrs-system-client-%{version}.tgz

View File

@ -0,0 +1,4 @@
.testrepository
coverage.xml
.coverage
cover

View File

@ -0,0 +1,10 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./cgtsclient/tests} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
# group tests when running concurrently
# This regex groups by classname
#group_regex=([^\.]+\.)+

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
# import pbr.version
try:
import cgtsclient.client
Client = cgtsclient.client.Client
@ -22,5 +20,4 @@ except ImportError:
import warnings
warnings.warn("Could not import cgtsclient.client", ImportWarning)
__version__ = "1.0"
#__version__ = pbr.version.VersionInfo('python-cgtsclient').version_string()
__version__ = "1.0.0"

View File

@ -4,10 +4,9 @@
# SPDX-License-Identifier: Apache-2.0
#
from cgtsclient import exc
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.openstack.common.gettextutils import _
from keystoneclient.v3 import client as ksclient
def _get_ksclient(**kwargs):
@ -22,6 +21,7 @@ def _get_ksclient(**kwargs):
* insecure: allow insecure SSL (no cert verification)
* project_name: Project name for project scoping.
"""
from keystoneclient.v3 import client as ksclient
return ksclient.Client(username=kwargs.get('username'),
password=kwargs.get('password'),
user_domain_name=kwargs.get('user_domain_name'),
@ -89,9 +89,7 @@ def get_client(api_version, **kwargs):
'os_cacert': kwargs.get('ca_file')
}
_ksclient = _get_ksclient(**ks_kwargs)
token = kwargs.get('os_auth_token') \
if kwargs.get('os_auth_token') \
else _ksclient.auth_ref.auth_token
token = kwargs.get('os_auth_token') if kwargs.get('os_auth_token') else _ksclient.auth_ref.auth_token
ep_kwargs = {
'service_type': kwargs.get('os_service_type'),
@ -117,8 +115,6 @@ def get_client(api_version, **kwargs):
'cert_file': kwargs.get('cert_file'),
'key_file': kwargs.get('key_file'),
'auth_ref': auth_ref,
#'tenant_id': kwargs.get('os_tenant_id'),
#'tenant_name': kwargs.get('os_tenant_name'),
'auth_url': kwargs.get('os_auth_url'),
'smapi_endpoint': 'http:localhost:7777',
}

View File

@ -11,6 +11,7 @@ used by the wrapping_formatters module
_no_wrap = [False]
def is_nowrap_set(no_wrap=None):
"""
returns True if no wrapping desired.

View File

@ -15,13 +15,10 @@
# under the License.
#
import copy
import httplib
import logging
import os
import requests
import socket
import StringIO
import httplib2
@ -46,7 +43,6 @@ if not hasattr(urlparse, 'parse_qsl'):
from cgtsclient import exc as exceptions
from neutronclient.common import utils
from cgtsclient.openstack.common.gettextutils import _
_logger = logging.getLogger(__name__)
@ -248,8 +244,8 @@ class HTTPClient(httplib2.Http):
connection_url = self._get_connection_url(url)
try:
resp, body_iter = self._cs_request(connection_url, method,
**kwargs)
resp, body_iter = self._cs_request(connection_url,
method, **kwargs)
except exceptions.HTTPUnauthorized:
self.authenticate()
resp, body_iter = self._cs_request(
@ -408,8 +404,7 @@ class HTTPClient(httplib2.Http):
body = json.loads(body)
for endpoint in body.get('endpoints', []):
if (endpoint['type'] == 'platform' and
endpoint.get('region') == self.region_name):
if (endpoint['type'] == 'platform' and endpoint.get('region') == self.region_name):
if self.endpoint_type not in endpoint:
raise exceptions.EndpointTypeNotFound(
self.endpoint_type)

View File

@ -17,22 +17,25 @@
try:
import tsconfig.tsconfig as tsc
is_remote = False
except:
except Exception:
is_remote = True
import argparse
import copy
import dateutil
import os
import prettytable
import re
import six
import sys
import textwrap
import uuid
import six
import prettytable
from prettytable import FRAME, ALL, NONE
from prettytable import ALL
from prettytable import FRAME
from prettytable import NONE
import re
from datetime import datetime
import dateutil
from dateutil import parser
from cgtsclient import exc
@ -217,9 +220,11 @@ def _sort_for_list(objs, fields, formatters={}, sortby=0, reversesort=False):
return rows_to_sort
def default_printer(s):
print s
def pt_builder(field_labels, fields, formatters, paging, printer=default_printer):
"""
returns an object that 'fronts' a prettyTable object
@ -440,7 +445,7 @@ def print_dict(d, dict_property="Property", wrap=0):
pt = prettytable.PrettyTable([dict_property, 'Value'],
caching=False, print_empty=False)
pt.align = 'l'
for k, v in d.iteritems():
for k, v in sorted(d.iteritems()):
v = parse_date(v)
# convert dict to str to check length
if isinstance(v, dict):
@ -516,9 +521,8 @@ def args_array_to_dict(kwargs, key_to_convert):
kwargs[key_to_convert] = dict(v.split("=", 1)
for v in values_to_convert)
except ValueError:
raise exc.CommandError(
'%s must be a list of KEY=VALUE not "%s"' % (
key_to_convert, values_to_convert))
raise exc.CommandError('%s must be a list of KEY=VALUE not "%s"' %
(key_to_convert, values_to_convert))
return kwargs
@ -634,16 +638,17 @@ def is_uuid_like(val):
def get_terminal_size():
"""Returns a tuple (x, y) representing the width(x) and the height(x)
in characters of the terminal window."""
in characters of the terminal window.
"""
def ioctl_GWINSZ(fd):
try:
import fcntl
import termios
import struct
import termios
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
'1234'))
except:
except Exception:
return None
if cr == (0, 0):
return None
@ -657,7 +662,7 @@ def get_terminal_size():
fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_GWINSZ(fd)
os.close(fd)
except:
except Exception:
pass
if not cr:
cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
@ -675,8 +680,7 @@ def normalize_field_data(obj, fields):
class WRPrettyTable(prettytable.PrettyTable):
""" A PrettyTable that allows word wrapping of its headers.
"""
"""A PrettyTable that allows word wrapping of its headers."""
def __init__(self, field_names=None, **kwargs):
super(WRPrettyTable, self).__init__(field_names, **kwargs)
@ -742,11 +746,13 @@ def extract_keypairs(args):
attributes[key] = value
return attributes
# Convert size from BYTE to KiB, MiB, GiB, TiB, PiB
# 1 - KiB, 2 - MiB, 3 - GiB, 4 - TiB, 5 - PiB
def convert_size_from_bytes(bytes, type):
return '%.2f' % (float(bytes) / (1024 ** type))
def _get_system_info(cc):
"""Gets the system mode and type"""
if is_remote:

View File

@ -21,17 +21,19 @@ The basic idea is:
the existing prettyTable code base for rendering.
"""
import six
import copy
import textwrap, re
import re
import six
import textwrap
from cgtsclient.common.cli_no_wrap import is_nowrap_set
from cgtsclient.common.cli_no_wrap import set_no_wrap
from prettytable import _get_size
from cgtsclient.common.cli_no_wrap import is_nowrap_set, set_no_wrap
UUID_MIN_LENGTH = 36
# monkey patch (customize) how the textwrap module breaks text into chunks
wordsep_re = re.compile(
r'(\s+|' # any whitespace
wordsep_re = re.compile(r'(\s+|' # any whitespace
r',|'
r'=|'
r'\.|'
@ -41,10 +43,11 @@ wordsep_re = re.compile(
textwrap.TextWrapper.wordsep_re = wordsep_re
def _get_width(value):
if value is None:
return 0
# TODO: take into account \n
# TODO(jkung): take into account \n
return _get_size(six.text_type(value))[0] # get width from [width,height]
@ -186,8 +189,7 @@ class WrapperFormatter(object):
self.actual_column_char_len = actual
def get_actual_column_char_len(self, desired_char_len, check_remaining_row_chars=True):
"""
Utility method to adjust desired width to a width
"""Utility method to adjust desired width to a width
that can actually be applied based on current table width
and current terminal width
@ -216,7 +218,7 @@ class WrapperFormatter(object):
if actual > self.min_width:
# shrink column
while actual > self.min_width:
actual -= 1 # TODO: fix in next sprint
actual -= 1 # TODO(jkung): fix in next sprint
# each column needs to share in
# table shrinking - but this is good
# enough for now - also - why the loop?
@ -360,6 +362,7 @@ class WrapperWithCustomFormatter(WrapperLambdaFormatter):
def get_basic_desired_width(self):
return self.wrapper_formatter.get_basic_desired_width()
def wrapper_formatter_factory(ctx, field, formatter):
"""
This function is a factory for building WrapperFormatter objects.
@ -462,8 +465,7 @@ def build_column_stats_for_best_guess_formatting(objs, fields, field_labels, cus
self.average_percent = float(self.average_width) / float(avg_total_width)
def __str__(self):
return str(
[self.field,
return str([self.field,
self.average_width,
self.min_width,
self.max_width,
@ -474,8 +476,7 @@ def build_column_stats_for_best_guess_formatting(objs, fields, field_labels, cus
self.isUUID])
def __repr__(self):
return str(
[self.field,
return str([self.field,
self.average_width,
self.min_width,
self.max_width,
@ -770,15 +771,13 @@ def _simpleTestHarness(no_wrap):
fields = ['timestamp', 'state', 'event_log_id', 'reason_text',
'entity_instance_id', 'severity', 'number']
formatterSpecX = {
"timestamp" : 10,
formatterSpecX = {"timestamp": 10,
"state": 8,
"event_log_id": 70,
"reason_text": 30,
"entity_instance_id": 30,
"severity": 12,
"number" : 4
}
"number": 4}
formatterSpec = {}
for f in fields:
@ -798,7 +797,6 @@ def _simpleTestHarness(no_wrap):
formatters = build_wrapping_formatters(logs, fields, field_labels, formatterSpec)
utils.print_list(logs, fields, field_labels, formatters=formatters, sortby=6,
reversesort=True, no_wrap_fields=['entity_instance_id'])

View File

@ -41,8 +41,7 @@ def import_object(import_str, *args, **kwargs):
def import_object_ns(name_space, import_str, *args, **kwargs):
"""
Import a class and return an instance of it, first by trying
"""Import a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
"""

View File

@ -28,7 +28,6 @@ from cgtsclient import client as cgclient
from cgtsclient.common import utils
from cgtsclient import exc
import keyring
import os
@ -151,8 +150,7 @@ class CgtsShell(object):
help=argparse.SUPPRESS)
parser.add_argument('--system-api-version',
default=utils.env(
'SYSTEM_API_VERSION', default='1'),
default=utils.env('SYSTEM_API_VERSION', default='1'),
help='Defaults to env[SYSTEM_API_VERSION] '
'or 1')
@ -233,9 +231,7 @@ class CgtsShell(object):
httplib2.debuglevel = 1
else:
logging.basicConfig(
format="%(levelname)s %(message)s",
level=logging.CRITICAL)
logging.basicConfig(format="%(levelname)s %(message)s", level=logging.CRITICAL)
def main(self, argv):
# Parse args once to find version
@ -274,6 +270,7 @@ class CgtsShell(object):
if not args.os_password:
# priviledge check (only allow Keyring retrieval if we are root)
if os.geteuid() == 0:
import keyring
args.os_password = keyring.get_password('CGCS', args.os_username)
else:
raise exc.CommandError("You must provide a password via "
@ -315,7 +312,6 @@ class CgtsShell(object):
commands.remove('bash_completion')
print(' '.join(commands | options))
@utils.arg('command', metavar='<subcommand>', nargs='?',
help='Display help for <subcommand>')
def do_help(self, args):

View File

@ -1,44 +0,0 @@
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cgtsclient.tests import utils
from cgtsclient.common import http
fixtures = {}
class HttpClientTest(utils.BaseTestCase):
def test_url_generation_trailing_slash_in_base(self):
client = http.HTTPClient('http://localhost/')
url = client._make_connection_url('/v1/resources')
self.assertEqual(url, '/v1/resources')
def test_url_generation_without_trailing_slash_in_base(self):
client = http.HTTPClient('http://localhost')
url = client._make_connection_url('/v1/resources')
self.assertEqual(url, '/v1/resources')
def test_url_generation_prefix_slash_in_path(self):
client = http.HTTPClient('http://localhost/')
url = client._make_connection_url('/v1/resources')
self.assertEqual(url, '/v1/resources')
def test_url_generation_without_prefix_slash_in_path(self):
client = http.HTTPClient('http://localhost')
url = client._make_connection_url('v1/resources')
self.assertEqual(url, '/v1/resources')

View File

@ -78,8 +78,12 @@ class ShellTest(utils.BaseTestCase):
def test_help_on_subcommand(self):
required = [
'.*?^usage: system host-show',
".*?^Show a host",
'.*?^usage: system host-show <hostname or id>'
'',
".*?^Show host attributes.",
'',
".*?^Positional arguments:",
".*?^ <hostname or id> Name or ID of host",
]
argstrings = [
'help host-show',

View File

@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
@ -23,7 +22,6 @@
import copy
import testtools
#hello
from cgtsclient.tests import utils
import cgtsclient.v1.ihost
@ -39,9 +37,7 @@ IHOST = {'id': 123,
'rootfs_device': 'sda',
'install_output': "text",
'console': 'ttyS0,115200',
'tboot': '',
}
# 'administrative': 'unlocked'} if have this, fails create
'tboot': ''}
PORT = {'id': 456,
'uuid': '11111111-2222-3333-4444-555555555555',
@ -57,9 +53,6 @@ UPDATED_IHOST = copy.deepcopy(IHOST)
NEW_LOC = 'newlocOttawa'
UPDATED_IHOST['location'] = NEW_LOC
#NEW_MTCADMINSTATE = 'locked'
#UPDATED_IHOST['administrative'] = NEW_MTCADMINSTATE
fixtures = {
'/v1/ihosts':
@ -148,17 +141,3 @@ class ihostManagerTest(testtools.TestCase):
]
self.assertEqual(self.api.calls, expect)
self.assertEqual(ihost.location, NEW_LOC)
#def test_ihost_port_list(self):
# ports = self.mgr.list_iport(IHOST['uuid'])
#def test_ihost_port_list(self):
# ports = self.mgr.list_iport(IHOST['uuid'])
# expect = [
# ('GET', '/v1/ihosts/%s/iport'
# % IHOST['uuid'], {}, None),
# ]
# self.assertEqual(self.api.calls, expect)
# self.assertEqual(len(ports), 1)
# self.assertEqual(ports[0].uuid, PORT['uuid'])
# self.assertEqual(ports[0].address, PORT['address'])

View File

@ -1,6 +1,3 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@ -18,4 +15,3 @@
#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#

View File

@ -63,8 +63,7 @@ def do_addrpool_delete(cc, args):
def _get_range_tuples(data):
"""
Split the ranges field from a comma separated list of start-end to a
"""Split the ranges field from a comma separated list of start-end to a
real list of (start, end) tuples.
"""
ranges = []
@ -94,7 +93,7 @@ def do_addrpool_add(cc, args):
field_list = ['name', 'network', 'prefix', 'order', 'ranges']
## Prune input fields down to required/expected values
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))

View File

@ -71,15 +71,15 @@ def do_host_addr_add(cc, args):
field_list = ['address', 'prefix']
## Lookup parent host and interface
# Lookup parent host and interface
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
iinterface = iinterface_utils._find_interface(cc, ihost, args.ifnameorid)
## Prune input fields down to required/expected values
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))
## Insert interface UUID
# Insert interface UUID
data['interface_uuid'] = iinterface.uuid
address = cc.address.create(**data)

View File

@ -8,9 +8,7 @@
#
from cgtsclient.common import base
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import ihost as ihost_utils
CREATION_ATTRIBUTES = ['ceph_mon_gib', 'ceph_mon_dev',
'ceph_mon_dev_ctrl0', 'ceph_mon_dev_ctrl1']

View File

@ -9,8 +9,8 @@
# All Rights Reserved.
#
from cgtsclient.common import utils
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient.v1 import ihost as ihost_utils
@ -36,8 +36,7 @@ def _print_ceph_mon_list(cc):
constants.CONTROLLER_1_HOSTNAME],
help='Specify controller host name <%s | %s> ' % (
constants.CONTROLLER_0_HOSTNAME,
constants.CONTROLLER_1_HOSTNAME
))
constants.CONTROLLER_1_HOSTNAME))
@utils.arg('attributes',
metavar='<path=value>',
nargs='+',
@ -76,6 +75,7 @@ def do_ceph_mon_list(cc, args):
"""List ceph mons"""
_print_ceph_mon_list(cc)
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="name or ID of host [REQUIRED]")

View File

@ -9,9 +9,9 @@
# All Rights Reserved.
#
import os
from cgtsclient import exc
from cgtsclient.common import utils
from collections import OrderedDict
from cgtsclient import exc
def _print_certificate_show(certificate):
@ -77,7 +77,7 @@ def do_certificate_install(cc, args):
certificate_file = args.certificate_file
try:
sec_file = open(certificate_file, 'rb')
except:
except Exception:
raise exc.CommandError("Error: Could not open file %s." %
certificate_file)

View File

@ -20,59 +20,59 @@
from cgtsclient.common import http
from cgtsclient.v1 import address
from cgtsclient.v1 import address_pool
from cgtsclient.v1 import isystem
from cgtsclient.v1 import ihost
from cgtsclient.v1 import inode
from cgtsclient.v1 import icpu
from cgtsclient.v1 import imemory
from cgtsclient.v1 import iinterface
from cgtsclient.v1 import idisk
from cgtsclient.v1 import istor
from cgtsclient.v1 import ipv
from cgtsclient.v1 import ilvg
from cgtsclient.v1 import iuser
from cgtsclient.v1 import idns
from cgtsclient.v1 import intp
from cgtsclient.v1 import iextoam
from cgtsclient.v1 import controller_fs
from cgtsclient.v1 import storage_backend
from cgtsclient.v1 import storage_lvm
from cgtsclient.v1 import storage_file
from cgtsclient.v1 import storage_external
from cgtsclient.v1 import storage_ceph
from cgtsclient.v1 import ceph_mon
from cgtsclient.v1 import certificate
from cgtsclient.v1 import cluster
from cgtsclient.v1 import controller_fs
from cgtsclient.v1 import drbdconfig
from cgtsclient.v1 import iprofile
from cgtsclient.v1 import icommunity
from cgtsclient.v1 import itrapdest
from cgtsclient.v1 import ialarm
from cgtsclient.v1 import iinfra
from cgtsclient.v1 import port
from cgtsclient.v1 import ethernetport
from cgtsclient.v1 import route
from cgtsclient.v1 import event_log
from cgtsclient.v1 import event_suppression
from cgtsclient.v1 import firewallrules
from cgtsclient.v1 import health
from cgtsclient.v1 import ialarm
from cgtsclient.v1 import icommunity
from cgtsclient.v1 import icpu
from cgtsclient.v1 import idisk
from cgtsclient.v1 import idns
from cgtsclient.v1 import iextoam
from cgtsclient.v1 import ihost
from cgtsclient.v1 import iinfra
from cgtsclient.v1 import iinterface
from cgtsclient.v1 import ilvg
from cgtsclient.v1 import imemory
from cgtsclient.v1 import inode
from cgtsclient.v1 import intp
from cgtsclient.v1 import iprofile
from cgtsclient.v1 import ipv
from cgtsclient.v1 import isensor
from cgtsclient.v1 import isensorgroup
from cgtsclient.v1 import load
from cgtsclient.v1 import pci_device
from cgtsclient.v1 import upgrade
from cgtsclient.v1 import network
from cgtsclient.v1 import service_parameter
from cgtsclient.v1 import cluster
from cgtsclient.v1 import istor
from cgtsclient.v1 import isystem
from cgtsclient.v1 import itrapdest
from cgtsclient.v1 import iuser
from cgtsclient.v1 import license
from cgtsclient.v1 import lldp_agent
from cgtsclient.v1 import lldp_neighbour
from cgtsclient.v1 import license
from cgtsclient.v1 import sm_service_nodes
from cgtsclient.v1 import sm_service
from cgtsclient.v1 import sm_servicegroup
from cgtsclient.v1 import health
from cgtsclient.v1 import remotelogging
from cgtsclient.v1 import sdn_controller
from cgtsclient.v1 import firewallrules
from cgtsclient.v1 import load
from cgtsclient.v1 import network
from cgtsclient.v1 import partition
from cgtsclient.v1 import certificate
from cgtsclient.v1 import pci_device
from cgtsclient.v1 import port
from cgtsclient.v1 import remotelogging
from cgtsclient.v1 import route
from cgtsclient.v1 import sdn_controller
from cgtsclient.v1 import service_parameter
from cgtsclient.v1 import sm_service
from cgtsclient.v1 import sm_service_nodes
from cgtsclient.v1 import sm_servicegroup
from cgtsclient.v1 import storage_backend
from cgtsclient.v1 import storage_ceph
from cgtsclient.v1 import storage_external
from cgtsclient.v1 import storage_file
from cgtsclient.v1 import storage_lvm
from cgtsclient.v1 import storage_tier
from cgtsclient.v1 import upgrade
class Client(http.HTTPClient):

View File

@ -10,8 +10,8 @@
#
from cgtsclient.common import utils
from cgtsclient.v1 import cluster as cluster_utils
from cgtsclient import exc
from cgtsclient.v1 import cluster as cluster_utils
import os

View File

@ -33,6 +33,7 @@ def _print_controller_fs_show(controller_fs):
data = [(f, getattr(controller_fs, f)) for f in fields]
utils.print_tuple_list(data, labels)
@utils.arg('attributes',
metavar='<fs_name=size>',
nargs='+',
@ -43,7 +44,6 @@ def _print_controller_fs_show(controller_fs):
action='store_true',
default=False,
help="Force the resize operation ")
def do_controllerfs_modify(cc, args):
"""Modify controller filesystem sizes."""
@ -90,6 +90,7 @@ def _print_controllerfs_list(cc):
fields = ['uuid', 'name', 'size', 'logical_volume', 'replicated', 'state']
utils.print_list(controller_fs_list, fields, field_labels, sortby=1)
def do_controllerfs_list(cc, args):
"""Show list of controller filesystems"""
_print_controllerfs_list(cc)

View File

@ -18,6 +18,7 @@ from cgtsclient import exc
CONTROLLER = 'controller'
def _print_drbdsync_show(drbdconfig):
fields = ['uuid',
'isystem_uuid',
@ -25,8 +26,7 @@ def _print_drbdsync_show(drbdconfig):
'updated_at',
'link_util',
'num_parallel',
'rtt_ms',
]
'rtt_ms']
data = [(f, getattr(drbdconfig, f, '')) for f in fields]
utils.print_tuple_list(data)
@ -34,8 +34,7 @@ def _print_drbdsync_show(drbdconfig):
def _print_controller_config_show(ihosts):
fields = ['id', 'hostname', 'personality',
'administrative', 'operational', 'availability',
'config_status',
]
'config_status']
field_labels = list(fields)
utils.print_list(ihosts, fields, field_labels, sortby=0)
@ -89,8 +88,7 @@ def do_drbdsync_modify(cc, args):
is_config = False
ihosts = cc.ihost.list_personality(personality=CONTROLLER)
for ihost in ihosts:
if ihost.config_target and \
ihost.config_applied != ihost.config_target:
if ihost.config_target and ihost.config_applied != ihost.config_target:
is_config = True
print ("host %s is configuring ..." % (ihost.hostname))
if is_config:
@ -114,14 +112,13 @@ def do_drbdsync_modify(cc, args):
do_wait = False
hosts = []
for ihost in ihosts:
if ihost.config_target and \
ihost.config_applied != ihost.config_target:
if ihost.config_target and ihost.config_applied != ihost.config_target:
do_wait = True
hosts.append(ihost.hostname)
if do_wait:
if x == 0:
print ("waiting for hosts: %s to finish configuring"
% ', '.join(hosts)),
print ("waiting for hosts: %s to finish configuring" %
', '.join(hosts)),
sys.stdout.flush()
else:
print ".",

View File

@ -12,13 +12,13 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
def _bootp_formatter(value):
return bool(value)
def _bootp_port_formatter(port):
return _bootp_formatter(port.bootp)
@ -52,7 +52,7 @@ def _find_port(cc, ihost, portnameoruuid):
break
else:
raise exc.CommandError('Ethernet port not found: host %s port %s' % (ihost.id, portnameoruuid))
p.autoneg = 'Yes' # TODO Remove when autoneg supported in DB
p.autoneg = 'Yes' # TODO(jkung) Remove when autoneg supported in DB
return p
@ -76,7 +76,7 @@ def do_host_ethernet_port_list(cc, args):
ports = cc.ethernet_port.list(ihost.uuid)
for p in ports:
p.autoneg = 'Yes' # TODO Remove when autoneg supported in DB
p.autoneg = 'Yes' # TODO(jkung) Remove when autoneg supported in DB
field_labels = ['uuid', 'name', 'mac address', 'pci address', 'processor', 'auto neg', 'device type', 'boot i/f']
fields = ['uuid', 'name', 'mac', 'pciaddr', 'numa_node', 'autoneg', 'pdevice', 'bootp']

View File

@ -4,9 +4,8 @@
# SPDX-License-Identifier: Apache-2.0
#
from cgtsclient.common import base
from ceilometerclient.v2 import options
from cgtsclient.common import base
class EventLog(base.Resource):
@ -29,9 +28,9 @@ class EventLogManager(base.Manager):
params.append('marker=%s' % str(marker))
if include_suppress:
params.append('include_suppress=True')
if alarms==True and logs==False:
if alarms is True and logs is False:
params.append('alarms=True')
elif alarms==False and logs==True:
elif alarms is False and logs is True:
params.append('logs=True')
restAPIURL = options.build_url(self._path(), q, params)
@ -44,4 +43,3 @@ class EventLogManager(base.Manager):
return self._list(self._path(iid))[0]
except IndexError:
return None

View File

@ -9,10 +9,10 @@
# All Rights Reserved.
#
from cgtsclient import exc
from ceilometerclient.v2 import options
from cgtsclient.common import utils
from cgtsclient.common import wrapping_formatters
from cgtsclient import exc
def _display_event(log):
@ -43,29 +43,21 @@ def do_event_show(cc, args={}):
'but if supplied must be string, integer, float, or boolean. '
'Valid query fields (event_log_id, entity_type_id, '
'entity_instance_id, severity, start, end)'
' Example: system event-list -q \'start=20160131 10:23:45;end=20171225\''
)
' Example: system event-list -q \'start=20160131 10:23:45;end=20171225\'')
@utils.arg('-l', '--limit', metavar='<NUMBER>',
help='Maximum number of event logs to return.')
@utils.arg('--alarms',
action='store_true',
help='Show alarms only')
@utils.arg('--logs', action='store_true',
help='Show logs only')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
@utils.arg('--include_suppress',
action='store_true',
help='Include suppressed alarms in output')
@utils.arg('--nopaging', action='store_true',
help='Output is not paged')
def do_event_list(cc, args={}):
'''List event logs.'''
@ -108,33 +100,28 @@ def do_event_list(cc, args={}):
'Entity Instance ID', 'Severity']
fields = ['uuid', 'timestamp', 'state', 'event_log_id', 'reason_text',
'entity_instance_id', 'severity']
formatterSpec = {
"uuid" : wrapping_formatters.UUID_MIN_LENGTH,
formatterSpec = {"uuid": wrapping_formatters.UUID_MIN_LENGTH,
"timestamp": .08,
"state": .08,
"event_log_id": {"formatter": hightlightEventId, "wrapperFormatter": .07},
"reason_text": .42,
"entity_instance_id": .13,
"severity" : .12
}
"severity": .12}
else:
field_labels = ['Time Stamp', 'State', 'Event Log ID', 'Reason Text',
'Entity Instance ID', 'Severity']
fields = ['timestamp', 'state', 'event_log_id', 'reason_text',
'entity_instance_id', 'severity']
# for best results, ensure width ratios add up to 1 (=100%)
formatterSpec = {
"timestamp" : .08,
formatterSpec = {"timestamp": .08,
"state": .08,
"event_log_id": {"formatter": hightlightEventId, "wrapperFormatter": .07},
"reason_text": .52,
"entity_instance_id": .13,
"severity" : .12
}
"severity": .12}
formatters = wrapping_formatters.build_wrapping_formatters(logs, fields,
field_labels, formatterSpec)
utils.print_long_list(logs, fields, field_labels,
formatters=formatters, sortby=fields.index('timestamp'),
reversesort=True, no_paging=no_paging)

View File

@ -4,8 +4,8 @@
# SPDX-License-Identifier: Apache-2.0
#
from cgtsclient.common import base
from ceilometerclient.v2 import options
from cgtsclient.common import base
class EventSuppression(base.Resource):

View File

@ -8,9 +8,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# All Rights Reserved.
#
import prettytable
from cgtsclient import exc
from ceilometerclient.v2 import options
from cgtsclient.common import utils
from cgtsclient.common import wrapping_formatters
@ -21,19 +18,15 @@ def _get_display_config(includeUUID):
field_labels = ['UUID', 'Event ID', 'Status']
fields = ['uuid', 'alarm_id', 'suppression_status']
formatterSpec = {
"uuid" : 40,
formatterSpec = {"uuid": 40,
"alarm_id": 25,
"suppression_status" : 15
}
"suppression_status": 15}
else:
field_labels = ['Event ID', 'Status']
fields = ['alarm_id', 'suppression_status']
formatterSpec = {
"alarm_id" : 25,
"suppression_status" : 15
}
formatterSpec = {"alarm_id": 25,
"suppression_status": 15}
return {
'field_labels': field_labels,
@ -43,22 +36,23 @@ def _get_display_config(includeUUID):
def _display_event_suppression(log):
fields = ['uuid', 'alarm_id', 'description', 'suppression_status']
data = dict([(f, getattr(log, f, '')) for f in fields])
utils.print_dict(data, wrap=72)
def _get_suppressed_alarms_tuples(data):
"""
Split the suppressed_alarms field from a comma separated list alarm id's to a
"""Split the suppressed_alarms field from a comma separated list alarm id's to a
real list of (start, end) tuples. ??????
"""
suppressed_alarms = []
for a in data['suppressed_alarms'].split(',') or []:
suppressed_alarms.append((a))
return suppressed_alarms
def _event_suppression_list(cc, include_unsuppressed=False):
query = 'suppression_status=string::suppressed'
queryAsArray = []
@ -66,7 +60,7 @@ def _event_suppression_list(cc, include_unsuppressed=False):
if include_unsuppressed:
query = None
if query != None:
if query is not None:
queryAsArray = options.cli_to_array(query)
event_suppression_list = cc.event_suppression.list(q=queryAsArray)
@ -113,13 +107,10 @@ def event_suppression_update(cc, data, suppress=False):
@utils.arg('--include-unsuppressed', action='store_true',
help='Include unsuppressed Event ID\'s')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
@utils.arg('--nopaging', action='store_true',
help='Output is not paged')
def do_event_suppress_list(cc, args={}):
'''List Suppressed Event ID's '''
@ -143,22 +134,20 @@ def do_event_suppress_list(cc, args={}):
utils.print_long_list(event_suppression_list, fields, field_labels, formatters=formatters, sortby=1,
reversesort=False, no_paging=no_paging)
@utils.arg('--alarm_id',
metavar='<alarm_id>,...',
help="The alarm_id list (comma separated) of alarm ID's to suppress.")
@utils.arg('--nopaging', action='store_true',
help='Output is not paged')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
def do_event_suppress(cc, args={}):
'''Suppress specified Event ID's.'''
field_list = ['alarm_id']
## Prune input fields down to required/expected values
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))
@ -174,18 +163,15 @@ def do_event_suppress(cc, args={}):
@utils.arg('--alarm_id',
metavar='<alarm_id>,...',
help="The alarm_id list (comma separated) of alarm ID's to unsuppress.")
@utils.arg('--nopaging', action='store_true',
help='Output is not paged')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
def do_event_unsuppress(cc, args):
'''Unsuppress specified Event ID's.'''
field_list = ['alarm_id']
## Prune input fields down to required/expected values
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))
@ -200,15 +186,11 @@ def do_event_unsuppress(cc, args):
@utils.arg('--nopaging', action='store_true',
help='Output is not paged')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
def do_event_unsuppress_all(cc, args):
'''Unsuppress all Event ID's.'''
patch = []
alarms_suppression_list = _event_suppression_list(cc, include_unsuppressed=True)
for alarm_type in alarms_suppression_list:

View File

@ -39,10 +39,9 @@ def do_firewall_rules_install(cc, args):
filename = args.firewall_rules_path
try:
fw_file = open(filename, 'rb')
except:
raise exc.CommandError(
"Error: Could not open file %s for read." % filename)
except Exception:
raise exc.CommandError("Error: Could not open file %s for read." %
filename)
try:
response = cc.firewallrules.import_firewall_rules(fw_file)
error = response.get('error')

View File

@ -10,24 +10,20 @@
# All Rights Reserved.
#
import datetime
import json
import os
import requests
import time
from collections import OrderedDict
from cgtsclient import exc
import datetime
import os
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.openstack.common.gettextutils import _
from cgtsclient.v1 import icpu as icpu_utils
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import iinterface as iinterface_utils
from cgtsclient.v1 import ilvg as ilvg_utils
from cgtsclient.v1 import iprofile as iprofile_utils
from cgtsclient.v1 import ipv as ipv_utils
from cgtsclient.v1 import istor as istor_utils
from sys import stdout
from cgtsclient.common import constants
def _print_ihost_show(ihost):
fields = ['id', 'uuid', 'personality', 'hostname', 'invprovision',
@ -184,7 +180,7 @@ def do_host_bulk_add(cc, args):
raise exc.CommandError("Error: %s is a directory." % hostsfile)
try:
req = open(hostsfile, 'rb')
except:
except Exception:
raise exc.CommandError("Error: Could not open file %s." % hostsfile)
response = cc.ihost.create_many(req)
@ -457,6 +453,8 @@ NOTE (neid):
or a profile including all of cpu, stor, if
or a profile including all of cpu, stor, if
"""
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="Name or ID of host")
@ -637,9 +635,7 @@ def _timestamped(dname, fmt='%Y-%m-%d-%H-%M-%S_{dname}'):
metavar='<hostname or id>',
help="Name or ID of host")
def do_host_patch_reboot(cc, args):
"""Command has been deprecated.
"""
"""Command has been deprecated."""
try:
ihost = cc.ihost.get(args.hostnameorid)
except exc.HTTPNotFound:
@ -673,7 +669,7 @@ def do_host_bulk_export (cc, args):
fw.write(xml_content)
print _('Export successfully to %s') % config_filename
except IOError:
print _('Cannot write to file: %s' % config_filename)
print _('Cannot write to file: %s') % config_filename
return

View File

@ -4,8 +4,9 @@
# SPDX-License-Identifier: Apache-2.0
#
from cgtsclient.common import base
from ceilometerclient.v2 import options
from cgtsclient.common import base
class ialarm(base.Resource):
def __repr__(self):

View File

@ -9,11 +9,11 @@
# All Rights Reserved.
#
from cgtsclient import exc
from ceilometerclient.v2 import options
from ceilometerclient.common import utils
from cgtsclient.common import wrapping_formatters
from ceilometerclient.v2 import options
from cgtsclient.common import utils as cgts_utils
from cgtsclient.common import wrapping_formatters
from cgtsclient import exc
def _display_fault(fault):
@ -49,18 +49,14 @@ def do_alarm_delete(cc, args={}):
@utils.arg('-q', '--query', metavar='<QUERY>',
help='key[op]data_type::value; list. data_type is optional, '
'but if supplied must be string, integer, float, or boolean.')
@utils.arg('--uuid', action='store_true',
help='Include UUID in output')
@utils.arg('--include_suppress',
action='store_true',
help='Include suppressed alarms in output')
@utils.arg('--mgmt_affecting',
action='store_true',
help='Include management affecting status in output')
def do_alarm_list(cc, args={}):
'''List all active alarms.'''
@ -93,8 +89,7 @@ def do_alarm_list(cc, args={}):
field_labels = ['Alarm ID', 'Reason Text', 'Entity ID', 'Severity', 'Time Stamp']
fields = ['alarm_id', 'reason_text', 'entity_instance_id', 'severity', 'timestamp']
# for best results, ensure width ratios add up to 1 (=100%)
formatterSpec = {
"alarm_id" : {"formatter" : hightlightAlarmId, "wrapperFormatter": .08},
formatterSpec = {"alarm_id": {"formatter": hightlightAlarmId, "wrapperFormatter": .08},
"reason_text": .54,
"entity_instance_id": .15,
"severity": .10,
@ -122,6 +117,7 @@ def do_alarm_list(cc, args={}):
cgts_utils.print_list(faults, fields, field_labels, formatters=formatters,
sortby=fields.index('timestamp'), reversesort=True)
@utils.arg('--include_suppress',
action='store_true',
help='Include suppressed alarms in output')
@ -136,5 +132,3 @@ def do_alarm_summary(cc, args={}):
field_labels = ['Critical Alarms', 'Major Alarms', 'Minor Alarms', 'Warnings']
fields = ['critical', 'major', 'minor', 'warnings']
cgts_utils.print_list(faults, fields, field_labels)

View File

@ -78,7 +78,3 @@ def do_snmp_comm_delete(cc, args):
except exc.HTTPNotFound:
raise exc.CommandError('Community not found: %s' % c)
print 'Deleted community %s' % c

View File

@ -121,12 +121,14 @@ def check_core_functions(personality, icpus):
VMS_CPU_TYPE_FORMAT)
return error_string
def compress_range(c_list):
c_list.append(999)
c_list.sort()
c_sep = ""
c_item = ""
c_str = ""
pn = 0 # pn is not used until second loop anyways
for n in c_list:
if not c_item:
c_item = "%s" % n
@ -141,6 +143,7 @@ def compress_range(c_list):
pn = n
return c_str
def restructure_host_cpu_data(host):
host.core_assignment = []
if host.cpus:
@ -166,7 +169,7 @@ def restructure_host_cpu_data(host):
if cpu.cpu > host.node_min_max_cores[cpu.numa_node]['max']:
host.node_min_max_cores[cpu.numa_node]['max'] = cpu.cpu
if cpu.allocated_function == None:
if cpu.allocated_function is None:
cpu.allocated_function = NONE_CPU_TYPE
if cpu.allocated_function not in core_assignment:
@ -179,7 +182,6 @@ def restructure_host_cpu_data(host):
core_assignment[cpu.allocated_function][cpu.numa_node].append(int(cpu.cpu))
number_of_cores[cpu.allocated_function][cpu.numa_node] = number_of_cores[cpu.allocated_function][cpu.numa_node] + 1
for f in CPU_TYPE_LIST:
cpufunction = CpuFunction(f)
if f in core_assignment:
@ -188,9 +190,8 @@ def restructure_host_cpu_data(host):
cpufunction.socket_cores[s] = compress_range(cores)
cpufunction.socket_cores_number[s] = number_of_cores[f][s]
else:
if (f == PLATFORM_CPU_TYPE or
(hasattr(host, 'subfunctions') and
'compute' in host.subfunctions)):
if (f == PLATFORM_CPU_TYPE or (hasattr(host, 'subfunctions')
and 'compute' in host.subfunctions)):
if f != NONE_CPU_TYPE:
host.core_assignment.append(cpufunction)
for s in range(0, len(host.nodes)):

View File

@ -12,9 +12,8 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import icpu as icpu_utils
from cgtsclient.v1 import ihost as ihost_utils
def _print_icpu_show(icpu):

View File

@ -13,7 +13,6 @@
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils

View File

@ -11,7 +11,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
def _print_idns_show(idns):

View File

@ -9,8 +9,8 @@
# All Rights Reserved.
#
from cgtsclient.common import utils
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict

View File

@ -9,9 +9,8 @@
from cgtsclient.common import base
from cgtsclient.common import utils
from cgtsclient.v1 import icpu
from cgtsclient import exc
from cgtsclient.v1 import icpu
CREATION_ATTRIBUTES = ['hostname', 'personality', 'subfunctions',
@ -134,5 +133,3 @@ def _find_ihost(cc, ihost):
return h
else:
raise exc.CommandError('host not found: %s' % ihost)

View File

@ -11,7 +11,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import iinterface as iinterface_utils
@ -82,7 +81,7 @@ def do_host_if_list(cc, args):
attr_str = "%s,AE_XMIT_POLICY=%s" % (
attr_str, i.txhashpolicy)
if (i.networktype and
any(network in ['data'] for \
any(network in ['data'] for
network in i.networktype.split(","))):
if False in i.dpdksupport:
attr_str = "%s,accelerated=False" % attr_str
@ -283,7 +282,7 @@ def do_host_if_modify(cc, args):
for p in interface.ports:
user_specified_fields['ifname'] = p
break
if any(network in ['data'] for \
if any(network in ['data'] for
network in interface.networktype.split(",")):
user_specified_fields['providernetworks'] = 'none'

View File

@ -9,8 +9,8 @@
# All Rights Reserved.
#
from cgtsclient.common import utils
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import ilvg as ilvg_utils

View File

@ -60,8 +60,7 @@ def _print_imemory_show(imemory):
if d[0] == 'vm_hugepages_nr_1G_pending':
if d[1] is None:
fields.remove(d[0])
labels.pop(len(labels)-labels[::-1].
index(' Total Pending')-1)
labels.pop(len(labels) - labels[::-1].index(' Total Pending') - 1)
data = [(f, getattr(imemory, f, '')) for f in fields]
utils.print_tuple_list(data, labels)
@ -141,21 +140,19 @@ def do_host_memory_list(cc, args):
utils.print_list(imemorys, fields, field_labels, sortby=1)
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="Name or ID of host")
@utils.arg('numa_node',
metavar='<processor>',
help="processor")
@utils.arg('-m', '--platform_reserved_mib',
metavar='<Platform Reserved MiB>',
help='The amount of platform memory (MiB) for the numa node')
@utils.arg('-2M', '--vm_hugepages_nr_2M_pending',
metavar='<2M hugepages number>',
help='The number of 2M vm huge pages for the numa node')
@utils.arg('-1G', '--vm_hugepages_nr_1G_pending',
metavar='<1G hugepages number>',
help='The number of 1G vm huge pages for the numa node')
@ -195,4 +192,3 @@ def do_host_memory_modify(cc, args):
if patch:
imemory = cc.imemory.update(mem.uuid, patch)
_print_imemory_show(imemory)

View File

@ -11,9 +11,7 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import inode as inode_utils
def _print_inode_show(inode):

View File

@ -11,7 +11,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
def _print_intp_show(intp):

View File

@ -7,9 +7,9 @@
# -*- encoding: utf-8 -*-
#
from cgtsclient import exc
from cgtsclient.common import base
from cgtsclient.common import utils
from cgtsclient import exc
CREATION_ATTRIBUTES = ['profiletype', 'profilename', 'ihost_uuid']

View File

@ -10,9 +10,9 @@
# All Rights Reserved.
#
from cgtsclient import exc
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import ethernetport as ethernetport_utils
from cgtsclient.v1 import icpu as icpu_utils
from cgtsclient.v1 import ihost as ihost_utils
@ -47,7 +47,7 @@ def get_portconfig(iprofile):
pstr = ''
for port in iprofile.ports:
pstr = pstr + "%s: %s" % (ethernetport_utils.get_port_display_name(port), port.pdevice)
port.autoneg = 'Yes' # TODO Remove when autoneg supported in DB
port.autoneg = 'Yes' # TODO(jkung) Remove when autoneg supported in DB
if port.autoneg != 'na':
pstr = pstr + " | Auto Neg = %s" % (port.autoneg)
if port.bootp:
@ -654,7 +654,7 @@ def do_profile_import(cc, args):
try:
file = open(filename, 'rb')
except:
except Exception:
raise exc.CommandError("Error: Could not open file %s for read." % filename)
results = cc.iprofile.import_profile(file)

View File

@ -12,9 +12,9 @@
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import idisk as idisk_utils
from cgtsclient.v1 import partition as partition_utils
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import ilvg as ilvg_utils
from cgtsclient.v1 import partition as partition_utils
def _print_ipv_show(ipv):

View File

@ -12,8 +12,8 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from collections import OrderedDict
def _print_isensor_show(isensor):

View File

@ -12,9 +12,9 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import isensorgroup as isensorgroup_utils
from collections import OrderedDict
def _print_isensorgroup_show(isensorgroup):

View File

@ -25,6 +25,7 @@ from cgtsclient import exc
CREATION_ATTRIBUTES = ['servicename', 'hostname', 'state', 'activity', 'reason']
# missing forihostid
class iService(base.Resource):
def __repr__(self):
return "<iService %s>" % self._info

View File

@ -45,8 +45,7 @@ def do_servicegroup_show(cc, args):
try:
iservicegroup = cc.iservicegroup.get(args.iservicegroup)
except exc.HTTPNotFound:
raise exc.CommandError(
'servicegroup not found: %s' % args.iservicegroup)
raise exc.CommandError('servicegroup not found: %s' % args.iservicegroup)
else:
_print_iservicegroup_show(iservicegroup)
@ -100,6 +99,5 @@ def donot_servicegroup_modify_labonly(cc, args):
try:
iservicegroup = cc.iservicegroup.update(args.iservicegroup, patch)
except exc.HTTPNotFound:
raise exc.CommandError(
'Service Group not found: %s' % args.iservicegroup)
raise exc.CommandError('Service Group not found: %s' % args.iservicegroup)
_print_iservicegroup_show(iservicegroup)

View File

@ -10,13 +10,9 @@
# All Rights Reserved.
#
import subprocess
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import isystem as isystem_utils
from cgtsclient.common import constants
def _print_isystem_show(isystem):
@ -89,7 +85,6 @@ def do_show(cc, args):
help='The vswitch type for the system')
def do_modify(cc, args):
"""Modify system attributes."""
isystems = cc.isystem.list()
isystem = isystems[0]

View File

@ -51,4 +51,3 @@ class iTrapdestManager(base.Manager):
def update(self, iid, patch):
return self._update(self._path(iid), patch)

View File

@ -82,8 +82,3 @@ def do_snmp_trapdest_delete(cc, args):
except exc.HTTPNotFound:
raise exc.CommandError('IP not found: %s' % c)
print 'Deleted ip %s' % c

View File

@ -17,7 +17,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
def _print_iuser_show(iuser):
@ -36,6 +35,7 @@ def donot_user_show(cc, args):
_print_iuser_show(iusers[0])
@utils.arg('attributes',
metavar='<path=value>',
nargs='+',

View File

@ -8,7 +8,6 @@
#
from cgtsclient.common import base
from cgtsclient import exc
class License(base.Resource):

View File

@ -29,6 +29,7 @@ def do_license_list(cc, args):
utils.print_list(licenses, fields, labels, sortby=0)
@utils.arg('license_file_path',
metavar='<license file path>',
default=None,
@ -38,7 +39,7 @@ def do_license_install(cc, args):
filename = args.license_file_path
try:
license_file = open(filename, 'rb')
except:
except Exception:
raise exc.CommandError(
"Error: Could not open file %s for read." % filename)

View File

@ -8,7 +8,7 @@
#
from cgtsclient.common import base
from cgtsclient import exc
class LldpAgent(base.Resource):
def __repr__(self):
@ -33,4 +33,3 @@ class LldpAgentManager(base.Manager):
def get_by_port(self, port_id):
path = '/v1/ports/%s/lldp_agents' % port_id
return self._list(path, "lldp_agents")

View File

@ -11,15 +11,15 @@
#
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
class LldpAgentObj:
def __init__(self, dictionary):
for k, v in dictionary.items():
setattr(self, k, v)
def _print_lldp_agent_show(agent):
fields = ['uuid', 'host_uuid',
'created_at', 'updated_at',
@ -40,6 +40,7 @@ def _print_lldp_agent_show(agent):
data = [(f, getattr(agent, f, '')) for f in fields]
utils.print_tuple_list(data, labels)
def _lldp_carriage_formatter(value):
chars = ['\n', '\\n', '\r', '\\r']
for char in chars:
@ -47,28 +48,31 @@ def _lldp_carriage_formatter(value):
value = value.replace(char, '. ')
return value
def _lldp_system_name_formatter(lldp):
system_name = getattr(lldp, 'system_name')
if system_name:
return _lldp_carriage_formatter(system_name)
def _lldp_system_description_formatter(lldp):
system_description = getattr(lldp, 'system_description')
if system_description:
return _lldp_carriage_formatter(system_description)
def _lldp_port_description_formatter(lldp):
port_description = getattr(lldp, 'port_description')
if port_description:
return _lldp_carriage_formatter(port_description)
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="Name or ID of host")
def do_host_lldp_agent_list(cc, args):
"""List host lldp agents."""
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
agent_list = []
agents = cc.lldp_agent.list(ihost.uuid)
field_labels = ['uuid', 'local_port', 'status', 'chassis_id', 'port_id',
@ -82,6 +86,7 @@ def do_host_lldp_agent_list(cc, args):
utils.print_list(agents, fields, field_labels, sortby=1,
formatters=formatters)
@utils.arg('uuid',
metavar='<uuid>',
help="UUID of the LLDP agent")
@ -90,4 +95,3 @@ def do_lldp_agent_show(cc, args):
agent = cc.lldp_agent.get(args.uuid)
_print_lldp_agent_show(agent)
return

View File

@ -8,7 +8,7 @@
#
from cgtsclient.common import base
from cgtsclient import exc
class LldpNeighbour(base.Resource):
def __repr__(self):

View File

@ -11,16 +11,15 @@
#
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
from cgtsclient.v1 import port as port_utils
class LldpNeighbourObj:
def __init__(self, dictionary):
for k, v in dictionary.items():
setattr(self, k, v)
def _lldp_carriage_formatter(value):
chars = ['\n', '\\n', '\r', '\\r']
for char in chars:
@ -28,21 +27,25 @@ def _lldp_carriage_formatter(value):
value = value.replace(char, '. ')
return value
def _lldp_system_name_formatter(lldp):
system_name = getattr(lldp, 'system_name')
if system_name:
return _lldp_carriage_formatter(system_name)
def _lldp_system_description_formatter(lldp):
system_description = getattr(lldp, 'system_description')
if system_description:
return _lldp_carriage_formatter(system_description)
def _lldp_port_description_formatter(lldp):
port_description = getattr(lldp, 'port_description')
if port_description:
return _lldp_carriage_formatter(port_description)
def _print_lldp_neighbour_show(neighbour):
fields = ['uuid', 'host_uuid',
'created_at', 'updated_at',
@ -97,4 +100,3 @@ def do_lldp_neighbor_show(cc, args):
neighbour = cc.lldp_neighbour.get(args.uuid)
_print_lldp_neighbour_show(neighbour)
return

View File

@ -8,7 +8,6 @@
#
from cgtsclient.common import base
from cgtsclient import exc
class PciDevice(base.Resource):
@ -44,4 +43,3 @@ def get_pci_device_display_name(p):
return p.name
else:
return '(' + str(p.uuid)[-8:] + ')'

View File

@ -12,9 +12,9 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils
def _print_device_show(device):
fields = ['name', 'pciaddr', 'pclass_id', 'pvendor_id', 'pdevice_id',
'pclass', 'pvendor', 'pdevice', 'numa_node', 'enabled',
@ -30,6 +30,7 @@ def _print_device_show(device):
data = [(f, getattr(device, f, '')) for f in fields]
utils.print_tuple_list(data, labels)
def _find_device(cc, host, nameorpciaddr):
devices = cc.pci_device.list(host.uuid)
for d in devices:
@ -39,6 +40,7 @@ def _find_device(cc, host, nameorpciaddr):
raise exc.CommandError('PCI devices not found: host %s device %s' % (host.id, nameorpciaddr))
return d
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="Name or ID of host")
@ -78,6 +80,7 @@ def do_host_device_list(cc, args):
utils.print_list(devices, fields, labels, sortby=1)
@utils.arg('hostnameorid',
metavar='<hostname or id>',
help="Name or ID of host")
@ -115,5 +118,4 @@ def do_host_device_modify(cc, args):
device = cc.pci_device.update(device.uuid, patch)
_print_device_show(device)
except exc.HTTPNotFound:
raise exc.CommandError('Device update failed: host %s device %s : update %s' % (args.hostnameorid, nameorpciaddr, patch))
raise exc.CommandError('Device update failed: host %s device %s : update %s' % (args.hostnameorid, args.nameorpciaddr, patch))

View File

@ -8,7 +8,6 @@
#
from cgtsclient.common import base
from cgtsclient import exc
class Port(base.Resource):
@ -38,4 +37,3 @@ def get_port_display_name(p):
return p.namedisplay
else:
return '(' + str(p.uuid)[-8:] + ')'

View File

@ -12,7 +12,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from cgtsclient.v1 import ihost as ihost_utils

View File

@ -11,7 +11,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
def _print_remotelogging_show(remotelogging):
@ -20,7 +19,6 @@ def _print_remotelogging_show(remotelogging):
'enabled',
'transport',
'port',
#NC 'key_file',
'created_at',
'updated_at']
@ -64,10 +62,6 @@ def donot_config_remotelogging_list(cc, args):
metavar='<port>',
default=None,
help="Remote log server port.")
#@utils.arg('--key_file',
# metavar='<key_file>',
# default=None,
# help="Remote log server TLS key file.")
def do_remotelogging_modify(cc, args):
"""Modify Remote Logging attributes."""

View File

@ -79,15 +79,15 @@ def do_host_route_add(cc, args):
field_list = ['network', 'prefix', 'gateway', 'metric']
## Lookup parent host and interface
# Lookup parent host and interface
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
iinterface = iinterface_utils._find_interface(cc, ihost, args.ifnameorid)
## Prune input fields down to required/expected values
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))
## Insert interface UUID
# Insert interface UUID
data['interface_uuid'] = iinterface.uuid
route = cc.route.create(**data)

View File

@ -11,7 +11,6 @@
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.common import constants
def _print_sdn_controller_show(obj):
@ -22,6 +21,7 @@ def _print_sdn_controller_show(obj):
data = [(f, getattr(obj, f, '')) for f in fields]
utils.print_tuple_list(data, labels)
@utils.arg('uuid', metavar='<uuid>',
help="ID of the SDN controller to show")
def do_sdn_controller_show(cc, args):
@ -34,6 +34,7 @@ def do_sdn_controller_show(cc, args):
args.uuid)
_print_sdn_controller_show(controller)
def do_sdn_controller_list(cc, args):
"""List all SDN controllers."""
@ -87,6 +88,7 @@ def do_sdn_controller_add(cc, args):
% uuid)
_print_sdn_controller_show(controller)
@utils.arg('uuid',
metavar='<uuid>',
help="The UUID of the SDN Controller")
@ -100,6 +102,7 @@ def do_sdn_controller_delete(cc, args):
"invalid uuid: %s" % args.uuid)
print 'Deleted SDN controller: uuid %s' % args.uuid
@utils.arg('uuid',
metavar='<uuid>',
help="UUID of the SDN Controller being modified [REQUIRED]")
@ -144,4 +147,3 @@ def do_sdn_controller_modify(cc, args):
patch.append({'op': 'replace', 'path': '/' + k, 'value': v})
updated_controller = cc.sdn_controller.update(controller.uuid, patch)
_print_sdn_controller_show(updated_controller)

View File

@ -7,9 +7,8 @@
# -*- encoding: utf-8 -*-
#
from cgtsclient.common import base
from cgtsclient import exc
from ceilometerclient.v2 import options
from cgtsclient.common import base
class ServiceParameter(base.Resource):
@ -52,4 +51,3 @@ class ServiceParameterManager(base.Manager):
new = {}
new['service'] = service
return self.api.json_request('POST', self._path() + "/apply", body=new)

View File

@ -8,10 +8,10 @@
# All Rights Reserved.
#
from ceilometerclient.v2 import options
from cgtsclient.common import utils
from cgtsclient import exc
from collections import OrderedDict
from ceilometerclient.v2 import options
def _print_service_parameter_show(obj):
fields = ['uuid', 'service', 'section', 'name', 'value',
@ -25,7 +25,6 @@ def _print_service_parameter_show(obj):
help="UUID of service parameter")
def do_service_parameter_show(cc, args):
"""Show Service parameter."""
service_parameter = cc.service_parameter.get(args.uuid)
_print_service_parameter_show(service_parameter)
@ -41,7 +40,6 @@ def do_service_parameter_show(cc, args):
help="Search by parameter name")
def do_service_parameter_list(cc, args):
"""List Service parameters."""
query = None
field_list = ['service', 'section', 'name']
for (k, v) in vars(args).items():
@ -69,9 +67,7 @@ def do_service_parameter_delete(cc, args):
def _find_service_parameter(cc, service, section, name):
service_parameters = cc.service_parameter.list()
for p in service_parameters:
if (p.service == service and
p.section == section and
p.name == name):
if p.service == service and p.section == section and p.name == name:
break
else:
p = None
@ -187,5 +183,3 @@ def do_service_parameter_add(cc, args):
raise exc.CommandError('Service parameter not found: %s' % uuid)
_print_service_parameter_show(parameter)

View File

@ -3,62 +3,62 @@
#
# SPDX-License-Identifier: Apache-2.0
#
#
from cgtsclient.common import utils
from cgtsclient.v1 import address_shell
from cgtsclient.v1 import address_pool_shell
from cgtsclient.v1 import isystem_shell
from cgtsclient.v1 import iHost_shell
from cgtsclient.v1 import address_shell
from cgtsclient.v1 import ceph_mon_shell
from cgtsclient.v1 import certificate_shell
from cgtsclient.v1 import cluster_shell
from cgtsclient.v1 import controller_fs_shell
from cgtsclient.v1 import drbdconfig_shell
from cgtsclient.v1 import ethernetport_shell
from cgtsclient.v1 import event_log_shell
from cgtsclient.v1 import event_suppression_shell
from cgtsclient.v1 import firewallrules_shell
from cgtsclient.v1 import health_shell
from cgtsclient.v1 import ialarm_shell
from cgtsclient.v1 import icommunity_shell
from cgtsclient.v1 import icpu_shell
from cgtsclient.v1 import imemory_shell
from cgtsclient.v1 import iinterface_shell
from cgtsclient.v1 import idisk_shell
from cgtsclient.v1 import istor_shell
from cgtsclient.v1 import idns_shell
from cgtsclient.v1 import iextoam_shell
from cgtsclient.v1 import iHost_shell
from cgtsclient.v1 import iinfra_shell
from cgtsclient.v1 import iinterface_shell
from cgtsclient.v1 import ilvg_shell
from cgtsclient.v1 import ipv_shell
from cgtsclient.v1 import imemory_shell
from cgtsclient.v1 import intp_shell
from cgtsclient.v1 import iprofile_shell
from cgtsclient.v1 import ipv_shell
from cgtsclient.v1 import isensor_shell
from cgtsclient.v1 import isensorgroup_shell
from cgtsclient.v1 import istor_shell
from cgtsclient.v1 import isystem_shell
from cgtsclient.v1 import itrapdest_shell
from cgtsclient.v1 import iuser_shell
from cgtsclient.v1 import license_shell
from cgtsclient.v1 import lldp_agent_shell
from cgtsclient.v1 import lldp_neighbour_shell
from cgtsclient.v1 import load_shell
from cgtsclient.v1 import network_shell
from cgtsclient.v1 import partition_shell
from cgtsclient.v1 import pci_device_shell
from cgtsclient.v1 import port_shell
from cgtsclient.v1 import remotelogging_shell
from cgtsclient.v1 import route_shell
from cgtsclient.v1 import sdn_controller_shell
from cgtsclient.v1 import service_parameter_shell
from cgtsclient.v1 import sm_service_nodes_shell
from cgtsclient.v1 import sm_service_shell
from cgtsclient.v1 import sm_servicegroup_shell
from cgtsclient.v1 import ialarm_shell
from cgtsclient.v1 import icommunity_shell
from cgtsclient.v1 import itrapdest_shell
from cgtsclient.v1 import iuser_shell
from cgtsclient.v1 import idns_shell
from cgtsclient.v1 import intp_shell
from cgtsclient.v1 import iextoam_shell
from cgtsclient.v1 import controller_fs_shell
from cgtsclient.v1 import storage_backend_shell
from cgtsclient.v1 import ceph_mon_shell
from cgtsclient.v1 import drbdconfig_shell
from cgtsclient.v1 import event_log_shell
from cgtsclient.v1 import event_suppression_shell
from cgtsclient.v1 import iinfra_shell
from cgtsclient.v1 import ethernetport_shell
from cgtsclient.v1 import port_shell
from cgtsclient.v1 import route_shell
from cgtsclient.v1 import isensor_shell
from cgtsclient.v1 import isensorgroup_shell
from cgtsclient.v1 import load_shell
from cgtsclient.v1 import pci_device_shell
from cgtsclient.v1 import upgrade_shell
from cgtsclient.v1 import network_shell
from cgtsclient.v1 import service_parameter_shell
#from cgtsclient.v1 import storagepool_shell
from cgtsclient.v1 import cluster_shell
from cgtsclient.v1 import lldp_agent_shell
from cgtsclient.v1 import lldp_neighbour_shell
from cgtsclient.v1 import license_shell
from cgtsclient.v1 import health_shell
from cgtsclient.v1 import remotelogging_shell
from cgtsclient.v1 import sdn_controller_shell
from cgtsclient.v1 import firewallrules_shell
from cgtsclient.v1 import partition_shell
from cgtsclient.v1 import certificate_shell
from cgtsclient.v1 import storage_tier_shell
from cgtsclient.v1 import upgrade_shell
COMMAND_MODULES = [
isystem_shell,
@ -100,7 +100,6 @@ COMMAND_MODULES = [
upgrade_shell,
network_shell,
service_parameter_shell,
#storagepool_shell,
cluster_shell,
lldp_agent_shell,
lldp_neighbour_shell,

View File

@ -53,8 +53,7 @@ def do_servicenode_show(cc, args):
try:
node = cc.sm_service_nodes.get(args.node)
except exc.HTTPNotFound:
raise exc.CommandError(
'Service Node not found: %s' % args.node)
raise exc.CommandError('Service Node not found: %s' % args.node)
except exc.Forbidden:
raise exc.CommandError("Not authorized. The requested action "
"requires 'admin' level")

View File

@ -18,9 +18,8 @@
#
# Copyright (c) 2013-2017 Wind River Systems, Inc.
#
import socket
from cgtsclient.common import utils
from cgtsclient import exc

View File

@ -18,11 +18,10 @@
#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#
from cgtsclient.common import utils
from cgtsclient import exc
def _print_iservicegroup_show(servicegroup):
fields = ['uuid', 'name', 'hostname', 'service_group_name', 'state']
data = dict([(f, getattr(servicegroup, f, '')) for f in fields])
@ -52,8 +51,7 @@ def do_servicegroup_show(cc, args):
try:
servicegroup = cc.sm_servicegroup.get(args.servicegroup)
except exc.HTTPNotFound:
raise exc.CommandError(
'Service Group not found: %s' % args.servicegroup)
raise exc.CommandError('Service Group not found: %s' % args.servicegroup)
except exc.Forbidden:
raise exc.CommandError("Not authorized. The requested action "
"requires 'admin' level")
@ -114,6 +112,5 @@ def donot_servicegroup_modify_labonly(cc, args):
try:
iservicegroup = cc.smapiClient.iservicegroup.update(args.iservicegroup, patch)
except exc.HTTPNotFound:
raise exc.CommandError(
'Service Group not found: %s' % args.iservicegroup)
raise exc.CommandError('Service Group not found: %s' % args.iservicegroup)
_print_iservicegroup_show(iservicegroup)

View File

@ -8,14 +8,14 @@
#
from cgtsclient.common import base
from cgtsclient.common import utils
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import ceph_mon as ceph_mon_utils
from cgtsclient.v1 import storage_ceph # noqa
from cgtsclient.v1 import storage_external # noqa
from cgtsclient.v1 import storage_file # noqa
from cgtsclient.v1 import storage_lvm # noqa
from cgtsclient.v1 import storage_external # noqa
from oslo_serialization import jsonutils
CREATION_ATTRIBUTES = ['forisystemid', 'backend']

View File

@ -14,10 +14,12 @@ CREATION_ATTRIBUTES = ['confirmed', 'name', 'services', 'capabilities']
DISPLAY_ATTRIBUTES = []
PATCH_ATTRIBUTES = []
class StorageExternal(base.Resource):
def __repr__(self):
return "<storage_external %s>" % self._info
class StorageExternalManager(base.Manager):
resource_class = StorageExternal

View File

@ -8,8 +8,6 @@
#
from cgtsclient.common import base
from cgtsclient import exc
CREATION_ATTRIBUTES = ['state', 'from_load', 'to_load']

View File

@ -9,9 +9,9 @@
# All Rights Reserved.
#
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.common import constants
def _print_upgrade_show(obj):

View File

@ -0,0 +1,218 @@
[MASTER]
# Specify a configuration file.
rcfile=pylint.rc
# Python code to execute, usually for sys.path manipulation such as pygtk.require().
#init-hook=
# Add files or directories to the blacklist. They should be base names, not paths.
ignore=tests
# Pickle collected data for later comparisons.
persistent=yes
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
[MESSAGES CONTROL]
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
# https://pylint.readthedocs.io/en/latest/user_guide/output.html#source-code-analysis-section
# We are disabling (C)onvention
# We are disabling (R)efactor
# We are probably disabling (W)arning
# We are not disabling (F)atal, (E)rror
#disable=C,R,W
disable=C,R,W
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html
output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no
# Tells whether to display a full report or only the messages
reports=no
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=4
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=85
# Maximum number of lines in a module
max-module-lines=1000
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).
indent-string=' '
[TYPECHECK]
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
generated-members=REQUEST,acl_users,aq_parent
[BASIC]
# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input
# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression which should only match correct module level names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Regular expression which should only match correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$
# Regular expression which should only match correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct method names
method-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct instance attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct variable names
variable-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct list comprehension /
# generator expression variable names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,ex,Run,_
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Regular expression which should only match functions or classes name which do
# not require a docstring
no-docstring-rgx=__.*__
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
[VARIABLES]
# Tells whether we should check for unused import in __init__ files.
init-import=no
# A regular expression matching the beginning of the name of dummy variables
# (i.e. not used).
dummy-variables-rgx=_|dummy
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
[IMPORTS]
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of branch for function / method body
max-branchs=12
# Maximum number of statements in function / method body
max-statements=50
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

View File

@ -0,0 +1,2 @@
python-neutronclient
python-ceilometerclient

View File

@ -0,0 +1,36 @@
[metadata]
name = cgtsclient
version = 1.0.0
summary = Titanium Cloud System Client and CLI
description-file =
README.rst
author = WindRiver
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: windriver
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
[global]
setup-hooks =
pbr.hooks.setup_hook
[files]
packages =
cgtsclient
[entry_points]
console_scripts =
system = cgtsclient.shell:main
[pbr]
autodoc_index_modules = False
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0

View File

@ -6,18 +6,25 @@
import setuptools
setuptools.setup(
name='cgtsclient',
description='CGCS System Client and CLI',
version='1.0.0',
license='Apache-2.0',
packages=['cgtsclient', 'cgtsclient.v1', 'cgtsclient.openstack',
'cgtsclient.openstack.common',
'cgtsclient.openstack.common.config',
'cgtsclient.openstack.common.rootwrap',
'cgtsclient.common'],
entry_points={
'console_scripts': [
'system = cgtsclient.shell:main'
]}
description='Titanium Cloud System Client and CLI',
classifiers=[
'Environment :: OpenStack',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: windriver',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2.6',
],
include_package_data=True,
setup_requires=['pbr>=0.5'],
pbr=True,
packages=setuptools.find_packages()
)

View File

@ -0,0 +1,22 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
bandit>=1.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0 # BSD
mox
os-testr>=0.8.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
sphinx>=1.6.2 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
testresources>=0.2.4 # Apache-2.0/BSD
tempest>=16.1.0 # Apache-2.0
httplib2
python-keystoneclient
keyring

View File

@ -0,0 +1,75 @@
[tox]
envlist = py27,pep8,cover,pylint
minversion = 1.6
#skipsdist = True
# tox does not work if the path to the workdir is too long, so move it to /tmp
toxworkdir = /tmp/{env:USER}_cgtsclienttox
wrsdir = {toxinidir}/../../../../../../../../..
cgcsdir = {toxinidir}/../../../../..
avsdir = {toxinidir}/../../../../../../../../wr-avs/layers/avs
distshare={toxworkdir}/.tox/distshare
wrdeps = -e{[tox]cgcsdir}/tsconfig/tsconfig
[testenv]
setenv = VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
OS_TEST_PATH=cgtsclient/tests
TESTR_START_DIR=cgtsclient/tests
basepython = python2.7
usedevelop = True
install_command = pip install -U {[tox]wrdeps} -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}'
whitelist_externals =
bash
find
rm
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:pep8]
commands =
flake8 cgtsclient
[testenv:venv]
commands = {posargs}
[testenv:cover]
basepython = python2.7
commands =
find . -type f -name ".coverage\.*" -delete
rm -f .coverage
rm -Rf cover
rm -f coverage.xml
python setup.py testr --coverage --testr-args='{posargs}'
coverage xml
[flake8]
show-source = true
exclude=.*,dist,*lib/python*,*egg,build
max-complexity=25
ignore = H102,H104,H105,H233,H238,H404,H405,E501,F841
#H102 Apache 2.0 license header not found
#H104 File contains nothing but comments
#H105 Don't use author tags
#H233 Python 3.x incompatible use of print operator
#H238 old style class declaration, use new style (inherit from `object`)
#H404 multi line docstring should start without a leading new line
#H405 multi line docstring summary not separated with an empty line
#E501 line too long
#F841 local variable 'X' is assigned to but never used
[testenv:pylint]
basepython = python2.7
deps = {[testenv]deps}
pylint
commands = pylint {posargs} cgtsclient --rcfile=./pylint.rc --extension-pkg-whitelist=lxml.etree,greenlet