blob: 0bf4a0df6ef379b3dd1c6e9107abdcb61a38dcf7 [file] [log] [blame]
#! /usr/bin/env python
# -----------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# -----------------------------------------------------------------------
import os
import sys
from helper import Helper
class Prep():
helper = Helper();
def __init__(self):
pass
def getServiceType(self, id):
if(id == 1):
return 'auto-start'
return 'on-demand'
def run(self):
file_home = os.path.dirname(os.path.realpath(sys.argv[0]))
ducc_home = file_home.rsplit('/',3)[0]
#
for i in range(0,5):
self.user = self.helper.getUser()
print self.user
os.environ['USER'] = self.user
script = ducc_home+'/examples/systemtest/reg_service'
service_id = str(i)
service_type = self.getServiceType(i)
description = '"'+'Test Service'+' '+service_id+' '+'Type'+' '+service_type+'"'
command = script+' '+'-i'+' '+service_id+' '+'--description'+' '+description
print 'cmd: '+command
os.system(command)
print 'registered service: '+service_id
if(service_type == 'auto-start'):
script = ducc_home+'/bin/ducc_services'
command = script+' '+'--autostart'+' '+'true'+' '+'--modify'+' '+service_id
print 'cmd: '+command
os.system(command)
print 'autostart service: '+service_id
if __name__ == '__main__':
function = Prep()
function.run()