diff --git a/shade/_tasks.py b/shade/_tasks.py deleted file mode 100644 index c7350977b..000000000 --- a/shade/_tasks.py +++ /dev/null @@ -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) diff --git a/shade/operatorcloud.py b/shade/operatorcloud.py index 5f98a2af6..64ed996ad 100644 --- a/shade/operatorcloud.py +++ b/shade/operatorcloud.py @@ -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,