Added online field on processing nodes, which fixes #107

pull/116/head
Piero Toffanin 2017-03-06 17:59:00 -05:00
rodzic 0fa38e310b
commit 6276ebbe18
4 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -10,6 +10,11 @@ from nodeodm.models import ProcessingNode
class ProcessingNodeSerializer(serializers.ModelSerializer):
online = serializers.SerializerMethodField()
def get_online(self, obj):
return obj.is_online()
class Meta:
model = ProcessingNode
fields = '__all__'

Wyświetl plik

@ -76,16 +76,13 @@ class EditTaskForm extends React.Component {
let now = new Date();
let nodes = json.map(node => {
let last_refreshed = new Date(node.last_refreshed);
let enabled = (now - last_refreshed) < 1000 * 60 * 5; // 5 minutes
return {
id: node.id,
key: node.id,
label: `${node.hostname}:${node.port} (queue: ${node.queue_count})`,
options: node.available_options,
queue_count: node.queue_count,
enabled: enabled,
enabled: node.online,
url: `http://${node.hostname}:${node.port}`
};
});

Wyświetl plik

@ -321,6 +321,11 @@ class TestApi(BootTestCase):
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertTrue(res.data["hostname"] == "localhost")
# Verify online field exists
self.assertTrue("online" in res.data)
# Should be set to false
self.assertFalse(res.data['online'])
# Cannot delete a processing node as normal user
res = client.delete('/api/processingnodes/{}/'.format(pnode.id))

Wyświetl plik

@ -5,6 +5,7 @@
```json
{
"id": 2,
"online": true,
"hostname": "nodeodm.masseranolabs.com",
"port": 80,
"api_version": "1.0.1",
@ -27,6 +28,7 @@ take care of processing input images. Processing nodes are computers or virtual
Field | Type | Description
----- | ---- | -----------
id | int | Unique Identifier
online | bool | Whether the processing node could be reached in the last 5 minutes
hostname | string | Hostname/IP address
port | int | Port
api_version | string | Version of node-OpenDroneMap currently running