def _install_uninstall(self, blueprint_name, inputs={},
                           expected_node_properties=None,
                           timeout=DEFAULT_EXECUTE_TIMEOUT):
        resources_dir = os.path.join(os.path.dirname(handler.__file__),
                                     BLUEPRINTS_DIR_NAME)
        self.blueprint_yaml = os.path.join(resources_dir, blueprint_name)
        inputs['domain'] = self.domain
        if 'hostname' not in inputs:
            inputs['hostname'] = 'install'
        hostname_suffix = str(uuid.uuid4())[:3]
        inputs['hostname'] = '{0}{1}'.format(
            inputs['hostname'], hostname_suffix)
        inputs['install_agent'] = True
        self.upload_deploy_and_execute_install(execute_timeout=timeout,
                                               inputs=inputs)
        prefix = self.env.resources_prefix
        hostname = generate_hostname(
            hostname=inputs['hostname'], prefix=prefix)
        instance_id = self._get_instance_id(
            unique_domain=self.domain, hostname=hostname)
        self._assert_instance_properties(instance_id, expected_node_properties)

        self.execute_uninstall()

        self._validate_transactions_begun(instance_id)
        # waiting for instance to be deleted
        self.repetitive(
            func=self._assert_instance_not_exist,
            args={instance_id: instance_id},
            timeout=DEFAULT_EXECUTE_TIMEOUT)
    def _install_uninstall(self,
                           blueprint_name,
                           inputs={},
                           expected_node_properties=None,
                           timeout=DEFAULT_EXECUTE_TIMEOUT):
        resources_dir = os.path.join(os.path.dirname(handler.__file__),
                                     BLUEPRINTS_DIR_NAME)
        self.blueprint_yaml = os.path.join(resources_dir, blueprint_name)
        inputs['domain'] = self.domain
        if 'hostname' not in inputs:
            inputs['hostname'] = 'install'
        hostname_suffix = str(uuid.uuid4())[:3]
        inputs['hostname'] = '{0}{1}'.format(inputs['hostname'],
                                             hostname_suffix)
        inputs['install_agent'] = True
        self.upload_deploy_and_execute_install(execute_timeout=timeout,
                                               inputs=inputs)
        prefix = self.env.resources_prefix
        hostname = generate_hostname(hostname=inputs['hostname'],
                                     prefix=prefix)
        instance_id = self._get_instance_id(unique_domain=self.domain,
                                            hostname=hostname)
        self._assert_instance_properties(instance_id, expected_node_properties)

        self.execute_uninstall()

        self._validate_transactions_begun(instance_id)
        # waiting for instance to be deleted
        self.repetitive(func=self._assert_instance_not_exist,
                        args={instance_id: instance_id},
                        timeout=DEFAULT_EXECUTE_TIMEOUT)
Example #3
0
 def test_generate_hostname(self, mock_get_ctx):
     mock_get_ctx.return_value = MockCloudifyContext()
     long_prefix = 'long_prefix'
     node_id = '__illegal_underscores_very_long_id'
     name = softlayer_plugin.generate_hostname(hostname=node_id,
                                               prefix=long_prefix)
     self.assertLessEqual(len(name), constants.MAX_HOSTNAME_CHARS)
     prefix = long_prefix[:constants.HOST_PREFIX_LEN].replace('_', '-')
     self.assertEqual(name[:constants.HOST_PREFIX_LEN], prefix)
     id_len = constants.MAX_HOSTNAME_CHARS - constants.HOST_PREFIX_LEN - 1
     expected_id = node_id[-id_len:].replace('_', '-')
     self.assertEqual(name[constants.HOST_PREFIX_LEN:], expected_id)
Example #4
0
 def test_generate_hostname(self, mock_get_ctx):
     mock_get_ctx.return_value = MockCloudifyContext()
     long_prefix = 'long_prefix'
     node_id = '__illegal_underscores_very_long_id'
     name = softlayer_plugin.generate_hostname(
         hostname=node_id, prefix=long_prefix)
     self.assertLessEqual(len(name), constants.MAX_HOSTNAME_CHARS)
     prefix = long_prefix[:constants.HOST_PREFIX_LEN].replace('_', '-')
     self.assertEqual(name[:constants.HOST_PREFIX_LEN], prefix)
     id_len = constants.MAX_HOSTNAME_CHARS - constants.HOST_PREFIX_LEN - 1
     expected_id = node_id[-id_len:].replace('_', '-')
     self.assertEqual(name[constants.HOST_PREFIX_LEN:], expected_id)
Example #5
0
 def test_missing_prefix_hostname(self, mock_get_ctx):
     mock_get_ctx.return_value = MockCloudifyContext()
     hostname = 'test-id'
     name = softlayer_plugin.generate_hostname(hostname=hostname)
     self.assertEqual(name, hostname)
Example #6
0
 def test_missing_prefix_hostname(self, mock_get_ctx):
     mock_get_ctx.return_value = MockCloudifyContext()
     hostname = 'test-id'
     name = softlayer_plugin.generate_hostname(hostname=hostname)
     self.assertEqual(name, hostname)
Example #7
0
def _generate_hostname(hosts, hostname, prefix=''):
    name = softlayer_plugin.generate_hostname(hostname, prefix)
    if name in hosts:
        raise NonRecoverableError('hostname [{0}] already exists'.format(name))
    return name
Example #8
0
def _generate_hostname(hosts, hostname, prefix=''):
    name = softlayer_plugin.generate_hostname(hostname, prefix)
    if name in hosts:
        raise NonRecoverableError('hostname [{0}] already exists'.format(name))
    return name