Exemplo n.º 1
0
 def test_parse_instance_info_nonglance_image(self):
     info = INST_INFO_DICT.copy()
     info['image_source'] = 'file:///image.qcow2'
     info['kernel'] = 'file:///image.vmlinuz'
     info['ramdisk'] = 'file:///image.initrd'
     node = obj_utils.create_test_node(
               self.context, instance_info=info,
               driver_internal_info=DRV_INTERNAL_INFO_DICT,
            )
     iscsi_deploy.parse_instance_info(node)
Exemplo n.º 2
0
 def test_parse_instance_info_good(self):
     # make sure we get back the expected things
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_pxe',
                                       instance_info=INST_INFO_DICT)
     info = iscsi_deploy.parse_instance_info(node)
     self.assertIsNotNone(info.get('image_source'))
     self.assertIsNotNone(info.get('root_gb'))
     self.assertEqual(0, info.get('ephemeral_gb'))
Exemplo n.º 3
0
 def test_parse_instance_info_valid_preserve_ephemeral_false(self):
     info = dict(INST_INFO_DICT)
     for opt in ['false', 'FALSE', 'False', 'f', 'off', 'no', 'n', '0']:
         info['preserve_ephemeral'] = opt
         node = obj_utils.create_test_node(self.context,
                                           uuid=utils.generate_uuid(),
                                           instance_info=info)
         data = iscsi_deploy.parse_instance_info(node)
         self.assertFalse(data.get('preserve_ephemeral'))
Exemplo n.º 4
0
 def test_parse_instance_info_configdrive(self):
     info = dict(INST_INFO_DICT)
     info['configdrive'] = 'http://1.2.3.4/cd'
     node = obj_utils.create_test_node(
               self.context, instance_info=info,
               driver_internal_info=DRV_INTERNAL_INFO_DICT,
            )
     instance_info = iscsi_deploy.parse_instance_info(node)
     self.assertEqual('http://1.2.3.4/cd', instance_info['configdrive'])
Exemplo n.º 5
0
 def test_parse_instance_info_valid_preserve_ephemeral_true(self):
     info = dict(INST_INFO_DICT)
     for opt in ['true', 'TRUE', 'True', 't', 'on', 'yes', 'y', '1']:
         info['preserve_ephemeral'] = opt
         node = obj_utils.create_test_node(self.context,
                                           uuid=utils.generate_uuid(),
                                           instance_info=info)
         data = iscsi_deploy.parse_instance_info(node)
         self.assertTrue(data.get('preserve_ephemeral'))
Exemplo n.º 6
0
 def test_parse_instance_info_good(self):
     # make sure we get back the expected things
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_pxe',
                                       instance_info=INST_INFO_DICT)
     info = iscsi_deploy.parse_instance_info(node)
     self.assertIsNotNone(info.get('image_source'))
     self.assertIsNotNone(info.get('root_gb'))
     self.assertEqual(0, info.get('ephemeral_gb'))
Exemplo n.º 7
0
 def test_parse_instance_info_valid_ephemeral_missing_format(self):
     ephemeral_gb = 10
     ephemeral_fmt = 'test-fmt'
     info = dict(INST_INFO_DICT)
     info['ephemeral_gb'] = ephemeral_gb
     info['ephemeral_format'] = None
     self.config(default_ephemeral_format=ephemeral_fmt, group='pxe')
     node = obj_utils.create_test_node(self.context, instance_info=info)
     instance_info = iscsi_deploy.parse_instance_info(node)
     self.assertEqual(ephemeral_fmt, instance_info['ephemeral_format'])
Exemplo n.º 8
0
 def test_parse_instance_info_valid_ephemeral_gb(self):
     ephemeral_gb = 10
     ephemeral_fmt = 'test-fmt'
     info = dict(INST_INFO_DICT)
     info['ephemeral_gb'] = ephemeral_gb
     info['ephemeral_format'] = ephemeral_fmt
     node = obj_utils.create_test_node(self.context, instance_info=info)
     data = iscsi_deploy.parse_instance_info(node)
     self.assertEqual(ephemeral_gb, data.get('ephemeral_gb'))
     self.assertEqual(ephemeral_fmt, data.get('ephemeral_format'))
Exemplo n.º 9
0
 def test_parse_instance_info_valid_preserve_ephemeral_false(self):
     info = dict(INST_INFO_DICT)
     for opt in ['false', 'FALSE', 'False', 'f',
                 'off', 'no', 'n', '0']:
         info['preserve_ephemeral'] = opt
         node = obj_utils.create_test_node(self.context,
                                           uuid=utils.generate_uuid(),
                                           instance_info=info)
         data = iscsi_deploy.parse_instance_info(node)
         self.assertFalse(data.get('preserve_ephemeral'))
Exemplo n.º 10
0
 def test_parse_instance_info_valid_preserve_ephemeral_true(self):
     info = dict(INST_INFO_DICT)
     for opt in ['true', 'TRUE', 'True', 't',
                 'on', 'yes', 'y', '1']:
         info['preserve_ephemeral'] = opt
         node = obj_utils.create_test_node(self.context,
                                           uuid=utils.generate_uuid(),
                                           instance_info=info)
         data = iscsi_deploy.parse_instance_info(node)
         self.assertTrue(data.get('preserve_ephemeral'))
Exemplo n.º 11
0
 def test_parse_instance_info_valid_ephemeral_missing_format(self):
     ephemeral_gb = 10
     ephemeral_fmt = 'test-fmt'
     info = dict(INST_INFO_DICT)
     info['ephemeral_gb'] = ephemeral_gb
     info['ephemeral_format'] = None
     self.config(default_ephemeral_format=ephemeral_fmt, group='pxe')
     node = obj_utils.create_test_node(self.context, instance_info=info)
     instance_info = iscsi_deploy.parse_instance_info(node)
     self.assertEqual(ephemeral_fmt, instance_info['ephemeral_format'])
Exemplo n.º 12
0
 def test_parse_instance_info_valid_ephemeral_gb(self):
     ephemeral_gb = 10
     ephemeral_fmt = 'test-fmt'
     info = dict(INST_INFO_DICT)
     info['ephemeral_gb'] = ephemeral_gb
     info['ephemeral_format'] = ephemeral_fmt
     node = obj_utils.create_test_node(self.context, instance_info=info)
     data = iscsi_deploy.parse_instance_info(node)
     self.assertEqual(ephemeral_gb, data.get('ephemeral_gb'))
     self.assertEqual(ephemeral_fmt, data.get('ephemeral_format'))
Exemplo n.º 13
0
 def test_parse_instance_info_whole_disk_image(self):
     driver_internal_info = dict(DRV_INTERNAL_INFO_DICT)
     driver_internal_info['is_whole_disk_image'] = True
     node = obj_utils.create_test_node(
               self.context, instance_info=INST_INFO_DICT,
               driver_internal_info=driver_internal_info,
            )
     instance_info = iscsi_deploy.parse_instance_info(node)
     self.assertIsNotNone(instance_info.get('image_source'))
     self.assertIsNotNone(instance_info.get('root_gb'))
     self.assertEqual(0, instance_info.get('swap_mb'))
     self.assertEqual(0, instance_info.get('ephemeral_gb'))
     self.assertIsNone(instance_info.get('configdrive'))
Exemplo n.º 14
0
def _parse_deploy_info(node):
    """Gets the instance and driver specific Node deployment info.

    This method validates whether the 'instance_info' and 'driver_info'
    property of the supplied node contains the required information for
    this driver to deploy images to the node.

    :param node: a single Node.
    :returns: A dict with the instance_info and driver_info values.
    :raises: MissingParameterValue
    :raises: InvalidParameterValue
    """
    info = {}
    info.update(iscsi_deploy.parse_instance_info(node))
    info.update(_parse_driver_info(node))
    return info
Exemplo n.º 15
0
def _parse_deploy_info(node):
    """Gets the instance and driver specific Node deployment info.

    This method validates whether the 'instance_info' and 'driver_info'
    property of the supplied node contains the required information for
    this driver to deploy images to the node.

    :param node: a single Node.
    :returns: A dict with the instance_info and driver_info values.
    :raises: MissingParameterValue
    :raises: InvalidParameterValue
    """
    info = {}
    info.update(iscsi_deploy.parse_instance_info(node))
    info.update(_parse_driver_info(node))
    return info
Exemplo n.º 16
0
def _parse_deploy_info(node):
    """Gets the instance and driver specific Node deployment info.

    This method validates whether the 'instance_info' and 'driver_info'
    property of the supplied node contains the required information for
    this driver to deploy images to the node.

    :param node: a target node of the deployment
    :returns: a dict with the instance_info and driver_info values.
    :raises: MissingParameterValue, if any of the required parameters are
        missing.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    """
    deploy_info = {}
    deploy_info.update(iscsi_deploy.parse_instance_info(node))
    deploy_info.update(_parse_driver_info(node))
    deploy_info.update(_parse_instance_info(node))

    return deploy_info