Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API ports update for WSME 0.5b6 compliance
This makes use of the mandatory option of WSME, to remove some of the custom validation code. The patch also includes a new attribute on Ports API object called node_uuid to store the UUID of the node that Port belongs to, once this field is set it magically converts the UUID to the numeric ID of the node and sets the node_id attribute to be used internally. Change-Id: I973987de48fa008f5752861a2acfaf819f80e2ad Partial-Bug: #1252213
- Loading branch information
Showing
6 changed files
with
271 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
# coding: utf-8 | ||
# | ||
# Copyright 2013 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from wsme import types as wtypes | ||
|
||
from ironic.common import exception | ||
from ironic.common import utils | ||
|
||
|
||
class MacAddressType(wtypes.UserType): | ||
"""A simple MAC address type.""" | ||
|
||
basetype = wtypes.text | ||
name = 'macaddress' | ||
|
||
@staticmethod | ||
def validate(value): | ||
if not utils.is_valid_mac(value): | ||
raise exception.InvalidMAC(mac=value) | ||
return value | ||
|
||
@staticmethod | ||
def frombasetype(value): | ||
return MacAddressType.validate(value) | ||
|
||
|
||
# TODO(lucasagomes): WSME already has one UuidType implementation on trunk, | ||
# so remove it on the next WSME release (> 0.5b6) | ||
class UuidType(wtypes.UserType): | ||
"""A simple UUID type.""" | ||
|
||
basetype = wtypes.text | ||
name = 'uuid' | ||
|
||
@staticmethod | ||
def validate(value): | ||
if not utils.is_uuid_like(value): | ||
raise exception.InvalidUUID(uuid=value) | ||
return value | ||
|
||
@staticmethod | ||
def frombasetype(value): | ||
return UuidType.validate(value) | ||
|
||
|
||
macaddress = MacAddressType() | ||
uuid = UuidType() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.