Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-reid committed Aug 31, 2016
1 parent 9052ca5 commit c9c1344
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 16 deletions.
12 changes: 11 additions & 1 deletion lib/api/2.0/nodes.js
Expand Up @@ -149,6 +149,14 @@ var nodesGetRelations = controller(function(req) {
return nodes.getNodeRelations(req.swagger.params.identifier.value);
});

var nodesGetObmsByNodeId = controller(function(req) {
return nodes.getObmsByNodeId(req.swagger.params.identifier.value);
});

var nodesPutObmsByNodeId = controller({success: 201}, function(req) {
return nodes.putObmsByNodeId(req.swagger.params.identifier.value, req.body);
});

module.exports = {
nodesGetAll: nodesGetAll,
nodesPost: nodesPost,
Expand All @@ -169,5 +177,7 @@ module.exports = {
nodesMasterDelTagById: nodesMasterDelTagById,
nodesDelRelations: nodesDelRelations,
nodesAddRelations: nodesAddRelations,
nodesGetRelations: nodesGetRelations
nodesGetRelations: nodesGetRelations,
nodesGetObmsByNodeId: nodesGetObmsByNodeId,
nodesPutObmsByNodeId: nodesPutObmsByNodeId
};
1 change: 1 addition & 0 deletions lib/api/2.0/obms.js
Expand Up @@ -67,6 +67,7 @@ var obmsPostLed = controller({success: 201}, function(req) {
}
});


module.exports = {
obmsDefinitionsGetAll: obmsDefinitionsGetAll,
obmsDefinitionsGetByName: obmsDefinitionsGetByName,
Expand Down
34 changes: 34 additions & 0 deletions lib/services/nodes-api-service.js
Expand Up @@ -639,5 +639,39 @@ function nodeApiServiceFactory(
});
};

/**
* Get a list of all OBMs for the specified Node id
* @param {String} id
* @return {Promise} Resolves to an array of OBMs
*/
NodeApiService.prototype.getObmsByNodeId = function(id) {
return waterline.nodes.getNodeById(id)
.then(function (node){
if (!node) {
throw new Errors.NotFoundError(
'Node not Found ' + id
);
}
return waterline.obms.findAllByNode(id, false);
});
};

/**
* Create an OBM for the specified Node id
* @param {String} id, obm
* @return {Promise}
*/
NodeApiService.prototype.putObmsByNodeId = function(id, obm) {
return waterline.nodes.getNodeById(id)
.then(function (node) {
if (!node) {
throw new Errors.NotFoundError(
'Node not Found ' + id
);
}
return waterline.obms.upsertByNode(id, obm);
});
};

return new NodeApiService();
}
100 changes: 95 additions & 5 deletions static/monorail-2.0.yaml
Expand Up @@ -2590,6 +2590,77 @@ paths:
description: Unexpected error
schema:
$ref: '#/definitions/Error'

/nodes/{identifier}/obm:
x-swagger-router-controller: nodes
get:
operationId: nodesGetObmsByNodeId
x-privileges: [ 'Read' ]
x-authentication-type: [ 'jwt' ]
x-view: obm.2.0.json
summary: |
Get an OBM service
description: |
Get the OBM settings for the specified node.
parameters:
- name: identifier
in: path
description: |
The Node identifier
required: true
type: string
tags: [ "/api/2.0" ]
responses:
200:
description: |
Successfully retrieved the specified OBM service
schema:
type: object
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
put:
operationId: nodesPutObmsByNodeId
x-privileges: [ 'Write' ]
x-authentication-type: [ 'jwt' ]
x-swagger-schema: obm
x-view: obm.2.0.json
summary: |
Put an OBM service
description: |
Create or update a single OBM service with the associated Node ID
parameters:
- name: identifier
in: path
description: |
The Node identifier
required: true
type: string
- name: body
in: body
description: |
The OBM settings information to create
required: true
schema:
$ref: '#/definitions/nodes_post_obm_by_id'
tags: [ "/api/2.0" ]
responses:
201:
description: |
Successfully put the OBM service
schema:
type: object
500:
description: |
OBM service creation failed
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'

/nodes:
x-swagger-router-controller: nodes
get:
Expand Down Expand Up @@ -3766,8 +3837,30 @@ definitions:
$ref: '#/definitions/tag_rule'
type: object

ipmi-obm-service_Obm:
nodes_post_obm_by_id:
description: IPMI OBM settings
properties:
config:
# properties:
# host:
# description: BMC address
# type: string
# password:
# description: IPMI password
# type: string
# user:
# description: IPMI username
# type: string
type: object
service:
type: string
required:
- service
- config
type: object

ipmi-obm-service_Obm:
description: OBM settings
properties:
config:
properties:
Expand All @@ -3780,10 +3873,6 @@ definitions:
user:
description: IPMI username
type: string
required:
- host
- user
- password
type: object
nodeId:
type: string
Expand All @@ -3795,6 +3884,7 @@ definitions:
- config
type: object


node.2.0_PartialNode:
description: Post a node in RackHD
properties:
Expand Down
2 changes: 1 addition & 1 deletion static/schemas/obms/amt-obm-service.json
Expand Up @@ -26,7 +26,7 @@
"required": ["host", "password"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/apc-obm-service.json
Expand Up @@ -30,7 +30,7 @@
"required": ["host", "community", "port"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/ipmi-obm-service.json
Expand Up @@ -30,7 +30,7 @@
"required": ["host", "user", "password"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/noop-obm-service.json
Expand Up @@ -15,7 +15,7 @@
"type": "object"
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/panduit-obm-service.json
Expand Up @@ -51,7 +51,7 @@
"required": ["host", "community", "cyclePassword", "pduOutlets"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/raritan-obm-service.json
Expand Up @@ -34,7 +34,7 @@
"required": ["host", "user", "password", "port"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/redfish-obm-service.json
Expand Up @@ -51,7 +51,7 @@
"required": ["host", "user", "password", "root", "uri", "protocol"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/servertech-obm-service.json
Expand Up @@ -30,7 +30,7 @@
"required": ["host", "community", "port"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/vbox-obm-service.json
Expand Up @@ -26,7 +26,7 @@
"required": ["alias", "user"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}
2 changes: 1 addition & 1 deletion static/schemas/obms/vmrun-obm-service.json
Expand Up @@ -22,7 +22,7 @@
"required": ["vmxpath"]
}
},
"required": ["nodeId", "service", "config"]
"required": ["service", "config"]
}
}
}

0 comments on commit c9c1344

Please sign in to comment.