Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions device-types/Testing/Test-2000.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
manufacturer: Generic
model: TEST-2000
slug: generic-test-2000
u_height: 0
is_full_depth: true
subdevice_role: child
console-ports:
- name: Console Port 1
type: de-9
- name: Console Port 2
type: de-9
- name: Console Port 3
type: de-9
console-server-ports:
- name: Console Server Port 1
type: rj-45
- name: Console Server Port 2
type: rj-45
interfaces:
- name: Interface 1
type: 1000base-t
mgmt_only: true
- name: Interface 2
type: 1000base-t
- name: Interface 3
type: 1000base-t
module-bays:
- name: Module Bay 1
position: '1'
- name: Module Bay 2
position: '2'
- name: Module Bay 3
position: '3'
10 changes: 10 additions & 0 deletions schema/devicetype.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@
"type": "string"
}
},
"allOf": [
{
"if": { "required": ["weight"] },
"then": { "required": ["weight_unit"] }
},
{
"if": { "required": ["weight_unit"] },
"then": { "required": ["weight"] }
}
],
"required": ["manufacturer", "model", "slug", "u_height","is_full_depth"],
"additionalProperties": false
}
10 changes: 10 additions & 0 deletions schema/moduletype.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
"type": "string"
}
},
"allOf": [
{
"if": { "required": ["weight"] },
"then": { "required": ["weight_unit"] }
},
{
"if": { "required": ["weight_unit"] },
"then": { "required": ["weight"] }
}
],
"required": ["manufacturer", "model"],
"additionalProperties": false
}
1 change: 1 addition & 0 deletions tests/definitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def iterlist(var):
if this_device.isDevice:
assert this_device.validate_power(), pytest.fail(this_device.failureMessage, False)
assert this_device.ensure_no_vga(), pytest.fail(this_device.failureMessage, False)
assert this_device.validate_child_u_height(), pytest.fail(this_device.failureMessage, False)

# Check for images if front_image or rear_image is True
if (definition.get('front_image') or definition.get('rear_image')):
Expand Down
7 changes: 7 additions & 0 deletions tests/device_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ def verify_slug(self, KNOWN_SLUGS):
# Add the slug to the list of known slugs
KNOWN_SLUGS.add((self.slug, self.file_path))
return True
def validate_child_u_height(self):
subdevice_role = self.definition.get('subdevice_role')
u_height = self.definition.get('u_height', None)

if subdevice_role == "child" and u_height != 0:
self.failureMessage = f'{self.file_path} is a child device but has u_height={u_height}. Must be 0.'
return False
return True
def validate_power(self):
CUSTOM_POWER_SOURCE_PROPERTY = '_is_power_source'

Expand Down
Loading