Class: SSC::Client

Inherits:
Handler::Base show all
Includes:
DirectoryManager
Defined in:
lib/ssc.rb

Constant Summary

Constants inherited from Handler::Base

Handler::Base::API_URL

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Handler::Base

#initialize

Methods included from Handler::Helper

included

Constructor Details

This class inherits a constructor from SSC::Handler::Base

Class Method Details

.help(*args) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ssc.rb', line 122

def help(*args)
  message= <<HELP_MESSAGE 
Tasks:
  ssc checkout          # checkout the latest changes to an appliance
  ssc commit            # commit changes to studio
  ssc status            # show status of the appliance

  ssc appliance         # manage appliances
  ssc build             # manage builds
  ssc file              # manage files
  ssc package           # manage packages
  ssc repository        # manage repositories
  ssc template          # manage templates

  ssc help [TASK]       # Describe available tasks or one specific task
HELP_MESSAGE
 puts message
end

Instance Method Details

#checkoutObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ssc.rb', line 61

def checkout
  params= {:appliance_id => options.appliance_id,
           :username     => options.username,
           :password     => options.password}
  require_appliance_directory do |appliance, files|
    options= params.merge(:remote => true)
    invoke "s_s_c:handler:package:list", ["installed"], options
    invoke "s_s_c:handler:repository:list",  [], options
    invoke "s_s_c:handler:overlay_file:list",  [], options
  end
rescue ApplianceDirectoryError
  require_appliance do |appliance|
    ApplianceDirectory.new(appliance.name, params).create
    Dir.chdir(appliance.name)
    options= params.merge(:remote => true)
    invoke "s_s_c:handler:package:list", ["installed"], options
    invoke "s_s_c:handler:repository:list",  [], options
    invoke "s_s_c:handler:overlay_file:list",  [], options
  end
end

#commitObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/ssc.rb', line 84

def commit
  params= {:remote       => true,
           :appliance_id => options.appliance_id,
           :username     => options.username,
           :password     => options.password}

  # Add or Remove Repositories
  repository_file= RepositoryFile.new
  ["add", "remove"].each do |action|
    while repository= repository_file.pop(action)
      invoke "s_s_c:handler:repository:#{action}", [repository], params
    end
  end
  repository_file.save

  # Add, Remove, Ban and Unban  Packages
  package_file= PackageFile.new
  ["add", "remove", "ban", "unban"].each do |action|
    while package= package_file.pop(action)
      invoke "s_s_c:handler:package:#{action}", [package], params
    end
  end
  package_file.save

  # Add Overlay Files
  file_list = FileListFile.new
  while file= file_list.pop("add")
    params= params.merge(file[:params])
    invoke "s_s_c:handler:overlay_file:add", [file[:full_path]], params
  end
  # Remove Overlay Files
  while file= file_list.pop("remove")
    invoke "s_s_c:handler:overlay_file:remove", [file[:name]], params
  end
  file_list.save
end

#statusObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ssc.rb', line 24

def status
  require_appliance_directory do |appliance, files|
    # Show appliance status
    say "Appliance: id: #{appliance.id} | name: #{appliance.name}"
    say "Status: #{appliance.status.state}"
    say appliance.status.issues

    # Show additions
    say "\nAdditions : \n"
    say "\nPackages : \n"
    say_array files[:package]["add"]
    say "\nRepositories : \n"
    say_array files[:repository]["add"]
    say "\nOverlay Files : \n"
    say_array(files[:file_list]["add"]) {|i| i.keys[0]}

    # Show removals
    say "\nRemovals : \n"
    say "\nPackages : \n"
    say_array files[:package]["remove"]
    say "\nRepositories : \n"
    say_array files[:repository]["remove"]
    say "\nOverlay Files :\n "
    say_array(files[:file_list]["remove"]) {|i| i.keys[0]}

    # Show banned
    say "\nBanned Packages : \n"
    say_array files[:package]["ban"]
  
    # Show unbanned
    say "\nUnBanned Packages : \n"
    say_array files[:package]["unban"]
  end
end