Exemple #1
0
    def test__cache_tftp_images_master_path(self):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=os.path.join(temp_dir,
                                                  'tftp_master_path'),
                    group='pxe')
        image_info = {'deploy_kernel': ['deploy_kernel',
                                        os.path.join(temp_dir,
                                                     self.node.uuid,
                                                     'deploy_kernel')]}
        fileutils.ensure_tree(CONF.pxe.tftp_master_path)
        fd, tmp_master_image = tempfile.mkstemp(dir=CONF.pxe.tftp_master_path)

        with mock.patch.object(images, 'fetch_to_raw') as fetch_to_raw_mock:
            with mock.patch.object(tempfile, 'mkstemp') as mkstemp_mock:
                fetch_to_raw_mock.return_value = None
                mkstemp_mock.return_value = (fd, tmp_master_image)

                pxe._cache_tftp_images(None, self.node, image_info)

                fetch_to_raw_mock.assert_called_once_with(None,
                                                          'deploy_kernel',
                                                          tmp_master_image,
                                                          None)
                mkstemp_mock.assert_called_once_with(
                                                dir=CONF.pxe.tftp_master_path)
Exemple #2
0
    def test__cache_tftp_images_master_path(self):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=os.path.join(temp_dir,
                                                  'tftp_master_path'),
                    group='pxe')
        image_info = {
            'deploy_kernel': [
                'deploy_kernel',
                os.path.join(temp_dir, self.node.uuid, 'deploy_kernel')
            ]
        }
        fileutils.ensure_tree(CONF.pxe.tftp_master_path)
        fd, tmp_master_image = tempfile.mkstemp(dir=CONF.pxe.tftp_master_path)

        with mock.patch.object(images, 'fetch_to_raw') as fetch_to_raw_mock:
            with mock.patch.object(tempfile, 'mkstemp') as mkstemp_mock:
                fetch_to_raw_mock.return_value = None
                mkstemp_mock.return_value = (fd, tmp_master_image)

                pxe._cache_tftp_images(None, self.node, image_info)

                fetch_to_raw_mock.assert_called_once_with(
                    None, 'deploy_kernel', tmp_master_image, None)
                mkstemp_mock.assert_called_once_with(
                    dir=CONF.pxe.tftp_master_path)
Exemple #3
0
    def test__cache_tftp_images_master_path(self, mock_fetch_image):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group="pxe")
        self.config(tftp_master_path=os.path.join(temp_dir, "tftp_master_path"), group="pxe")
        image_path = os.path.join(temp_dir, self.node.uuid, "deploy_kernel")
        image_info = {"deploy_kernel": ("deploy_kernel", image_path)}
        fileutils.ensure_tree(CONF.pxe.tftp_master_path)

        pxe._cache_tftp_images(None, self.node, image_info)

        mock_fetch_image.assert_called_once_with(None, mock.ANY, [("deploy_kernel", image_path)])
Exemple #4
0
 def test__cache_tftp_images_no_master_path(self):
     temp_dir = tempfile.mkdtemp()
     CONF.set_default('tftp_root', temp_dir, group='pxe')
     CONF.set_default('tftp_master_path', None, group='pxe')
     image_info = {'deploy_kernel': ['deploy_kernel',
                                     os.path.join(temp_dir,
                                     'instance_uuid_123/deploy_kernel')]}
     self.mox.StubOutWithMock(images, 'fetch_to_raw')
     images.fetch_to_raw(None, 'deploy_kernel',
                         os.path.join(temp_dir,
                                      'instance_uuid_123/deploy_kernel'),
                         None).AndReturn(None)
     self.mox.ReplayAll()
     pxe._cache_tftp_images(None, self.node, image_info)
     self.mox.VerifyAll()
Exemple #5
0
    def test__cache_tftp_images_master_path(self, mock_fetch_image):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=os.path.join(temp_dir,
                                                  'tftp_master_path'),
                    group='pxe')
        image_path = os.path.join(temp_dir, self.node.uuid,
                                  'deploy_kernel')
        image_info = {'deploy_kernel': ['deploy_kernel', image_path]}
        fileutils.ensure_tree(CONF.pxe.tftp_master_path)

        pxe._cache_tftp_images(None, self.node, image_info)

        mock_fetch_image.assert_called_once_with('deploy_kernel',
                                                 image_path,
                                                 ctx=None)
Exemple #6
0
    def test__cache_tftp_images_no_master_path(self):
        temp_dir = tempfile.mkdtemp()
        CONF.set_default('tftp_root', temp_dir, group='pxe')
        CONF.set_default('tftp_master_path', None, group='pxe')
        image_info = {'deploy_kernel': ['deploy_kernel',
                                        os.path.join(temp_dir,
                                        'instance_uuid_123/deploy_kernel')]}

        with mock.patch.object(images, 'fetch_to_raw') as fetch_to_raw_mock:
            fetch_to_raw_mock.return_value = None

            pxe._cache_tftp_images(None, self.node, image_info)

            fetch_to_raw_mock.assert_called_once_with(None,
                    'deploy_kernel',
                    os.path.join(temp_dir, 'instance_uuid_123/deploy_kernel'),
                    None)
Exemple #7
0
    def test__cache_tftp_images_no_master_path(self):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=None, group='pxe')
        image_info = {'deploy_kernel': ['deploy_kernel',
                                        os.path.join(temp_dir,
                                        self.node.uuid, 'deploy_kernel')]}

        with mock.patch.object(images, 'fetch_to_raw') as fetch_to_raw_mock:
            fetch_to_raw_mock.return_value = None

            pxe._cache_tftp_images(None, self.node, image_info)

            fetch_to_raw_mock.assert_called_once_with(None,
                    'deploy_kernel',
                    os.path.join(temp_dir, self.node.uuid, 'deploy_kernel'),
                    None)
Exemple #8
0
    def test__cache_tftp_images_master_path(self, mock_fetch_image):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=os.path.join(temp_dir,
                                                  'tftp_master_path'),
                    group='pxe')
        image_path = os.path.join(temp_dir, self.node.uuid,
                                  'deploy_kernel')
        image_info = {'deploy_kernel': ('deploy_kernel', image_path)}
        fileutils.ensure_tree(CONF.pxe.tftp_master_path)

        pxe._cache_tftp_images(None, self.node, image_info)

        mock_fetch_image.assert_called_once_with(None,
                                                 mock.ANY,
                                                 [('deploy_kernel',
                                                   image_path)])
Exemple #9
0
    def test__cache_tftp_images_no_master_path(self):
        temp_dir = tempfile.mkdtemp()
        self.config(tftp_root=temp_dir, group='pxe')
        self.config(tftp_master_path=None, group='pxe')
        image_info = {
            'deploy_kernel': [
                'deploy_kernel',
                os.path.join(temp_dir, self.node.uuid, 'deploy_kernel')
            ]
        }

        with mock.patch.object(images, 'fetch_to_raw') as fetch_to_raw_mock:
            fetch_to_raw_mock.return_value = None

            pxe._cache_tftp_images(None, self.node, image_info)

            fetch_to_raw_mock.assert_called_once_with(
                None, 'deploy_kernel',
                os.path.join(temp_dir, self.node.uuid, 'deploy_kernel'), None)
Exemple #10
0
 def test__cache_tftp_images_master_path(self):
     temp_dir = tempfile.mkdtemp()
     CONF.set_default('tftp_root', temp_dir, group='pxe')
     CONF.set_default('tftp_master_path', os.path.join(temp_dir,
                                                       'tftp_master_path'),
                      group='pxe')
     image_info = {'deploy_kernel': ['deploy_kernel', temp_dir +
                                     '/instance_uuid_123/deploy_kernel']}
     fileutils.ensure_tree(CONF.pxe.tftp_master_path)
     fd, tmp_master_image = tempfile.mkstemp(dir=CONF.pxe.tftp_master_path)
     self.mox.StubOutWithMock(images, 'fetch_to_raw')
     self.mox.StubOutWithMock(tempfile, 'mkstemp')
     tempfile.mkstemp(dir=CONF.pxe.tftp_master_path).\
         AndReturn((fd, tmp_master_image))
     images.fetch_to_raw(None, 'deploy_kernel', tmp_master_image, None).\
         AndReturn(None)
     self.mox.ReplayAll()
     pxe._cache_tftp_images(None, self.node, image_info)
     self.mox.VerifyAll()