-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d4a38b7
Showing
696 changed files
with
41,169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ecms</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.python.pydev.PyDevBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.python.pydev.pythonNature</nature> | ||
<nature>org.python.pydev.django.djangoNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?> | ||
|
||
<pydev_project> | ||
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION"> | ||
<key>DJANGO_MANAGE_LOCATION</key> | ||
<value>manage.py</value> | ||
</pydev_variables_property> | ||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
<path>/ecms</path> | ||
</pydev_pathproperty> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | ||
</pydev_project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
eclipse.preferences.version=1 | ||
encoding//UI/views.py=utf-8 | ||
encoding//aix/add_resource_pool.py=utf-8 | ||
encoding//aix/aix_function.py=utf-8 | ||
encoding//charge/charge_function.py=utf-8 | ||
encoding//ecms/settings.py=utf-8 | ||
encoding//workflow/description.py=utf-8 | ||
encoding//workflow/models.py=utf-8 | ||
encoding//workflow/setting.py=utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cat /etc/hosts|grep "$1 " | ||
a=$? | ||
#echo $a | ||
cat /etc/hosts|grep "$2" | ||
b=$? | ||
#echo $b | ||
if [ "$a" -ne "0" -a "$b" -ne "0" ]; then | ||
#echo "hahaha" | ||
echo "$1" "$2" >> /etc/hosts | ||
nim -o define -t standalone -a platform="chrp" -a netboot_kernel="mp" -a if1="network1 $2 0" -a cable_type1="bnc" $2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
FUN_delete() | ||
{ | ||
ed $1 <<EOF | ||
$2 | ||
d | ||
w | ||
q | ||
EOF | ||
} | ||
|
||
if [ "$1" = "" ];then | ||
exit 0; | ||
else | ||
cat /etc/hosts|grep "$1" | ||
a=$? | ||
if [ "$a" -eq "0" ]; then | ||
nim -Fo deallocate -a subclass=all $1 | ||
nim -o reset -F $1 | ||
nim -o remove -F $1 | ||
Line_Num=`cat /etc/hosts|grep -E -n "$1"|cut -f1 -d':'` | ||
FUN_delete /etc/hosts $Line_Num | ||
|
||
fi | ||
|
||
fi |
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.contrib import admin | ||
|
||
from EUAO.models import euao_service_function | ||
from EUAO.models import euao_service_space | ||
from EUAO.models import task | ||
from EUAO.models import task_status | ||
from EUAO.models import check_task | ||
from EUAO.models import target_type | ||
|
||
admin.site.register(euao_service_function) | ||
admin.site.register(euao_service_space) | ||
admin.site.register(task) | ||
admin.site.register(task_status) | ||
admin.site.register(check_task) | ||
admin.site.register(target_type) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import EUAO.models | ||
import logging | ||
logger=logging.getLogger('ecms') | ||
|
||
from apscheduler.scheduler import Scheduler | ||
from datetime import date | ||
import datetime | ||
import suds | ||
from time import sleep | ||
sched=Scheduler() | ||
sched.start() | ||
from ecms.commonfunction import * | ||
|
||
def _run(task): | ||
space=task.task_space | ||
function_name=task.function.name | ||
webservice=suds.client.Client(space.url) | ||
function_str='webservice.service.%s(%s)' % (function_name,task.parameters) | ||
logger.debug('euao function str: %s' % function_str) | ||
try: | ||
thread_id=eval(function_str) | ||
logger.debug('euao thread: %s' % thread_id) | ||
if thread_id: | ||
task.euao_thread_id=thread_id | ||
task_executing=EUAO.models.task_status.objects.get(name='executing') | ||
task.status=task_executing | ||
task.save() | ||
else: | ||
logger.error('Error in executing euao task.') | ||
except Exception,e: | ||
logger.error('Error in calling EUAO. %s' % e) | ||
logger.debug(trace_back()) | ||
task.status=EUAO.models.task_status.objects.get(name='error') | ||
|
||
def run_task(task): | ||
if task.plan_execute_time==None or task.plan_execute_time=='': | ||
#run immediately | ||
_run(task) | ||
|
||
def run_check_task(check_task_item): | ||
space=check_task_item.task_space | ||
function_name=check_task_item.function | ||
webservice=suds.client.Client(space.url) | ||
function_str='webservice.service.%s(%s)' % (function_name,check_task_item.parameters) | ||
logger.debug('euao function str: %s' % function_str) | ||
|
||
try: | ||
thread_id=eval(function_str) | ||
logger.debug('euao thread: %s' % thread_id) | ||
if thread_id: | ||
check_task_item.euao_thread_id=thread_id | ||
task_executing=EUAO.models.task_status.objects.get(name='executing') | ||
check_task_item.status=task_executing | ||
check_task_item.save() | ||
else: | ||
logger.error('Error in executing euao task.') | ||
except Exception,e: | ||
logger.error('Error in calling EUAO. %s' % e) | ||
check_task_item.status=EUAO.models.task_status.objects.get(name='error') | ||
|
||
#sucks, need a new thread to do this | ||
def GetResponse(task_item,retry_count): | ||
space=task_item.task_space | ||
webservice=suds.client.Client(space.url) | ||
function_str="""webservice.service.GetCommandResponse('%s')""" % task_item.euao_thread_id | ||
try: | ||
not_finished=True | ||
try_count=0 | ||
while not_finished and try_count<retry_count: | ||
output_t,exit_code_t=eval(function_str) | ||
output=output_t[1] | ||
exit_code=exit_code_t[1] | ||
logger.debug('output: %s, exit_code: %d' % (output,exit_code)) | ||
if exit_code==2:#running | ||
try_count+=1 | ||
sleep(10) | ||
elif exit_code==0:# finished | ||
finished_status=EUAO.models.task_status.objects.get(name='finished') | ||
task_item.status=finished_status | ||
task_item.result=output | ||
logger.debug('Task: %s, exit_code: %d, output: %s' % (task_item,exit_code,output)) | ||
task_item.save() | ||
not_finished=False | ||
else: | ||
error_status=EUAO.models.task_status.objects.get(name='error') | ||
logger.debug('Task: %s, exit_code: %d, output: %s' % (task_item,exit_code,output)) | ||
task_item.status=error_status | ||
task_item.result=output | ||
task_item.save() | ||
not_finished=False | ||
|
||
if try_count==retry_count: | ||
error_status=EUAO.models.task_status.objects.get(name='error') | ||
logger.info('Task %s timeout for %d seconds.' % (task_item,try_count*10)) | ||
logger.debug('Task: %s, exit_code: %d, output: %s' % (task_item,exit_code,output)) | ||
task_item.status=error_status | ||
task_item.result=output | ||
task_item.save() | ||
not_finished=False | ||
|
||
|
||
|
||
except Exception,e: | ||
logger.error('Error in Get %s response. %s' % (task_item,e)) | ||
logger.debug(trace_back()) | ||
error_status=EUAO.models.task_status.objects.get(name='error') | ||
logger.debug('Task: %s, exit_code: %d, output: %s' % (task_item,exit_code,output)) | ||
task_item.status=error_status | ||
task_item.result=output | ||
task_item.save() | ||
|
||
def run_job_interval_times(job_name,job_parameter,interval_seconds,times): | ||
now_time=datetime.datetime.now() | ||
timedelta=datetime.timedelta(seconds=interval_seconds) | ||
jobs=[] | ||
for i in range(times): | ||
job=sched.add_date_job(job_name,now_time+i*timedelta,job_parameter) | ||
jobs.append(job) | ||
return jobs | ||
|
||
def reset_all(): | ||
test_delete_euao_check_task() | ||
test_delete_euao_task() | ||
|
||
def test_delete_euao_task(): | ||
euao_tasks=EUAO.models.task.objects.all() | ||
for et in euao_tasks: | ||
et.delete() | ||
|
||
def test_delete_euao_check_task(): | ||
euao_check_tasks=EUAO.models.check_task.objects.all() | ||
for ect in euao_check_tasks: | ||
ect.delete() |
Binary file not shown.
Oops, something went wrong.