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
Instance Method Details
#add_dns_record(location, stage, domain) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/shards/client.rb', line 152 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
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/shards/client.rb', line 84 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
98 99 100 101 102 103 104 105 106 |
# File 'lib/shards/client.rb', line 98 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
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/shards/client.rb', line 133 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
111 112 113 114 115 116 117 |
# File 'lib/shards/client.rb', line 111 def dns(location, stage, domain) d = get_dns location.downcase, stage, domain puts "Host: #{d.host} , exists: #{d.exist?}" end |
#fingerprints(location, stage) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/shards/client.rb', line 185 def fingerprints(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :fingerprints end |
#list(location, stage) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/shards/client.rb', line 66 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
52 53 54 55 56 57 58 59 60 |
# File 'lib/shards/client.rb', line 52 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 terminal=Shards::Workflow::FingerprintsTerminal.new config terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage } terminal.start end |
#puppet(location, stage) ⇒ Object
195 196 197 198 199 200 201 |
# File 'lib/shards/client.rb', line 195 def puppet(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :puppet_agent! end |
#reload_shards(location, stage) ⇒ Object
205 206 207 208 209 210 211 |
# File 'lib/shards/client.rb', line 205 def reload_shards(location, stage) s = get_stage location, stage puts s.check_remote_process remote_check: :reload_shards! end |
#sites(location, stage) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/shards/client.rb', line 167 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
121 122 123 124 125 126 127 128 129 |
# File 'lib/shards/client.rb', line 121 def subdomain_dns(location, stage, subdomain) d = get_dns location, stage d.subdomain_param=subdomain puts "Subdomain: #{subdomain} , exists: #{d.exist?}" end |