Class: Shards::Client
- Inherits:
-
Thor
- Object
- Thor
- Shards::Client
- Defined in:
- lib/shards/client.rb
Instance Method Summary collapse
- #add_dns_record(location, stage, domain) ⇒ Object
- #create(location, stage, client, domain) ⇒ Object
- #databases(location, stage) ⇒ Object
- #delete(location, stage, subdomain) ⇒ Object
- #delete_db(location, stage, database) ⇒ Object
- #delete_subdomain_record(location, stage, subdomain) ⇒ Object
- #dns(location, stage, domain) ⇒ Object
- #fingerprints(location, stage) ⇒ Object
- #list(location, stage) ⇒ Object
- #locations ⇒ Object
- #loop_fingerprint_check(location, stage, client, domain) ⇒ Object
- #puppet(location, stage) ⇒ Object
- #reload_shards(location, stage) ⇒ Object
- #sites(location, stage) ⇒ Object
- #subdomain_dns(location, stage, subdomain) ⇒ Object
- #terminal ⇒ Object
Instance Method Details
#add_dns_record(location, stage, domain) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/shards/client.rb', line 159 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 |
#databases(location, stage) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/shards/client.rb', line 91 def databases(location, stage) s = get_stage location, stage db=Shards::Db.new stage: s db.show rows=filter db.database_server, [:filter] columns %w(Database Server), rows end |
#delete(location, stage, subdomain) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/shards/client.rb', line 42 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
105 106 107 108 109 110 111 112 113 |
# File 'lib/shards/client.rb', line 105 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
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/shards/client.rb', line 140 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
118 119 120 121 122 123 124 |
# File 'lib/shards/client.rb', line 118 def dns(location, stage, domain) d = get_dns location.downcase, stage, domain puts "Host: #{d.host} , exists: #{d.exist?}" end |
#fingerprints(location, stage) ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/shards/client.rb', line 192 def fingerprints(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :fingerprints end |
#list(location, stage) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/shards/client.rb', line 73 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, [:filter] columns %w(Shard Database Host), rows end |
#locations ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/shards/client.rb', line 59 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
21 22 23 24 25 26 27 |
# File 'lib/shards/client.rb', line 21 def loop_fingerprint_check location, stage, client, domain fast_terminal=Shards::Workflow::FingerprintTerminal.new config fast_terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage } fast_terminal.start end |
#puppet(location, stage) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/shards/client.rb', line 202 def puppet(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :puppet_agent! end |
#reload_shards(location, stage) ⇒ Object
212 213 214 215 216 217 218 |
# File 'lib/shards/client.rb', line 212 def reload_shards(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :reload_shards! end |
#sites(location, stage) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/shards/client.rb', line 174 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, [:filter] columns %w(Name Subdomain Shard), rows end |
#subdomain_dns(location, stage, subdomain) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/shards/client.rb', line 128 def subdomain_dns(location, stage, subdomain) d = get_dns location, stage d.subdomain_param=subdomain puts "Subdomain: #{subdomain} , exists: #{d.exist?}" end |
#terminal ⇒ Object
52 53 54 55 |
# File 'lib/shards/client.rb', line 52 def terminal t=Shards::Workflow::Terminal.new config t.start end |