コード例 #1
0
    def create_component(self, staged_component_path, application_name, component, properties):
        logging.debug("create_component: %s %s %s", application_name, json.dumps(component), properties)

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = self._environment['jupyter_host']
        application_user = properties['application_user']
        delete_commands = []

        mkdircommands = []
        remote_component_tmp_path = '%s/%s/%s/%s' % ('/tmp/%s' % self._namespace, application_user, application_name, component['component_name'])
        remote_notebook_path = '/home/%s/%s' % (application_user, self._environment['jupyter_notebook_directory'])
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo -u %s mkdir -p %s' % (application_user, remote_notebook_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, mkdircommands)

        file_list = component['component_detail']
        for file_name in file_list:
            if file_name.endswith(r'.ipynb'):
                self._fill_properties('%s/%s' % (staged_component_path, file_name), properties)
                logging.debug('Copying %s/* to %s:%s', staged_component_path, target_host, remote_component_tmp_path)
                os.system("scp -i %s -o StrictHostKeyChecking=no %s/%s %s@%s:%s" %
                          (key_file, staged_component_path, file_name, root_user, target_host, remote_component_tmp_path))

                remote_component_install_path = '%s/%s_%s' % (remote_notebook_path, application_name, file_name)
                deployer_utils.exec_ssh(
                    target_host, root_user, key_file,
                    ['sudo mv %s %s' % (remote_component_tmp_path + '/*.ipynb', remote_component_install_path)])
                delete_commands.append('sudo rm -rf %s\n' % remote_component_install_path)

        logging.debug("uninstall commands: %s", delete_commands)
        return {'delete_commands': delete_commands}
コード例 #2
0
 def destroy_component(self, application_name, create_data):
     logging.debug("destroy_component: %s %s", application_name,
                   json.dumps(create_data))
     key_file = self._environment['cluster_private_key']
     root_user = self._environment['cluster_root_user']
     target_host = self._environment['jupyter_host']
     deployer_utils.exec_ssh(target_host, root_user, key_file,
                             create_data['delete_commands'])
コード例 #3
0
def create(descriptor_path, environment):
    with open(descriptor_path) as descriptor_file:
        contents = descriptor_file.read()
        descriptor = json.loads(contents)

    logging.debug('_deploy_opentsdb: %s', descriptor)

    cmds = []
    for element in descriptor:
        if 'name' in element:
            cmds.append('sudo /usr/share/opentsdb/bin/tsdb mkmetric %s' % element['name'])

    key_file = environment['cluster_private_key']
    root_user = environment['cluster_root_user']
    target_host = environment['opentsdb'].split(':')[0]
    deployer_utils.exec_ssh(target_host, root_user, key_file, cmds)
コード例 #4
0
def create(descriptor_path, environment):
    with open(descriptor_path) as descriptor_file:
        contents = descriptor_file.read()
        descriptor = json.loads(contents)

    logging.debug('_deploy_opentsdb: %s', descriptor)

    cmds = []
    for element in descriptor:
        if 'name' in element:
            cmds.append('sudo /usr/share/opentsdb/bin/tsdb mkmetric %s' %
                        element['name'])

    key_file = environment['cluster_private_key']
    root_user = environment['cluster_root_user']
    target_host = environment['opentsdb'].split(':')[0]
    deployer_utils.exec_ssh(target_host, root_user, key_file, cmds)
コード例 #5
0
    def create_component(self, staged_component_path, application_name,
                         component, properties):
        logging.debug("create_component: %s %s %s", application_name,
                      json.dumps(component), properties)
        distro = platform.dist()
        usesSystemd = distro[0] in ('redhat', 'centos')
        remote_component_tmp_path = '%s/%s/%s' % ('/tmp/%s' % self._namespace,
                                                  application_name,
                                                  component['component_name'])
        remote_component_install_path = '%s/%s/%s' % (
            '/opt/%s' % self._namespace, application_name,
            component['component_name'])
        service_name = '%s-%s-%s' % (self._namespace, application_name,
                                     component['component_name'])

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = 'localhost'

        if 'component_spark_submit_args' not in properties:
            properties['component_spark_submit_args'] = ''
        if 'component_py_files' not in properties:
            properties['component_py_files'] = ''

        if 'upstart.conf' in component['component_detail']:
            # old style applications for backward compatibility
            service_script = 'upstart.conf'
            service_script_install_path = '/etc/init/%s.conf' % service_name
        else:
            # new style applications that don't need to provide upstart.conf or yarn-kill.py
            if 'component_main_jar' in properties and 'component_main_class' not in properties:
                raise Exception(
                    'properties.json must contain "main_class" for %s sparkStreaming %s'
                    % (application_name, component['component_name']))

            java_app = None
            if 'component_main_jar' in properties:
                java_app = True
            elif 'component_main_py' in properties:
                java_app = False
            else:
                raise Exception(
                    'properties.json must contain "main_jar or main_py" for %s sparkStreaming %s'
                    % (application_name, component['component_name']))

            this_dir = os.path.dirname(os.path.realpath(__file__))
            copy(os.path.join(this_dir, 'yarn-kill.py'), staged_component_path)
            if usesSystemd:
                service_script = 'systemd.service.tpl' if java_app else 'systemd.service.py.tpl'
                service_script_install_path = '/usr/lib/systemd/system/%s.service' % service_name
            else:
                service_script = 'upstart.conf.tpl' if java_app else 'upstart.conf.py.tpl'
                service_script_install_path = '/etc/init/%s.conf' % service_name
            copy(os.path.join(this_dir, service_script), staged_component_path)

        self._fill_properties(
            os.path.join(staged_component_path, service_script), properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'log4j.properties'),
            properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'application.properties'),
            properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'yarn-kill.py'), properties)

        mkdircommands = []
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo mkdir -p %s' %
                             remote_component_install_path)
        deployer_utils.exec_ssh(target_host, root_user, key_file,
                                mkdircommands)

        os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                  (key_file, staged_component_path + '/*', root_user,
                   target_host, remote_component_tmp_path))

        for node in self._environment['yarn_node_managers'].split(','):
            deployer_utils.exec_ssh(
                node, root_user, key_file,
                ['mkdir -p %s' % remote_component_tmp_path])
            os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                      (key_file, staged_component_path + '/log4j.properties',
                       root_user, node,
                       remote_component_tmp_path + '/log4j.properties'))
            deployer_utils.exec_ssh(node, root_user, key_file, [
                'sudo mkdir -p %s' % remote_component_install_path,
                'sudo mv %s %s' %
                (remote_component_tmp_path + '/log4j.properties',
                 remote_component_install_path + '/log4j.properties')
            ])

        if 'component_main_py' in properties:
            main_jar_name = None
        if 'component_main_jar' in properties:
            main_jar_name = properties['component_main_jar']
        else:
            main_jar_name = '*.jar'

        commands = []
        commands.append('sudo cp %s/%s %s' %
                        (remote_component_tmp_path, service_script,
                         service_script_install_path))
        commands.append(
            'sudo cp %s/* %s' %
            (remote_component_tmp_path, remote_component_install_path))
        commands.append('sudo chmod a+x %s/yarn-kill.py' %
                        (remote_component_install_path))
        if main_jar_name is not None:
            commands.append('cd %s && sudo jar uf %s application.properties' %
                            (remote_component_install_path, main_jar_name))
        commands.append('sudo rm -rf %s' % (remote_component_tmp_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, commands)

        undo_commands = []
        undo_commands.append('sudo service %s stop\n' % service_name)
        undo_commands.append('sudo rm -rf %s\n' %
                             remote_component_install_path)
        undo_commands.append('sudo rm  %s\n' % service_script_install_path)
        logging.debug("uninstall commands: %s", undo_commands)

        start_commands = []
        if usesSystemd:
            start_commands.append('sudo systemctl daemon-reload\n')
        start_commands.append('sudo service %s start\n' % service_name)
        logging.debug("start commands: %s", start_commands)

        stop_commands = []
        stop_commands.append('sudo service %s stop\n' % service_name)
        logging.debug("stop commands: %s", stop_commands)

        return {
            'ssh': undo_commands,
            'start_cmds': start_commands,
            'stop_cmds': stop_commands
        }
コード例 #6
0
 def _control_component(self, cmds):
     key_file = self._environment['cluster_private_key']
     root_user = self._environment['cluster_root_user']
     target_host = 'localhost'
     deployer_utils.exec_ssh(target_host, root_user, key_file, cmds)
コード例 #7
0
 def exec_cmds(self, exec_commands):
     key_file = self._environment['cluster_private_key']
     root_user = self._environment['cluster_root_user']
     target_host = 'localhost'
     deployer_utils.exec_ssh(target_host, root_user, key_file,
                             exec_commands)
コード例 #8
0
    def create_component(self, staged_component_path, application_name, component, properties):
        logging.debug("create_component: %s %s %s", application_name, json.dumps(component), properties)
        distro = platform.dist()
        usesSystemd = distro[0] in ('redhat', 'centos')
        remote_component_tmp_path = '%s/%s/%s' % (
            '/tmp/%s' % self._namespace, application_name, component['component_name'])
        remote_component_install_path = '%s/%s/%s' % (
            '/opt/%s' % self._namespace, application_name, component['component_name'])
        service_name = '%s-%s-%s' % (self._namespace, application_name, component['component_name'])

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = 'localhost'

        if 'component_spark_submit_args' not in properties:
            properties['component_spark_submit_args'] = ''
        if 'component_py_files' not in properties:
            properties['component_py_files'] = ''

        if 'upstart.conf' in component['component_detail']:
            # old style applications for backward compatibility
            service_script = 'upstart.conf'
            service_script_install_path = '/etc/init/%s.conf' % service_name
        else:
            # new style applications that don't need to provide upstart.conf or yarn-kill.py
            if 'component_main_jar' in properties and 'component_main_class' not in properties:
                raise Exception('properties.json must contain "main_class" for %s sparkStreaming %s' % (application_name, component['component_name']))

            java_app = None
            if 'component_main_jar' in properties:
                java_app = True
            elif 'component_main_py' in properties:
                java_app = False
            else:
                raise Exception('properties.json must contain "main_jar or main_py" for %s sparkStreaming %s' % (application_name, component['component_name']))

            this_dir = os.path.dirname(os.path.realpath(__file__))
            copy(os.path.join(this_dir, 'yarn-kill.py'), staged_component_path)
            if usesSystemd:
                service_script = 'systemd.service.tpl' if java_app else 'systemd.service.py.tpl'
                service_script_install_path = '/usr/lib/systemd/system/%s.service' % service_name
            else:
                service_script = 'upstart.conf.tpl' if java_app else 'upstart.conf.py.tpl'
                service_script_install_path = '/etc/init/%s.conf' % service_name
            copy(os.path.join(this_dir, service_script), staged_component_path)

        self._fill_properties(os.path.join(staged_component_path, service_script), properties)
        self._fill_properties(os.path.join(staged_component_path, 'log4j.properties'), properties)
        self._fill_properties(os.path.join(staged_component_path, 'application.properties'), properties)
        self._fill_properties(os.path.join(staged_component_path, 'yarn-kill.py'), properties)

        mkdircommands = []
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo mkdir -p %s' % remote_component_install_path)
        deployer_utils.exec_ssh(target_host, root_user, key_file, mkdircommands)

        os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s"
                  % (key_file, staged_component_path + '/*', root_user, target_host, remote_component_tmp_path))

        for node in self._environment['yarn_node_managers'].split(','):
            deployer_utils.exec_ssh(node, root_user, key_file, ['mkdir -p %s' % remote_component_tmp_path])
            os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s"
                      % (key_file, staged_component_path + '/log4j.properties', root_user, node, remote_component_tmp_path + '/log4j.properties'))
            deployer_utils.exec_ssh(node, root_user, key_file,
                                    ['sudo mkdir -p %s' % remote_component_install_path,
                                     'sudo mv %s %s' % (remote_component_tmp_path + '/log4j.properties', remote_component_install_path + '/log4j.properties')])

        if 'component_main_py' in properties:
            main_jar_name = None
        if 'component_main_jar' in properties:
            main_jar_name = properties['component_main_jar']
        else:
            main_jar_name = '*.jar'

        commands = []
        commands.append('sudo cp %s/%s %s' % (remote_component_tmp_path, service_script, service_script_install_path))
        commands.append('sudo cp %s/* %s' % (remote_component_tmp_path, remote_component_install_path))
        commands.append('sudo chmod a+x %s/yarn-kill.py' % (remote_component_install_path))
        if main_jar_name is not None:
            commands.append('cd %s && sudo jar uf %s application.properties' % (remote_component_install_path, main_jar_name))
        commands.append('sudo rm -rf %s' % (remote_component_tmp_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, commands)

        undo_commands = []
        undo_commands.append('sudo service %s stop\n' % service_name)
        undo_commands.append('sudo rm -rf %s\n' % remote_component_install_path)
        undo_commands.append('sudo rm  %s\n' % service_script_install_path)
        logging.debug("uninstall commands: %s", undo_commands)

        start_commands = []
        if usesSystemd:
            start_commands.append('sudo systemctl daemon-reload\n')
        start_commands.append('sudo service %s start\n' % service_name)
        logging.debug("start commands: %s", start_commands)

        stop_commands = []
        stop_commands.append('sudo service %s stop\n' % service_name)
        logging.debug("stop commands: %s", stop_commands)

        return {'ssh': undo_commands, 'start_cmds': start_commands, 'stop_cmds': stop_commands}
コード例 #9
0
 def _control_component(self, cmds):
     key_file = self._environment['cluster_private_key']
     root_user = self._environment['cluster_root_user']
     target_host = 'localhost'
     deployer_utils.exec_ssh(target_host, root_user, key_file, cmds)
コード例 #10
0
    def create_component(self, staged_component_path, application_name,
                         component, properties):
        logging.debug("create_component: %s %s %s", application_name,
                      json.dumps(component), properties)

        remote_component_tmp_path = '%s/%s/%s' % ('/tmp/%s' % self._namespace,
                                                  application_name,
                                                  component['component_name'])
        remote_component_install_path = '%s/%s/%s' % (
            '/opt/%s' % self._namespace, application_name,
            component['component_name'])

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = 'localhost'

        self._fill_properties(
            '%s/%s' % (staged_component_path, 'upstart.conf'), properties)
        self._fill_properties(
            '%s/%s' % (staged_component_path, 'log4j.properties'), properties)
        self._fill_properties(
            '%s/%s' % (staged_component_path, 'application.properties'),
            properties)
        self._fill_properties(
            '%s/%s' % (staged_component_path, 'yarn-kill.py'), properties)

        mkdircommands = []
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo mkdir -p %s' %
                             remote_component_install_path)
        deployer_utils.exec_ssh(target_host, root_user, key_file,
                                mkdircommands)

        os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                  (key_file, staged_component_path + '/*', root_user,
                   target_host, remote_component_tmp_path))

        for node in self._environment['yarn_node_managers'].split(','):
            deployer_utils.exec_ssh(
                node, root_user, key_file,
                ['mkdir -p %s' % remote_component_tmp_path])
            os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                      (key_file, staged_component_path + '/log4j.properties',
                       root_user, node,
                       remote_component_tmp_path + '/log4j.properties'))
            deployer_utils.exec_ssh(node, root_user, key_file, [
                'sudo mkdir -p %s' % remote_component_install_path,
                'sudo mv %s %s' %
                (remote_component_tmp_path + '/log4j.properties',
                 remote_component_install_path + '/log4j.properties')
            ])

        commands = []
        service_name = '%s-%s-%s' % (self._namespace, application_name,
                                     component['component_name'])
        upstart_script = '/etc/init/%s.conf' % service_name
        commands.append('sudo cp %s/upstart.conf %s' %
                        (remote_component_tmp_path, upstart_script))
        commands.append(
            'sudo cp %s/* %s' %
            (remote_component_tmp_path, remote_component_install_path))
        commands.append('sudo chmod a+x %s/yarn-kill.py' %
                        (remote_component_install_path))
        commands.append('cd %s && sudo jar uf *.jar application.properties' %
                        (remote_component_install_path))
        commands.append('sudo rm -rf %s' % (remote_component_tmp_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, commands)

        undo_commands = []
        undo_commands.append('sudo initctl stop %s\n' % service_name)
        undo_commands.append('sudo rm -rf %s\n' %
                             remote_component_install_path)
        undo_commands.append('sudo rm  %s\n' % upstart_script)
        logging.debug("uninstall commands: %s", undo_commands)

        start_commands = []
        start_commands.append('sudo initctl start %s\n' % service_name)
        logging.debug("start commands: %s", start_commands)

        stop_commands = []
        stop_commands.append('sudo initctl stop %s\n' % service_name)
        logging.debug("stop commands: %s", stop_commands)

        return {
            'ssh': undo_commands,
            'start_cmds': start_commands,
            'stop_cmds': stop_commands
        }
コード例 #11
0
 def destroy_component(self, application_name, create_data):
     logging.debug("destroy_component: %s %s", application_name, json.dumps(create_data))
     key_file = self._environment['cluster_private_key']
     root_user = self._environment['cluster_root_user']
     target_host = self._environment['jupyter_host']
     deployer_utils.exec_ssh(target_host, root_user, key_file, create_data['delete_commands'])
コード例 #12
0
    def create_component(self, staged_component_path, application_name,
                         user_name, component, properties):
        logging.debug("create_component: %s %s %s %s", application_name,
                      user_name, json.dumps(component), properties)
        remote_component_tmp_path = '%s/%s/%s' % ('/tmp/%s' % self._namespace,
                                                  application_name,
                                                  component['component_name'])
        remote_component_install_path = '%s/%s/%s' % (
            '/opt/%s' % self._namespace, application_name,
            component['component_name'])
        service_name = '%s-%s-%s' % (self._namespace, application_name,
                                     component['component_name'])

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = 'localhost'

        if 'component_flink_version' not in properties:
            properties['component_flink_version'] = '1.4'
        if 'component_flink_config_args' not in properties:
            properties['component_flink_config_args'] = '-yn 1'
        if 'component_py_files' not in properties:
            properties['component_py_files'] = ''
        if 'component_flink_job_type' not in properties:
            properties['component_flink_job_type'] = 'streaming'
        if 'component_application_args' not in properties:
            properties['component_application_args'] = ''

        java_app = None
        if 'component_main_jar' in properties and 'component_main_class' in properties:
            java_app = True
        elif 'component_main_py' in properties:
            java_app = False
            flink_lib_dir = properties['environment_flink_lib_dir']
            for jar in os.listdir(flink_lib_dir):
                if os.path.isfile(os.path.join(flink_lib_dir,
                                               jar)) and 'flink-python' in jar:
                    properties['flink_python_jar'] = '%s/%s' % (flink_lib_dir,
                                                                jar)
        else:
            raise Exception(
                'properties.json must contain "main_jar or main_py" for %s flink %s'
                % (application_name, component['component_name']))

        this_dir = os.path.dirname(os.path.realpath(__file__))
        copy(os.path.join(this_dir, 'yarn-kill.py'), staged_component_path)
        service_script = 'flink.systemd.service.tpl' if java_app else 'flink.systemd.service.py.tpl'
        service_script_install_path = '/usr/lib/systemd/system/%s.service' % service_name
        if 'component_respawn_type' not in properties:
            if properties['component_flink_job_type'] == 'batch':
                properties['component_respawn_type'] = 'no'
            else:
                properties['component_respawn_type'] = 'always'

        if 'component_respawn_timeout_sec' not in properties:
            if properties['component_flink_job_type'] == 'batch':
                properties['component_respawn_timeout_sec'] = '0'
            else:
                properties['component_respawn_timeout_sec'] = '2'

        copy(os.path.join(this_dir, service_script), staged_component_path)

        self._fill_properties(
            os.path.join(staged_component_path, service_script), properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'application.properties'),
            properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'yarn-kill.py'), properties)

        mkdircommands = []
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo mkdir -p %s' %
                             remote_component_install_path)
        deployer_utils.exec_ssh(target_host, root_user, key_file,
                                mkdircommands)

        os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                  (key_file, staged_component_path + '/*', root_user,
                   target_host, remote_component_tmp_path))

        commands = []
        commands.append('sudo cp %s/%s %s' %
                        (remote_component_tmp_path, service_script,
                         service_script_install_path))
        commands.append(
            'sudo cp %s/* %s' %
            (remote_component_tmp_path, remote_component_install_path))
        commands.append('sudo chmod a+x %s/yarn-kill.py' %
                        (remote_component_install_path))

        if 'component_main_jar' in properties:
            commands.append('cd %s && sudo jar uf %s application.properties' %
                            (remote_component_install_path,
                             properties['component_main_jar']))
        commands.append('sudo rm -rf %s' % (remote_component_tmp_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, commands)

        undo_commands = []
        undo_commands.append('sudo service %s stop\n' % service_name)
        undo_commands.append('sudo rm -rf %s\n' %
                             remote_component_install_path)
        undo_commands.append('sudo rm  %s\n' % service_script_install_path)
        logging.debug("uninstall commands: %s", undo_commands)

        start_commands = []
        start_commands.append('sudo systemctl daemon-reload\n')
        start_commands.append('sudo service %s start\n' % service_name)
        logging.debug("start commands: %s", start_commands)

        stop_commands = []
        stop_commands.append('sudo service %s stop\n' % service_name)
        logging.debug("stop commands: %s", stop_commands)

        return {
            'ssh': undo_commands,
            'start_cmds': start_commands,
            'stop_cmds': stop_commands
        }
コード例 #13
0
    def create_component(self, staged_component_path, application_name,
                         user_name, component, properties):
        logging.debug("create_component: %s %s %s %s", application_name,
                      user_name, json.dumps(component), properties)
        remote_component_tmp_path = '%s/%s/%s' % ('/tmp/%s' % self._namespace,
                                                  application_name,
                                                  component['component_name'])
        remote_component_install_path = '%s/%s/%s' % (
            '/opt/%s' % self._namespace, application_name,
            component['component_name'])
        service_name = '%s-%s-%s' % (self._namespace, application_name,
                                     component['component_name'])

        key_file = self._environment['cluster_private_key']
        root_user = self._environment['cluster_root_user']
        target_host = 'localhost'

        if 'component_spark_version' not in properties:
            properties['component_spark_version'] = '1'
        if 'component_spark_submit_args' not in properties:
            properties['component_spark_submit_args'] = ''
        if 'component_py_files' not in properties:
            properties['component_py_files'] = ''

        if 'upstart.conf' in component['component_detail']:
            # old style applications - reject these
            raise Exception(
                'Support for user supplied upstart.conf files has been deprecated, '
                + 'the deployment manager will supply one automatically. ' +
                'Please see PNDA example-applications for usage.')
        else:
            # new style applications that don't need to provide upstart.conf or yarn-kill.py
            if 'component_main_jar' in properties and 'component_main_class' not in properties:
                raise Exception(
                    'properties.json must contain "main_class" for %s sparkStreaming %s'
                    % (application_name, component['component_name']))

            java_app = None
            if 'component_main_jar' in properties:
                java_app = True
            elif 'component_main_py' in properties:
                java_app = False
            else:
                raise Exception(
                    'properties.json must contain "main_jar or main_py" for %s sparkStreaming %s'
                    % (application_name, component['component_name']))

            this_dir = os.path.dirname(os.path.realpath(__file__))
            copy(os.path.join(this_dir, 'yarn-kill.py'), staged_component_path)
            service_script = 'systemd.service.tpl' if java_app else 'systemd.service.py.tpl'
            service_script_install_path = '/usr/lib/systemd/system/%s.service' % service_name
            if 'component_respawn_type' not in properties:
                properties['component_respawn_type'] = 'always'
            if 'component_respawn_timeout_sec' not in properties:
                properties['component_respawn_timeout_sec'] = '2'
            copy(os.path.join(this_dir, service_script), staged_component_path)

        self._fill_properties(
            os.path.join(staged_component_path, service_script), properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'log4j.properties'),
            properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'application.properties'),
            properties)
        self._fill_properties(
            os.path.join(staged_component_path, 'yarn-kill.py'), properties)

        mkdircommands = []
        mkdircommands.append('mkdir -p %s' % remote_component_tmp_path)
        mkdircommands.append('sudo mkdir -p %s' %
                             remote_component_install_path)
        deployer_utils.exec_ssh(target_host, root_user, key_file,
                                mkdircommands)

        os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                  (key_file, staged_component_path + '/*', root_user,
                   target_host, remote_component_tmp_path))

        for node in self._environment['yarn_node_managers'].split(','):
            deployer_utils.exec_ssh(
                node, root_user, key_file,
                ['mkdir -p %s' % remote_component_tmp_path])
            os.system("scp -i %s -o StrictHostKeyChecking=no %s %s@%s:%s" %
                      (key_file, staged_component_path + '/log4j.properties',
                       root_user, node,
                       remote_component_tmp_path + '/log4j.properties'))
            deployer_utils.exec_ssh(node, root_user, key_file, [
                'sudo mkdir -p %s' % remote_component_install_path,
                'sudo mv %s %s' %
                (remote_component_tmp_path + '/log4j.properties',
                 remote_component_install_path + '/log4j.properties')
            ])

        commands = []
        commands.append('sudo cp %s/%s %s' %
                        (remote_component_tmp_path, service_script,
                         service_script_install_path))
        commands.append(
            'sudo cp %s/* %s' %
            (remote_component_tmp_path, remote_component_install_path))
        commands.append('sudo chmod a+x %s/yarn-kill.py' %
                        (remote_component_install_path))
        if 'component_main_jar' in properties:
            commands.append('cd %s && sudo jar uf %s application.properties' %
                            (remote_component_install_path,
                             properties['component_main_jar']))
        commands.append('sudo rm -rf %s' % (remote_component_tmp_path))
        deployer_utils.exec_ssh(target_host, root_user, key_file, commands)

        undo_commands = []
        undo_commands.append('sudo service %s stop\n' % service_name)
        undo_commands.append('sudo rm -rf %s\n' %
                             remote_component_install_path)
        undo_commands.append('sudo rm  %s\n' % service_script_install_path)
        logging.debug("uninstall commands: %s", undo_commands)

        start_commands = []
        start_commands.append('sudo systemctl daemon-reload\n')
        start_commands.append('sudo service %s start\n' % service_name)
        logging.debug("start commands: %s", start_commands)

        stop_commands = []
        stop_commands.append('sudo service %s stop\n' % service_name)
        logging.debug("stop commands: %s", stop_commands)

        return {
            'ssh': undo_commands,
            'start_cmds': start_commands,
            'stop_cmds': stop_commands
        }