Project

General

Profile

Download (1.52 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / lib / hammer_cli_csv / subscriptions.rb @ f8ecc788

1
# Copyright 2013-2014 Red Hat, Inc.
2
#
3
# This software is licensed to you under the GNU General Public
4
# License as published by the Free Software Foundation; either version
5
# 2 of the License (GPLv2) or (at your option) any later version.
6
# There is NO WARRANTY for this software, express or implied,
7
# including the implied warranties of MERCHANTABILITY,
8
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
# have received a copy of GPLv2 along with this software; if not, see
10
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11

    
12
#
13
# -= Systems CSV =-
14
#
15
# Columns
16
#   Name
17
#     - System name
18
#     - May contain '%d' which will be replaced with current iteration number of Count
19
#     - eg. "os%d" -> "os1"
20
#   Count
21
#     - Number of times to iterate on this line of the CSV file
22

    
23

    
24
require 'hammer_cli'
25
require 'json'
26
require 'csv'
27
require 'uri'
28

    
29
module HammerCLICsv
30
  class SubscriptionsCommand < BaseCommand
31

    
32
    ORGANIZATION = 'Organization'
33
    MANIFEST = 'Manifest File'
34

    
35
    def export
36
      # TODO
37
    end
38

    
39
    def import
40
      thread_import do |line|
41
        create_subscriptions_from_csv(line)
42
      end
43
    end
44

    
45
    def create_subscriptions_from_csv(line)
46
      puts "TODO: import #{line[MANIFEST]} into organization #{line[ORGANIZATION]}"
47
    rescue RuntimeError => e
48
      raise "#{e}\n       #{line}"
49
    end
50
  end
51

    
52
  HammerCLICsv::CsvCommand.subcommand("subscriptions",
53
                                      "import or export subscriptions",
54
                                      HammerCLICsv::SubscriptionsCommand)
55
end