De-client-ify fixed method get_nic_by_mac

Additionally removed traces of ironic exceptions
being parsed in operatorcloud.py and removed legacy
tasks related to port lookups.

Also remove patch machine task wrapper as that appears
to have been migrated previously.

Change-Id: Iee9e15f44b8375fdcf00ddba2b44afe217faf478
This commit is contained in:
Julia Kreger 2017-11-29 15:54:50 -05:00
parent bd38f39243
commit 6f5bfd16a1
2 changed files with 18 additions and 51 deletions

View File

@ -1,37 +0,0 @@
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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 shade import task_manager
class MachinePortGet(task_manager.Task):
def main(self, client):
return client.ironic_client.port.get(**self.args)
class MachinePortGetByAddress(task_manager.Task):
def main(self, client):
return client.ironic_client.port.get_by_address(**self.args)
class MachineNodeUpdate(task_manager.Task):
def main(self, client):
return client.ironic_client.node.update(**self.args)
class MachineNodeValidate(task_manager.Task):
def main(self, client):
return client.ironic_client.node.validate(**self.args)

View File

@ -15,11 +15,8 @@ import iso8601
import jsonpatch
import munch
from ironicclient import exceptions as ironic_exceptions
from shade.exc import * # noqa
from shade import openstackcloud
from shade import _tasks
from shade import _utils
@ -54,13 +51,14 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
error_message=msg)
def get_nic_by_mac(self, mac):
# TODO(TheJulia): Query /ports?address=mac when converting
try:
return self._normalize_machine(
self.manager.submit_task(
_tasks.MachinePortGetByAddress(address=mac)))
except ironic_exceptions.ClientException:
return None
url = '/ports/detail?address=%s' % mac
data = self._baremetal_client.get(url)
if len(data['ports']) == 1:
return data['ports'][0]
except Exception:
pass
return None
def list_machines(self):
msg = "Error fetching machine node list"
@ -568,14 +566,20 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
)
def validate_node(self, uuid):
with _utils.shade_exceptions():
ifaces = self.manager.submit_task(
_tasks.MachineNodeValidate(node_uuid=uuid))
# TODO(TheJulia): There are soooooo many other interfaces
# that we can support validating, while these are essential,
# we should support more.
# TODO(TheJulia): Add a doc string :(
msg = ("Failed to query the API for validation status of "
"node {node_id}").format(node_id=uuid)
url = '/nodes/{node_id}/validate'.format(node_id=uuid)
ifaces = self._baremetal_client.get(url, error_message=msg)
if not ifaces.deploy or not ifaces.power:
if not ifaces['deploy'] or not ifaces['power']:
raise OpenStackCloudException(
"ironic node %s failed to validate. "
"(deploy: %s, power: %s)" % (ifaces.deploy, ifaces.power))
"(deploy: %s, power: %s)" % (ifaces['deploy'],
ifaces['power']))
def node_set_provision_state(self,
name_or_id,