def test_invalid_personality(self):
     """
     Invalid personality causes InvalidLaunchConfiguration
     """
     self.validate_personality.return_value = defer.fail(InvalidPersonality(":("))
     d = validate_launch_server_config(self.log, "dfw", "catalog", "token", self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(f.value.message, "Following problems with launch configuration:\n:(")
Esempio n. 2
0
 def when_authenticated((auth_token, service_catalog)):
     log.msg('Validating launch server config')
     return validate_config.validate_launch_server_config(
         log,
         self.region,
         service_catalog,
         auth_token,
         launch_config['args'])
Esempio n. 3
0
 def test_invalid_flavor(self):
     """
     Invalid flavor causes InvalidLaunchConfiguration
     """
     self.validate_flavor.return_value = defer.fail(InvalidLaunchConfiguration(':('))
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(f.value.message, 'Following problems with launch configuration:\n:(')
Esempio n. 4
0
 def test_inactive_image(self):
     """
     Image that is not in 'ACTIVE' state causes InvalidLaunchConfiguration
     """
     self.validate_image.return_value = defer.fail(InactiveImage('meh'))
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(f.value.message, ('Following problems with launch configuration:\n' +
                                        'Inactive imageRef "meh" in launchConfiguration'))
Esempio n. 5
0
 def test_optional_property(self):
     """
     If any of the optional properties is not available, it does not validate
     those and continues validating others
     """
     # Note: flavorRef is actually mandatory. It is used only for testing purpose
     del self.launch_config['server']['flavorRef']
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     self.successResultOf(d)
     self.assertFalse(self.validate_flavor.called)
    def test_valid(self):
        """
        `validate_launch_server_config` succeeds when all the validate_* are called and succeeds
        """
        d = validate_launch_server_config(self.log, "dfw", "catalog", "token", self.launch_config)
        self.successResultOf(d)

        for suffix, prop in zip(self.func_suffixes, self.properties):
            func = getattr(self, "validate_{}".format(suffix))
            func.assert_called_once_with(self.log, "token", "service", self.launch_config["server"][prop])
Esempio n. 7
0
 def test_invalid_image_and_flavor(self):
     """
     InvalidLaunchConfiguration is raised if both image and flavor are invalid
     """
     self.validate_image.return_value = defer.fail(InvalidLaunchConfiguration('image problem'))
     self.validate_flavor.return_value = defer.fail(InvalidLaunchConfiguration('flavor problem'))
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(
         f.value.message,
         'Following problems with launch configuration:\nimage problem\nflavor problem')
Esempio n. 8
0
    def test_valid(self):
        """
        `validate_launch_server_config` succeeds when all the validate_* are called and succeeds
        """
        d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
        self.successResultOf(d)

        for suffix, prop in zip(self.func_suffixes, self.properties):
            func = getattr(self, 'validate_{}'.format(suffix))
            func.assert_called_once_with(self.log, 'token', 'service',
                                         self.launch_config['server'][prop])
Esempio n. 9
0
 def test_validation_error_logged(self):
     """
     `InvalidLaunchConfiguration` is logged as msg
     """
     self.validate_image.return_value = defer.fail(InvalidLaunchConfiguration(':('))
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     self.failureResultOf(d, InvalidLaunchConfiguration)
     self.log.msg.assert_called_once_with(
         'Invalid {prop_name} "{prop_value}" in launchConfiguration',
         prop_name='imageRef', prop_value='imagegood',
         reason=CheckFailure(InvalidLaunchConfiguration))
Esempio n. 10
0
 def test_other_error_raised(self):
     """
     `InvalidLaunchConfiguration` is raised even if any of the internal validate_* functions
     raise some other error
     """
     self.validate_image.return_value = defer.fail(ValueError(':('))
     d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(f.value.message,
                      ('Following problems with launch configuration:\n'
                       'Invalid imageRef "imagegood" in launchConfiguration'))
Esempio n. 11
0
 def test_invalid_image(self):
     """
     Invalid image causes InvalidLaunchConfiguration
     """
     self.validate_image.return_value = defer.fail(UnknownImage("meh"))
     d = validate_launch_server_config(self.log, "dfw", "catalog", "token", self.launch_config)
     f = self.failureResultOf(d, InvalidLaunchConfiguration)
     self.assertEqual(
         f.value.message,
         ("Following problems with launch configuration:\n" + 'Invalid imageRef "meh" in launchConfiguration'),
     )
Esempio n. 12
0
    def test_null_image(self):
        """
        None in the image param means that Nova will use boot-from-volume.
        The ``None`` ``imageRef`` still validates.
        """
        self.launch_config['server']['imageRef'] = None

        d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
        self.successResultOf(d)

        self.assertFalse(self.validate_image.called)
Esempio n. 13
0
    def test_empty_image(self):
        """
        An empty string in the image param means that Nova will use
        boot-from-volume.  The empty string still validates.
        """
        self.launch_config['server']['imageRef'] = ""

        d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
        self.successResultOf(d)

        self.assertFalse(self.validate_image.called)
Esempio n. 14
0
    def test_no_image(self):
        """
        Not providing an ``imageRef`` param means that Nova will use
        boot-from-volume.  The server args still validate.
        """
        self.launch_config['server'].pop('imageRef')

        d = validate_launch_server_config(self.log, 'dfw', 'catalog', 'token', self.launch_config)
        self.successResultOf(d)

        self.assertFalse(self.validate_image.called)
Esempio n. 15
0
 def test_validation_error_logged(self):
     """
     `InvalidLaunchConfiguration` is logged as msg
     """
     self.validate_image.return_value = defer.fail(InvalidLaunchConfiguration(":("))
     d = validate_launch_server_config(self.log, "dfw", "catalog", "token", self.launch_config)
     self.failureResultOf(d, InvalidLaunchConfiguration)
     self.log.msg.assert_called_once_with(
         'Invalid {prop_name} "{prop_value}" in launchConfiguration',
         prop_name="imageRef",
         prop_value="imagegood",
         reason=CheckFailure(InvalidLaunchConfiguration),
     )