Beispiel #1
0
 def test_validate_fail(self):
     info = dict(INST_INFO_DICT)
     del info["image_source"]
     self.node.instance_info = json.dumps(info)
     with task_manager.acquire(self.context, self.node.uuid, shared=True) as task:
         task.node["instance_info"] = json.dumps(info)
         self.assertRaises(exception.InvalidParameterValue, task.driver.deploy.validate, task)
Beispiel #2
0
 def test_validate_fail(self):
     info = dict(INST_INFO_DICT)
     del info['image_source']
     self.node.instance_info = json.dumps(info)
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=True) as task:
         task.node['instance_info'] = json.dumps(info)
         self.assertRaises(exception.MissingParameterValue,
                           task.driver.deploy.validate, task)
Beispiel #3
0
    def __call__(self, target, creds):
        """
        Check http: rules by calling to a remote server.

        This example implementation simply verifies that the response
        is exactly 'True'.
        """

        url = ('http:' + self.match) % target
        data = {'target': jsonutils.dumps(target),
                'credentials': jsonutils.dumps(creds)}
        post_data = urllib.urlencode(data)
        f = urllib2.urlopen(url, post_data)
        return f.read() == "True"
Beispiel #4
0
    def _pack_json_msg(self, msg):
        """Qpid cannot serialize dicts containing strings longer than 65535
           characters.  This function dumps the message content to a JSON
           string, which Qpid is able to handle.

        :param msg: May be either a Qpid Message object or a bare dict.
        :returns: A Qpid Message with its content field JSON encoded.
        """
        try:
            msg.content = jsonutils.dumps(msg.content)
        except AttributeError:
            # Need to have a Qpid message so we can set the content_type.
            msg = qpid_messaging.Message(jsonutils.dumps(msg))
        msg.content_type = JSON_CONTENT_TYPE
        return msg
Beispiel #5
0
def serialize_msg(raw_msg):
    # NOTE(russellb) See the docstring for _RPC_ENVELOPE_VERSION for more
    # information about this format.
    msg = {_VERSION_KEY: _RPC_ENVELOPE_VERSION,
           _MESSAGE_KEY: jsonutils.dumps(raw_msg)}

    return msg
Beispiel #6
0
def serialize_remote_exception(failure_info, log_failure=True):
    """Prepares exception data to be sent over rpc.

    Failure_info should be a sys.exc_info() tuple.

    """
    tb = traceback.format_exception(*failure_info)
    failure = failure_info[1]
    if log_failure:
        LOG.error(_("Returning exception %s to caller"), unicode(failure))
        LOG.error(tb)

    kwargs = {}
    if hasattr(failure, 'kwargs'):
        kwargs = failure.kwargs

    data = {
        'class': str(failure.__class__.__name__),
        'module': str(failure.__class__.__module__),
        'message': unicode(failure),
        'tb': tb,
        'args': failure.args,
        'kwargs': kwargs
    }

    json_data = jsonutils.dumps(data)

    return json_data
Beispiel #7
0
    def format(self, record):
        message = {
            'message': record.getMessage(),
            'asctime': self.formatTime(record, self.datefmt),
            'name': record.name,
            'msg': record.msg,
            'args': record.args,
            'levelname': record.levelname,
            'levelno': record.levelno,
            'pathname': record.pathname,
            'filename': record.filename,
            'module': record.module,
            'lineno': record.lineno,
            'funcname': record.funcName,
            'created': record.created,
            'msecs': record.msecs,
            'relative_created': record.relativeCreated,
            'thread': record.thread,
            'thread_name': record.threadName,
            'process_name': record.processName,
            'process': record.process,
            'traceback': None
        }

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
Beispiel #8
0
    def format(self, record):
        message = {'message': record.getMessage(),
                   'asctime': self.formatTime(record, self.datefmt),
                   'name': record.name,
                   'msg': record.msg,
                   'args': record.args,
                   'levelname': record.levelname,
                   'levelno': record.levelno,
                   'pathname': record.pathname,
                   'filename': record.filename,
                   'module': record.module,
                   'lineno': record.lineno,
                   'funcname': record.funcName,
                   'created': record.created,
                   'msecs': record.msecs,
                   'relative_created': record.relativeCreated,
                   'thread': record.thread,
                   'thread_name': record.threadName,
                   'process_name': record.processName,
                   'process': record.process,
                   'traceback': None}

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
Beispiel #9
0
    def __init__(self, conf, session, node_name, node_opts=None):
        """Init the Publisher class with the exchange_name, routing_key,
        and other options
        """
        self.sender = None
        self.session = session

        if conf.qpid_topology_version == 1:
            addr_opts = {
                "create": "always",
                "node": {
                    "type": "topic",
                    "x-declare": {
                        "durable": False,
                        # auto-delete isn't implemented for exchanges in qpid,
                        # but put in here anyway
                        "auto-delete": True,
                    },
                },
            }
            if node_opts:
                addr_opts["node"]["x-declare"].update(node_opts)

            self.address = "%s ; %s" % (node_name, jsonutils.dumps(addr_opts))
        elif conf.qpid_topology_version == 2:
            self.address = node_name
        else:
            raise_invalid_topology_version()

        self.reconnect(session)
Beispiel #10
0
    def __call__(self, target, creds):
        """
        Check http: rules by calling to a remote server.

        This example implementation simply verifies that the response
        is exactly 'True'.
        """

        url = ('http:' + self.match) % target
        data = {
            'target': jsonutils.dumps(target),
            'credentials': jsonutils.dumps(creds)
        }
        post_data = urllib.urlencode(data)
        f = urllib2.urlopen(url, post_data)
        return f.read() == "True"
Beispiel #11
0
    def __init__(self, session, node_name, node_opts=None):
        """Init the Publisher class with the exchange_name, routing_key,
        and other options
        """
        self.sender = None
        self.session = session

        addr_opts = {
            "create": "always",
            "node": {
                "type": "topic",
                "x-declare": {
                    "durable": False,
                    # auto-delete isn't implemented for exchanges in qpid,
                    # but put in here anyway
                    "auto-delete": True,
                },
            },
        }
        if node_opts:
            addr_opts["node"]["x-declare"].update(node_opts)

        self.address = "%s ; %s" % (node_name, jsonutils.dumps(addr_opts))

        self.reconnect(session)
Beispiel #12
0
def serialize_remote_exception(failure_info, log_failure=True):
    """Prepares exception data to be sent over rpc.

    Failure_info should be a sys.exc_info() tuple.

    """
    tb = traceback.format_exception(*failure_info)
    failure = failure_info[1]
    if log_failure:
        LOG.error(_("Returning exception %s to caller"), unicode(failure))
        LOG.error(tb)

    kwargs = {}
    if hasattr(failure, 'kwargs'):
        kwargs = failure.kwargs

    data = {
        'class': str(failure.__class__.__name__),
        'module': str(failure.__class__.__module__),
        'message': unicode(failure),
        'tb': tb,
        'args': failure.args,
        'kwargs': kwargs
    }

    json_data = jsonutils.dumps(data)

    return json_data
Beispiel #13
0
def serialize_remote_exception(failure_info, log_failure=True):
    """Prepares exception data to be sent over rpc.

    Failure_info should be a sys.exc_info() tuple.

    """
    tb = traceback.format_exception(*failure_info)
    failure = failure_info[1]
    if log_failure:
        LOG.error(_("Returning exception %s to caller"), six.text_type(failure))
        LOG.error(tb)

    kwargs = {}
    if hasattr(failure, "kwargs"):
        kwargs = failure.kwargs

    data = {
        "class": str(failure.__class__.__name__),
        "module": str(failure.__class__.__module__),
        "message": six.text_type(failure),
        "tb": tb,
        "args": failure.args,
        "kwargs": kwargs,
    }

    json_data = jsonutils.dumps(data)

    return json_data
Beispiel #14
0
 def test__parse_driver_info_missing_key(self):
     # make sure error is raised when info is missing
     tmp_dict = dict(INFO_DICT)
     del tmp_dict["password"]
     info = json.dumps({"ssh": tmp_dict})
     node = db_utils.get_test_node(driver_info=info)
     self.assertRaises(exception.FileNotFound, ssh._parse_driver_info, node)
     self.mox.VerifyAll()
Beispiel #15
0
 def test_validate_fail(self):
     tmp_dict = dict(INFO_DICT)
     del tmp_dict['image_source']
     self.node['driver_info'] = json.dumps({'pxe': tmp_dict})
     with task_manager.acquire([self.node['uuid']], shared=True) as task:
         self.assertRaises(exception.InvalidParameterValue,
                           task.resources[0].driver.deploy.validate,
                           self.node)
Beispiel #16
0
def notify(_context, message):
    """Notifies the recipient of the desired event given the model.
    Log notifications using openstack's default logging system"""

    priority = message.get('priority', CONF.default_notification_level)
    priority = priority.lower()
    logger = logging.getLogger('ironic.openstack.common.notification.%s' %
                               message['event_type'])
    getattr(logger, priority)(jsonutils.dumps(message))
Beispiel #17
0
    def __init__(self, conf, session, callback, node_name, node_opts,
                 link_name, link_opts):
        """Declare a queue on an amqp session.

        'session' is the amqp session to use
        'callback' is the callback to call when messages are received
        'node_name' is the first part of the Qpid address string, before ';'
        'node_opts' will be applied to the "x-declare" section of "node"
                    in the address string.
        'link_name' goes into the "name" field of the "link" in the address
                    string
        'link_opts' will be applied to the "x-declare" section of "link"
                    in the address string.
        """
        self.callback = callback
        self.receiver = None
        self.session = None

        if conf.qpid_topology_version == 1:
            addr_opts = {
                "create": "always",
                "node": {
                    "type": "topic",
                    "x-declare": {
                        "durable": True,
                        "auto-delete": True,
                    },
                },
                "link": {
                    "durable": True,
                    "x-declare": {
                        "durable": False,
                        "auto-delete": True,
                        "exclusive": False,
                    },
                },
            }
            addr_opts["node"]["x-declare"].update(node_opts)
        elif conf.qpid_topology_version == 2:
            addr_opts = {
                "link": {
                    "x-declare": {
                        "auto-delete": True,
                        "exclusive": False,
                    },
                },
            }
        else:
            raise_invalid_topology_version()

        addr_opts["link"]["x-declare"].update(link_opts)
        if link_name:
            addr_opts["link"]["name"] = link_name

        self.address = "%s ; %s" % (node_name, jsonutils.dumps(addr_opts))

        self.connect(session)
Beispiel #18
0
def serialize_msg(raw_msg):
    # NOTE(russellb) See the docstring for _RPC_ENVELOPE_VERSION for more
    # information about this format.
    msg = {
        _VERSION_KEY: _RPC_ENVELOPE_VERSION,
        _MESSAGE_KEY: jsonutils.dumps(raw_msg)
    }

    return msg
Beispiel #19
0
 def test_validate_fail(self):
     info = dict(INFO_DICT)
     del info['pxe_image_source']
     self.node['driver_info'] = json.dumps(info)
     with task_manager.acquire(self.context, [self.node.uuid],
                               shared=True) as task:
         self.assertRaises(exception.InvalidParameterValue,
                           task.resources[0].driver.deploy.validate,
                           task, self.node)
Beispiel #20
0
 def test_validate_fail(self):
     info = dict(INFO_DICT)
     del info['pxe_image_source']
     self.node['driver_info'] = json.dumps(info)
     with task_manager.acquire(self.context, [self.node['uuid']],
                               shared=True) as task:
         self.assertRaises(exception.InvalidParameterValue,
                           task.resources[0].driver.deploy.validate, task,
                           self.node)
Beispiel #21
0
 def test__parse_driver_info_missing_virt_type(self):
     # make sure error is raised when info is missing
     tmp_dict = dict(INFO_DICT)
     del tmp_dict["virt_type"]
     del tmp_dict["key_filename"]
     info = json.dumps({"ssh": tmp_dict})
     node = db_utils.get_test_node(driver_info=info)
     self.assertRaises(exception.InvalidParameterValue, ssh._parse_driver_info, node)
     self.mox.VerifyAll()
Beispiel #22
0
 def test__parse_driver_info_missing_key(self):
     # make sure error is raised when info is missing
     tmp_dict = dict(INFO_DICT)
     del tmp_dict['password']
     info = json.dumps({'ssh': tmp_dict})
     node = db_utils.get_test_node(driver_info=info)
     self.assertRaises(exception.FileNotFound,
             ssh._parse_driver_info,
             node)
     self.mox.VerifyAll()
Beispiel #23
0
 def test__parse_driver_info_missing_virt_type(self):
     # make sure error is raised when info is missing
     tmp_dict = dict(INFO_DICT)
     del tmp_dict['virt_type']
     del tmp_dict['key_filename']
     info = json.dumps({'ssh': tmp_dict})
     node = db_utils.get_test_node(driver_info=info)
     self.assertRaises(exception.InvalidParameterValue,
             ssh._parse_driver_info,
             node)
     self.mox.VerifyAll()
Beispiel #24
0
def notify(_context, message):
    """Notifies the recipient of the desired event given the model.
    Log notifications using openstack's default logging system"""

    priority = message.get('priority',
                           CONF.default_notification_level)
    priority = priority.lower()
    logger = logging.getLogger(
        'ironic.openstack.common.notification.%s' %
        message['event_type'])
    getattr(logger, priority)(jsonutils.dumps(message))
Beispiel #25
0
def _serialize(data):
    """Serialization wrapper.

    We prefer using JSON, but it cannot encode all types.
    Error if a developer passes us bad data.
    """
    try:
        return jsonutils.dumps(data, ensure_ascii=True)
    except TypeError:
        with excutils.save_and_reraise_exception():
            LOG.error(_("JSON serialization failed."))
Beispiel #26
0
def _serialize(data):
    """
    Serialization wrapper
    We prefer using JSON, but it cannot encode all types.
    Error if a developer passes us bad data.
    """
    try:
        return jsonutils.dumps(data, ensure_ascii=True)
    except TypeError:
        with excutils.save_and_reraise_exception():
            LOG.error(_("JSON serialization failed."))
Beispiel #27
0
    def __str__(self):
        """Dumps a string representation of the rules."""

        # Start by building the canonical strings for the rules
        out_rules = {}
        for key, value in self.items():
            # Use empty string for singleton TrueCheck instances
            if isinstance(value, TrueCheck):
                out_rules[key] = ''
            else:
                out_rules[key] = str(value)

        # Dump a pretty-printed JSON representation
        return jsonutils.dumps(out_rules, indent=4)
Beispiel #28
0
def _convert(metadata, method):
    metadata = copy.deepcopy(metadata)
    properties = metadata.get('properties')
    if properties:
        for attr in _CONVERT_PROPS:
            if attr in properties:
                prop = properties[attr]
                if method == 'from':
                    if isinstance(prop, six.string_types):
                        properties[attr] = jsonutils.loads(prop)
                if method == 'to':
                    if not isinstance(prop, six.string_types):
                        properties[attr] = jsonutils.dumps(prop)
    return metadata
Beispiel #29
0
def _convert(metadata, method):
    metadata = copy.deepcopy(metadata)
    properties = metadata.get('properties')
    if properties:
        for attr in _CONVERT_PROPS:
            if attr in properties:
                prop = properties[attr]
                if method == 'from':
                    if isinstance(prop, six.string_types):
                        properties[attr] = jsonutils.loads(prop)
                if method == 'to':
                    if not isinstance(prop, six.string_types):
                        properties[attr] = jsonutils.dumps(prop)
    return metadata
Beispiel #30
0
    def __str__(self):
        """Dumps a string representation of the rules."""

        # Start by building the canonical strings for the rules
        out_rules = {}
        for key, value in self.items():
            # Use empty string for singleton TrueCheck instances
            if isinstance(value, TrueCheck):
                out_rules[key] = ''
            else:
                out_rules[key] = str(value)

        # Dump a pretty-printed JSON representation
        return jsonutils.dumps(out_rules, indent=4)
Beispiel #31
0
    def test__parse_driver_info(self):
        # make sure we get back the expected things
        self.assertIsNotNone(self.info.get('address'))
        self.assertIsNotNone(self.info.get('username'))
        self.assertIsNotNone(self.info.get('password'))
        self.assertIsNotNone(self.info.get('uuid'))

        # make sure error is raised when info, eg. username, is missing
        _driver_info = json.dumps(
            {'ipmi': {
                "address": "1.2.3.4",
                "password": "******",
            }})
        node = db_utils.get_test_node(driver_info=_driver_info)
        self.assertRaises(exception.InvalidParameterValue,
                          ipmi._parse_driver_info, node)
Beispiel #32
0
	def test__parse_driver_info(self):
        # make sure we get back the expected things
		self.assertIsNotNone(self.info.get('address'))
		self.assertIsNotNone(self.info.get('username'))
		self.assertIsNotNone(self.info.get('password'))
		self.assertIsNotNone(self.info.get('ccard'))
		self.assertIsNotNone(self.info.get('uuid'))

        # make sure error is raised when info, eg. username, is missing
		_driver_info = json.dumps(
			{
				'seamicro': {
					"address": "1.2.3.4",
					"password": "******",
				}
			})
		node = db_utils.get_test_node(driver_info=_driver_info)
		self.assertRaises(exception.InvalidParameterValue,seamicro._parse_driver_info,node)
Beispiel #33
0
def get_test_node(**kw):
    power_info = json.dumps({'driver': 'ipmi',
                             'user': '******',
                             'password': '******',
                             'address': 'fake-address'})
    node = models.Node()
    node.id = kw.get('id', 123)
    node.uuid = kw.get('uuid', '1be26c0b-03f2-4d2e-ae87-c02d7f33c123')
    node.cpu_arch = kw.get('cpu_arch', 'x86_64')
    node.cpu_num = kw.get('cpu_num', 4)
    node.local_storage_max = kw.get('local_storage_max', 1000)
    node.task_state = kw.get('task_state', 'NOSTATE')
    node.image_path = kw.get('image_path', '/fake/image/path')
    node.instance_uuid = kw.get('instance_uuid',
                                '8227348d-5f1d-4488-aad1-7c92b2d42504')
    node.instance_name = kw.get('instance_name', 'fake-image-name')
    node.power_info = kw.get('power_info', power_info)
    node.extra = kw.get('extra', '{}')

    return node
Beispiel #34
0
def get_test_node(**kw):
    power_info = json.dumps({
        'driver': 'ipmi',
        'user': '******',
        'password': '******',
        'address': 'fake-address'
    })
    node = models.Node()
    node.id = kw.get('id', 123)
    node.uuid = kw.get('uuid', '1be26c0b-03f2-4d2e-ae87-c02d7f33c123')
    node.cpu_arch = kw.get('cpu_arch', 'x86_64')
    node.cpu_num = kw.get('cpu_num', 4)
    node.local_storage_max = kw.get('local_storage_max', 1000)
    node.task_state = kw.get('task_state', 'NOSTATE')
    node.image_path = kw.get('image_path', '/fake/image/path')
    node.instance_uuid = kw.get('instance_uuid',
                                '8227348d-5f1d-4488-aad1-7c92b2d42504')
    node.instance_name = kw.get('instance_name', 'fake-image-name')
    node.power_info = kw.get('power_info', power_info)
    node.extra = kw.get('extra', '{}')

    return node
Beispiel #35
0
def serialize_remote_exception(failure_info, log_failure=True):
    """Prepares exception data to be sent over rpc.

    Failure_info should be a sys.exc_info() tuple.

    """
    tb = traceback.format_exception(*failure_info)
    failure = failure_info[1]
    if log_failure:
        LOG.error(_("Returning exception %s to caller"),
                  six.text_type(failure))
        LOG.error(tb)

    kwargs = {}
    if hasattr(failure, 'kwargs'):
        kwargs = failure.kwargs

    # NOTE(matiu): With cells, it's possible to re-raise remote, remote
    # exceptions. Lets turn it back into the original exception type.
    cls_name = str(failure.__class__.__name__)
    mod_name = str(failure.__class__.__module__)
    if (cls_name.endswith(_REMOTE_POSTFIX)
            and mod_name.endswith(_REMOTE_POSTFIX)):
        cls_name = cls_name[:-len(_REMOTE_POSTFIX)]
        mod_name = mod_name[:-len(_REMOTE_POSTFIX)]

    data = {
        'class': cls_name,
        'module': mod_name,
        'message': six.text_type(failure),
        'tb': tb,
        'args': failure.args,
        'kwargs': kwargs
    }

    json_data = jsonutils.dumps(data)

    return json_data
Beispiel #36
0
def serialize_remote_exception(failure_info, log_failure=True):
    """Prepares exception data to be sent over rpc.

    Failure_info should be a sys.exc_info() tuple.

    """
    tb = traceback.format_exception(*failure_info)
    failure = failure_info[1]
    if log_failure:
        LOG.error(_("Returning exception %s to caller"), six.text_type(failure))
        LOG.error(tb)

    kwargs = {}
    if hasattr(failure, "kwargs"):
        kwargs = failure.kwargs

    # NOTE(matiu): With cells, it's possible to re-raise remote, remote
    # exceptions. Lets turn it back into the original exception type.
    cls_name = str(failure.__class__.__name__)
    mod_name = str(failure.__class__.__module__)
    if cls_name.endswith(_REMOTE_POSTFIX) and mod_name.endswith(_REMOTE_POSTFIX):
        cls_name = cls_name[: -len(_REMOTE_POSTFIX)]
        mod_name = mod_name[: -len(_REMOTE_POSTFIX)]

    data = {
        "class": cls_name,
        "module": mod_name,
        "message": six.text_type(failure),
        "tb": tb,
        "args": failure.args,
        "kwargs": kwargs,
    }

    json_data = jsonutils.dumps(data)

    return json_data
Beispiel #37
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.
"""Ironic test utilities."""

from ironic.common import states

from ironic.openstack.common import jsonutils as json


fake_info = {"foo": "bar"}

ipmi_info = json.dumps(
        {
            'ipmi': {
                "address": "1.2.3.4",
                "username": "******",
                "password": "******",
            }
         })

ssh_info = json.dumps(
        {
            'ssh': {
                "address": "1.2.3.4",
                "username": "******",
                "password": "******",
                "port": 22,
                "virt_type": "vbox",
                "key_filename": "/not/real/file",
            }
         })
Beispiel #38
0
 def _get_command_body(self, method, params):
     return jsonutils.dumps({
         'name': method,
         'params': params,
     })
Beispiel #39
0
#    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.
"""Ironic test utilities."""

from ironic.db.sqlalchemy import models
from ironic.openstack.common import jsonutils as json


_control_info = json.dumps({"ipmi_address": "1.2.3.4", "ipmi_username": "******", "ipmi_password": "******"})

_deploy_info = json.dumps(
    {
        "image_path": "/path/to/image.qcow2",
        "image_source": "glance://image-uuid",
        "deploy_image_source": "glance://deploy-image-uuid",
    }
)

_properties = json.dumps({"cpu_arch": "x86_64", "cpu_num": 8, "storage": 1024, "memory": 4096})


def get_test_node(**kw):
    node = models.Node()
Beispiel #40
0
#    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.
"""Ironic test utilities."""

from ironic.openstack.common import jsonutils as json


fake_info = json.dumps({"foo": "bar"})

ipmi_info = json.dumps(
        {
            'ipmi': {
                "address": "1.2.3.4",
                "username": "******",
                "password": "******",
            }
         })

ssh_info = json.dumps(
        {
            'ssh': {
                "address": "1.2.3.4",
                "username": "******",
Beispiel #41
0
 def _get_command_body(self, method, params):
     return jsonutils.dumps({
         'name': method,
         'params': params,
     })
Beispiel #42
0
 def _get_command_body(self, method, params):
     return jsonutils.dumps({"name": method, "params": params})
Beispiel #43
0
#
#         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.
"""Ironic test utilities."""

from ironic.db.sqlalchemy import models
from ironic.openstack.common import jsonutils as json

_control_info = json.dumps({
    "ipmi_address": "1.2.3.4",
    "ipmi_username": "******",
    "ipmi_password": "******",
})

_deploy_info = json.dumps({
    "image_path": "/path/to/image.qcow2",
    "image_source": "glance://image-uuid",
    "deploy_image_source": "glance://deploy-image-uuid",
})

_properties = json.dumps({
    "cpu_arch": "x86_64",
    "cpu_num": 8,
    "storage": 1024,
    "memory": 4096,
})
Beispiel #44
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.
"""Ironic test utilities."""

from ironic.common import states

from ironic.openstack.common import jsonutils as json


fake_info = {"foo": "bar"}

ipmi_info = json.dumps(
        {
            'ipmi': {
                "address": "1.2.3.4",
                "username": "******",
                "password": "******",
            }
         })

ssh_info = json.dumps(
        {
            'ssh': {
                "address": "1.2.3.4",
                "username": "******",
                "password": "******",
                "port": 22,
                "virt_type": "vbox",
                "key_filename": "/not/real/file",
            }
         })
Beispiel #45
0
#    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.
"""Ironic test utilities."""

from ironic.common import states

from ironic.openstack.common import jsonutils as json


fake_info = {"foo": "bar"}

ipmi_info = json.dumps(
        {
            "ipmi_address": "1.2.3.4",
            "ipmi_username": "******",
            "ipmi_password": "******",
         })

ssh_info = json.dumps(
        {
            "ssh_address": "1.2.3.4",
            "ssh_username": "******",
            "ssh_password": "******",
            "ssh_port": 22,
            "ssh_virt_type": "vbox",
            "ssh_key_filename": "/not/real/file",
         })

pxe_info = json.dumps(
        {