Restored metadata publishing from agent
This commit is contained in:
parent
7fb0c5dce0
commit
239213fba1
@ -9,15 +9,19 @@ module NodeAgent
|
||||
interfaces = node["network"]["interfaces"].inject([]) do |result, elm|
|
||||
result << { :name => elm[0], :addresses => elm[1]["addresses"] }
|
||||
end
|
||||
|
||||
data = { :fqdn => node["fqdn"],
|
||||
:mac => node["macaddress"],
|
||||
:ip => node["ipaddress"],
|
||||
metadata = {
|
||||
:block_device => node["block_device"].to_hash,
|
||||
:interfaces => interfaces,
|
||||
:cpu => node["cpu"].to_hash,
|
||||
:memory => node["memory"].to_hash
|
||||
}
|
||||
}
|
||||
|
||||
data = { :fqdn => node["fqdn"],
|
||||
:mac => node["macaddress"],
|
||||
:ip => node["ipaddress"],
|
||||
:metadata => metadata
|
||||
}
|
||||
|
||||
headers = {"Content-Type" => "application/json"}
|
||||
|
||||
cli = HTTPClient.new
|
||||
|
@ -24,8 +24,9 @@ class EnvironmentForm(forms.Form):
|
||||
def validate_node_metadata(value):
|
||||
if value is not None:
|
||||
if isinstance(value, dict):
|
||||
for field in ('block_device', 'interfaces', 'cpu', 'memory', \
|
||||
'fqdn', 'ip', 'mac'):
|
||||
for field in ('block_device', 'interfaces', 'cpu', 'memory'):
|
||||
# TODO(mihgen): We need more comprehensive checks here
|
||||
# For example, now, it's possible to store value[field] = []
|
||||
if not field in value or value[field] == "":
|
||||
raise ValidationError("Node metadata '%s' \
|
||||
field is required" % field)
|
||||
|
@ -14,10 +14,7 @@ class TestHandlers(TestCase):
|
||||
self.old_meta = {'block_device': 'value',
|
||||
'interfaces': 'val2',
|
||||
'cpu': 'asf',
|
||||
'memory': 'sd',
|
||||
'ip': '192.168.124.185',
|
||||
'mac': '08:00:27:99:8F:33',
|
||||
'fqdn': 'test.server.com'
|
||||
'memory': 'sd'
|
||||
}
|
||||
self.another_environment = Environment(id=2,
|
||||
name='Another environment')
|
||||
@ -54,10 +51,7 @@ class TestHandlers(TestCase):
|
||||
self.new_meta = {'block_device': 'new-val',
|
||||
'interfaces': 'd',
|
||||
'cpu': 'u',
|
||||
'memory': 'a',
|
||||
'ip': '10.1.1.1',
|
||||
'mac': '09:02:FB:AA:AB:AC',
|
||||
'fqdn': 'new.com'
|
||||
'memory': 'a'
|
||||
}
|
||||
self.meta_json = json.dumps(self.new_meta)
|
||||
|
||||
@ -221,9 +215,9 @@ class TestHandlers(TestCase):
|
||||
self.assertEquals(len(nodes_from_db), 1)
|
||||
self.assertEquals(nodes_from_db[0].metadata, self.old_meta)
|
||||
|
||||
def test_put_returns_400_if_ipaddress_empty(self):
|
||||
def test_put_returns_400_if_interfaces_empty(self):
|
||||
meta = self.new_meta.copy()
|
||||
meta['ip'] = ""
|
||||
meta['interfaces'] = ""
|
||||
resp = self.client.put(self.node_url,
|
||||
json.dumps({'metadata': meta}),
|
||||
"application/json")
|
||||
|
Loading…
Reference in New Issue
Block a user