Alexey Deryugin 914a2d9c69 Application resource implementation
Change-Id: I5627f94d4fc0d0fa1a63968cfa7ed67350fcc769
2015-11-18 15:55:26 +03:00

39 lines
803 B
Ruby

require File.join(File.dirname(__FILE__), '..','..','..',
'puppet/provider/murano')
Puppet::Type.type(:murano_application).provide(
:murano,
:parent => Puppet::Provider::Murano
) do
desc 'Manage murano applications'
commands :murano => 'murano'
mk_resource_methods
def exists?
packages = auth_murano('package-list')
return packages.split("\n")[1..-1].detect do |n|
n =~ /^(\S+)\s+(#{resource[:name]})/
end
end
def destroy
auth_murano('package-delete', resource[:name])
end
def create
opts = [ resource[:package_path] ]
unless resource[:category].nil?
opts.push('-c').push(resource[:category])
end
opts.push('--is-public').push('--exists-action').push('u')
auth_murano('package-import', opts)
end
end