-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitialDsaDeployOp.cpp
100 lines (84 loc) · 2.62 KB
/
InitialDsaDeployOp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <unistd.h>
#include <syslog.h>
#include "InitialDsaDeployOp.h"
namespace IrvCS
{
InitialDsaDeployOp::InitialDsaDeployOp(DsaController *controller):controller_(controller)
{
}
InitialDsaDeployOp::~InitialDsaDeployOp()
{
}
OpStatus InitialDsaDeployOp::release(DsaId id){
//Release 3 times, 45 seconds timeout each, return if successful
for (int i = 0; i < 3; i++) {
syslog(LOG_INFO, "Attempt %d", (i+1));
int relStat = controller_ ->
performDsaOperation(id, Release, DSA_RELEASE_TIMEOUT);
if(relStat == StatOk){
syslog(LOG_INFO, "Success");
return StatOk;
}
syslog(LOG_WARNING, "Timed out");
sleep(DSA_RELEASE_WAIT);
}
syslog(LOG_INFO, "Attempting Emergency Release");
OpStatus relStat = controller_ ->
performDsaOperation(id, Release, DSA_EMERGENCY_RELEASE_TIMEOUT);
if(relStat == StatOk){
syslog(LOG_INFO, "Success");
return StatOk;
}
syslog(LOG_WARNING, "Timed out");
return relStat;
}
OpStatus InitialDsaDeployOp::deploy(DsaId id){
OpStatus status = controller_->performDsaOperation(id, Deploy,
DSA_DEPLOY_TIMEOUT);
if(status == StatOk){
syslog(LOG_INFO, "Success");
return StatOk;
}else{
syslog(LOG_WARNING, "Timed out");
return status;
}
}
OpStatus InitialDsaDeployOp::execute()
{
syslog(LOG_INFO, "Executing Initial DSA Release/Deploy Operation");
OpStatus status=StatErr;
// Release DSA1 3 times with timeout 45 sec
// Emergency release additional 15 sec if necessary
syslog(LOG_INFO, "Attempting to release DSA 1");
OpStatus rel1 = release(DSA_1);
// Release DSA2 3 times with timeout 45 sec
// Emergency release 15 sec if necessary
syslog(LOG_INFO, "Attempting to release DSA 2");
OpStatus rel2 = release(DSA_2);
sleep(DSA_OP_WAIT);
// Deploy DSA1 timeout 10 sec
syslog(LOG_INFO, "Attempting to deploy DSA 1");
OpStatus dep1 = deploy(DSA_1);
sleep(DSA_OP_WAIT);
// Deploy DSA2 timeout 10 sec
syslog(LOG_INFO, "Attempting to deploy DSA 2");
OpStatus dep2 = deploy(DSA_2);
sleep(DSA_OP_WAIT);
if (dep1+dep2+rel1+rel2 == 0)
{
status=StatOk;
} else if(dep2!=StatOk || dep1!=StatOk || rel1!=StatOk || rel2!=StatOk)
{
status = StatTimeOut;
}
if (status == StatOk)
{
syslog(LOG_INFO, "Successfully Completed Initial DSA Deploy Operation");
} else
{
syslog(LOG_WARNING, "Completed Initial DSA Deploy Operation with status %d",
status);
}
return status;
}
}