示例#1
0
def get_client(token=None, context=None):
    if not context:
        context = ironic_context.RequestContext(auth_token=token)
    # NOTE(pas-ha) neutronclient supports passing both session
    # and the auth to client separately, makes things easier
    session = _get_neutron_session()
    service_auth = keystone.get_auth('neutron')

    # TODO(pas-ha) remove in Rocky, always simply load from config
    # 'noauth' then would correspond to 'auth_type=none' and
    # 'endpoint_override'
    adapter_params = {}
    if (CONF.neutron.auth_strategy == 'noauth'
            and CONF.neutron.auth_type is None):
        CONF.set_override('auth_type', 'none', group='neutron')
        if not CONF.neutron.endpoint_override:
            adapter_params['endpoint_override'] = (CONF.neutron.url
                                                   or DEFAULT_NEUTRON_URL)
    else:
        if CONF.neutron.url and not CONF.neutron.endpoint_override:
            adapter_params['endpoint_override'] = CONF.neutron.url
    adapter = keystone.get_adapter('neutron', session=session,
                                   auth=service_auth, **adapter_params)
    endpoint = adapter.get_endpoint()

    user_auth = None
    if CONF.neutron.auth_type != 'none' and context.auth_token:
        user_auth = keystone.get_service_auth(context, endpoint, service_auth)
    return clientv20.Client(session=session,
                            auth=user_auth or service_auth,
                            endpoint_override=endpoint,
                            retries=CONF.neutron.retries,
                            global_request_id=context.global_id,
                            timeout=CONF.neutron.request_timeout)
示例#2
0
 def test_get_target_version_pinned_no_myobj(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'NotMyObj': '1.4',
         }
     }
     obj = MyObj(self.context)
     self.assertEqual('1.5', obj.get_target_version())
示例#3
0
 def test_get_target_version_pinned(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': ['1.4'],
         }
     }
     obj = MyObj(self.context)
     self.assertEqual('1.4', obj.get_target_version())
示例#4
0
 def test_get_changes_pinned_2versions(self, mock_release_mapping):
     # obj_get_changes() is not affected by pinning
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': ['1.3', '1.4'],
         }
     }
     self._test_get_changes(target_version='1.4')
示例#5
0
 def test_get_changes_pinned(self, mock_release_mapping):
     # obj_get_changes() is not affected by pinning
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': '1.4',
         }
     }
     self._test_get_changes(target_version='1.4')
示例#6
0
    def wrapper(self, *args, **kwargs):
        """Wrapper around methods calls.

        :param image_href: href that describes the location of an image
        """

        if self.client:
            return func(self, *args, **kwargs)

        # TODO(pas-ha) remove in Rocky
        session_params = {}
        if CONF.glance.glance_api_insecure and not CONF.glance.insecure:
            session_params['insecure'] = CONF.glance.glance_api_insecure
        if CONF.glance.glance_cafile and not CONF.glance.cafile:
            session_params['cacert'] = CONF.glance.glance_cafile
        # NOTE(pas-ha) glanceclient uses Adapter-based SessionClient,
        # so we can pass session and auth separately, makes things easier
        session = _get_glance_session(**session_params)

        # TODO(pas-ha) remove in Rocky
        # NOTE(pas-ha) new option must win if configured
        if (CONF.glance.glance_api_servers
                and not CONF.glance.endpoint_override):
            # NOTE(pas-ha) all the 2 methods have image_href as the first
            #              positional arg, but check in kwargs too
            image_href = args[0] if args else kwargs.get('image_href')
            url = service_utils.get_glance_api_server(image_href)
            CONF.set_override('endpoint_override', url, group='glance')

        # TODO(pas-ha) remove in Rocky
        if CONF.glance.auth_strategy == 'noauth':
            CONF.set_override('auth_type', 'none', group='glance')

        service_auth = keystone.get_auth('glance')

        adapter_params = {}
        adapter = keystone.get_adapter('glance',
                                       session=session,
                                       auth=service_auth,
                                       **adapter_params)
        self.endpoint = adapter.get_endpoint()

        user_auth = None
        # NOTE(pas-ha) our ContextHook removes context.auth_token in noauth
        # case, so when ironic is in noauth but glance is not, we will not
        # enter the next if-block and use auth from [glance] config section
        if self.context.auth_token:
            user_auth = keystone.get_service_auth(self.context, self.endpoint,
                                                  service_auth)
        self.client = client.Client(2,
                                    session=session,
                                    auth=user_auth or service_auth,
                                    endpoint_override=self.endpoint,
                                    global_request_id=self.context.global_id)
        return func(self, *args, **kwargs)
示例#7
0
 def test_max_version_pinned(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.get.return_value = {
         'api': '1.5',
         'rpc': '1.4',
         'objects': {
             'MyObj': ['1.4'],
         }
     }
     self.assertEqual('1.5', versions.max_version_string())
示例#8
0
 def test_get_target_version_pinned_bad(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': ['1.6'],
         }
     }
     obj = MyObj(self.context)
     self.assertRaises(object_exception.IncompatibleObjectVersion,
                       obj.get_target_version)
示例#9
0
 def test_max_version_pinned(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.get.return_value = {
         'api': '1.5',
         'rpc': '1.4',
         'objects': {
             'MyObj': ['1.4'],
         }
     }
     self.assertEqual('1.5', versions.max_version_string())
示例#10
0
 def test_get_target_version_pinned_bad(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': '1.6',
         }
     }
     obj = MyObj(self.context)
     self.assertRaises(object_exception.IncompatibleObjectVersion,
                       obj.get_target_version)
示例#11
0
 def test_prepare_whole_disk_image_uefi(self, prepare_node_for_deploy_mock,
                                        pxe_prepare_mock):
     CONF.set_override('default_boot_option', 'netboot', 'deploy')
     self.node.provision_state = states.DEPLOYING
     self.node.save()
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.properties['capabilities'] = 'boot_mode:uefi'
         task.node.driver_internal_info['is_whole_disk_image'] = True
         task.driver.deploy.prepare(task)
         prepare_node_for_deploy_mock.assert_called_once_with(task)
         pxe_prepare_mock.assert_called_once_with(mock.ANY, task)
示例#12
0
def _get_inspector_session(**kwargs):
    global _INSPECTOR_SESSION
    if not _INSPECTOR_SESSION:
        if CONF.auth_strategy != 'keystone':
            # NOTE(dtantsur): using set_default instead of set_override because
            # the native keystoneauth option must have priority.
            CONF.set_default('auth_type', 'none', group='inspector')
        service_auth = keystone.get_auth('inspector')
        _INSPECTOR_SESSION = keystone.get_session('inspector',
                                                  auth=service_auth,
                                                  **kwargs)
    return _INSPECTOR_SESSION
示例#13
0
 def test_serialize_entity_invalid_pin(self, mock_release_mapping):
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': '1.6',
         }
     }
     serializer = base.IronicObjectSerializer()
     obj = MyObj(self.context)
     self.assertRaises(object_exception.InvalidTargetVersion,
                       serializer.serialize_entity, self.context, obj)
    def wrapper(self, *args, **kwargs):
        """Wrapper around methods calls.

        :param image_href: href that describes the location of an image
        """

        if self.client:
            return func(self, *args, **kwargs)

        # TODO(pas-ha) remove in Rocky
        session_params = {}
        if CONF.glance.glance_api_insecure and not CONF.glance.insecure:
            session_params['insecure'] = CONF.glance.glance_api_insecure
        if CONF.glance.glance_cafile and not CONF.glance.cafile:
            session_params['cacert'] = CONF.glance.glance_cafile
        # NOTE(pas-ha) glanceclient uses Adapter-based SessionClient,
        # so we can pass session and auth separately, makes things easier
        session = _get_glance_session(**session_params)

        # TODO(pas-ha) remove in Rocky
        # NOTE(pas-ha) new option must win if configured
        if (CONF.glance.glance_api_servers
                and not CONF.glance.endpoint_override):
            # NOTE(pas-ha) all the 2 methods have image_href as the first
            #              positional arg, but check in kwargs too
            image_href = args[0] if args else kwargs.get('image_href')
            url = service_utils.get_glance_api_server(image_href)
            CONF.set_override('endpoint_override', url, group='glance')

        # TODO(pas-ha) remove in Rocky
        if CONF.glance.auth_strategy == 'noauth':
            CONF.set_override('auth_type', 'none', group='glance')

        service_auth = keystone.get_auth('glance')

        adapter_params = {}
        adapter = keystone.get_adapter('glance', session=session,
                                       auth=service_auth, **adapter_params)
        self.endpoint = adapter.get_endpoint()

        user_auth = None
        # NOTE(pas-ha) our ContextHook removes context.auth_token in noauth
        # case, so when ironic is in noauth but glance is not, we will not
        # enter the next if-block and use auth from [glance] config section
        if self.context.auth_token:
            user_auth = keystone.get_service_auth(self.context, self.endpoint,
                                                  service_auth)
        self.client = client.Client(2, session=session,
                                    auth=user_auth or service_auth,
                                    endpoint_override=self.endpoint,
                                    global_request_id=self.context.global_id)
        return func(self, *args, **kwargs)
示例#15
0
文件: dbsync.py 项目: pshchelo/ironic
def main():
    command_opt = cfg.SubCommandOpt('command',
                                    title='Command',
                                    help=_('Available commands'),
                                    handler=add_command_parsers)

    CONF.register_cli_opt(command_opt)

    # this is hack to work with previous usage of ironic-dbsync
    # pls change it to ironic-dbsync upgrade
    valid_commands = set([
        'upgrade', 'revision',
        'version', 'stamp', 'create_schema',
        'online_data_migrations',
    ])
    if not set(sys.argv) & valid_commands:
        sys.argv.append('upgrade')

    service.prepare_service(sys.argv)
    CONF.command.func()
示例#16
0
def main():
    command_opt = cfg.SubCommandOpt('command',
                                    title='Command',
                                    help=_('Available commands'),
                                    handler=add_command_parsers)

    CONF.register_cli_opt(command_opt)

    # this is hack to work with previous usage of ironic-dbsync
    # pls change it to ironic-dbsync upgrade
    valid_commands = set([
        'upgrade', 'revision',
        'version', 'stamp', 'create_schema',
        'online_data_migrations',
    ])
    if not set(sys.argv) & valid_commands:
        sys.argv.append('upgrade')

    service.prepare_service(sys.argv)
    CONF.command.func()
示例#17
0
    def test_deserialize_entity_pin_ignored(self, mock_release_mapping):
        # Deserializing doesn't look at pinning
        CONF.set_override('pin_release_version',
                          release_mappings.RELEASE_VERSIONS[-1])
        mock_release_mapping.__getitem__.return_value = {
            'objects': {
                'MyTestObj': ['1.0'],
            }
        }
        ser = base.IronicObjectSerializer()

        @base.IronicObjectRegistry.register
        class MyTestObj(MyObj):
            VERSION = '1.1'

        obj = MyTestObj(self.context)
        primitive = obj.obj_to_primitive()
        result = ser.deserialize_entity(self.context, primitive)
        self.assertEqual('1.1', result.VERSION)
        self.assertEqual('1.0', result.get_target_version())
        self.assertFalse(mock_release_mapping.called)
示例#18
0
    def test_deserialize_entity_pin_ignored(self, mock_release_mapping):
        # Deserializing doesn't look at pinning
        CONF.set_override('pin_release_version',
                          release_mappings.RELEASE_VERSIONS[-1])
        mock_release_mapping.__getitem__.return_value = {
            'objects': {
                'MyTestObj': '1.0',
            }
        }
        ser = base.IronicObjectSerializer()

        @base.IronicObjectRegistry.register
        class MyTestObj(MyObj):
            VERSION = '1.1'

        obj = MyTestObj(self.context)
        primitive = obj.obj_to_primitive()
        result = ser.deserialize_entity(self.context, primitive)
        self.assertEqual('1.1', result.VERSION)
        self.assertEqual('1.0', result.get_target_version())
        self.assertFalse(mock_release_mapping.called)
示例#19
0
 def test_serialize_entity_backport(self, mock_release_mapping):
     """Test single element serializer with backport."""
     CONF.set_override('pin_release_version',
                       release_mappings.RELEASE_VERSIONS[-1])
     mock_release_mapping.__getitem__.return_value = {
         'objects': {
             'MyObj': '1.4',
         }
     }
     serializer = base.IronicObjectSerializer()
     obj = MyObj(self.context)
     obj.foo = 1
     obj.bar = 'text'
     obj.missing = 'textt'
     primitive = serializer.serialize_entity(self.context, obj)
     self.assertEqual('1.4', primitive['ironic_object.version'])
     data = primitive['ironic_object.data']
     self.assertEqual(1, data['foo'])
     self.assertEqual('text', data['bar'])
     self.assertNotIn('missing', data)
     changes = primitive['ironic_object.changes']
     self.assertEqual(set(['foo', 'bar']), set(changes))
示例#20
0
def _get_client(context):
    """Helper to get inspector client instance."""
    # NOTE(pas-ha) remove in Rocky
    if CONF.auth_strategy != 'keystone':
        CONF.set_override('auth_type', 'none', group='inspector')
    service_auth = keystone.get_auth('inspector')
    session = _get_inspector_session(auth=service_auth)
    adapter_params = {}
    if CONF.inspector.service_url and not CONF.inspector.endpoint_override:
        adapter_params['endpoint_override'] = CONF.inspector.service_url
    inspector_url = keystone.get_endpoint('inspector', session=session,
                                          **adapter_params)
    # TODO(pas-ha) investigate possibility of passing user context here,
    # similar to what neutron/glance-related code does
    # NOTE(pas-ha) ironic-inspector-client has no Adaper-based
    # SessionClient, so we'll resolve inspector API form adapter loaded
    # form config options
    # TODO(pas-ha) rewrite when inspectorclient is based on ksa Adapter,
    #              also add global_request_id to the call
    return client.ClientV1(api_version=INSPECTOR_API_VERSION,
                           session=session,
                           inspector_url=inspector_url)
示例#21
0
def get_ironic_api_url():
    """Resolve Ironic API endpoint

    either from config of from Keystone catalog.
    """
    adapter_opts = {'session': _get_ironic_session()}
    # NOTE(pas-ha) force 'none' auth plugin for noauth mode
    if CONF.auth_strategy != 'keystone':
        CONF.set_override('auth_type', 'none', group='service_catalog')
    adapter_opts['auth'] = keystone.get_auth('service_catalog')

    try:
        ironic_api = keystone.get_endpoint('service_catalog', **adapter_opts)
    except (exception.KeystoneFailure, exception.CatalogNotFound,
            exception.KeystoneUnauthorized) as e:
        raise exception.InvalidParameterValue(
            _("Couldn't get the URL of the Ironic API service from the "
              "configuration file or keystone catalog. Keystone error: "
              "%s") % str(e))
    # NOTE: we should strip '/' from the end because it might be used in
    # hardcoded ramdisk script
    ironic_api = ironic_api.rstrip('/')
    return ironic_api
示例#22
0
def _get_client(context):
    """Helper to get inspector client instance."""
    # NOTE(pas-ha) remove in Rocky
    if CONF.auth_strategy != 'keystone':
        CONF.set_override('auth_type', 'none', group='inspector')
    service_auth = keystone.get_auth('inspector')
    session = _get_inspector_session(auth=service_auth)
    adapter_params = {}
    if CONF.inspector.service_url and not CONF.inspector.endpoint_override:
        adapter_params['endpoint_override'] = CONF.inspector.service_url
    adapter = keystone.get_adapter('inspector', session=session,
                                   **adapter_params)
    inspector_url = adapter.get_endpoint()
    # TODO(pas-ha) investigate possibility of passing user context here,
    # similar to what neutron/glance-related code does
    # NOTE(pas-ha) ironic-inspector-client has no Adaper-based
    # SessionClient, so we'll resolve inspector API form adapter loaded
    # form config options
    # TODO(pas-ha) rewrite when inspectorclient is based on ksa Adapter,
    #              also add global_request_id to the call
    return client.ClientV1(api_version=INSPECTOR_API_VERSION,
                           session=session,
                           inspector_url=inspector_url)
示例#23
0
def get_client(token=None, context=None):
    if not context:
        context = ironic_context.RequestContext(auth_token=token)
    # NOTE(pas-ha) neutronclient supports passing both session
    # and the auth to client separately, makes things easier
    session = _get_neutron_session()
    service_auth = keystone.get_auth('neutron')

    # TODO(pas-ha) remove in Rocky, always simply load from config
    # 'noauth' then would correspond to 'auth_type=none' and
    # 'endpoint_override'
    adapter_params = {}
    if (CONF.neutron.auth_strategy == 'noauth'
            and CONF.neutron.auth_type is None):
        CONF.set_override('auth_type', 'none', group='neutron')
        if not CONF.neutron.endpoint_override:
            adapter_params['endpoint_override'] = (CONF.neutron.url
                                                   or DEFAULT_NEUTRON_URL)
    else:
        if CONF.keystone.region_name and not CONF.neutron.region_name:
            adapter_params['region_name'] = CONF.keystone.region_name
        if CONF.neutron.url and not CONF.neutron.endpoint_override:
            adapter_params['endpoint_override'] = CONF.neutron.url
    adapter = keystone.get_adapter('neutron',
                                   session=session,
                                   auth=service_auth,
                                   **adapter_params)
    endpoint = adapter.get_endpoint()

    user_auth = None
    if CONF.neutron.auth_type != 'none' and context.auth_token:
        user_auth = keystone.get_service_auth(context, endpoint, service_auth)
    return clientv20.Client(session=session,
                            auth=user_auth or service_auth,
                            endpoint_override=endpoint,
                            retries=CONF.neutron.retries,
                            global_request_id=context.global_id)
示例#24
0
 def test_max_version_not_pinned_in_release_mappings(self):
     CONF.set_override('pin_release_version', None)
     self.assertEqual(release_mappings.RELEASE_MAPPING['master']['api'],
                      versions.max_version_string())
示例#25
0
 def test_max_version_not_pinned(self):
     CONF.set_override('pin_release_version', None)
     self.assertEqual(versions._MAX_VERSION_STRING,
                      versions.max_version_string())
示例#26
0
               help=_('Amount of time (in seconds) to wait between polling '
                      'power state after trigger soft poweroff.')),
    cfg.IntOpt('extra_memory',
               default=10,
               help=_('Extra amount of memory in MiB expected to be consumed '
                      'by Ansible-related processes on the node. Affects '
                      'decision whether image will fit into RAM.')),
    cfg.BoolOpt('use_ramdisk_callback',
                default=True,
                help=_('Use callback request from ramdisk for start deploy or '
                       'cleaning. Disable it when using custom ramdisk '
                       'without callback script. '
                       'When callback is disabled, Neutron is mandatory.')),
]

CONF.register_opts(ansible_opts, group='ansible')

LOG = log.getLogger(__name__)

METRICS = metrics_utils.get_metrics_logger(__name__)

DEFAULT_PLAYBOOKS = {
    'deploy': 'deploy.yaml',
    'shutdown': 'shutdown.yaml',
    'clean': 'clean.yaml'
}
DEFAULT_CLEAN_STEPS = 'clean_steps.yaml'

OPTIONAL_PROPERTIES = {
    'ansible_deploy_username': _('Deploy ramdisk username for Ansible. '
                                 'This user must have passwordless sudo '
示例#27
0
from ironic.common import states
from ironic.common import utils
from ironic.conductor import utils as manager_utils
from ironic.conf import CONF
from ironic.drivers.modules import agent_client
from ironic.drivers.modules import image_cache
from ironic.drivers import utils as driver_utils
from ironic import objects

# TODO(Faizan): Move this logic to common/utils.py and deprecate
# rootwrap_config.
# This is required to set the default value of ironic_lib option
# only if rootwrap_config does not contain the default value.
if CONF.rootwrap_config != '/etc/ironic/rootwrap.conf':
    root_helper = 'sudo ironic-rootwrap %s' % CONF.rootwrap_config
    CONF.set_default('root_helper', root_helper, 'ironic_lib')

LOG = logging.getLogger(__name__)

METRICS = metrics_utils.get_metrics_logger(__name__)

SUPPORTED_CAPABILITIES = {
    'boot_option': ('local', 'netboot'),
    'boot_mode': ('bios', 'uefi'),
    'secure_boot': ('true', 'false'),
    'trusted_boot': ('true', 'false'),
    'disk_label': ('msdos', 'gpt'),
}

DISK_LAYOUT_PARAMS = ('root_gb', 'swap_mb', 'ephemeral_gb')
示例#28
0
def main():
    service.prepare_service()
    CONF.set_override('debug', False)
    _create_test_nodes()
示例#29
0
 def test_get_network_interface_use_field(self):
     CONF.set_override('default_network_interface', None)
     for nif in ('neutron', 'flat', 'noop'):
         self.node.network_interface = nif
         self.assertEqual(nif, self.node.network_interface)
示例#30
0
文件: dbsync.py 项目: Tehsmash/ironic
        'version',
        help=_("Print the current version information and exit."))
    parser.set_defaults(func=command_object.version)

    parser = subparsers.add_parser(
        'create_schema',
        help=_("Create the database schema."))
    parser.set_defaults(func=command_object.create_schema)


command_opt = cfg.SubCommandOpt('command',
                                title='Command',
                                help=_('Available commands'),
                                handler=add_command_parsers)

CONF.register_cli_opt(command_opt)


def main():
    # this is hack to work with previous usage of ironic-dbsync
    # pls change it to ironic-dbsync upgrade
    valid_commands = set([
        'upgrade', 'revision',
        'version', 'stamp', 'create_schema',
    ])
    if not set(sys.argv) & valid_commands:
        sys.argv.append('upgrade')

    service.prepare_service(sys.argv)
    CONF.command.func()
示例#31
0
#    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 six.moves import http_client
from six.moves.urllib import parse
from swiftclient import client as swift_client
from swiftclient import exceptions as swift_exceptions
from swiftclient import utils as swift_utils

from ironic.common import exception
from ironic.common.i18n import _
from ironic.common import keystone
from ironic.conf import CONF

CONF.import_opt('admin_user', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('admin_tenant_name', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('admin_password', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('auth_version', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('insecure', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('cafile', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
CONF.import_opt('region_name', 'keystonemiddleware.auth_token',
                group='keystone_authtoken')
示例#32
0
 def test_max_version_not_pinned_in_release_mappings(self):
     CONF.set_override('pin_release_version', None)
     self.assertEqual(release_mappings.RELEASE_MAPPING['master']['api'],
                      versions.max_version_string())
示例#33
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 keystoneclient import exceptions as ksexception
from oslo_concurrency import lockutils
from six.moves.urllib import parse

from ironic.common import exception
from ironic.common.i18n import _
from ironic.conf import CONF

CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')

_KS_CLIENT = None


def _is_apiv3(auth_url, auth_version):
    """Checks if V3 version of API is being used or not.

    This method inspects auth_url and auth_version, and checks whether V3
    version of the API is being used or not.

    :param auth_url: a http or https url to be inspected (like
        'http://127.0.0.1:9898/').
    :param auth_version: a string containing the version (like 'v2', 'v3.0')
    :returns: True if V3 of the API is being used.
    """
示例#34
0
from ironic.common import utils
from ironic.conductor import utils as manager_utils
from ironic.conf import CONF
from ironic.drivers.modules import agent_client
from ironic.drivers.modules import image_cache
from ironic.drivers import utils as driver_utils
from ironic import objects


# TODO(Faizan): Move this logic to common/utils.py and deprecate
# rootwrap_config.
# This is required to set the default value of ironic_lib option
# only if rootwrap_config does not contain the default value.
if CONF.rootwrap_config != '/etc/ironic/rootwrap.conf':
    root_helper = 'sudo ironic-rootwrap %s' % CONF.rootwrap_config
    CONF.set_default('root_helper', root_helper, 'ironic_lib')

LOG = logging.getLogger(__name__)

METRICS = metrics_utils.get_metrics_logger(__name__)

SUPPORTED_CAPABILITIES = {
    'boot_option': ('local', 'netboot'),
    'boot_mode': ('bios', 'uefi'),
    'secure_boot': ('true', 'false'),
    'trusted_boot': ('true', 'false'),
    'disk_label': ('msdos', 'gpt'),
}

DISK_LAYOUT_PARAMS = ('root_gb', 'swap_mb', 'ephemeral_gb')
示例#35
0
 def test_get_network_interface_use_conf(self):
     for nif in ('neutron', 'flat', 'noop'):
         CONF.set_override('default_network_interface', nif)
         self.node = obj_utils.get_test_node(self.ctxt, **self.fake_node)
         self.assertEqual(nif, self.node.network_interface)
示例#36
0
import sendfile
import six
from six.moves import http_client
import six.moves.urllib.parse as urlparse

from ironic.common import exception
from ironic.common.i18n import _
from ironic.common import keystone
from ironic.common import utils
from ironic.conf import CONF

IMAGE_CHUNK_SIZE = 1024 * 1024  # 1mb

# TODO(rama_y): This import should be removed,
# once https://review.openstack.org/#/c/309070 is merged.
CONF.import_opt('my_ip', 'ironic.netconf')


def import_versioned_module(version, submodule=None):
    module = 'ironic.common.glance_service.v%s' % version
    if submodule:
        module = '.'.join((module, submodule))
    return importutils.try_import(module)


def GlanceImageService(client=None, version=1, context=None):
    module = import_versioned_module(version, 'image_service')
    service_class = getattr(module, 'GlanceImageService')
    if (context is not None and CONF.glance.auth_strategy == 'keystone'
        and not context.auth_token):
        context.auth_token = keystone.get_admin_auth_token()
示例#37
0
               help=_('Amount of time (in seconds) to wait between polling '
                      'power state after trigger soft poweroff.')),
    cfg.IntOpt('extra_memory',
               default=10,
               help=_('Extra amount of memory in MiB expected to be consumed '
                      'by Ansible-related processes on the node. Affects '
                      'decision whether image will fit into RAM.')),
    cfg.BoolOpt('use_ramdisk_callback',
                default=True,
                help=_('Use callback request from ramdisk for start deploy or '
                       'cleaning. Disable it when using custom ramdisk '
                       'without callback script. '
                       'When callback is disabled, Neutron is mandatory.')),
]

CONF.register_opts(ansible_opts, group='ansible')

LOG = log.getLogger(__name__)

DEFAULT_PLAYBOOKS = {'deploy': 'deploy.yaml', 'clean': 'clean.yaml'}
DEFAULT_CLEAN_STEPS = 'clean_steps.yaml'

OPTIONAL_PROPERTIES = {
    'ansible_deploy_username':
    _('Deploy ramdisk username for Ansible. '
      'This user must have passwordless sudo '
      'permissions. Default is "ansible". '
      'Optional.'),
    'ansible_deploy_key_file':
    _('Path to private key file. If not specified, '
      'default keys for user running '
示例#38
0
 def test_get_network_interface_use_dhcp_provider(self):
     CONF.set_override('default_network_interface', None)
     for dhcp, nif in (('neutron', 'flat'), ('none', 'noop')):
         CONF.set_override('dhcp_provider', dhcp, 'dhcp')
         self.node = obj_utils.get_test_node(self.ctxt, **self.fake_node)
         self.assertEqual(nif, self.node.network_interface)
示例#39
0
from oslo_utils import importutils

from ironic.common import exception
from ironic.common.i18n import _
from ironic.common.i18n import _LE
from ironic.common.i18n import _LI
from ironic.common import keystone
from ironic.common import states
from ironic.conductor import task_manager
from ironic.conf import CONF
from ironic.drivers import base


LOG = logging.getLogger(__name__)

CONF.import_opt("auth_strategy", "ironic.api.app")

client = importutils.try_import("ironic_inspector_client")


INSPECTOR_API_VERSION = (1, 0)


class Inspector(base.InspectInterface):
    """In-band inspection via ironic-inspector project."""

    @classmethod
    def create_if_enabled(cls, driver_name):
        """Create instance of Inspector if it's enabled.

        Reports log warning with given driver_name if it's not.
示例#40
0
    parser = subparsers.add_parser(
        'version', help=_("Print the current version information and exit."))
    parser.set_defaults(func=command_object.version)

    parser = subparsers.add_parser('create_schema',
                                   help=_("Create the database schema."))
    parser.set_defaults(func=command_object.create_schema)


command_opt = cfg.SubCommandOpt('command',
                                title='Command',
                                help=_('Available commands'),
                                handler=add_command_parsers)

CONF.register_cli_opt(command_opt)


def main():
    # this is hack to work with previous usage of ironic-dbsync
    # pls change it to ironic-dbsync upgrade
    valid_commands = set([
        'upgrade',
        'revision',
        'version',
        'stamp',
        'create_schema',
    ])
    if not set(sys.argv) & valid_commands:
        sys.argv.append('upgrade')
示例#41
0
from ironic.common.i18n import _LW
from ironic.common import image_service
from ironic.common import states
from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils
from ironic.conf import CONF
from ironic.drivers.modules import agent
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules.ilo import boot as ilo_boot
from ironic.drivers.modules.ilo import common as ilo_common
from ironic.drivers.modules import iscsi_deploy
from ironic.drivers.modules import pxe

LOG = logging.getLogger(__name__)

CONF.import_opt('pxe_append_params', 'ironic.drivers.modules.iscsi_deploy',
                group='pxe')


def _prepare_agent_vmedia_boot(task):
    """Ejects virtual media devices and prepares for vmedia boot."""
    # Eject all virtual media devices, as we are going to use them
    # during deploy.
    ilo_common.eject_vmedia_devices(task)

    deploy_ramdisk_opts = deploy_utils.build_agent_options(task.node)
    deploy_iso = task.node.driver_info['ilo_deploy_iso']
    ilo_common.setup_vmedia(task, deploy_iso, deploy_ramdisk_opts)
    manager_utils.node_power_action(task, states.REBOOT)


def _disable_secure_boot(task):
示例#42
0
 def test_max_version_not_pinned(self):
     CONF.set_override('pin_release_version', None)
     self.assertEqual(versions._MAX_VERSION_STRING,
                      versions.max_version_string())