Browse Source

Rename files and fix things.

changes/94/29394/1
Devananda van der Veen 9 years ago
parent
commit
0480834614
  1. 5
      .gitignore
  2. 6
      etc/ironic/policy.json
  3. 16
      ironic/__init__.py
  4. 27
      ironic/cmd/__init__.py
  5. 2
      ironic/cmd/ironic_deploy_helper.py
  6. 4
      ironic/cmd/ironic_manage.py
  7. 3
      ironic/db/__init__.py
  8. 30
      ironic/db/api.py
  9. 5
      ironic/db/migration.py
  10. 0
      ironic/db/sqlalchemy/__init__.py
  11. 6
      ironic/db/sqlalchemy/api.py
  12. 0
      ironic/db/sqlalchemy/migrate_repo/__init__.py
  13. 0
      ironic/db/sqlalchemy/migrate_repo/migrate.cfg
  14. 0
      ironic/db/sqlalchemy/migrate_repo/versions/001_init.py
  15. 0
      ironic/db/sqlalchemy/migrate_repo/versions/002_drop_bm_deployments.py
  16. 0
      ironic/db/sqlalchemy/migrate_repo/versions/003_add_uuid_to_bm_nodes.py
  17. 0
      ironic/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py
  18. 0
      ironic/db/sqlalchemy/migrate_repo/versions/005_drop_unused_columns_from_nodes.py
  19. 2
      ironic/db/sqlalchemy/migrate_repo/versions/006_move_prov_mac_address.py
  20. 0
      ironic/db/sqlalchemy/migrate_repo/versions/__init__.py
  21. 6
      ironic/db/sqlalchemy/migration.py
  22. 0
      ironic/db/sqlalchemy/models.py
  23. 4
      ironic/db/sqlalchemy/session.py
  24. 0
      ironic/doc/README.rst
  25. 20
      ironic/exception.py
  26. 2
      ironic/manager/__init__.py
  27. 10
      ironic/manager/base.py
  28. 52
      ironic/manager/driver.py
  29. 2
      ironic/manager/fake.py
  30. 42
      ironic/manager/ipmi.py
  31. 0
      ironic/manager/net-dhcp.ubuntu.template
  32. 0
      ironic/manager/net-static.ubuntu.template
  33. 67
      ironic/manager/pxe.py
  34. 0
      ironic/manager/pxe_config.template
  35. 55
      ironic/manager/tilera.py
  36. 56
      ironic/manager/tilera_pdu.py
  37. 2
      ironic/manager/utils.py
  38. 22
      ironic/manager/vif_driver.py
  39. 58
      ironic/manager/virtual_power_driver.py
  40. 0
      ironic/manager/virtual_power_driver_settings.py
  41. 32
      ironic/manager/volume_driver.py
  42. 8
      ironic/openstack/common/rpc/__init__.py
  43. 4
      ironic/policy.py
  44. 10
      ironic/service.py
  45. 0
      ironic/states.py
  46. 28
      ironic/test.py
  47. 38
      ironic/tests/__init__.py
  48. 36
      ironic/tests/conf_fixture.py
  49. 2
      ironic/tests/db/__init__.py
  50. 15
      ironic/tests/db/base.py
  51. 2
      ironic/tests/db/test_bm_interface.py
  52. 0
      ironic/tests/db/test_bm_node.py
  53. 2
      ironic/tests/db/test_bm_pxe_ip.py
  54. 4
      ironic/tests/db/utils.py
  55. 2
      ironic/tests/fake_policy.py
  56. 3
      ironic/tests/manager/__init__.py
  57. 0
      ironic/tests/manager/test_driver.py
  58. 0
      ironic/tests/manager/test_ipmi.py
  59. 49
      ironic/tests/manager/test_pxe.py
  60. 2
      ironic/tests/manager/test_tilera.py
  61. 0
      ironic/tests/manager/test_tilera_pdu.py
  62. 0
      ironic/tests/manager/test_utils.py
  63. 0
      ironic/tests/manager/test_virtual_power_driver.py
  64. 0
      ironic/tests/manager/test_volume_driver.py
  65. 12
      ironic/tests/policy_fixture.py
  66. 2
      ironic/tests/test_ironic_deploy_helper.py
  67. 0
      ironic/tests/test_ironic_manage.py
  68. 16
      ironic/utils.py
  69. 0
      tools/__init__.py
  70. 74
      tools/install_venv.py
  71. 22
      tools/install_venv_common.py
  72. 6
      tools/patch_tox_venv.py
  73. 7
      tools/with_venv.sh

5
.gitignore

@ -21,6 +21,7 @@ develop-eggs
.installed.cfg
# Other
*.DS_Store
.testrepository
.tox
.*.swp
@ -28,3 +29,7 @@ develop-eggs
cover
AUTHORS
ChangeLog
.testrepository/
.tox
.venv

6
etc/ironic/policy.json

@ -0,0 +1,6 @@
{
"admin_api": "is_admin:True",
"admin_or_owner": "is_admin:True or project_id:%(project_id)s",
"context_is_admin": "role:admin",
"default": "rule:admin_or_owner",
}

16
ironic/__init__.py

@ -0,0 +1,16 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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.

27
ironic/cmd/__init__.py

@ -0,0 +1,27 @@
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# 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.
# TODO(mikal): move eventlet imports to ironic.__init__ once we move to PBR
import os
import sys
os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
import eventlet
eventlet.monkey_patch(os=False)
from ironic.openstack.common import gettextutils
gettextutils.install('ironic')

2
ironic/cmd/baremetal_deploy_helper.py → ironic/cmd/ironic_deploy_helper.py

@ -33,7 +33,7 @@ from wsgiref import simple_server
from nova import config
from nova import context as nova_context
from nova import exception
from nova.openstack.common import log as logging
from ironic.openstack.common import log as logging
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import db

4
ironic/cmd/baremetal_manage.py → ironic/cmd/ironic_manage.py

@ -63,8 +63,8 @@ from oslo.config import cfg
gettext.install('nova', unicode=1)
from nova import config
from nova.openstack.common import cliutils
from nova.openstack.common import log as logging
from ironic.openstack.common import cliutils
from ironic.openstack.common import log as logging
from nova import version
from nova.virt.baremetal.db import migration as bmdb_migration

3
ironic/tests/baremetal/__init__.py → ironic/db/__init__.py

@ -12,4 +12,5 @@
# 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 nova.tests.baremetal import *
from ironic.db.api import *

30
ironic/virt/baremetal/db/api.py → ironic/db/api.py

@ -22,9 +22,9 @@
The underlying driver is loaded as a :class:`LazyPluggable`.
Functions in this module are imported into the nova.virt.baremetal.db
namespace. Call these functions from nova.virt.baremetal.db namespace, not
the nova.virt.baremetal.db.api namespace.
Functions in this module are imported into the ironic.db
namespace. Call these functions from ironic.db namespace, not
the ironic.db.api namespace.
All functions in this module return objects that implement a dictionary-like
interface. Currently, many of these objects are sqlalchemy objects that
@ -34,38 +34,30 @@ these objects be simple dictionaries.
**Related Flags**
:baremetal_db_backend: string to lookup in the list of LazyPluggable backends.
`sqlalchemy` is the only supported backend right now.
:db_backend: string to lookup in the list of LazyPluggable backends.
`sqlalchemy` is the only supported backend right now.
:[BAREMETAL] sql_connection: string specifying the sqlalchemy connection to
use, like: `sqlite:///var/lib/nova/nova.sqlite`.
:sql_connection: string specifying the sqlalchemy connection to
use, like: `sqlite:///var/lib/ironic/ironic.sqlite`.
"""
from oslo.config import cfg
from nova import utils
from ironic import utils
# NOTE(deva): we can't move baremetal_db_backend into an OptGroup yet
# because utils.LazyPluggable doesn't support reading from
# option groups. See bug #1093043.
db_opts = [
cfg.StrOpt('db_backend',
default='sqlalchemy',
help='The backend to use for bare-metal database'),
help='The backend to use for the ironic database'),
]
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(db_opts, baremetal_group)
CONF.register_opts(db_opts)
IMPL = utils.LazyPluggable(
'db_backend',
config_group='baremetal',
sqlalchemy='nova.virt.baremetal.db.sqlalchemy.api')
sqlalchemy='ironic.db.sqlalchemy.api')
def bm_node_get_all(context, service_host=None):

5
ironic/virt/baremetal/db/migration.py → ironic/db/migration.py

@ -18,13 +18,12 @@
"""Database setup and migration commands."""
from nova import utils
from ironic import utils
IMPL = utils.LazyPluggable(
'db_backend',
config_group='baremetal',
sqlalchemy='nova.virt.baremetal.db.sqlalchemy.migration')
sqlalchemy='ironic.db.sqlalchemy.migration')
INIT_VERSION = 0

0
ironic/virt/baremetal/db/sqlalchemy/__init__.py → ironic/db/sqlalchemy/__init__.py

6
ironic/virt/baremetal/db/sqlalchemy/api.py → ironic/db/sqlalchemy/api.py

@ -28,9 +28,9 @@ from sqlalchemy.sql.expression import literal_column
import nova.context
from nova.db.sqlalchemy import api as sqlalchemy_api
from nova import exception
from nova.openstack.common.db import exception as db_exc
from nova.openstack.common import timeutils
from nova.openstack.common import uuidutils
from ironic.openstack.common.db import exception as db_exc
from ironic.openstack.common import timeutils
from ironic.openstack.common import uuidutils
from nova.virt.baremetal.db.sqlalchemy import models
from nova.virt.baremetal.db.sqlalchemy import session as db_session

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/__init__.py → ironic/db/sqlalchemy/migrate_repo/__init__.py

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/migrate.cfg → ironic/db/sqlalchemy/migrate_repo/migrate.cfg

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/001_init.py → ironic/db/sqlalchemy/migrate_repo/versions/001_init.py

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/002_drop_bm_deployments.py → ironic/db/sqlalchemy/migrate_repo/versions/002_drop_bm_deployments.py

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/003_add_uuid_to_bm_nodes.py → ironic/db/sqlalchemy/migrate_repo/versions/003_add_uuid_to_bm_nodes.py

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py → ironic/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/005_drop_unused_columns_from_nodes.py → ironic/db/sqlalchemy/migrate_repo/versions/005_drop_unused_columns_from_nodes.py

2
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/006_move_prov_mac_address.py → ironic/db/sqlalchemy/migrate_repo/versions/006_move_prov_mac_address.py

@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from nova.openstack.common import log as logging
from ironic.openstack.common import log as logging
from sqlalchemy import and_, MetaData, select, Table, exists
from sqlalchemy import exc

0
ironic/virt/baremetal/db/sqlalchemy/migrate_repo/versions/__init__.py → ironic/db/sqlalchemy/migrate_repo/versions/__init__.py

6
ironic/virt/baremetal/db/sqlalchemy/migration.py → ironic/db/sqlalchemy/migration.py

@ -22,9 +22,9 @@ from migrate.versioning import util as migrate_util
import os
import sqlalchemy
from nova import exception
from nova.virt.baremetal.db import migration
from nova.virt.baremetal.db.sqlalchemy import session
from ironic import exception
from ironic.db import migration
from ironic.db.sqlalchemy import session
@migrate_util.decorator

0
ironic/virt/baremetal/db/sqlalchemy/models.py → ironic/db/sqlalchemy/models.py

4
ironic/virt/baremetal/db/sqlalchemy/session.py → ironic/db/sqlalchemy/session.py

@ -21,7 +21,7 @@
from oslo.config import cfg
from nova.openstack.common.db.sqlalchemy import session as nova_session
from ironic.openstack.common.db.sqlalchemy import session as nova_session
from nova import paths
opts = [
@ -39,7 +39,7 @@ CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.import_opt('sqlite_db', 'nova.openstack.common.db.sqlalchemy.session')
CONF.import_opt('sqlite_db', 'ironic.openstack.common.db.sqlalchemy.session')
_ENGINE = None
_MAKER = None

0
ironic/virt/baremetal/doc/README.rst → ironic/doc/README.rst

20
ironic/exception.py

@ -16,9 +16,9 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Nova base exception handling.
"""Ironic base exception handling.
Includes decorator for re-raising Nova-type exceptions.
Includes decorator for re-raising Ironic-type exceptions.
SHOULD include dedicated exception logging.
@ -27,11 +27,11 @@ SHOULD include dedicated exception logging.
import functools
from oslo.config import cfg
import webob.exc
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova import safe_utils
from ironic.openstack.common import excutils
from ironic.openstack.common import log as logging
from ironic import safe_utils
LOG = logging.getLogger(__name__)
@ -45,14 +45,6 @@ CONF = cfg.CONF
CONF.register_opts(exc_log_opts)
class ConvertedException(webob.exc.WSGIHTTPException):
def __init__(self, code=0, title="", explanation=""):
self.code = code
self.title = title
self.explanation = explanation
super(ConvertedException, self).__init__()
class ProcessExecutionError(IOError):
def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
description=None):

2
ironic/virt/baremetal/__init__.py → ironic/manager/__init__.py

@ -12,6 +12,6 @@
# 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 nova.virt.baremetal import driver
from ironic.manager import driver
BareMetalDriver = driver.BareMetalDriver

10
ironic/virt/baremetal/base.py → ironic/manager/base.py

@ -16,7 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from nova.virt.baremetal import baremetal_states
from ironic import states
class NodeDriver(object):
@ -51,19 +51,19 @@ class NodeDriver(object):
class PowerManager(object):
def __init__(self, **kwargs):
self.state = baremetal_states.DELETED
self.state = states.DELETED
pass
def activate_node(self):
self.state = baremetal_states.ACTIVE
self.state = states.ACTIVE
return self.state
def reboot_node(self):
self.state = baremetal_states.ACTIVE
self.state = states.ACTIVE
return self.state
def deactivate_node(self):
self.state = baremetal_states.DELETED
self.state = states.DELETED
return self.state
def is_power_on(self):

52
ironic/virt/baremetal/driver.py → ironic/manager/driver.py

@ -24,14 +24,14 @@ A driver for Bare-metal platform.
from oslo.config import cfg
from nova.compute import power_state
from nova import context as nova_context
from nova import exception
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from ironic import context as ironic_context
from ironic import exception
from ironic.openstack.common import excutils
from ironic.openstack.common import importutils
from ironic.openstack.common import log as logging
from nova import paths
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import db
from ironic import states
from ironic import db
from nova.virt import driver
from nova.virt import firewall
from nova.virt.libvirt import imagecache
@ -70,13 +70,9 @@ opts = [
LOG = logging.getLogger(__name__)
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.import_opt('host', 'nova.netconf')
CONF.register_opts(opts)
CONF.import_opt('host', 'ironic.netconf')
DEFAULT_FIREWALL_DRIVER = "%s.%s" % (
firewall.__name__,
@ -107,7 +103,7 @@ def _update_state(context, node, instance, state):
def get_power_manager(**kwargs):
cls = importutils.import_class(CONF.baremetal.power_manager)
cls = importutils.import_class(CONF.power_manager)
return cls(**kwargs)
@ -122,18 +118,18 @@ class BareMetalDriver(driver.ComputeDriver):
super(BareMetalDriver, self).__init__(virtapi)
self.driver = importutils.import_object(
CONF.baremetal.driver, virtapi)
CONF.driver, virtapi)
self.vif_driver = importutils.import_object(
CONF.baremetal.vif_driver)
CONF.vif_driver)
self.firewall_driver = firewall.load_driver(
default=DEFAULT_FIREWALL_DRIVER)
self.volume_driver = importutils.import_object(
CONF.baremetal.volume_driver, virtapi)
CONF.volume_driver, virtapi)
self.image_cache_manager = imagecache.ImageCacheManager()
extra_specs = {}
extra_specs["baremetal_driver"] = CONF.baremetal.driver
for pair in CONF.baremetal.instance_type_extra_specs:
extra_specs["baremetal_driver"] = CONF.driver
for pair in CONF.instance_type_extra_specs:
keyval = pair.split(':', 1)
keyval[0] = keyval[0].strip()
keyval[1] = keyval[1].strip()
@ -234,7 +230,7 @@ class BareMetalDriver(driver.ComputeDriver):
node = db.bm_node_associate_and_update(context, node_uuid,
{'instance_uuid': instance['uuid'],
'instance_name': instance['hostname'],
'task_state': baremetal_states.BUILDING})
'task_state': states.BUILDING})
try:
self._plug_vifs(instance, network_info, context=context)
@ -251,7 +247,7 @@ class BareMetalDriver(driver.ComputeDriver):
self.driver.activate_bootloader(context, node, instance)
self.power_on(instance, node)
self.driver.activate_node(context, node, instance)
_update_state(context, node, instance, baremetal_states.ACTIVE)
_update_state(context, node, instance, states.ACTIVE)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_("Error deploying instance %(instance)s "
@ -261,7 +257,7 @@ class BareMetalDriver(driver.ComputeDriver):
# Do not set instance=None yet. This prevents another
# spawn() while we are cleaning up.
_update_state(context, node, instance, baremetal_states.ERROR)
_update_state(context, node, instance, states.ERROR)
self.driver.deactivate_node(context, node, instance)
self.power_off(instance, node)
@ -272,7 +268,7 @@ class BareMetalDriver(driver.ComputeDriver):
self._stop_firewall(instance, network_info)
self._unplug_vifs(instance, network_info)
_update_state(context, node, None, baremetal_states.DELETED)
_update_state(context, node, None, states.DELETED)
def reboot(self, context, instance, network_info, reboot_type,
block_device_info=None, bad_volumes_callback=None):
@ -280,7 +276,7 @@ class BareMetalDriver(driver.ComputeDriver):
ctx = nova_context.get_admin_context()
pm = get_power_manager(node=node, instance=instance)
state = pm.reboot_node()
if pm.state != baremetal_states.ACTIVE:
if pm.state != states.ACTIVE:
raise exception.InstanceRebootFailure(_(
"Baremetal power manager failed to restart node "
"for instance %r") % instance['uuid'])
@ -306,14 +302,14 @@ class BareMetalDriver(driver.ComputeDriver):
self._stop_firewall(instance, network_info)
self._unplug_vifs(instance, network_info)
_update_state(context, node, None, baremetal_states.DELETED)
_update_state(context, node, None, states.DELETED)
except Exception as e:
with excutils.save_and_reraise_exception():
try:
LOG.error(_("Error from baremetal driver "
"during destroy: %s") % e)
_update_state(context, node, instance,
baremetal_states.ERROR)
states.ERROR)
except Exception:
LOG.error(_("Error while recording destroy failure in "
"baremetal database: %s") % e)
@ -324,7 +320,7 @@ class BareMetalDriver(driver.ComputeDriver):
node = _get_baremetal_node_by_instance_uuid(instance['uuid'])
pm = get_power_manager(node=node, instance=instance)
pm.deactivate_node()
if pm.state != baremetal_states.DELETED:
if pm.state != states.DELETED:
raise exception.InstancePowerOffFailure(_(
"Baremetal power manager failed to stop node "
"for instance %r") % instance['uuid'])
@ -336,7 +332,7 @@ class BareMetalDriver(driver.ComputeDriver):
node = _get_baremetal_node_by_instance_uuid(instance['uuid'])
pm = get_power_manager(node=node, instance=instance)
pm.activate_node()
if pm.state != baremetal_states.ACTIVE:
if pm.state != states.ACTIVE:
raise exception.InstancePowerOnFailure(_(
"Baremetal power manager failed to start node "
"for instance %r") % instance['uuid'])

2
ironic/virt/baremetal/fake.py → ironic/manager/fake.py

@ -16,7 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from nova.virt.baremetal import base
from ironic.manager import base
from nova.virt import firewall

42
ironic/virt/baremetal/ipmi.py → ironic/manager/ipmi.py

@ -27,14 +27,14 @@ import tempfile
from oslo.config import cfg
from nova import exception
from nova.openstack.common import log as logging
from nova.openstack.common import loopingcall
from ironic import exception
from ironic.openstack.common import log as logging
from ironic.openstack.common import loopingcall
from nova import paths
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
from nova.virt.baremetal import utils as bm_utils
from ironic import utils
from ironic import states
from ironic.manager import base
from ironic import utils as bm_utils
opts = [
cfg.StrOpt('terminal',
@ -51,12 +51,8 @@ opts = [
help='maximal number of retries for IPMI operations'),
]
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.register_opts(opts)
LOG = logging.getLogger(__name__)
@ -71,7 +67,7 @@ def _make_password_file(password):
def _get_console_pid_path(node_id):
name = "%s.pid" % node_id
path = os.path.join(CONF.baremetal.terminal_pid_dir, name)
path = os.path.join(CONF.terminal_pid_dir, name)
return path
@ -149,10 +145,10 @@ class IPMI(base.PowerManager):
"""Called at an interval until the node's power is on."""
if self._is_power("on"):
self.state = baremetal_states.ACTIVE
self.state = states.ACTIVE
raise loopingcall.LoopingCallDone()
if self.retries > CONF.baremetal.ipmi_power_retry:
self.state = baremetal_states.ERROR
if self.retries > CONF.ipmi_power_retry:
self.state = states.ERROR
raise loopingcall.LoopingCallDone()
try:
self.retries += 1
@ -171,10 +167,10 @@ class IPMI(base.PowerManager):
"""Called at an interval until the node's power is off."""
if self._is_power("off"):
self.state = baremetal_states.DELETED
self.state = states.DELETED
raise loopingcall.LoopingCallDone()
if self.retries > CONF.baremetal.ipmi_power_retry:
self.state = baremetal_states.ERROR
if self.retries > CONF.ipmi_power_retry:
self.state = states.ERROR
raise loopingcall.LoopingCallDone()
try:
self.retries += 1
@ -194,7 +190,7 @@ class IPMI(base.PowerManager):
def activate_node(self):
"""Turns the power to node ON."""
if self._is_power("on") and self.state == baremetal_states.ACTIVE:
if self._is_power("on") and self.state == states.ACTIVE:
LOG.warning(_("Activate node called, but node %s "
"is already active") % self.address)
self._set_pxe_for_next_boot()
@ -220,10 +216,10 @@ class IPMI(base.PowerManager):
if not self.port:
return
args = []
args.append(CONF.baremetal.terminal)
if CONF.baremetal.terminal_cert_dir:
args.append(CONF.terminal)
if CONF.terminal_cert_dir:
args.append("-c")
args.append(CONF.baremetal.terminal_cert_dir)
args.append(CONF.terminal_cert_dir)
else:
args.append("-t")
args.append("-p")

0
ironic/virt/baremetal/net-dhcp.ubuntu.template → ironic/manager/net-dhcp.ubuntu.template

0
ironic/virt/baremetal/net-static.ubuntu.template → ironic/manager/net-static.ubuntu.template

67
ironic/virt/baremetal/pxe.py → ironic/manager/pxe.py

@ -26,16 +26,16 @@ import os
from oslo.config import cfg
from nova.compute import instance_types
from nova import exception
from nova.openstack.common.db import exception as db_exc
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova.openstack.common import loopingcall
from nova.openstack.common import timeutils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
from nova.virt.baremetal import db
from nova.virt.baremetal import utils as bm_utils
from ironic import exception
from ironic.openstack.common.db import exception as db_exc
from ironic.openstack.common import fileutils
from ironic.openstack.common import log as logging
from ironic.openstack.common import loopingcall
from ironic.openstack.common import timeutils
from ironic import states
from ironic.manager import base
from ironic import db
from ironic import utils as bm_utils
pxe_opts = [
cfg.StrOpt('deploy_kernel',
@ -43,13 +43,12 @@ pxe_opts = [
cfg.StrOpt('deploy_ramdisk',
help='Default ramdisk image ID used in deployment phase'),
cfg.StrOpt('net_config_template',
default='$pybasedir/nova/virt/baremetal/'
'net-dhcp.ubuntu.template',
default='$pybasedir/ironic/net-dhcp.ubuntu.template',
help='Template file for injected network config'),
cfg.StrOpt('pxe_append_params',
help='additional append parameters for baremetal PXE boot'),
cfg.StrOpt('pxe_config_template',
default='$pybasedir/nova/virt/baremetal/pxe_config.template',
default='$pybasedir/ironic/pxe_config.template',
help='Template file for PXE configuration'),
cfg.IntOpt('pxe_deploy_timeout',
help='Timeout for PXE deployments. Default: 0 (unlimited)',
@ -58,13 +57,9 @@ pxe_opts = [
LOG = logging.getLogger(__name__)
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(pxe_opts, baremetal_group)
CONF.import_opt('use_ipv6', 'nova.netconf')
CONF.register_opts(pxe_opts)
CONF.import_opt('use_ipv6', 'ironic.netconf')
CHEETAH = None
@ -98,11 +93,11 @@ def build_pxe_config(deployment_id, deployment_key, deployment_iscsi_iqn,
'deployment_ari_path': deployment_ari_path,
'aki_path': aki_path,
'ari_path': ari_path,
'pxe_append_params': CONF.baremetal.pxe_append_params,
'pxe_append_params': CONF.pxe_append_params,
}
cheetah = _get_cheetah()
pxe_config = str(cheetah(
open(CONF.baremetal.pxe_config_template).read(),
open(CONF.pxe_config_template).read(),
searchList=[{'pxe_options': pxe_options,
'ROOT': '${ROOT}',
}]))
@ -139,7 +134,7 @@ def build_network_config(network_info):
cheetah = _get_cheetah()
network_config = str(cheetah(
open(CONF.baremetal.net_config_template).read(),
open(CONF.net_config_template).read(),
searchList=[
{'interfaces': interfaces,
'use_ipv6': CONF.use_ipv6,
@ -150,12 +145,12 @@ def build_network_config(network_info):
def get_deploy_aki_id(instance_type):
return instance_type.get('extra_specs', {}).\
get('baremetal:deploy_kernel_id', CONF.baremetal.deploy_kernel)
get('baremetal:deploy_kernel_id', CONF.deploy_kernel)
def get_deploy_ari_id(instance_type):
return instance_type.get('extra_specs', {}).\
get('baremetal:deploy_ramdisk_id', CONF.baremetal.deploy_ramdisk)
get('baremetal:deploy_ramdisk_id', CONF.deploy_ramdisk)
def get_image_dir_path(instance):
@ -170,7 +165,7 @@ def get_image_file_path(instance):
def get_pxe_config_file_path(instance):
"""Generate the path for an instances PXE config file."""
return os.path.join(CONF.baremetal.tftp_root, instance['uuid'], 'config')
return os.path.join(CONF.tftp_root, instance['uuid'], 'config')
def get_partition_sizes(instance):
@ -190,7 +185,7 @@ def get_partition_sizes(instance):
def get_pxe_mac_path(mac):
"""Convert a MAC address into a PXE config file name."""
return os.path.join(
CONF.baremetal.tftp_root,
CONF.tftp_root,
'pxelinux.cfg',
"01-" + mac.replace(":", "-").lower()
)
@ -225,7 +220,7 @@ def get_tftp_image_info(instance, instance_type):
if not uuid:
missing_labels.append(label)
else:
image_info[label][1] = os.path.join(CONF.baremetal.tftp_root,
image_info[label][1] = os.path.join(CONF.tftp_root,
instance['uuid'], label)
if missing_labels:
raise exception.NovaException(_(
@ -250,7 +245,7 @@ class PXE(base.NodeDriver):
def _cache_tftp_images(self, context, instance, image_info):
"""Fetch the necessary kernels and ramdisks for the instance."""
fileutils.ensure_tree(
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
os.path.join(CONF.tftp_root, instance['uuid']))
LOG.debug(_("Fetching kernel and ramdisk for instance %s") %
instance['name'])
@ -272,7 +267,7 @@ class PXE(base.NodeDriver):
to the appropriate places on local disk.
Both sets of kernel and ramdisk are needed for PXE booting, so these
are stored under CONF.baremetal.tftp_root.
are stored under CONF.tftp_root.
At present, the AMI is cached and certain files are injected.
Debian/ubuntu-specific assumptions are made regarding the injected
@ -444,7 +439,7 @@ class PXE(base.NodeDriver):
bm_utils.unlink_without_raise(get_pxe_mac_path(mac))
bm_utils.rmtree_without_raise(
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
os.path.join(CONF.tftp_root, instance['uuid']))
def activate_node(self, context, node, instance):
"""Wait for PXE deployment to complete."""
@ -461,23 +456,23 @@ class PXE(base.NodeDriver):
raise loopingcall.LoopingCallDone()
status = row.get('task_state')
if (status == baremetal_states.DEPLOYING
if (status == states.DEPLOYING
and locals['started'] is False):
LOG.info(_("PXE deploy started for instance %s")
% instance['uuid'])
locals['started'] = True
elif status in (baremetal_states.DEPLOYDONE,
baremetal_states.ACTIVE):
elif status in (states.DEPLOYDONE,
states.ACTIVE):
LOG.info(_("PXE deploy completed for instance %s")
% instance['uuid'])
raise loopingcall.LoopingCallDone()
elif status == baremetal_states.DEPLOYFAIL:
elif status == states.DEPLOYFAIL:
locals['error'] = _("PXE deploy failed for instance %s")
except exception.NodeNotFound:
locals['error'] = _("Baremetal node deleted while waiting "
"for deployment of instance %s")
if (CONF.baremetal.pxe_deploy_timeout and
if (CONF.pxe_deploy_timeout and
timeutils.utcnow() > expiration):
locals['error'] = _("Timeout reached while waiting for "
"PXE deploy of instance %s")
@ -485,7 +480,7 @@ class PXE(base.NodeDriver):
raise loopingcall.LoopingCallDone()
expiration = timeutils.utcnow() + datetime.timedelta(
seconds=CONF.baremetal.pxe_deploy_timeout)
seconds=CONF.pxe_deploy_timeout)
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_deploy)
timer.start(interval=1).wait()

0
ironic/virt/baremetal/pxe_config.template → ironic/manager/pxe_config.template

55
ironic/virt/baremetal/tilera.py → ironic/manager/tilera.py

@ -25,32 +25,27 @@ import os
from oslo.config import cfg
from nova.compute import instance_types
from nova import exception
from nova.openstack.common.db import exception as db_exc
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
from nova.virt.baremetal import db
from nova.virt.baremetal import utils as bm_utils
from ironic import exception
from ironic.openstack.common.db import exception as db_exc
from ironic.openstack.common import fileutils
from ironic.openstack.common import log as logging
from ironic import utils
from ironic import states
from ironic.manager import base
from ironic import db
from ironic import utils as bm_utils
tilera_opts = [
cfg.StrOpt('net_config_template',
default='$pybasedir/nova/virt/baremetal/'
'net-dhcp.ubuntu.template',
default='$pybasedir/ironic/net-dhcp.ubuntu.template',
help='Template file for injected network config'),
]
LOG = logging.getLogger(__name__)
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(tilera_opts, baremetal_group)
CONF.import_opt('use_ipv6', 'nova.netconf')
CONF.register_opts(tilera_opts)
CONF.import_opt('use_ipv6', 'ironic.netconf')
CHEETAH = None
@ -91,7 +86,7 @@ def build_network_config(network_info):
cheetah = _get_cheetah()
network_config = str(cheetah(
open(CONF.baremetal.net_config_template).read(),
open(CONF.net_config_template).read(),
searchList=[
{'interfaces': interfaces,
'use_ipv6': CONF.use_ipv6,
@ -113,7 +108,7 @@ def get_image_file_path(instance):
def get_tilera_nfs_path(node_id):
"""Generate the path for an instances Tilera nfs."""
tilera_nfs_dir = "fs_" + str(node_id)
return os.path.join(CONF.baremetal.tftp_root, tilera_nfs_dir)
return os.path.join(CONF.tftp_root, tilera_nfs_dir)
def get_partition_sizes(instance):
@ -147,7 +142,7 @@ def get_tftp_image_info(instance):
if not uuid:
missing_labels.append(label)
else:
image_info[label][1] = os.path.join(CONF.baremetal.tftp_root,
image_info[label][1] = os.path.join(CONF.tftp_root,
instance['uuid'], label)
if missing_labels:
raise exception.NovaException(_(
@ -173,7 +168,7 @@ class Tilera(base.NodeDriver):
def _cache_tftp_images(self, context, instance, image_info):
"""Fetch the necessary kernels and ramdisks for the instance."""
fileutils.ensure_tree(
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
os.path.join(CONF.tftp_root, instance['uuid']))
LOG.debug(_("Fetching kernel and ramdisk for instance %s") %
instance['name'])
@ -195,7 +190,7 @@ class Tilera(base.NodeDriver):
to the appropriate places on local disk.
Both sets of kernel and ramdisk are needed for Tilera booting, so these
are stored under CONF.baremetal.tftp_root.
are stored under CONF.tftp_root.
At present, the AMI is cached and certain files are injected.
Debian/ubuntu-specific assumptions are made regarding the injected
@ -335,10 +330,10 @@ class Tilera(base.NodeDriver):
except db_exc.DBError:
pass
if os.path.exists(os.path.join(CONF.baremetal.tftp_root,
if os.path.exists(os.path.join(CONF.tftp_root,
instance['uuid'])):
bm_utils.rmtree_without_raise(
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
os.path.join(CONF.tftp_root, instance['uuid']))
def _iptables_set(self, node_ip, user_data):
"""Sets security setting (iptables:port) if needed.
@ -346,7 +341,7 @@ class Tilera(base.NodeDriver):
iptables -A INPUT -p tcp ! -s $IP --dport $PORT -j DROP
/tftpboot/iptables_rule script sets iptables rule on the given node.
"""
rule_path = CONF.baremetal.tftp_root + "/iptables_rule"
rule_path = CONF.tftp_root + "/iptables_rule"
if user_data is not None:
open_ip = base64.b64decode(user_data)
utils.execute(rule_path, node_ip, open_ip)
@ -363,14 +358,14 @@ class Tilera(base.NodeDriver):
" while waiting for deploy of %s")
status = row.get('task_state')
if (status == baremetal_states.DEPLOYING and
if (status == states.DEPLOYING and
locals['started'] is False):
LOG.info(_('Tilera deploy started for instance %s')
% instance['uuid'])
locals['started'] = True
elif status in (baremetal_states.DEPLOYDONE,
baremetal_states.BUILDING,
baremetal_states.ACTIVE):
elif status in (states.DEPLOYDONE,
states.BUILDING,
states.ACTIVE):
LOG.info(_("Tilera deploy completed for instance %s")
% instance['uuid'])
node_ip = node['pm_address']
@ -381,7 +376,7 @@ class Tilera(base.NodeDriver):
self.deactivate_bootloader(context, node, instance)
raise exception.NovaException(_("Node is "
"unknown error state."))
elif status == baremetal_states.DEPLOYFAIL:
elif status == states.DEPLOYFAIL:
locals['error'] = _("Tilera deploy failed for instance %s")
except exception.NodeNotFound:
locals['error'] = _("Baremetal node deleted while waiting "

56
ironic/virt/baremetal/tilera_pdu.py → ironic/manager/tilera_pdu.py

@ -24,11 +24,11 @@ import time
from oslo.config import cfg
from nova import exception
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
from ironic import exception
from ironic.openstack.common import log as logging
from ironic import utils
from ironic import states
from ironic.manager import base
opts = [
cfg.StrOpt('tile_pdu_ip',
@ -52,12 +52,8 @@ opts = [
'after tilera power operations'),
]
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.register_opts(opts)
LOG = logging.getLogger(__name__)
@ -98,56 +94,56 @@ class Pdu(base.PowerManager):
changed. /tftpboot/pdu_mgr script handles power management of
PDU (Power Distribution Unit).
"""
if mode == CONF.baremetal.tile_pdu_status:
if mode == CONF.tile_pdu_status:
try:
utils.execute('ping', '-c1', self.address,
check_exit_code=True)
return CONF.baremetal.tile_pdu_on
return CONF.tile_pdu_on
except exception.ProcessExecutionError:
return CONF.baremetal.tile_pdu_off
return CONF.tile_pdu_off
else:
try:
utils.execute(CONF.baremetal.tile_pdu_mgr,
CONF.baremetal.tile_pdu_ip, mode)
time.sleep(CONF.baremetal.tile_power_wait)
utils.execute(CONF.tile_pdu_mgr,
CONF.tile_pdu_ip, mode)
time.sleep(CONF.tile_power_wait)
return mode
except exception.ProcessExecutionError:
LOG.exception(_("PDU failed"))
def _is_power(self, state):
out_err = self._exec_pdutool(CONF.baremetal.tile_pdu_status)
out_err = self._exec_pdutool(CONF.tile_pdu_status)
return out_err == state
def _power_on(self):
"""Turn the power to this node ON."""
try:
self._exec_pdutool(CONF.baremetal.tile_pdu_on)
if self._is_power(CONF.baremetal.tile_pdu_on):
self.state = baremetal_states.ACTIVE
self._exec_pdutool(CONF.tile_pdu_on)
if self._is_power(CONF.tile_pdu_on):
self.state = states.ACTIVE
else:
self.state = baremetal_states.ERROR
self.state = states.ERROR
except Exception:
self.state = baremetal_states.ERROR
self.state = states.ERROR
LOG.exception(_("PDU power on failed"))
def _power_off(self):
"""Turn the power to this node OFF."""
try:
self._exec_pdutool(CONF.baremetal.tile_pdu_off)
if self._is_power(CONF.baremetal.tile_pdu_off):
self.state = baremetal_states.DELETED
self._exec_pdutool(CONF.tile_pdu_off)
if self._is_power(CONF.tile_pdu_off):
self.state = states.DELETED
else:
self.state = baremetal_states.ERROR
self.state = states.ERROR
except Exception:
self.state = baremetal_states.ERROR
self.state = states.ERROR
LOG.exception(_("PDU power off failed"))
def activate_node(self):
"""Turns the power to node ON."""
if (self._is_power(CONF.baremetal.tile_pdu_on)
and self.state == baremetal_states.ACTIVE):
if (self._is_power(CONF.tile_pdu_on)
and self.state == states.ACTIVE):
LOG.warning(_("Activate node called, but node %s "
"is already active") % self.address)
self._power_on()
@ -165,7 +161,7 @@ class Pdu(base.PowerManager):
return self.state
def is_power_on(self):
return self._is_power(CONF.baremetal.tile_pdu_on)
return self._is_power(CONF.tile_pdu_on)
def start_console(self):
pass

2
ironic/virt/baremetal/utils.py → ironic/manager/utils.py

@ -19,7 +19,7 @@ import errno
import os
import shutil
from nova.openstack.common import log as logging
from ironic.openstack.common import log as logging
from nova.virt.disk import api as disk_api
from nova.virt.libvirt import utils as libvirt_utils

22
ironic/virt/baremetal/vif_driver.py → ironic/manager/vif_driver.py

@ -15,10 +15,10 @@
from oslo.config import cfg
from nova import context
from nova import exception
from nova.openstack.common import log as logging
from nova.virt.baremetal import db as bmdb
from ironic import context as nova_context
from ironic import exception
from ironic.openstack.common import log as logging
from ironic import db
CONF = cfg.CONF
@ -38,15 +38,15 @@ class BareMetalVIFDriver(object):
% {'uuid': instance['uuid'], 'vif': vif})
network, mapping = vif
vif_uuid = mapping['vif_uuid']
ctx = context.get_admin_context()
node = bmdb.bm_node_get_by_instance_uuid(ctx, instance['uuid'])
ctx = nova_context.get_admin_context()
node = db.bm_node_get_by_instance_uuid(ctx, instance['uuid'])
# TODO(deva): optimize this database query
# this is just searching for a free physical interface
pifs = bmdb.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
pifs = db.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
for pif in pifs:
if not pif['vif_uuid']:
bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], vif_uuid)
db.bm_interface_set_vif_uuid(ctx, pif['id'], vif_uuid)
LOG.debug(_("pif:%(id)s is plugged (vif_uuid=%(vif_uuid)s)")
% {'id': pif['id'], 'vif_uuid': vif_uuid})
self._after_plug(instance, network, mapping, pif)
@ -64,10 +64,10 @@ class BareMetalVIFDriver(object):
{'uuid': instance['uuid'], 'vif': vif})
network, mapping = vif
vif_uuid = mapping['vif_uuid']
ctx = context.get_admin_context()
ctx = nova_context.get_admin_context()
try:
pif = bmdb.bm_interface_get_by_vif_uuid(ctx, vif_uuid)
bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], None)
pif = db.bm_interface_get_by_vif_uuid(ctx, vif_uuid)
db.bm_interface_set_vif_uuid(ctx, pif['id'], None)
LOG.debug(_("pif:%(id)s is unplugged (vif_uuid=%(vif_uuid)s)")
% {'id': pif['id'], 'vif_uuid': vif_uuid})
self._after_unplug(instance, network, mapping, pif)

58
ironic/virt/baremetal/virtual_power_driver.py → ironic/manager/virtual_power_driver.py

@ -19,14 +19,14 @@
from oslo.config import cfg
from nova import context as nova_context
from nova import exception
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
from nova.virt.baremetal import db
from ironic import context as nova_context
from ironic import exception
from ironic.openstack.common import importutils
from ironic.openstack.common import log as logging
from ironic import utils
from ironic import states
from ironic.manager import base
from ironic import db
import nova.virt.powervm.common as connection
opts = [
@ -51,12 +51,8 @@ opts = [
]
baremetal_vp = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_vp)
CONF.register_opts(opts, baremetal_vp)
CONF.register_opts(opts)
_conn = None
_virtual_power_settings = None
@ -89,9 +85,9 @@ class VirtualPowerManager(base.PowerManager):
if _cmds is None:
LOG.debug("Setting up %s commands." %
CONF.baremetal.virtual_power_type)
_vpc = 'nova.virt.baremetal.virtual_power_driver_settings.%s' % \
CONF.baremetal.virtual_power_type
CONF.virtual_power_type)
_vpc = 'ironic.virtual_power_driver_settings.%s' % \
CONF.virtual_power_type
_cmds = importutils.import_class(_vpc)
self._vp_cmd = _cmds()
self.connection_data = _conn
@ -106,26 +102,26 @@ class VirtualPowerManager(base.PowerManager):
self.state = None
def _get_conn(self):
if not CONF.baremetal.virtual_power_ssh_host:
if not CONF.virtual_power_ssh_host:
raise exception.NovaException(
_('virtual_power_ssh_host not defined. Can not Start'))
if not CONF.baremetal.virtual_power_host_user:
if not CONF.virtual_power_host_user:
raise exception.NovaException(
_('virtual_power_host_user not defined. Can not Start'))
if not CONF.baremetal.virtual_power_host_pass:
if not CONF.virtual_power_host_pass:
# it is ok to not have a password if you have a keyfile
if CONF.baremetal.virtual_power_host_key is None:
if CONF.virtual_power_host_key is None:
raise exception.NovaException(
_('virtual_power_host_pass/key not set. Can not Start'))
_conn = connection.Connection(
CONF.baremetal.virtual_power_ssh_host,
CONF.baremetal.virtual_power_host_user,
CONF.baremetal.virtual_power_host_pass,
CONF.baremetal.virtual_power_ssh_port,
CONF.baremetal.virtual_power_host_key)
CONF.virtual_power_ssh_host,
CONF.virtual_power_host_user,
CONF.virtual_power_host_pass,
CONF.virtual_power_ssh_port,
CONF.virtual_power_host_key)
return _conn
def _set_connection(self):
@ -163,9 +159,9 @@ class VirtualPowerManager(base.PowerManager):
self._run_command(cmd)
if self.is_power_on():
self.state = baremetal_states.ACTIVE
self.state = states.ACTIVE
else:
self.state = baremetal_states.ERROR
self.state = states.ERROR
return self.state
def reboot_node(self):
@ -174,9 +170,9 @@ class VirtualPowerManager(base.PowerManager):
cmd = self._vp_cmd.reboot_cmd
self._run_command(cmd)
if self.is_power_on():
self.state = baremetal_states.ACTIVE
self.state = states.ACTIVE
else:
self.state = baremetal_states.ERROR
self.state = states.ERROR
return self.state
def deactivate_node(self):
@ -187,9 +183,9 @@ class VirtualPowerManager(base.PowerManager):
self._run_command(cmd)
if self.is_power_on():
self.state = baremetal_states.ERROR
self.state = states.ERROR
else:
self.state = baremetal_states.DELETED
self.state = states.DELETED
return self.state
def is_power_on(self):

0
ironic/virt/baremetal/virtual_power_driver_settings.py → ironic/manager/virtual_power_driver_settings.py

32
ironic/virt/baremetal/volume_driver.py → ironic/manager/volume_driver.py

@ -20,12 +20,12 @@ import re
from oslo.config import cfg
from nova import context as nova_context
from nova import exception
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.baremetal import db as bmdb
from ironic import context as nova_context
from ironic import exception
from ironic.openstack.common import importutils
from ironic.openstack.common import log as logging
from ironic import utils
from ironic import db
from nova.virt.libvirt import utils as libvirt_utils
opts = [
@ -39,15 +39,11 @@ opts = [
help='iSCSI IQN prefix used in baremetal volume connections.'),
]
baremetal_group = cfg.OptGroup(name='baremetal',
title='Baremetal Options')
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.register_opts(opts)
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('use_ipv6', 'nova.netconf')
CONF.import_opt('host', 'ironic.netconf')
CONF.import_opt('use_ipv6', 'ironic.netconf')
CONF.import_opt('libvirt_volume_drivers', 'nova.virt.libvirt.driver')
LOG = logging.getLogger(__name__)
@ -55,7 +51,7 @@ LOG = logging.getLogger(__name__)
def _get_baremetal_node_by_instance_uuid(instance_uuid):
context = nova_context.get_admin_context()
return bmdb.bm_node_get_by_instance_uuid(context, instance_uuid)
return db.bm_node_get_by_instance_uuid(context, instance_uuid)
def _create_iscsi_export_tgtadm(path, tid, iqn):
@ -165,7 +161,7 @@ def _find_tid(iqn):
def _get_iqn(instance_name, mountpoint):
mp = mountpoint.replace('/', '-').strip('-')
iqn = '%s:%s-%s' % (CONF.baremetal.iscsi_iqn_prefix,
iqn = '%s:%s-%s' % (CONF.iscsi_iqn_prefix,