def _provision_pool(self):

        self.password_pool_host = util.generate_password()

        def _render_password_authentication_script():

            script_template = resources.get_resource(
                'enable_password_authentication.sh.template')
            return util.render_template(
                template_path=script_template,
                password=self.password_pool_host)

        blueprint_path = resources.get_resource(
            'pool-blueprint/pool-blueprint.yaml')
        self.blueprint_yaml = blueprint_path

        blueprint_id = '{0}-pool-blueprint'.format(self.test_id)
        deployment_id = '{0}-pool-deployment'.format(self.test_id)

        script = _render_password_authentication_script()

        self.upload_deploy_and_execute_install(
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            inputs={
                'image': self.env.ubuntu_trusty_image_id,
                'flavor': self.env.small_flavor_id,
                'enable_password_authentication_script': script
            }
        )
        self.pool_deployment_id = deployment_id
        def _render_password_authentication_script():

            script_template = resources.get_resource(
                'enable_password_authentication.sh.template')
            return util.render_template(
                template_path=script_template,
                password=self.password_pool_host)
示例#3
0
        def _render_password_authentication_script():

            script_template = resources.get_resource(
                'enable_password_authentication.sh.template')
            return util.render_template(
                template_path=script_template,
                password=self.password_pool_host)
    def _provision_pool(self):

        self.password_pool_host = util.generate_password()

        def _render_password_authentication_script():

            script_template = resources.get_resource(
                'enable_password_authentication.sh.template')
            return util.render_template(template_path=script_template,
                                        password=self.password_pool_host)

        blueprint_path = resources.get_resource(
            'pool-blueprint/pool-blueprint.yaml')
        self.blueprint_yaml = blueprint_path

        blueprint_id = '{0}-pool-blueprint'.format(self.test_id)
        deployment_id = '{0}-pool-deployment'.format(self.test_id)

        script = _render_password_authentication_script()

        self.upload_deploy_and_execute_install(
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            inputs={
                'image': self.env.ubuntu_trusty_image_id,
                'flavor': self.env.small_flavor_id,
                'enable_password_authentication_script': script
            })
        self.pool_deployment_id = deployment_id
    def _install_host_pool_service(self):
        def _render_pool(_runtime_blueprint_directory):

            hosts = self.client.deployments.outputs.get(
                deployment_id=self.pool_deployment_id).outputs['hosts']

            pool_template = resources.get_resource(
                'host-pool-service-blueprint/pool.yaml.template')
            util.render_template_to_file(
                template_path=pool_template,
                file_path=os.path.join(_runtime_blueprint_directory,
                                       'pool.yaml'),
                ip_pool_host_1=hosts['host_1']['ip'],
                ip_pool_host_2=hosts['host_2']['ip'],
                public_address_pool_host_1=hosts['host_1']['public_address'],
                public_address_pool_host_2=hosts['host_2']['public_address'],
                password_pool_host=self.password_pool_host)

        def _render_agent_key(_runtime_blueprint_directory):

            with open(
                    util.get_actual_keypath(self.env,
                                            self.env.agent_key_path)) as f:
                key_content = f.read()

            key_template = resources.get_resource(
                'host-pool-service-blueprint/keys/agent_key.pem.template')
            util.render_template_to_file(
                template_path=key_template,
                file_path=os.path.join(_runtime_blueprint_directory, 'keys',
                                       'agent_key.pem'),
                agent_private_key_file_content=key_content)

        # copy directory outside of source control since
        # we will be adding files to it.
        blueprint_directory = resources.get_resource(
            'host-pool-service-blueprint')
        runtime_blueprint_directory = os.path.join(
            self.workdir, 'host-pool-service-blueprint')
        shutil.copytree(src=blueprint_directory,
                        dst=runtime_blueprint_directory)

        _render_pool(runtime_blueprint_directory)
        _render_agent_key(runtime_blueprint_directory)

        self.blueprint_yaml = os.path.join(
            runtime_blueprint_directory,
            'openstack-host-pool-service-blueprint.yaml')

        blueprint_id = '{0}-host-pool-service-blueprint'.format(self.test_id)
        deployment_id = '{0}-host-pool-service-deployment'.format(self.test_id)
        self.upload_deploy_and_execute_install(
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            inputs={
                'image': self.env.ubuntu_trusty_image_id,
                'flavor': self.env.small_flavor_id
            })

        self.host_pool_service_deployment_id = deployment_id
    def test_winrm_agent(self):

        self.blueprint_yaml = resources.get_resource("winrm-agent-blueprint/winrm-agent-blueprint.yaml")
        self.upload_deploy_and_execute_install(
            inputs={"image": self.env.windows_image_id, "flavor": self.env.medium_flavor_id}
        )
        self.execute_uninstall()
    def test_ssh_agent(self):

        self.blueprint_yaml = resources.get_resource("ssh-agent-blueprint/ssh-agent-blueprint.yaml")
        self.upload_deploy_and_execute_install(
            inputs={"image": self.env.ubuntu_image_id, "flavor": self.env.small_flavor_id}
        )
        self.execute_uninstall()
    def test_ssh_agent(self):

        self.blueprint_yaml = resources.get_resource(
            'ssh-agent-blueprint/ssh-agent-blueprint.yaml')
        self.upload_deploy_and_execute_install(
            inputs={
                'image': self.env.ubuntu_trusty_image_id,
                'flavor': self.env.small_flavor_id
            }
        )
        self.execute_uninstall()
    def test_3_2_agent(self):

        self.blueprint_yaml = resources.get_resource(
            '3-2-agent-blueprint/3-2-agent-mispelled-blprint.yaml')
        self.upload_deploy_and_execute_install(
            inputs={
                'image': self.env.ubuntu_image_id,
                'flavor': self.env.small_flavor_id
            }
        )
        self.execute_uninstall()
    def test_userdata_agent(self):

        self.blueprint_yaml = resources.get_resource("userdata-agent-blueprint/userdata-agent-blueprint.yaml")
        self.upload_deploy_and_execute_install(
            inputs={
                "image": self.env.ubuntu_image_id,
                "flavor": self.env.small_flavor_id,
                "branch": os.environ.get("BRANCH_NAME_CORE", "master"),
            }
        )
        self.execute_uninstall()
    def test_winrm_agent(self):

        self.blueprint_yaml = resources.get_resource(
            'winrm-agent-blueprint/winrm-agent-blueprint.yaml')
        self.upload_deploy_and_execute_install(
            inputs={
                'image': self.env.windows_image_name,
                'flavor': self.env.medium_flavor_id
            }
        )
        self.execute_uninstall()
    def test_userdata_agent(self):

        self.blueprint_yaml = resources.get_resource(
            'userdata-agent-blueprint/userdata-agent-blueprint.yaml')
        self.upload_deploy_and_execute_install(
            inputs={
                'image': self.env.ubuntu_image_id,
                'flavor': self.env.small_flavor_id,
                'branch': os.environ.get('BRANCH_NAME_CORE', 'master')
            }
        )
        self.execute_uninstall()
        def _render_agent_key(_runtime_blueprint_directory):

            with open(
                    util.get_actual_keypath(self.env,
                                            self.env.agent_key_path)) as f:
                key_content = f.read()

            key_template = resources.get_resource(
                'host-pool-service-blueprint/keys/agent_key.pem.template')
            util.render_template_to_file(
                template_path=key_template,
                file_path=os.path.join(_runtime_blueprint_directory, 'keys',
                                       'agent_key.pem'),
                agent_private_key_file_content=key_content)
        def _render_pool(_runtime_blueprint_directory):

            hosts = self.client.deployments.outputs.get(
                deployment_id=self.pool_deployment_id).outputs['hosts']

            pool_template = resources.get_resource(
                'host-pool-service-blueprint/pool.yaml.template')
            util.render_template_to_file(
                template_path=pool_template,
                file_path=os.path.join(_runtime_blueprint_directory,
                                       'pool.yaml'),
                ip_pool_host_1=hosts['host_1']['ip'],
                ip_pool_host_2=hosts['host_2']['ip'],
                public_address_pool_host_1=hosts['host_1']['public_address'],
                public_address_pool_host_2=hosts['host_2']['public_address'],
                password_pool_host=self.password_pool_host)
        def _render_agent_key(_runtime_blueprint_directory):

            with open(util.get_actual_keypath(
                    self.env,
                    self.env.agent_key_path)) as f:
                key_content = f.read()

            key_template = resources.get_resource(
                'host-pool-service-blueprint/keys/agent_key.pem.template')
            util.render_template_to_file(
                template_path=key_template,
                file_path=os.path.join(
                    _runtime_blueprint_directory,
                    'keys',
                    'agent_key.pem'),
                agent_private_key_file_content=key_content
            )
        def _render_pool(_runtime_blueprint_directory):

            hosts = self.client.deployments.outputs.get(
                deployment_id=self.pool_deployment_id).outputs['hosts']

            pool_template = resources.get_resource(
                'host-pool-service-blueprint/pool.yaml.template')
            util.render_template_to_file(
                template_path=pool_template,
                file_path=os.path.join(
                    _runtime_blueprint_directory,
                    'pool.yaml'),
                ip_pool_host_1=hosts['host_1']['ip'],
                ip_pool_host_2=hosts['host_2']['ip'],
                public_address_pool_host_1=hosts['host_1']['public_address'],
                public_address_pool_host_2=hosts['host_2']['public_address'],
                password_pool_host=self.password_pool_host
            )
 def _test_userdata_agent(self, image, flavor, user, os_family,
                          userdata, file_path, install_method,
                          name=None):
     self.blueprint_yaml = resources.get_resource(
         'userdata-agent-blueprint/userdata-agent-blueprint.yaml')
     self.upload_deploy_and_execute_install(
         inputs={
             'image': image,
             'flavor': flavor,
             'agent_user': user,
             'os_family': os_family,
             'userdata': userdata,
             'file_path': file_path,
             'install_method': install_method,
             'name': name
         }
     )
     self.assert_outputs({'MY_ENV_VAR': 'MY_ENV_VAR_VALUE',
                          'file_content': self.expected_file_content})
     self.execute_uninstall()
    def _test_agent_alive_after_reboot(self, blueprint, inputs):

        self.blueprint_yaml = resources.get_resource(blueprint)
        value = str(uuid.uuid4())
        inputs['value'] = value
        deployment_id = self.test_id
        self.upload_deploy_and_execute_install(
            deployment_id=deployment_id,
            inputs=inputs)
        self.cfy.execute_workflow(
            workflow='execute_operation',
            deployment_id=deployment_id,
            parameters={
                'operation': 'cloudify.interfaces.reboot_test.reboot',
                'node_ids': ['host']
            },
            include_logs=True)
        self.execute_uninstall(deployment_id=deployment_id)
        app = self.client.node_instances.list(node_id='application',
                                              deployment_id=deployment_id)[0]
        self.assertEquals(value, app.runtime_properties['value'])
    def _install_host_pool_service(self):

        def _render_pool(_runtime_blueprint_directory):

            hosts = self.client.deployments.outputs.get(
                deployment_id=self.pool_deployment_id).outputs['hosts']

            pool_template = resources.get_resource(
                'host-pool-service-blueprint/pool.yaml.template')
            util.render_template_to_file(
                template_path=pool_template,
                file_path=os.path.join(
                    _runtime_blueprint_directory,
                    'pool.yaml'),
                ip_pool_host_1=hosts['host_1']['ip'],
                ip_pool_host_2=hosts['host_2']['ip'],
                public_address_pool_host_1=hosts['host_1']['public_address'],
                public_address_pool_host_2=hosts['host_2']['public_address'],
                password_pool_host=self.password_pool_host
            )

        def _render_agent_key(_runtime_blueprint_directory):

            with open(util.get_actual_keypath(
                    self.env,
                    self.env.agent_key_path)) as f:
                key_content = f.read()

            key_template = resources.get_resource(
                'host-pool-service-blueprint/keys/agent_key.pem.template')
            util.render_template_to_file(
                template_path=key_template,
                file_path=os.path.join(
                    _runtime_blueprint_directory,
                    'keys',
                    'agent_key.pem'),
                agent_private_key_file_content=key_content
            )

        # copy directory outside of source control since
        # we will be adding files to it.
        blueprint_directory = resources.get_resource(
            'host-pool-service-blueprint')
        runtime_blueprint_directory = os.path.join(
            self.workdir, 'host-pool-service-blueprint')
        shutil.copytree(src=blueprint_directory,
                        dst=runtime_blueprint_directory)

        _render_pool(runtime_blueprint_directory)
        _render_agent_key(runtime_blueprint_directory)

        self.blueprint_yaml = os.path.join(
            runtime_blueprint_directory,
            'openstack-host-pool-service-blueprint.yaml'
        )

        blueprint_id = '{0}-host-pool-service-blueprint'.format(self.test_id)
        deployment_id = '{0}-host-pool-service-deployment'.format(
            self.test_id)
        self.upload_deploy_and_execute_install(
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            inputs={
                'image': self.env.ubuntu_trusty_image_id,
                'flavor': self.env.small_flavor_id
            }
        )

        self.host_pool_service_deployment_id = deployment_id