Skip to content

Commit

Permalink
Add CLI cmds for import, delete and obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren committed Apr 3, 2018
1 parent cb34584 commit c290ed9
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion lib/hammer_cli_foreman_ansible/ansible_roles.rb
Expand Up @@ -2,9 +2,62 @@ module HammerCLIForemanAnsible
class AnsibleRolesCommand < HammerCLIForeman::Command
resource :ansible_roles

class ListCommand < HammerCLIForeman::ListCommand
class InfoCommand < HammerCLIForeman::InfoCommand
output do
field :id, _('Id')
field :name, _('Name')
field :created_at, _('Imported at')
end
build_options
end

class ListCommand < HammerCLIForeman::ListCommand
output HammerCLIForemanAnsible::AnsibleRolesCommand::InfoCommand.output_definition
build_options
end

class DeleteCommand < HammerCLIForeman::DeleteCommand
success_message _('Ansible role [%{name}] was deleted.')
failure_message _('Could not delete the role')

build_options
end

class ImportCommand < HammerCLIForeman::Command
action :import
command_name 'import'

failure_message _('Could not import the new roles')

def print_data(data)
if data.empty?
puts 'No changes in ansible roles detected.'
return
end
puts 'The following new ansible roles were imported:'
data.each do |role|
puts role['name']
end
end

build_options
end

class ObsoleteCommand < HammerCLIForeman::Command
action :obsolete
command_name 'obsolete'

failure_message _('Could not import the obsolete roles')

def print_data(data)
if data.empty?
puts 'No changes in ansible roles detected.'
return
end
puts 'The following obsolete ansible roles were imported:'
data.each do |role|
puts role['name']
end
end

build_options
Expand Down

0 comments on commit c290ed9

Please sign in to comment.