Client: add zone operations (add and del).
This commit is contained in:
		
							parent
							
								
									0ca5ec6f78
								
							
						
					
					
						commit
						41828a3f91
					
				
					 2 changed files with 31 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -37,8 +37,8 @@ class Actions
 | 
			
		|||
 | 
			
		||||
		# Maintenance
 | 
			
		||||
		@the_call["admin-maintenance"] = ->admin_maintenance
 | 
			
		||||
		@the_call["user-zone-add"]      = ->user_zone_add
 | 
			
		||||
		@the_call["user-zone-del"]      = ->user_zone_del
 | 
			
		||||
		@the_call["user-zone-add"]     = ->user_zone_add
 | 
			
		||||
		@the_call["user-zone-del"]     = ->user_zone_del
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	def admin_maintenance
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ def main
 | 
			
		|||
 | 
			
		||||
	# Authd configuration.
 | 
			
		||||
	authd_config = if no_configuration
 | 
			
		||||
		Baguette::Log.info "do not load a configuration file."
 | 
			
		||||
		Baguette::Log.info "do not load a configuration file (authd)."
 | 
			
		||||
		Baguette::Configuration::Auth.new
 | 
			
		||||
	else
 | 
			
		||||
		# Configuration file is for dnsmanagerd.
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ def main
 | 
			
		|||
 | 
			
		||||
	# Authd configuration.
 | 
			
		||||
	config = if no_configuration
 | 
			
		||||
		Baguette::Log.info "do not load a configuration file."
 | 
			
		||||
		Baguette::Log.info "do not load a configuration file (dnsmanagerd)."
 | 
			
		||||
		Baguette::Configuration::DNSManager.new
 | 
			
		||||
	else
 | 
			
		||||
		# Configuration file is for dnsmanagerd.
 | 
			
		||||
| 
						 | 
				
			
			@ -137,12 +137,14 @@ def main
 | 
			
		|||
	# Authd authentication, get the token and quit right away.
 | 
			
		||||
	# If login == pass == "undef": do not even try.
 | 
			
		||||
	if authd_config.login.nil? || authd_config.pass.nil?
 | 
			
		||||
		Baguette::Log.info "no authd login"
 | 
			
		||||
		Baguette::Log.info "no authd login."
 | 
			
		||||
	else
 | 
			
		||||
		Baguette::Log.info "authd login..."
 | 
			
		||||
		login = authd_config.login.not_nil!
 | 
			
		||||
		pass  = authd_config.pass.not_nil!
 | 
			
		||||
		token = authd_get_token login: login, pass: pass
 | 
			
		||||
		dnsmanagerd.login token
 | 
			
		||||
		Baguette::Log.info "logged."
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	#authd = AuthD::Client.new
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,12 +95,13 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
 | 
			
		|||
 | 
			
		||||
		# Admin section.
 | 
			
		||||
		parser.on "admin", "Admin operations." do
 | 
			
		||||
			parser.banner = "Admin operations (requires secret via -k)."
 | 
			
		||||
			# All admin operations require the shared key.
 | 
			
		||||
			opt_authd_admin.call parser, authd_config
 | 
			
		||||
 | 
			
		||||
			# Maintenance.
 | 
			
		||||
			parser.on("maintenance", "Maintenance operation of the website.") do
 | 
			
		||||
				Baguette::Log.info "Maintenance operation of the website."
 | 
			
		||||
				Baguette::Log.info "maintenance operation of the website."
 | 
			
		||||
				Context.command = "admin-maintenance"
 | 
			
		||||
				parser.banner = "COMMAND: admin maintenance subject [value]"
 | 
			
		||||
				unrecognized_args_to_context_args.call parser, nil, 1
 | 
			
		||||
| 
						 | 
				
			
			@ -108,6 +109,28 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
 | 
			
		|||
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		# User section.
 | 
			
		||||
		parser.on "user", "Simple user operations." do
 | 
			
		||||
			parser.banner = "Operations as a simple user."
 | 
			
		||||
			# Zone.
 | 
			
		||||
			parser.on("zone", "Zone operations.") do
 | 
			
		||||
				parser.on("add", "Add new zone.") do
 | 
			
		||||
					Baguette::Log.info "add zone."
 | 
			
		||||
					Context.command = "user-zone-add"
 | 
			
		||||
					parser.banner = "COMMAND: user zone add <file> [<file>...]"
 | 
			
		||||
					unrecognized_args_to_context_args.call parser, nil, 1
 | 
			
		||||
				end
 | 
			
		||||
 | 
			
		||||
				parser.on("del", "Delete a zone.") do
 | 
			
		||||
					Baguette::Log.info "del zone."
 | 
			
		||||
					Context.command = "user-zone-del"
 | 
			
		||||
					parser.banner = "COMMAND: user zone del domain [domain...]"
 | 
			
		||||
					unrecognized_args_to_context_args.call parser, nil, 1
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		opt_help.call parser
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue