Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into repo-path
Browse files Browse the repository at this point in the history
Conflicts:
	src/app/models/glue/pulp/repo.rb
	src/app/models/glue/pulp/repos.rb
	src/spec/models/repo_spec.rb
  • Loading branch information
iNecas committed Aug 30, 2011
2 parents 3669985 + 54d634b commit a836e86
Show file tree
Hide file tree
Showing 252 changed files with 10,719 additions and 3,279 deletions.
339 changes: 339 additions & 0 deletions cli/LICENSE

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions cli/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This is Katello command line client.

Usage: katello [options]

HACKING

Run unit tests (install python-mock - available in Fedora 17+)

nosetests

Compile a test RPM:

tito build --rpm --test --rpmbuild-options=--nodeps
1 change: 1 addition & 0 deletions cli/bin/katello
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def setup_admin(admin):
prod_cmd.add_action('create', product.Create())
prod_cmd.add_action('list', product.List())
prod_cmd.add_action('synchronize', product.Sync())
prod_cmd.add_action('status', product.Status())
prod_cmd.add_action('promote', product.Promote())
admin.add_command('product', prod_cmd)

Expand Down
51 changes: 48 additions & 3 deletions cli/katello-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Summary: Client package for managing application life-cycle for Linux syst
Group: Applications/System
License: GPLv2
URL: http://www.katello.org
Version: 0.1.5
Version: 0.1.6
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Expand Down Expand Up @@ -57,19 +57,64 @@ rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README LICENSE
%{python_sitelib}/%{base_name}/
%attr(755,root,root) %{_bindir}/%{base_name}
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/%{base_name}/client.conf
#%{_mandir}/man8/%{base_name}.8*


%changelog
* Mon Aug 29 2011 Lukas Zapletal <lzap+git@redhat.com> 0.1.6-1
- cli - fixes for several typos
- cli tests - removed call of nonexisting function
- cli - product and repo uses AsyncTask
- cli - changeset promotion fix
- fix for cli issues with removed cp_id
- cli tests - product promote 2
- cli tests - product promote
- cli tests - product status
- cli tests - product sync
- cli tests - tests for listing and creation use common test data
- cli tests - test data
- product cli - fix for using wrong field from hash
- cli tests - product list
- cli tests - added mocking for printer to utils
- products cli - now displaying provider name
- sync cli - sync format functions refactoring
- products cli - fixed commands according to recent changes
- products cli - added action status
- cli repo status - displaying synchronization progress
- cli - asynchronous tasks refactored
- repo status - repo now defined also by org,product,env and name
- katello-cli - storing options to client-options.conf
- katello-cli - adding LICENSE and README with unit test info
- katelli-cli spec changelog cleanup
- 723308 - verbose environment information should list names not ids
- simple puppet scripts
- cli unittests - fix in testing parameters 2
- cli unittests - fix in testing parameters tests were using stored values from
config files
- repo cli - all '--repo' renamed to '--name' to make the paramaters consistent
accross the cli
- fix for cli repo sync failing when sync was unsuccessful
- cli test utils - renamed variable
- cli unit tests for repo sync + cli test utils
- more tests for provider sync cli
- added provider sync tests for cli
- fixed failing product creation tests for cli
- Merge branch 'master' of ssh://git.fedorahosted.org/git/katello
- Get translations in for the cli
- repo sync - check for syncing only repos in locker
- Automatic commit of package [katello-cli] release [0.1.5-1].
- 731446 - more variable name fixes

* Thu Aug 18 2011 Mike McCune <mmccune@redhat.com> 0.1.5-1
- periodic retag of the cli package
- periodic retag of the cli package

* Mon Aug 01 2011 Lukas Zapletal <lzap+git@redhat.com> 0.1.4-1
- spec - rpmlint cleanup
- Added api support for activation keys
- Merge branch 'master' of ssh://git.fedorahosted.org/git/katello
- Turn on package updating
- Bug 725719 - Simple CLI tests are failing with -s parameter
- Bug 726416 - Katello-cli is failing on some terminals
Expand Down
6 changes: 6 additions & 0 deletions cli/src/katello/client/api/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# in this software or its documentation.

from katello.client.api.base import KatelloAPI
from pprint import pprint

class ProductAPI(KatelloAPI):
"""
Expand Down Expand Up @@ -60,3 +61,8 @@ def create(self, provId, name, description):
def sync(self, prodId):
path = "/api/products/%s/sync" % prodId
return self.server.POST(path)[1]

def last_sync_status(self, prodId):
path = "/api/products/%s/sync" % prodId
data = self.server.GET(path)[1]
return data
5 changes: 5 additions & 0 deletions cli/src/katello/client/api/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def sync(self, repo_id):
data = self.server.POST(path)[1]
return data

def last_sync_status(self, repo_id):
path = "/api/repositories/%s/sync" % repo_id
data = self.server.GET(path)[1]
return data

def repo_discovery(self, url, repotype):
discoverydata = {"url": url, "type": repotype}
path = "/api/repositories/discovery"
Expand Down
8 changes: 4 additions & 4 deletions cli/src/katello/client/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def get_environment(orgName, envName=None):
def get_product(orgName, prodName):
product_api = ProductAPI()

prov = product_api.product_by_name(orgName, prodName)
if prov == None:
prod = product_api.product_by_name(orgName, prodName)
if prod == None:
print _("Could not find product [ %s ] within organization [ %s ]") % (prodName, orgName)
return prov
return prod


def get_repo(orgName, prodName, repoName, envName=None):
Expand All @@ -70,7 +70,7 @@ def get_repo(orgName, prodName, repoName, envName=None):
print _("Could not find product [ %s ]") % prodName
return None

repos = repo_api.repos_by_env_product(env["id"], prod["cp_id"])
repos = repo_api.repos_by_env_product(env["id"], prod["id"])
for repo in repos:
if repo["name"] == repoName:
return repo
Expand Down
27 changes: 22 additions & 5 deletions cli/src/katello/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import os
import ConfigParser


class Config(object):
"""
The katello client configuration.
Expand All @@ -33,7 +32,8 @@ class Config(object):
http://docs.python.org/library/configparser.html .
To save to the config file after making changes, call 'Config.save()' and the
changes will be written to file.
changes will be written to file. Please note this only saves 'options'
section of the file storing it in the client-options.conf file.
Config throws an Exception if 'Config.save()' is called before initializing
the Config object.
Expand All @@ -48,6 +48,7 @@ class Config(object):
FILE = 'client.conf'
PATH = os.path.join('/etc/katello', FILE)
USER = os.path.expanduser(os.path.join('~/.katello', FILE))
USER_OPTIONS = os.path.expanduser(os.path.join('~/.katello', 'client-options.conf'))

parser = None

Expand All @@ -66,13 +67,29 @@ def __init__(self):
# read user config if it exists
Config.parser.read(Config.USER)

# read user options if it exists
Config.parser.read(Config.USER_OPTIONS)

if Config.parser.has_section("DEFAULT"):
raise Exception('Default section in configuration is not supported')

@staticmethod
def save():
"""
Save the current state of the RawConfigParser to file
Save the "options" section to the client-options.conf file.
Please note other settings (other sections) are not saved!
"""
if not Config.parser:
raise Exception('Config.parser has not been initialized.')

# only writes to ~/.katello/client.conf
Config.parser.write(open(Config.USER, 'w'))
opt = ConfigParser.RawConfigParser()
# write a comment informing user not to use this file for own settings
opt.set('', '# = do not edit and use client.conf instead', '')
opt.add_section('options')

for option in Config.parser.options('options'):
value = Config.parser.get('options', option)
opt.set('options', option, value)

opt.write(open(Config.USER_OPTIONS, 'w'))
1 change: 1 addition & 0 deletions cli/src/katello/client/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def require_credentials(self):
return True

def error(self, errorMsg):
print errorMsg
_log.error("error: %s" % str(errorMsg))
print >> sys.stderr, _('error: operation failed: ') + str(errorMsg)

Expand Down
14 changes: 6 additions & 8 deletions cli/src/katello/client/core/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from katello.client.api.changeset import ChangesetAPI
from katello.client.config import Config
from katello.client.core.base import Action, Command
from katello.client.core.utils import system_exit, is_valid_record, get_abs_path, run_spinner_in_bg, format_date, wait_for_async_task
from katello.client.core.utils import system_exit, is_valid_record, get_abs_path, run_spinner_in_bg, format_date, wait_for_async_task, AsyncTask
from katello.client.api.utils import get_environment, get_changeset

try:
Expand Down Expand Up @@ -315,18 +315,16 @@ def run(self):
if cset == None:
return os.EX_DATAERR

try:
task = self.api.promote(cset["id"])
except Exception, e:
system_exit(os.EX_DATAERR, _("Error: %s" % e))
task = self.api.promote(cset["id"])
task = AsyncTask(task)

result = run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the changeset, please wait... "))
run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the changeset, please wait... "))

if result['state'] == 'finished':
if task.succeeded():
print _("Changeset [ %s ] promoted" % csName)
return os.EX_OK
else:
print _("Changeset [ %s ] promotion failed: %s" % (csName, json.loads(result["result"])['errors'][0]))
print _("Changeset [ %s ] promotion failed: %s" % (csName, json.loads(task.get_hashes()[0]["result"])['errors'][0]))
return os.EX_DATAERR


Expand Down
4 changes: 2 additions & 2 deletions cli/src/katello/client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(self):
print ("Successfully " + verb + " option [ {} ] ").format(option)
except (Exception):
print "Unsuccessfully remembered option [ {} ]".format(option)
return os.EX_DATAERR
raise # re-raise to get into main method -> log

return os.EX_OK

Expand All @@ -88,7 +88,7 @@ def run(self):
print "Successfully forgot option [ {} ]".format(option)
except (Exception):
print "Unsuccessfully forgot option [ {} ]".format(option)
return os.EX_DATAERR
raise # re-raise to get into main method -> log

return os.EX_OK

Expand Down
4 changes: 2 additions & 2 deletions cli/src/katello/client/core/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def run(self):
self.printer.addColumn('id')
self.printer.addColumn('name')
self.printer.addColumn('description', multiline=True)
self.printer.addColumn('organization_id', 'Org Id')
self.printer.addColumn('prior', 'Prior Id')
self.printer.addColumn('organization', _('Org'))
self.printer.addColumn('prior', _('Prior Environment'))

self.printer.setHeader(_("Environment List"))
self.printer.printItems(envs)
Expand Down
Loading

0 comments on commit a836e86

Please sign in to comment.