Project

General

Profile

« Previous | Next » 

Revision 587327f4

Added by Thomas McKay about 10 years ago

cv-updates - a lot of updates and clean up
+ GPLv2 in files
+ updated to new dynamic apipie bindings
+ fixed domain and puppet environments associating to organizations

View differences:

lib/hammer_cli_csv/operating_systems.rb
# Copyright (c) 2013-2014 Red Hat
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Copyright 2013-2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# -= Operating Systems CSV =-
#
......
def export
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
csv << [NAME, COUNT, FAMILY]
@f_operatingsystem_api.index({:per_page => 999999})[0]['results'].each do |operatingsystem|
@api.resource(:operatingsystems).call(:index, {:per_page => 999999})['results'].each do |operatingsystem|
name = build_os_name(operatingsystem['name'], operatingsystem['major'], operatingsystem['minor'])
count = 1
family = operatingsystem['family']
......
def import
@existing = {}
@f_operatingsystem_api.index({:per_page => 999999})[0]['results'].each do |operatingsystem|
@api.resource(:operatingsystems).call(:index, {:per_page => 999999})['results'].each do |operatingsystem|
@existing[build_os_name(operatingsystem['name'], operatingsystem['major'], operatingsystem['minor'])] = operatingsystem['id'] if operatingsystem
end
......
(osname, major, minor) = split_os_name(name)
if !@existing.include? name
print "Creating operating system '#{name}'..." if option_verbose?
@f_operatingsystem_api.create({
@api.resource(:operatingsystems).call(:create, {
'operatingsystem' => {
'name' => osname,
'major' => major,
......
})
else
print "Updating operating system '#{name}'..." if option_verbose?
@f_operatingsystem_api.update({
@api.resource(:operatingsystems).call(:update, {
'id' => @existing[name],
'operatingsystem' => {
'name' => osname,

Also available in: Unified diff