41: def self.store(node, resources)
42: args = {}
43:
44: host = nil
45: railsmark "Stored node" do
46: transaction do
47:
48:
49: debug_benchmark("Searched for host")do
50: unless host = find_by_name(node.name)
51: host = new(:name => node.name)
52: end
53: end
54: if ip = node.parameters["ipaddress"]
55: host.ip = ip
56: end
57:
58: if env = node.environment
59: host.environment = env
60: end
61:
62:
63: host.merge_facts(node.parameters)
64:
65: debug_benchmark("Handled resources") {
66: host.merge_resources(resources)
67: }
68:
69: host.last_compile = Time.now
70:
71: debug_benchmark("Saved host") {
72: host.save
73: }
74: end
75:
76: end
77:
78:
79: write_benchmarks
80:
81: return host
82: end