class KnifeTopo::TopoImport
knife topo import
Public Class Methods
new(args)
click to toggle source
Calls superclass method
# File lib/chef/knife/topo_import.rb, line 52 def initialize(args) super @args = args @topo_file = @name_args[0] || 'topology.json' end
Public Instance Methods
create_topo_bag_dir()
click to toggle source
# File lib/chef/knife/topo_import.rb, line 65 def create_topo_bag_dir # make sure the topology bag directory exists path = File.join(topologies_path, topo_bag_name) FileUtils.mkdir_p(path) end
do_create_artifacts()
click to toggle source
# File lib/chef/knife/topo_import.rb, line 87 def do_create_artifacts @processor.generate_artifacts( 'cmd_args' => @args, 'cmd' => self ) end
import_topo()
click to toggle source
# File lib/chef/knife/topo_import.rb, line 71 def import_topo write_topo_to_file do_create_artifacts ui.info "Imported topology: #{@topo.display_info}" end
run()
click to toggle source
# File lib/chef/knife/topo_import.rb, line 58 def run @topo = load_topo_from_file_or_exit(@topo_file, config[:input_format]) @processor = KnifeTopo::Processor.for_topo(@topo) create_topo_bag_dir import_topo end
write_topo_to_file()
click to toggle source
# File lib/chef/knife/topo_import.rb, line 78 def write_topo_to_file path = File.join(topologies_path, topo_bag_name, @topo['name'] + '.json') File.open(path, 'w') do |f| f.write(Chef::JSONCompat.to_json_pretty(@topo.raw_data)) f.close ui.info "Created topology data bag: #{path}" end end