diff options
-rw-r--r-- | compass-deck/db/api/machine.py | 2 | ||||
-rw-r--r-- | compass-deck/db/models.py | 7 | ||||
-rw-r--r-- | compass-tasks-base/db/api/machine.py | 2 | ||||
-rw-r--r-- | compass-tasks-base/db/models.py | 7 |
4 files changed, 10 insertions, 8 deletions
diff --git a/compass-deck/db/api/machine.py b/compass-deck/db/api/machine.py index b7b16b2..7991ada 100644 --- a/compass-deck/db/api/machine.py +++ b/compass-deck/db/api/machine.py @@ -29,7 +29,7 @@ from compass.utils import util MACHINE_PRIMARY_FILEDS = ['mac', 'owner_id'] SUPPORTED_FIELDS = [ - 'mac', 'tag', 'location', + 'mac', 'tag', 'location', 'ipmi_credentials', 'machine_attributes', 'owner_id'] IGNORE_FIELDS = ['id', 'created_at', 'updated_at'] UPDATED_FIELDS = [ diff --git a/compass-deck/db/models.py b/compass-deck/db/models.py index d4b0324..5f8fb52 100644 --- a/compass-deck/db/models.py +++ b/compass-deck/db/models.py @@ -1532,11 +1532,11 @@ class Machine(BASE, HelperMixin, TimestampMixin): """Machine table.""" __tablename__ = 'machine' id = Column(Integer, primary_key=True) - mac = Column(String(24), unique=True, nullable=False) + mac = Column(JSONEncoded, nullable=False) ipmi_credentials = Column(JSONEncoded, default={}) tag = Column(JSONEncoded, default={}) location = Column(JSONEncoded, default={}) - owner_id = Column(Integer, ForeignKey('user.id')) + owner_id = Column(Integer, nullable=True) machine_attributes = Column(JSONEncoded, default={}) switch_machines = relationship( @@ -1564,7 +1564,8 @@ class Machine(BASE, HelperMixin, TimestampMixin): # TODO(xicheng): some validation can be moved to column. super(Machine, self).validate() try: - netaddr.EUI(self.mac) + for key, value in self.mac.items(): + netaddr.EUI(value) except Exception: raise exception.InvalidParameter( 'mac address %s format uncorrect' % self.mac diff --git a/compass-tasks-base/db/api/machine.py b/compass-tasks-base/db/api/machine.py index b7b16b2..7991ada 100644 --- a/compass-tasks-base/db/api/machine.py +++ b/compass-tasks-base/db/api/machine.py @@ -29,7 +29,7 @@ from compass.utils import util MACHINE_PRIMARY_FILEDS = ['mac', 'owner_id'] SUPPORTED_FIELDS = [ - 'mac', 'tag', 'location', + 'mac', 'tag', 'location', 'ipmi_credentials', 'machine_attributes', 'owner_id'] IGNORE_FIELDS = ['id', 'created_at', 'updated_at'] UPDATED_FIELDS = [ diff --git a/compass-tasks-base/db/models.py b/compass-tasks-base/db/models.py index d4b0324..5f8fb52 100644 --- a/compass-tasks-base/db/models.py +++ b/compass-tasks-base/db/models.py @@ -1532,11 +1532,11 @@ class Machine(BASE, HelperMixin, TimestampMixin): """Machine table.""" __tablename__ = 'machine' id = Column(Integer, primary_key=True) - mac = Column(String(24), unique=True, nullable=False) + mac = Column(JSONEncoded, nullable=False) ipmi_credentials = Column(JSONEncoded, default={}) tag = Column(JSONEncoded, default={}) location = Column(JSONEncoded, default={}) - owner_id = Column(Integer, ForeignKey('user.id')) + owner_id = Column(Integer, nullable=True) machine_attributes = Column(JSONEncoded, default={}) switch_machines = relationship( @@ -1564,7 +1564,8 @@ class Machine(BASE, HelperMixin, TimestampMixin): # TODO(xicheng): some validation can be moved to column. super(Machine, self).validate() try: - netaddr.EUI(self.mac) + for key, value in self.mac.items(): + netaddr.EUI(value) except Exception: raise exception.InvalidParameter( 'mac address %s format uncorrect' % self.mac |