Skip to content

Commit

Permalink
Merge pull request quattor#79 in AQUILON_AQD/aqd from ~AQBLD/aqd:for_…
Browse files Browse the repository at this point in the history
…merge/master/by_topic/barnesf_disk_parameters to master

* commit '969ca7f9bd25839fab07e75ad4bf0b638f6c4d48':
  Add new fields to Disk object
  • Loading branch information
Fred Barnes authored and Fred Barnes committed Oct 18, 2019
2 parents 7d19f77 + 969ca7f commit e2d90a7
Show file tree
Hide file tree
Showing 19 changed files with 469 additions and 49 deletions.
56 changes: 56 additions & 0 deletions doc/commands/add_disk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
</group>
<arg><option>--resourcegroup <replaceable>RG</replaceable></option></arg>
</group>
<arg><option>--disk_tech <replaceable>TECH</replaceable></option></arg>
<arg><option>--usage <replaceable>USE</replaceable></option></arg>
<arg><option>--diskgroup_key <replaceable>DGKEY</replaceable></option></arg>
<arg><option>--model_key <replaceable>MODELKEY</replaceable></option></arg>
<arg><option>--vsan_policy_key <replaceable>VSANPKEY</replaceable></option></arg>
<arg><option>--comments <replaceable>COMMENTS</replaceable></option></arg>
<xi:include href="../common/change_management.xml"/>
<xi:include href="../common/global_options.xml"/>
Expand Down Expand Up @@ -234,6 +239,57 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--disk_tech <replaceable>TECH</replaceable></option>
</term>
<listitem>
<para>
The disk technology (e.g. hdd, ssd, nvme).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--usage <replaceable>USE</replaceable></option>
</term>
<listitem>
<para>
Intended use for this disk (e.g. os, data, cache, swap).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--diskgroup_key <replaceable>DGKEY</replaceable></option>
</term>
<listitem>
<para>
Arbitrary foreign key for disk-group (storage infrastructure).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--model_key <replaceable>MODELKEY</replaceable></option>
</term>
<listitem>
<para>
Arbitrary foreign key for disk model (storage infrastructure).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--vsan_policy_key <replaceable>VSANPKEY</replaceable></option>
</term>
<listitem>
<para>
Arbitrary foreign key for VSAN policy (storage infrastructure). This
can only be used with virtual disks.
</para>
</listitem>
</varlistentry>
</variablelist>
<xi:include href="../common/change_management_desc.xml"/>
<xi:include href="../common/global_options_desc.xml"/>
Expand Down
57 changes: 57 additions & 0 deletions doc/commands/update_disk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
</group>
<arg><option>--resourcegroup <replaceable>RG</replaceable></option></arg>
</group>
<arg><option>--disk_tech <replaceable>TECH</replaceable></option></arg>
<arg><option>--usage <replaceable>USE</replaceable></option></arg>
<arg><option>--diskgroup_key <replaceable>DGKEY</replaceable></option></arg>
<arg><option>--model_key <replaceable>MODELKEY</replaceable></option></arg>
<arg><option>--vsan_policy_key <replaceable>VSANPKEY</replaceable></option></arg>
<arg><option>--comments <replaceable>COMMENTS</replaceable></option></arg>
<xi:include href="../common/change_management.xml"/>
<xi:include href="../common/global_options.xml"/>
Expand Down Expand Up @@ -240,6 +245,58 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--disk_tech <replaceable>TECH</replaceable></option>
</term>
<listitem>
<para>
Change the disk technology (e.g. hdd, ssd, nvme).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--usage <replaceable>USE</replaceable></option>
</term>
<listitem>
<para>
Change the intended use for this disk (e.g. os, data, cache, swap).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--diskgroup_key <replaceable>DGKEY</replaceable></option>
</term>
<listitem>
<para>
Change the arbitrary disk-group foreign key (storage infrastructure).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--model_key <replaceable>MODELKEY</replaceable></option>
</term>
<listitem>
<para>
Change the arbitrary disk model foreign key (storage infrastructure).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--vsan_policy_key <replaceable>VSANPKEY</replaceable></option>
</term>
<listitem>
<para>
Change the arbitrary VSAN policy foreign key (storage
infrastructure). This can only be used with virtual
disks.
</para>
</listitem>
</varlistentry>
</variablelist>
<xi:include href="../common/change_management_desc.xml"/>
<xi:include href="../common/global_options_desc.xml"/>
Expand Down
4 changes: 3 additions & 1 deletion etc/aqd.conf.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ auto_mac_start = 00:50:56:01:20:00
auto_mac_end = 00:50:56:3f:ff:ff

disk_controller_types = cciss, fibrechannel, flash, ide, nvme, sas, sata, scsi
disk_technology_types = hdd, ssd, nvme
disk_usage_types = os, data, swap, cache, capacity

dynamic_range_classes = vm, fab
default_dynamic_range_class = vm
Expand Down Expand Up @@ -424,4 +426,4 @@ precreated_compartments_only = False
ignore_network_compartments_regex =

[protocols]
directory = /ms/dist/aquilon/PROJ/protocols/1.50/common/lib/python/
directory = /ms/dist/aquilon/PROJ/protocols/1.51/common/lib/python/
12 changes: 11 additions & 1 deletion etc/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@
<command name="add_disk">
Add a new disk to a machine.
<p/>
The controller type must be one of: ide, scsi, sata, sas, cciss.
The controller type must be one of: ide, scsi, sata, sas, cciss, fibrechannel, flash, nvme.
<p/>
Examples of valid disk names: hda, hdb (IDE); sda, sdb (SCSI, SATA), c0d0 (CCISS).
<optgroup mandatory="True" fields="all">
Expand All @@ -935,6 +935,11 @@
<option name="wwn" type="string">World Wide Name of the disk</option>
<option name="bus_address" type="string">Hardware bus address of the controller hosting the disk</option>
<option name="iops_limit" type="int">IOPS limit on disks.</option>
<option name="disk_tech" type="string">Disk technology, one of: hdd, sdd, nvme</option>
<option name="diskgroup_key" type="string">Disk-group key (foreign system)</option>
<option name="model_key" type="string">Disk model key (foreign system)</option>
<option name="usage" type="string">Disk usage, one of: os, data, swap, cache, capacity</option>
<option name="vsan_policy_key" type="string">VSAN policy key (foreign system)</option>
<option name="justification" type="string">Authorization tokens (e.g. TCM number or "emergency") to validate the request</option>
<option name="reason" type="string">Human readable description of why the operation was performed</option>
<option name="cm_check" type="flag">Do a dry-run, and report the objects in-scope for change-management.</option>
Expand Down Expand Up @@ -989,6 +994,11 @@
<option name="wwn" type="string">World Wide Name of the disk</option>
<option name="bus_address" type="string">Hardware bus address of the controller hosting the disk</option>
<option name="iops_limit" type="int">IOPS limit on disks</option>
<option name="disk_tech" type="string">Disk technology, one of: hdd, sdd, nvme (empty string clears)</option>
<option name="diskgroup_key" type="string">Disk-group key (foreign system, empty string clears)</option>
<option name="model_key" type="string">Disk model key (foreign system, empty string clears)</option>
<option name="usage" type="string">Disk usage, one of: os, data, swap, cache, capacity (empty string clears)</option>
<option name="vsan_policy_key" type="string">VSAN policy key (foreign system, empty string clears)</option>
<option name="justification" type="string">Authorization tokens (e.g. TCM number or "emergency") to validate the request</option>
<option name="reason" type="string">Human readable description of why the operation was performed</option>
<option name="cm_check" type="flag">Do a dry-run, and report the objects in-scope for change-management.</option>
Expand Down
79 changes: 63 additions & 16 deletions lib/aquilon/aqdb/model/disk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2016 Contributor
# Copyright (C) 2008-2014,2016,2019 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,18 +16,39 @@
# limitations under the License.
""" Polymorphic representation of disks which may be local or san """

from aquilon.aqdb.column_types import AqStr
from aquilon.aqdb.model import (
Base,
DeviceLinkMixin,
Machine,
)
from aquilon.config import Config
from aquilon.exceptions_ import (
ArgumentError,
InternalError,
)
from aquilon.utils import force_wwn

from datetime import datetime
import re

from sqlalchemy import (Column, Integer, DateTime, Sequence, String, Boolean,
ForeignKey, UniqueConstraint)
from sqlalchemy.orm import relation, backref, deferred, validates
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
Sequence,
String,
UniqueConstraint,
)
from sqlalchemy.orm import (
backref,
deferred,
relation,
validates,
)

from aquilon.exceptions_ import ArgumentError
from aquilon.config import Config
from aquilon.utils import force_wwn
from aquilon.aqdb.column_types import AqStr
from aquilon.aqdb.model import Base, Machine, DeviceLinkMixin
import re

_TN = 'disk'

Expand Down Expand Up @@ -60,6 +81,11 @@ class Disk(DeviceLinkMixin, Base):
creation_date = deferred(Column(DateTime, default=datetime.now,
nullable=False))

disk_tech = Column(AqStr(32), nullable=True)
diskgroup_key = Column(String(255), nullable=True)
model_key = Column(String(255), nullable=True)
usage = Column(AqStr(32), nullable=True)

comments = deferred(Column(String(255), nullable=True))

machine = relation(Machine, innerjoin=True,
Expand All @@ -77,6 +103,21 @@ def __repr__(self):
(self._get_class_label(), self.device_name, self.controller_type,
self.machine.label, self.capacity)

def _config_match_values(self, section, entry, desc, value, allow_none):
if value is None and allow_none:
return value
if not _config.has_option(section, entry):
raise InternalError("Missing configuration for {}.{}"
.format(section, entry))
# expect a comma-separated list of values
valid_values = [s.strip() for s in
_config.get(section, entry).split(",")]
if value not in valid_values:
raise ArgumentError("{} is not a valid {}, use one of: {}."
.format(value, desc,
", ".join(sorted(valid_values))))
return value

@validates('address')
def validate_address(self, key, value): # pylint: disable=W0613
if not value:
Expand All @@ -88,17 +129,23 @@ def validate_address(self, key, value): # pylint: disable=W0613

@validates('controller_type')
def validate_controller_type(self, key, value): # pylint: disable=W0613
valid_values = [s.strip() for s in
_config.get("broker", "disk_controller_types").split(",")]
if value not in valid_values:
raise ArgumentError("%s is not a valid controller type, use one "
"of: %s." % (value, ", ".join(sorted(valid_values))))
return value
return self._config_match_values("broker", "disk_controller_types",
"controller type", value, False)

@validates('wwn')
def validate_wwn(self, key, value):
return force_wwn(key, value)

@validates('disk_tech')
def validate_disk_tech(self, key, value): # pylint: disable=W0613
return self._config_match_values("broker", "disk_technology_types",
"disk technology", value, True)

@validates('usage')
def validate_usage(self, key, value): # pylint: disable=W0613
return self._config_match_values("broker", "disk_usage_types",
"disk usage", value, True)

# Currently this is for curiosity only. It would be more useful if we could
# look up the vendor name somewhere, based on the OUI.
def oui(self): # pragma: no cover
Expand Down
32 changes: 26 additions & 6 deletions lib/aquilon/aqdb/model/virtual_disk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2016 Contributor
# Copyright (C) 2008-2014,2016,2019 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,30 @@

import re

from sqlalchemy import Column, Boolean, ForeignKey, Integer
from sqlalchemy.orm import relation, column_property, validates
from sqlalchemy.sql import select, func

from aquilon.aqdb.model import (
Disk,
Filesystem,
Resource,
Share,
)
from aquilon.exceptions_ import AquilonError
from aquilon.aqdb.model import Disk, Resource, Share, Filesystem

from sqlalchemy import (
Boolean,
Column,
ForeignKey,
Integer,
String,
)
from sqlalchemy.orm import (
column_property,
relation,
validates,
)
from sqlalchemy.sql import (
func,
select,
)

_TN = 'disk'

Expand All @@ -39,6 +57,8 @@ class VirtualDisk(Disk):
name='%s_backing_store_fk' % _TN),
nullable=True, index=True)

vsan_policy_key = Column(String(255), nullable=True)

backing_store = relation(Resource)

__mapper_args__ = {'polymorphic_identity': 'virtual_disk'}
Expand Down
4 changes: 3 additions & 1 deletion lib/aquilon/worker/commands/add_disk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2015,2016,2017 Contributor
# Copyright (C) 2008-2017,2019 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@ class CommandAddDisk(BrokerCommand):
def render(self, session, plenaries, disk, controller, share,
filesystem, resourcegroup, address, comments, size, boot,
snapshot, wwn, bus_address, iops_limit,
disk_tech, diskgroup_key, model_key, usage, vsan_policy_key,
user, justification, reason, logger, **kwargs):
dbmachine = get_hardware(session, compel=True, **kwargs)

Expand All @@ -42,6 +43,7 @@ def render(self, session, plenaries, disk, controller, share,

add_disk(dbmachine, disk, controller, share, filesystem, resourcegroup,
address, size, boot, snapshot, wwn, bus_address, iops_limit,
disk_tech, diskgroup_key, model_key, usage, vsan_policy_key,
comments)

plenaries.add(dbmachine)
Expand Down
Loading

0 comments on commit e2d90a7

Please sign in to comment.