Class: Shards::Client

Inherits:
Thor
  • Object
show all
Defined in:
lib/shards/client.rb

Instance Method Summary collapse

Instance Method Details

#add_dns_record(location, stage, domain) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
# File 'lib/shards/client.rb', line 172

def add_dns_record(location, stage, domain)

  d = get_dns location, stage, domain

  if d.exist?
    puts "There is already a record for the host %s " % d.host
  else
    d.set dryrun: false
  end

end

#create(location, stage, client, domain) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/shards/client.rb', line 11

def create location, stage, client, domain

  fast_terminal=Shards::Workflow::FastTerminal.new config
  fast_terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage }
  fast_terminal.start

end

#create2(location, stage, client, domain) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/shards/client.rb', line 21

def create2 location, stage, client, domain

  fast_terminal=Shards::Workflow::FastTerminalTwo.new config
  fast_terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage }
  fast_terminal.start

end

#databases(location, stage) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/shards/client.rb', line 104

def databases(location, stage)

  s = get_stage location, stage
  db=Shards::Db.new stage: s
  db.show

  rows=filter db.database_server, options[:filter]

  columns %w(Database Server), rows

end

#delete(location, stage, subdomain) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/shards/client.rb', line 62

def delete location, stage, subdomain

  terminal=Shards::Workflow::DeleteByTerminal.new config
  terminal.params= { subdomain: subdomain, location: location.downcase, stage: stage }
  terminal.start

end

#delete_db(location, stage, database) ⇒ Object



118
119
120
121
122
123
124
125
126
# File 'lib/shards/client.rb', line 118

def delete_db(location, stage, database)

  s = get_stage location, stage
  terminal=Shards::Workflow::DeleteByTerminal.new config
  terminal.stage=s
  terminal.database_to_drop=database
  terminal.start_at 'delete_database'

end

#delete_subdomain_record(location, stage, subdomain) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/shards/client.rb', line 153

def delete_subdomain_record(location, stage, subdomain)

  d = get_dns location, stage

  d.subdomain_param=subdomain

  exist=d.exist?

  puts "Subdomain: #{subdomain} , exists: #{exist}"

  if exist
    d.delete
    puts "Host: #{d.host_param} deleted!"
  end

end

#dns(location, stage, domain) ⇒ Object



131
132
133
134
135
136
137
# File 'lib/shards/client.rb', line 131

def dns(location, stage, domain)

  d = get_dns location.downcase, stage, domain

  puts "Host: #{d.host} , exists: #{d.exist?}"

end

#fingerprints(location, stage) ⇒ Object



205
206
207
208
209
210
211
# File 'lib/shards/client.rb', line 205

def fingerprints(location, stage)

  s = get_stage location, stage

  puts s.check_remote_process remote_check: :fingerprints

end

#list(location, stage) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/shards/client.rb', line 86

def list(location, stage)

  s = get_stage location, stage

  rows=s.shard.list.each_pair.map do |k,v|
    [ k, v['database'], v['host'] ]
  end

  rows=filter rows, options[:filter]

  columns %w(Shard Database Host), rows

end

#locationsObject



72
73
74
75
76
77
78
79
80
# File 'lib/shards/client.rb', line 72

def locations

  rows=config.locations.each_pair.map do |k, v|
    [k , v.stages.keys.join(' ') ]
  end

  columns %w(Locations Stages), rows

end

#loop_fingerprint_check(location, stage, client, domain) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/shards/client.rb', line 31

def loop_fingerprint_check location, stage, client, domain

  terminal=Shards::Workflow::FingerprintsTerminal.new config
  terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage }
  terminal.start

end

#loop_fingerprint_check2(location, stage) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/shards/client.rb', line 41

def loop_fingerprint_check2 location, stage

  terminal=Shards::Workflow::FingerprintsTerminalTwo.new config
  terminal.params= { location: location.downcase, stage: stage }
  terminal.start

end

#puppet(location, stage) ⇒ Object



215
216
217
218
219
220
221
# File 'lib/shards/client.rb', line 215

def puppet(location, stage)

  s = get_stage location, stage

  puts s.check_remote_process remote_check: :puppet_agent!

end

#reload_shards(location, stage) ⇒ Object



225
226
227
228
229
230
231
# File 'lib/shards/client.rb', line 225

def reload_shards(location, stage)

  s = get_stage location, stage

  puts s.check_remote_process remote_check: :reload_shards!

end

#sites(location, stage) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/shards/client.rb', line 187

def sites(location, stage)

  s = get_stage location, stage

  site=Shards::Site.new s

  rows=site.yaml.map do |x|
    [ x['name'], x['subdomain'], x['shard'] ]
  end

  rows=filter rows, options[:filter]
  columns %w(Name Subdomain Shard), rows

end

#subdomain_dns(location, stage, subdomain) ⇒ Object



141
142
143
144
145
146
147
148
149
# File 'lib/shards/client.rb', line 141

def subdomain_dns(location, stage, subdomain)

  d = get_dns location, stage

  d.subdomain_param=subdomain

  puts "Subdomain: #{subdomain} , exists: #{d.exist?}"

end