Class: KnifeTopo::TopoSearch
- Inherits:
-
Chef::Knife::Search
- Object
- Chef::Knife::Search
- KnifeTopo::TopoSearch
show all
- Includes:
- CommandHelper
- Defined in:
- lib/chef/knife/topo_search.rb
Overview
Instance Method Summary
collapse
#check_chef_env, #initialize_cmd_args, #most_common, #resource_exists?, #run_cmd
Instance Method Details
#combine(query, group_query, constraint) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/chef/knife/topo_search.rb', line 84
def combine(query, group_query, constraint)
find_in_topo = config[:topo] || config[:no_topo].nil?
if find_in_topo
query ? "#{constraint} AND #{group_query}" : constraint
else
query ? "#{group_query} NOT #{constraint}" : "NOT #{constraint}"
end
end
|
#constrain_query(query, topo_name) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/chef/knife/topo_search.rb', line 72
def constrain_query(query, topo_name)
group_query = query && !query.start_with?('NOT') ? "(#{query})" : query
constraint = topo_name ? 'topo_name:' + topo_name : 'topo_name:*'
combine(query, group_query, constraint)
end
|
#run ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/chef/knife/topo_search.rb', line 48
def run
setup_query
super
rescue StandardError => e
raise if Chef::Config[:verbosity] == 2
ui.error "Topology search for \"#{@query}\" exited with error"
humanize_exception(e)
end
|
#setup_query ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/chef/knife/topo_search.rb', line 57
def setup_query
query_str = @name_args[0] || config[:query]
topo_query = constrain_query(query_str, config[:topo])
@name_args[0] = 'node'
if config[:query]
config[:query] = topo_query
else
@name_args[1] = topo_query
end
end
|