def test_init_env_validate_definitions(self):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         "resources/blueprints/test-validate-version-blueprint.yaml")
     self.assertRaises(dsl_exceptions.DSLParsingException,
                       local.init_env,
                       blueprint_path,
                       validate_version=True)
     local.init_env(blueprint_path, validate_version=False)
 def test_init_env_validate_definitions(self):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         "resources/blueprints/test-validate-version-blueprint.yaml")
     self.assertRaises(
         dsl_exceptions.DSLParsingException,
         local.init_env, blueprint_path,
         validate_version=True)
     local.init_env(blueprint_path, validate_version=False)
    def test_no_password_fails(self):
        blueprint = os.path.join(self.blueprints_path,
                                 'no_password-blueprint.yaml')

        if self.env.install_plugins:
            self.logger.info('installing required plugins')
            self.cfy.install_plugins_locally(blueprint_path=blueprint)

        self.logger.info('Deploying windows host with no password set')

        self.no_password_fail_env = local.init_env(
            blueprint,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)
        try:
            self.no_password_fail_env.execute('install')
            self.no_password_fail_env.execute('uninstall', task_retries=50)
            raise AssertionError(
                'Windows deployment should fail with no password, '
                'but it succeeded.')
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'Windows' in err.message
            assert 'password must be set' in err.message
            assert 'properties.windows_password' in err.message
            assert 'properties.agent_config.password' in err.message
            self.logger.info('Windows passwordless deploy has correct error.')
    def test_local_agent_from_package(self, _):
        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
    def test_local_agent_from_package_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes

        Paths longer than 128 bytes break shebangs on linux.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
    def test_not_existing_cluster(self):
        blueprint = os.path.join(
            self.blueprints_path,
            'existing-cluster-blueprint.yaml'
        )

        inputs = copy(self.ext_inputs)
        inputs['test_cluster_name'] = 'systestTHISSHOULDNOTBEEXISTING'

        self.cluster_not_existing_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        try:
            self.cluster_not_existing_env.execute('install')
            self.cluster_not_existing_env.execute('uninstall',
                                                  task_retries=50)
            raise AssertionError(
                'Attempting to use existing cluster: {name} '
                'should fail, but succeeded!'.format(
                    target=inputs['test_cluster_name'],
                )
            )
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'not use existing' in err.message
            assert inputs['test_cluster_name'] in err.message
            assert 'no cluster by that name exists' in err.message
            self.logger.info('Use non-existing cluster with '
                             'use_external_resource has correct error.')
示例#7
0
 def test_uninstall_workflow(self):
     cfy_local = local.init_env(
         self.get_blueprint_path(),
         name='test_uninstall_workflow',
         inputs=self.get_inputs(),
         ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
     cfy_local.execute('install', task_retries=10)
     node_instances = cfy_local.storage.get_node_instances()
     copy_node_instances = deepcopy(node_instances)
     cfy_local.execute('uninstall', task_retries=10)
     vpc_client = self.vpc_client()
     current_resources = self.get_current_list_of_used_resources(vpc_client)
     for node_instance in copy_node_instances:
         node = cfy_local.storage.get_node(node_instance.node_id)
         if node.type in EC2_RESOURCES:
             continue
         actual_resource_id = \
             node_instance.runtime_properties['aws_resource_id']
         expected_resource_ids = \
             [resource.id for resource in current_resources[node.type]]
         if node.type in constants.CUSTOMER_GATEWAY['CLOUDIFY_NODE_TYPE']:
             customer_gateway = \
                 vpc_client.get_all_customer_gateways(
                     customer_gateway_ids=actual_resource_id)
             self.assertIn(customer_gateway[0].state,
                           ['detached', 'deleted'])
         elif node.type in constants.VPN_GATEWAY['CLOUDIFY_NODE_TYPE']:
             vpn_gateway = vpc_client.get_all_vpn_gateways(
                 vpn_gateway_ids=actual_resource_id)
             self.assertIn(vpn_gateway[0].state, ['detached', 'deleted'])
         else:
             self.assertNotIn(actual_resource_id, expected_resource_ids)
示例#8
0
 def setUp(self):
     super(TestSubgraphWorkflowLogic, self).setUp()
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         "resources/blueprints/test-subgraph-blueprint.yaml")
     self.env = local.init_env(
         blueprint_path, ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
示例#9
0
    def _set_up(self, inputs=None):
        if not inputs:
            inputs = {}
        # set logger
        self.logger = logging.getLogger(self._testMethodName)
        self.logger.addHandler(logging.StreamHandler(sys.stdout))
        self.logger.setLevel(logging.INFO)
        # build blueprint path
        blueprint_path = path.join(
            path.dirname(path.dirname(__file__)),
            'resources',
            'linux-blueprint.yaml')

        creds = _get_credentials()
        if 'api_key' not in inputs:
            inputs['api_key'] = creds['api_key']
        if 'username' not in inputs:
            inputs['username'] = creds['username']
        inputs['domain'] = self.domain
        if 'hostname' not in inputs:
            inputs['hostname'] = 'linux'
        hostname_suffix = str(uuid.uuid4())[:3]
        inputs['hostname'] = '{0}{1}'.format(
            inputs['hostname'], hostname_suffix)
        self.hostname = inputs['hostname']
        # setup local workflow execution environment
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=inputs,
                                  ignored_modules=['worker_installer.tasks',
                                                   'plugin_installer.tasks'])
    def _set_up(self, inputs=None):

        self.localenv = local.init_env(
            BLUEPRINT_PATH,
            name=self._testMethodName,
            inputs=inputs,
            ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
示例#11
0
    def _common_run(self, name, inputs):
        # set blueprint name
        blueprint = os.path.join(self.blueprints_path, name)

        # cfy local init
        self.comulative_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        # cfy local execute -w install
        self.comulative_env.execute(
            'install',
            task_retries=5,
            task_retry_interval=30,
        )

        # cfy local execute -w uninstall
        self.comulative_env.execute(
            'uninstall',
            task_retries=5,
            task_retry_interval=30,
        )

        self.comulative_env = None
    def _set_up(self, inputs=None):
        if not inputs:
            inputs = {}
        # set logger
        self.logger = logging.getLogger(self._testMethodName)
        self.logger.addHandler(logging.StreamHandler(sys.stdout))
        self.logger.setLevel(logging.INFO)
        # build blueprint path
        blueprint_path = path.join(path.dirname(path.dirname(__file__)),
                                   'resources', 'linux-blueprint.yaml')

        creds = _get_credentials()
        if 'api_key' not in inputs:
            inputs['api_key'] = creds['api_key']
        if 'username' not in inputs:
            inputs['username'] = creds['username']
        inputs['domain'] = self.domain
        if 'hostname' not in inputs:
            inputs['hostname'] = 'linux'
        hostname_suffix = str(uuid.uuid4())[:3]
        inputs['hostname'] = '{0}{1}'.format(inputs['hostname'],
                                             hostname_suffix)
        self.hostname = inputs['hostname']
        # setup local workflow execution environment
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=inputs,
                                  ignored_modules=[
                                      'worker_installer.tasks',
                                      'plugin_installer.tasks'
                                  ])
示例#13
0
    def setup_external_components_vm(self):
        blueprint_path = self.copy_blueprint('external-components-vm')
        self.blueprint_yaml = \
            blueprint_path / 'external-components-blueprint.yaml'

        if self.env.install_plugins:
            self.logger.info('installing required plugins')
            self.cfy.install_plugins_locally(
                blueprint_path=self.blueprint_yaml)

        self.logger.info('initialize external '
                         'components local env for running the '
                         'blueprint that starts a vm of es, rabbit, and '
                         'influx')
        self.ext_local_env = local.init_env(
            self.blueprint_yaml,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.logger.info('starting vm to serve as the management vm')
        self.ext_local_env.execute('install',
                                   task_retries=10,
                                   task_retry_interval=30)
        self.external_components_public_ip = \
            self.ext_local_env.outputs()[
                'external_components_vm_public_ip_address']
        self.external_components_private_ip = \
            self.ext_local_env.outputs()[
                'external_components_vm_private_ip_address']
        self.addCleanup(self.cleanup_ext)
    def setUp(self):
        self.counter = 0
        self.server = mock.MagicMock()
        blueprint_filename = 'test-start-operation-retry-blueprint.yaml'
        blueprint_path = path.join(path.dirname(__file__),
                                   'resources',
                                   blueprint_filename)
        plugin_yaml_filename = 'plugin.yaml'

        plugin_yaml_path = path.realpath(
            path.join(path.dirname(nova_plugin.__file__),
                      '../{0}'.format(plugin_yaml_filename)))

        self.tempdir = tempfile.mkdtemp(prefix='openstack-plugin-unit-tests-')

        temp_blueprint_path = path.join(self.tempdir, blueprint_filename)
        temp_plugin_yaml_path = path.join(self.tempdir, plugin_yaml_filename)

        shutil.copyfile(blueprint_path, temp_blueprint_path)
        shutil.copyfile(plugin_yaml_path, temp_plugin_yaml_path)

        # setup local workflow execution environment
        self.env = local.init_env(
            temp_blueprint_path,
            name=self._testMethodName,
            ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
示例#15
0
    def test_security_policy(self):
        """Platform check: security policy"""
        inputs = {k: self.ext_inputs[k] for k in self.ext_inputs}

        # Define inputs related to this function
        inputs['policy_name'] = os.environ.get(
            'POLICY_NAME', 'policy_name'
        )

        # set blueprint name
        blueprint = os.path.join(
            self.blueprints_path,
            'security_policy.yaml'
        )

        # check prexist of security policy
        resource_id, policy = nsx_security_policy.get_policy(
            self.client_session,
            inputs['node_name_prefix'] + inputs['policy_name']
        )

        self.assertIsNone(resource_id)

        # cfy local init
        self.local_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        # cfy local execute -w install
        self.local_env.execute(
            'install',
            task_retries=4,
            task_retry_interval=3,
        )

        # check security policy properties
        resource_id, policy = nsx_security_policy.get_policy(
            self.client_session,
            inputs['node_name_prefix'] + inputs['policy_name']
        )

        self.assertIsNotNone(resource_id)
        self.assertIsNotNone(policy)

        # cfy local execute -w uninstall
        self.local_env.execute(
            'uninstall',
            task_retries=50,
            task_retry_interval=3,
        )

        # must be deleted
        resource_id, policy = nsx_security_policy.get_policy(
            self.client_session,
            inputs['node_name_prefix'] + inputs['policy_name']
        )

        self.assertIsNone(resource_id)
示例#16
0
    def _init_env(self, bp_path, inputs):
        """ Initialize the cfy local environment """

        return local.init_env(bp_path,
                              name=self._testMethodName,
                              inputs=inputs,
                              ignored_modules=IGNORE)
 def _execute(self, operations,
              container_config=None,
              docker_env_var=None,
              custom_operation_kwargs=None,
              container_start=None,
              container_remove=None,
              image_build=None,
              image_import=None,
              default_sleep=0,
              task_retries=5):
     inputs = dict(
         daemon_client={},
         image_import=image_import or {},
         image_build=image_build or {
             'path': self.blueprint_dir
         },
         container_config=container_config or {
             'command': 'sleep {0}'.format(default_sleep)
         },
         container_start=container_start or {},
         container_stop={},
         container_remove=container_remove or {},
         docker_env_var=docker_env_var or {},
         custom_operation_kwargs=custom_operation_kwargs or {},
     )
     blueprint_path = os.path.join(self.blueprint_dir, 'blueprint.yaml')
     if not self.env:
         self.env = local.init_env(blueprint_path,
                                   name=self._testMethodName,
                                   inputs=inputs)
     self.env.execute('execute_operations',
                      parameters={'operations': operations},
                      task_retries=task_retries,
                      task_retry_interval=1)
示例#18
0
 def test_uninstall_workflow(self):
     cfy_local = local.init_env(
         self.get_blueprint_path(),
         name='test_uninstall_workflow',
         inputs=self.get_inputs(),
         ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
     cfy_local.execute('install', task_retries=10)
     node_instances = cfy_local.storage.get_node_instances()
     copy_node_instances = deepcopy(node_instances)
     cfy_local.execute('uninstall', task_retries=10)
     vpc_client = self.vpc_client()
     current_resources = self.get_current_list_of_used_resources(vpc_client)
     for node_instance in copy_node_instances:
         node = cfy_local.storage.get_node(node_instance.node_id)
         if node.type in EC2_RESOURCES:
             continue
         actual_resource_id = \
             node_instance.runtime_properties['aws_resource_id']
         expected_resource_ids = \
             [resource.id for resource in current_resources[node.type]]
         if node.type in constants.CUSTOMER_GATEWAY['CLOUDIFY_NODE_TYPE']:
             customer_gateway = \
                 vpc_client.get_all_customer_gateways(
                     customer_gateway_ids=actual_resource_id)
             self.assertIn(customer_gateway[0].state,
                           ['detached', 'deleted'])
         elif node.type in constants.VPN_GATEWAY['CLOUDIFY_NODE_TYPE']:
             vpn_gateway = vpc_client.get_all_vpn_gateways(
                 vpn_gateway_ids=actual_resource_id)
             self.assertIn(vpn_gateway[0].state, ['detached', 'deleted'])
         else:
             self.assertNotIn(actual_resource_id, expected_resource_ids)
    def _run(self, script,
             process=None,
             workflow_name='execute_operation',
             parameters=None,
             env_var='value',
             task_retries=0):

        self.script_path = self._create_script(script)
        process = process or {}
        process.update({'ctx_proxy_type': 'unix'})

        inputs = {
            'script_path': self.script_path,
            'process': process,
            'env_var': env_var
        }
        blueprint_path = os.path.join(BLUEPRINT_DIR, 'blueprint.yaml')
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=inputs)
        result = self.env.execute(workflow_name,
                                  parameters=parameters,
                                  task_retries=task_retries,
                                  task_retry_interval=0)
        if not result:
            result = self.env.storage.get_node_instances()[0][
                'runtime_properties']
        return result
示例#20
0
    def test_local_agent_from_package(self, _):
        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
示例#21
0
    def test_install_new_agent(self):
        agent_name = utils.internal.generate_agent_name()

        blueprint_path = resources.get_resource(
            'blueprints/install-new-agent/install-new-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        inputs = {
            'name': agent_name,
            'package_url': agent_package.get_package_url()
        }
        with self._manager_env():
            env = local.init_env(name=self._testMethodName,
                                 blueprint_path=blueprint_path,
                                 inputs=inputs)
            env.execute('install', task_retries=0)
            self.assert_daemon_alive(name=agent_name)
            node_instances = env.storage.get_node_instances()
            new_agent_host = [
                n for n in node_instances if n['name'] == 'new_agent_host'
            ][0]
            new_agent_name = new_agent_host['runtime_properties'][
                'cloudify_agent']['name']
            self.assertNotEqual(new_agent_name, agent_name)
            self.assert_daemon_alive(name=new_agent_name)
            env.execute('uninstall', task_retries=1)
            self.wait_for_daemon_dead(name=agent_name)
            self.wait_for_daemon_dead(name=new_agent_name)
示例#22
0
 def _create_env(self, inputs):
     return local.init_env(self._blueprint_path(),
                           inputs=inputs,
                           ignored_modules=[
                               'worker_installer.tasks',
                               'plugin_installer.tasks'
                           ])
示例#23
0
    def setUp(self):
        self.retry_count = 0
        blueprint_filename = 'simple-blueprint.yaml'
        blueprint_path = path.join(path.dirname(__file__),
                                   'resources',
                                   blueprint_filename)
        plugin_yaml_filename = 'plugin.yaml'
        plugin_yaml_path = path.realpath(
            path.join(path.dirname(softlayer_plugin.__file__),
                      '../{0}'.format(plugin_yaml_filename)))

        self.tempdir = tempfile.mkdtemp(prefix='softlayer-plugin-unit-tests-')

        temp_blueprint_path = path.join(self.tempdir, blueprint_filename)
        temp_plugin_yaml_path = path.join(self.tempdir, plugin_yaml_filename)

        shutil.copyfile(blueprint_path, temp_blueprint_path)
        shutil.copyfile(plugin_yaml_path, temp_plugin_yaml_path)

        self.env = local.init_env(
            temp_blueprint_path,
            name=self._testMethodName,
            ignored_modules=(
                'worker_installer.tasks',
                'plugin_installer.tasks'
            )
        )
    def setUp(self):
        # build blueprint path
        blueprint_path = os.path.join(os.path.dirname(__file__),
                                      'blueprint',
                                      'blueprint.yaml')

        # inject input from test
        self.inputs = {
            'host':             'cfy-bigip',
            'username':         '******',
            'password':         '******',
            'pool_id':          'test',
            'port':             '80'
        }

        IGNORED_LOCAL_WORKFLOW_MODULES = (
            'worker_installer.tasks',
            'plugin_installer.tasks'
        )

        # setup local workflow execution environment
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=self.inputs,
                                  ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
    def _set_up(self, inputs=None):

        self.localenv = local.init_env(
            BLUEPRINT_PATH,
            name=self._testMethodName,
            inputs=inputs,
            ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
    def test_local_agent_from_source_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes

        This test won't pass on windows because some files within the
        virtualenv exceed 256 bytes, and windows doesn't support paths
        that long.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
示例#27
0
    def test_blueprint(self):
        blueprint = os.path.join(self.blueprints_path, self.blueprint_name)

        self.logger.info('Creating a new Network')

        self.pre_install_hook()

        inputs = copy(self.ext_inputs)

        self.test_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.addCleanup(
            self.test_env.execute,
            'uninstall',
            task_retries=10,
            task_retry_interval=3,
        )

        self.test_env.execute(
            'install',
            task_retries=10,
            task_retry_interval=3,
        )

        self.outputs = self.test_env.outputs()

        self.assertions()

        print('\n{}:test_blueprint succeded\n'.format(type(self).__name__))
    def test_password_and_timezone(self):
        blueprint = os.path.join(self.blueprints_path,
                                 'password_and_timezone-blueprint.yaml')

        if self.env.install_plugins:
            self.logger.info('installing required plugins')
            self.cfy.install_plugins_locally(blueprint_path=blueprint)

        self.logger.info('Deploying windows host with '
                         'password and timezone set')

        self.password_and_timezone_env = local.init_env(
            blueprint,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)
        self.password_and_timezone_env.execute(
            'install',
            task_retries=50,
            task_retry_interval=3,
        )

        self.addCleanup(self.cleanup_password_and_timezone)

        vm_ip = self.password_and_timezone_env.outputs()['vm_ip']
        vm_password = self.ext_inputs['vm_password']

        self.check_vm_timezone_offset_is(
            offset=-7,
            vm_ip=vm_ip,
            vm_password=vm_password,
        )
 def setUp(self):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         "resources/blueprints/"
         "test-task-retry-event-context-blueprint.yaml")
     self.env = local.init_env(blueprint_path)
     super(TaskRetryEventContextTests, self).setUp()
 def setUp(self):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         "resources/blueprints/"
         "test-task-retry-event-context-blueprint.yaml")
     self.env = local.init_env(blueprint_path)
     super(TaskRetryEventContextTests, self).setUp()
示例#31
0
    def test_blueprint(self):
        blueprint = os.path.join(self.blueprints_path, self.blueprint_name)

        self.logger.info('Creating a new Network')

        self.pre_install_hook()

        inputs = copy(self.ext_inputs)

        self.test_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.addCleanup(
            self.test_env.execute,
            'uninstall',
            task_retries=10,
            task_retry_interval=3,
            )

        self.test_env.execute(
            'install',
            task_retries=10,
            task_retry_interval=3,
        )

        self.outputs = self.test_env.outputs()

        self.assertions()

        print('\n{}:test_blueprint succeded\n'.format(type(self).__name__))
    def test_network_bad_dvswitch(self):
        blueprint = os.path.join(self.blueprints_path,
                                 'network-blueprint.yaml')

        self.logger.info('Trying to deploy network on bad dvswitch')

        inputs = copy(self.ext_inputs)
        inputs['test_network_distributed'] = True
        inputs['test_network_name'] = 'systestTHISSHOULDNOTEXIST'
        if 'test_network_bad_dvswitch' in self.env.cloudify_config.keys():
            inputs['test_network_vswitch'] = self.env.cloudify_config[
                'test_network_bad_dvswitch']
        else:
            inputs['test_network_vswitch'] = 'notarealdvswitchatall'

        self.network_bad_dvswitch_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        try:
            self.network_bad_dvswitch_env.execute('install')
            self.network_bad_dvswitch_env.execute('uninstall', task_retries=50)
            raise AssertionError(
                'Attempting to deploy a dvswitch on invalid vswitch: '
                '{target} should fail, but succeeded!'.format(
                    target=inputs['test_network_vswitch'], ))
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'not a valid dvswitch' in err.message
            assert inputs['test_network_vswitch'] in err.message
            assert 'The valid dvswitches are:' in err.message
            self.logger.info('Network creation with bad dvswitch has correct '
                             'error.')
    def test_install_new_agent(self):
        agent_name = utils.internal.generate_agent_name()

        blueprint_path = resources.get_resource(
            'blueprints/install-new-agent/install-new-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        inputs = {
            'name': agent_name,
            'package_url': agent_package.get_package_url()
        }
        with self._manager_env():
            env = local.init_env(name=self._testMethodName,
                                 blueprint_path=blueprint_path,
                                 inputs=inputs)
            env.execute('install', task_retries=0)
            self.assert_daemon_alive(name=agent_name)
            node_instances = env.storage.get_node_instances()
            new_agent_host = [n for n in node_instances
                              if n['name'] == 'new_agent_host'][0]
            new_agent_name = new_agent_host['runtime_properties'][
                'cloudify_agent']['name']
            self.assertNotEqual(new_agent_name, agent_name)
            self.assert_daemon_alive(name=new_agent_name)
            env.execute('uninstall', task_retries=1)
            self.wait_for_daemon_dead(name=agent_name)
            self.wait_for_daemon_dead(name=new_agent_name)
 def _test(self, storage=None, blueprint='get_attribute.yaml'):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         'resources/blueprints/{0}'.format(blueprint))
     self.env = local.init_env(blueprint_path, storage=storage)
     self.env.execute('setup', task_retries=0)
     self.env.execute('run', task_retries=0)
    def setUp(self):
        self.counter = 0
        self.server = mock.MagicMock()
        blueprint_filename = 'test-start-operation-retry-blueprint.yaml'
        blueprint_path = path.join(path.dirname(__file__), 'resources',
                                   blueprint_filename)
        plugin_yaml_filename = 'plugin.yaml'

        plugin_yaml_path = path.realpath(
            path.join(path.dirname(nova_plugin.__file__),
                      '../{0}'.format(plugin_yaml_filename)))

        self.tempdir = tempfile.mkdtemp(prefix='openstack-plugin-unit-tests-')

        temp_blueprint_path = path.join(self.tempdir, blueprint_filename)
        temp_plugin_yaml_path = path.join(self.tempdir, plugin_yaml_filename)

        shutil.copyfile(blueprint_path, temp_blueprint_path)
        shutil.copyfile(plugin_yaml_path, temp_plugin_yaml_path)

        # setup local workflow execution environment
        self.env = local.init_env(
            temp_blueprint_path,
            name=self._testMethodName,
            ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
    def setUp(self):
        super(GCP2SubnetTest, self).setUp()

        self.logger.info('Creating a new Network')

        inputs = copy(self.ext_inputs)

        blueprint = os.path.join(self.blueprints_path, self.pre_blueprint_name)

        self.pre_setup_env = local.init_env(
            blueprint,
            inputs=inputs,
            name='external-networks-setup',
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.pre_install_hook()

        self.addCleanup(
            self.pre_setup_env.execute,
            'uninstall',
            task_retries=10,
            task_retry_interval=3,
            )

        self.pre_setup_env.execute(
            'install',
            task_retries=10,
            task_retry_interval=3,
        )

        self.pre_outputs = self.pre_setup_env.outputs()

        self.ext_inputs = {
                k: self.pre_outputs.get(k) or self.env.cloudify_config[k]
                for k in self.main_inputs}
示例#37
0
    def _init_env(self, bp_path, inputs):
        """ Initialize the cfy local environment """

        return local.init_env(bp_path,
                              name=self._testMethodName,
                              inputs=inputs,
                              ignored_modules=IGNORE)
 def test_local_blueprint(self):
     '''Execute a local blueprint using the service'''
     # Create a directory to act as the working directory
     tempdir = tempfile.mkdtemp(prefix='cloudify-host-pool-service')
     # Build the path to the blueprint
     blueprint_path = os.path.join(
         os.path.dirname(os.path.dirname(cloudify_hostpool.__file__)),
         'examples',
         'local-blueprint',
         'local-blueprint.yaml'
     )
     # Init the local workflow environment
     env = local.init_env(
         blueprint_path=blueprint_path,
         inputs={
             'working_directory': tempdir,
             'run_as_daemon': False
         },
         ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
     # Execute the "install" workflow
     env.execute('install', task_retries=0)
     self._post_install_assertions()
     # Execute the "uninstall" workflow
     env.execute('uninstall')
     self._post_uninstall_assertions()
 def initialize_local_blueprint(self):
     self.cfy_local = local.init_env(
         self.blueprint_path,
         self.test_name,
         inputs=self.inputs,
         ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
     self.verify_no_conflicting_resources()
示例#40
0
    def test_local_agent_from_source_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes (source)

        This test won't pass on windows because some files within the
        virtualenv exceed 256 bytes, and windows doesn't support paths
        that long.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'ssl_cert_path': self._rest_cert_path
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
    def _test_local_agent_from_package(self, agent_name, *_):

        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(agent_queue)
示例#42
0
    def test_local_agent_from_package_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes (package)

        Paths longer than 128 bytes break shebangs on linux.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
    def setup_external_components_vm(self):
        blueprint_path = self.copy_blueprint('external-components-vm')
        self.blueprint_yaml = \
            blueprint_path / 'external-components-blueprint.yaml'

        if self.env.install_plugins:
            self.logger.info('installing required plugins')
            self.cfy.install_plugins_locally(
                blueprint_path=self.blueprint_yaml)

        self.logger.info('initialize external '
                         'components local env for running the '
                         'blueprint that starts a vm of es, rabbit, and '
                         'influx')
        self.ext_local_env = local.init_env(
            self.blueprint_yaml,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.logger.info('starting vm to serve as the management vm')
        self.ext_local_env.execute('install',
                                   task_retries=10,
                                   task_retry_interval=30)
        self.external_components_public_ip = \
            self.ext_local_env.outputs()[
                'external_components_vm_public_ip_address']
        self.external_components_private_ip = \
            self.ext_local_env.outputs()[
                'external_components_vm_private_ip_address']
        self.addCleanup(self.cleanup_ext)
    def setUp(self):
        super(TestDockerPlugin, self).setUp()

        self.blueprint_path = \
            os.path.join(os.path.dirname(__file__),
                         'resources', 'blueprint.yaml')

        inputs = {
            'current_ip': '0.0.0.0/0',
            'external_network_name': self.env.external_network_name,
            'image_id': self.env.ubuntu_trusty_image_id,
            'flavor_id': self.env.small_flavor_id,
            'key_name': self.docker_host_key_name,
            'private_key_path': self.docker_host_key_path,
            'core_branch': self.core_branch,
            'plugins_branch': self.plugins_branch,
            'docker_plugin_branch': self.docker_plugin_branch,
            'agent_user': '******',
            'openstack_config': {
                'username': self.env.keystone_username,
                'password': self.env.keystone_password,
                'tenant_name': self.env.keystone_tenant_name,
                'auth_url': self.env.keystone_url
            }
        }

        self.env = local.init_env(
            self.blueprint_path, name=self._testMethodName,
            inputs=inputs,
            ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)
    def test_no_interfaces(self):
        blueprint = os.path.join(self.blueprints_path,
                                 'no-interfaces-blueprint.yaml')

        if self.env.install_plugins:
            self.logger.info('installing required plugins')
            self.cfy.install_plugins_locally(blueprint_path=blueprint)

        self.logger.info('Deploying linux host with no interfaces attached')

        self.no_interfaces_env = local.init_env(
            blueprint,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)
        self.no_interfaces_env.execute(
            'install',
            task_retries=50,
            task_retry_interval=3,
        )

        runtime_properties = get_runtime_props(
            target_node_id='testserver',
            node_instances=(
                self.no_interfaces_env.storage.get_node_instances()),
            logger=self.logger,
        )

        self.addCleanup(
            self.generic_cleanup,
            self.no_interfaces_env,
        )

        assert runtime_properties['public_ip'] is None
        assert runtime_properties['ip'] is None
    def boot(self):
        """
        Boots up the file server vm.
        :return:
        """
        self.logger.info('Initializing file server env')
        self.local_env = local.init_env(self.blueprint_path,
                                        inputs=self.inputs,
                                        name='File-Server',
                                        ignored_modules=cli_constants.
                                        IGNORED_LOCAL_WORKFLOW_MODULES)

        self.logger.info('Starting up a file server vm')
        self.local_env.execute('install', task_retries=40,
                               task_retry_interval=30)

        self.fab_env_conf = {
            'user': '******',
            'key_filename': self.inputs['key_pair_path'],
            'host_string': self.local_env.outputs()['vm_public_ip_address'],
            'timeout': 30,
            'connection_attempts': 10,
            'abort_on_prompts': True
        }

        self.fs_base_url = '{0}:{1}'.format(self.fab_env_conf['host_string'],
                                            FILE_SERVER_PORT)
        wait_for_connection(self.fab_env_conf,
                            self._execute_command,
                            self.logger)
示例#47
0
    def boot(self):
        """
        Boots up the file server vm.
        :return:
        """
        self.logger.info('Initializing file server env')
        self.local_env = local.init_env(
            self.blueprint_path,
            inputs=self.inputs,
            name='File-Server',
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self.logger.info('Starting up a file server vm')
        self.local_env.execute('install',
                               task_retries=40,
                               task_retry_interval=30)

        self.fab_env_conf = {
            'user': '******',
            'key_filename': self.inputs['key_pair_path'],
            'host_string': self.local_env.outputs()['vm_public_ip_address'],
            'timeout': 30,
            'connection_attempts': 10,
            'abort_on_prompts': True
        }

        self.fs_base_url = '{0}:{1}'.format(self.fab_env_conf['host_string'],
                                            FILE_SERVER_PORT)
        wait_for_connection(self.fab_env_conf, self._execute_command,
                            self.logger)
    def test_cluster(self):
        blueprint = os.path.join(
            self.blueprints_path,
            'cluster-blueprint.yaml'
        )

        inputs = copy(self.ext_inputs)
        inputs['test_cluster_name'] = 'systestSHOULDNOTCREATETHIS'

        self.cluster_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        try:
            self.cluster_env.execute('install')
            self.cluster_env.execute('uninstall',
                                     task_retries=50)
            raise AssertionError(
                'Attempting to create cluster: {name} '
                'should fail, but succeeded!'.format(
                    target=inputs['test_cluster_name'],
                )
            )
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'cannot currently be created' in err.message
            self.logger.info('Create cluster has correct error.')
示例#49
0
    def test_install_new_agent(self):
        agent_name = utils.internal.generate_agent_name()

        blueprint_path = resources.get_resource(
            'blueprints/install-new-agent/install-new-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        inputs = {'name': agent_name, 'ssl_cert_path': self._rest_cert_path}

        # Necessary to patch this method, because by default port 80 is used
        def http_rest_host():
            return os.environ[constants.MANAGER_FILE_SERVER_URL_KEY]

        # Necessary to patch, because by default https will be used
        def file_server_url(*args, **kwargs):
            return '{0}/resources'.format(http_rest_host())

        with self._manager_env():
            with patch('cloudify_agent.api.utils.get_manager_file_server_url',
                       file_server_url):
                env = local.init_env(name=self._testMethodName,
                                     blueprint_path=blueprint_path,
                                     inputs=inputs)
                with patch('cloudify_agent.operations._http_rest_host',
                           http_rest_host):
                    env.execute('install', task_retries=0)
            self.assert_daemon_alive(name=agent_name)
            agent_dict = self.get_agent_dict(env, 'new_agent_host')
            agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])
            new_agent_name = agent_dict['name']
            self.assertNotEqual(new_agent_name, agent_name)
            self.assert_daemon_alive(name=new_agent_name)
            env.execute('uninstall', task_retries=1)
            self.wait_for_daemon_dead(name=agent_name)
            self.wait_for_daemon_dead(name=new_agent_name)
示例#50
0
    def _run(self,
             script_path,
             process=None,
             workflow_name='execute_operation',
             parameters=None,
             env_var='value',
             task_retries=0):

        process = process or {}
        process.update({'ctx_proxy_type': self.ctx_proxy_type})

        inputs = {
            'script_path': script_path,
            'process': process,
            'env_var': env_var
        }
        blueprint_path = os.path.join(os.path.dirname(__file__), 'blueprint',
                                      'blueprint.yaml')
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=inputs)
        result = self.env.execute(workflow_name,
                                  parameters=parameters,
                                  task_retries=task_retries,
                                  task_retry_interval=0)
        if not result:
            result = self.env.storage.get_node_instances(
            )[0]['runtime_properties']
        return result
示例#51
0
    def test_install_new_agent(self):
        agent_name = utils.internal.generate_agent_name()

        blueprint_path = resources.get_resource(
            'blueprints/install-new-agent/install-new-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        inputs = {'name': agent_name, 'ssl_cert_path': self._rest_cert_path}

        # Necessary to patch this method, because by default port 80 is used
        def get_script_url(agent_self):
            return urljoin(os.environ[constants.MANAGER_FILE_SERVER_URL_KEY],
                           'cloudify_agent', agent_self._script_filename)

        with self._manager_env():
            env = local.init_env(name=self._testMethodName,
                                 blueprint_path=blueprint_path,
                                 inputs=inputs)
            with patch(
                    'cloudify_agent.operations.'
                    'AgentFilesGenerator._get_script_url', get_script_url):
                env.execute('install', task_retries=0)
            self.assert_daemon_alive(name=agent_name)
            agent_dict = self.get_agent_dict(env, 'new_agent_host')
            agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])
            new_agent_name = agent_dict['name']
            self.assertNotEqual(new_agent_name, agent_name)
            self.assert_daemon_alive(name=new_agent_name)
            env.execute('uninstall', task_retries=1)
            self.wait_for_daemon_dead(name=agent_name)
            self.wait_for_daemon_dead(name=new_agent_name)
    def _run(self, script_path,
             process=None,
             workflow_name='execute_operation',
             parameters=None):

        process = process or {}
        process.update({
            'ctx_proxy_type': self.ctx_proxy_type
        })

        inputs = {
            'script_path': script_path,
            'process': process
        }
        blueprint_path = os.path.join(os.path.dirname(__file__),
                                      'blueprint', 'blueprint.yaml')
        self.env = local.init_env(blueprint_path,
                                  name=self._testMethodName,
                                  inputs=inputs)
        result = self.env.execute(workflow_name,
                                  parameters=parameters,
                                  task_retries=0)
        if not result:
            result = self.env.storage.get_node_instances()[0][
                'runtime_properties']
        return result
示例#53
0
    def test_not_existing_datacenter(self):
        blueprint = os.path.join(self.blueprints_path,
                                 'existing-datacenter-blueprint.yaml')

        inputs = copy(self.ext_inputs)
        inputs['test_datacenter_name'] = 'systestTHISSHOULDNOTBEEXISTING'

        self.datacenter_not_existing_env = local.init_env(
            blueprint,
            inputs=inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        try:
            self.datacenter_not_existing_env.execute('install')
            self.datacenter_not_existing_env.execute('uninstall',
                                                     task_retries=50)
            raise AssertionError(
                'Attempting to use existing datacenter: {name} '
                'should fail, but succeeded!'.format(
                    target=inputs['test_datacenter_name'], ))
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'not use existing' in err.message
            assert inputs['test_datacenter_name'] in err.message
            assert 'no datacenter by that name exists' in err.message
            self.logger.info('Use non-existing datacenter with '
                             'use_external_resource has correct error.')
 def setUp(self):
   blueprint_path = os.path.join(os.path.dirname(__file__),
                                 'blueprint', 'test_rundeck.yaml')
   inputs = {}
   self.env = local.init_env(blueprint_path,
                             name=self._testMethodName,
                             inputs=inputs)
    def test_no_password_fails(self):
        blueprint = os.path.join(
            self.blueprints_path,
            'no_password-blueprint.yaml'
        )

        self.logger.info('Deploying windows host with no password set')

        self.no_password_fail_env = local.init_env(
            blueprint,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)
        try:
            self.no_password_fail_env.execute('install')
            self.no_password_fail_env.execute('uninstall', task_retries=50)
            raise AssertionError(
                'Windows deployment should fail with no password, '
                'but it succeeded.'
            )
        except RuntimeError as err:
            # Ensure the error message has pertinent information
            assert 'Windows' in err.message
            assert 'password must be set' in err.message
            assert 'properties.windows_password' in err.message
            assert 'properties.agent_config.password' in err.message
            self.logger.info('Windows passwordless deploy has correct error.')
    def boot(self):
        """
        Boots up the file server vm.
        :return:
        """
        self.logger.info("Initializing file server env")
        self.local_env = local.init_env(
            self.blueprint_path,
            inputs=self.inputs,
            name="File-Server",
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES,
        )

        self.logger.info("Starting up a file server vm")
        self.local_env.execute("install", task_retries=40, task_retry_interval=30)

        self.fab_env_conf = {
            "user": "******",
            "key_filename": self.inputs["key_pair_path"],
            "host_string": self.local_env.outputs()["vm_public_ip_address"],
            "timeout": 30,
            "connection_attempts": 10,
            "abort_on_prompts": True,
        }

        self.fs_base_url = "{0}:{1}".format(self.fab_env_conf["host_string"], FILE_SERVER_PORT)
示例#57
0
 def _test(self, storage=None):
     blueprint_path = os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         'resources/blueprints/get_attribute.yaml')
     self.env = local.init_env(blueprint_path, storage=storage)
     self.env.execute('setup', task_retries=0)
     self.env.execute('run', task_retries=0)
    def test_windows_basic_config(self):
        blueprint = os.path.join(
            self.blueprints_path,
            'windows_basic_config-blueprint.yaml'
        )

        self.logger.info(
            'Deploying windows host with '
            'password and timezone set'
        )

        self.windows_basic_config_env = local.init_env(
            blueprint,
            inputs=self.ext_inputs,
            name=self._testMethodName,
            ignored_modules=cli_constants.IGNORED_LOCAL_WORKFLOW_MODULES)

        self._add_env_cleanup(self.windows_basic_config_env)
        self.windows_basic_config_env.execute(
            'install',
            task_retries=50,
            task_retry_interval=3,
        )

        self._wait_for_customization_to_complete(
            self.windows_basic_config_env.outputs()['vm_name'],
        )

        vt = WindowsCommandHelper(
            self.logger,
            self.ext_inputs['vsphere_host'],
            self.ext_inputs['vsphere_username'],
            self.ext_inputs['vsphere_password'],
        )

        value = vt.run_windows_command(
            self.windows_basic_config_env.outputs()['vm_name'],
            'administrator',
            self.ext_inputs['vm_password'],
            'reg query "HKLM\\Software\\Microsoft\\Windows NT\\'
            'CurrentVersion" /v RegisteredOrganization',
            timeout=1500,
        )['output']

        self.assertEqual(
            'Cloudify Test',
            value.split('REG_SZ')[1].strip())

        tz_value = vt.run_windows_command(
            self.windows_basic_config_env.outputs()['vm_name'],
            'administrator',
            self.ext_inputs['vm_password'],
            'reg query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\'
            'TimeZoneInformation" /v TimeZoneKeyName',
        )['output']

        self.assertEqual(
            'Mountain Standard Time',
            tz_value.split('REG_SZ')[1].strip())
    def test_install_agent(self):
        blueprint_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            "resources/blueprints/test-install-agent-blueprint.yaml")

        with ExpectedException(ValueError,
                               "'install_agent': true is not supported*"):
            self.env = local.init_env(blueprint_path)
 def with_bad_id(self, blueprint, resources, bad_input_name,
                 bad_input_value):
     inputs = self.get_blueprint_inputs(resources)
     inputs.update({bad_input_name: bad_input_value})
     return local.init_env(blueprint,
                           name=self._testMethodName,
                           inputs=inputs,
                           ignored_modules=IGNORED_LOCAL_WORKFLOW_MODULES)