Skip to content

Commit 834cadd

Browse files
committed
wip
1 parent 95b5339 commit 834cadd

File tree

6 files changed

+160
-5
lines changed

6 files changed

+160
-5
lines changed

pkg/operator/registry.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ func StandardRegistry(options ...BaseOperatorOption) *Registry {
120120
})
121121
},
122122
},
123+
UnregisterHANASecondaryOperatorName: map[string]OperatorBuilder{
124+
"v1": func(operationID string, arguments OperatorArguments) Operator {
125+
return NewUnregisterHANASecondary(arguments, operationID, OperatorOptions[UnregisterHANASecondary]{
126+
BaseOperatorOptions: options,
127+
})
128+
},
129+
},
123130
},
124131
}
125132
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package operator
2+
3+
import (
4+
"context"
5+
6+
"github.com/trento-project/workbench/internal/support"
7+
)
8+
9+
const UnregisterHANASecondaryOperatorName = "unregisterhanasecondary"
10+
11+
type unregisterHANASecondaryDiffOutput struct {
12+
Unregistered bool `json:"unregistered"`
13+
}
14+
15+
type unregisterHanaSecondaryArguments struct {
16+
instanceNumber string
17+
}
18+
19+
type UnregisterHANASecondaryOption Option[UnregisterHANASecondary]
20+
21+
// UnregisterHANASecondary is an operator responsible for unregistering a HANA secondary instance.
22+
//
23+
// Arguments:
24+
// instance_number: The instance number of the HANA secondary instance to unregister.
25+
//
26+
// # Execution Phases
27+
// - PLAN:
28+
// - COMMIT:
29+
// - VERIFY:
30+
// - ROLLBACK:
31+
32+
type UnregisterHANASecondary struct {
33+
baseOperator
34+
parsedArguments *unregisterHanaSecondaryArguments
35+
executor support.CmdExecutor
36+
}
37+
38+
func WithCustomUnregisterHANASecondaryExecutor(executor support.CmdExecutor) UnregisterHANASecondaryOption {
39+
return func(o *UnregisterHANASecondary) {
40+
o.executor = executor
41+
}
42+
}
43+
44+
func NewUnregisterHANASecondary(
45+
arguments OperatorArguments,
46+
operationID string,
47+
options OperatorOptions[UnregisterHANASecondary],
48+
) *Executor {
49+
unregisterHANASecondary := &UnregisterHANASecondary{
50+
baseOperator: newBaseOperator(operationID, arguments, options.BaseOperatorOptions...),
51+
executor: support.CliExecutor{},
52+
}
53+
54+
for _, opt := range options.OperatorOptions {
55+
opt(unregisterHANASecondary)
56+
}
57+
58+
return &Executor{
59+
phaser: unregisterHANASecondary,
60+
operationID: operationID,
61+
}
62+
}
63+
64+
func (uhs *UnregisterHANASecondary) plan(ctx context.Context) (bool, error) {
65+
66+
return false, nil
67+
}
68+
69+
func (uhs *UnregisterHANASecondary) commit(ctx context.Context) error {
70+
return nil
71+
}
72+
73+
func (uhs *UnregisterHANASecondary) verify(ctx context.Context) error {
74+
return nil
75+
}
76+
77+
func (uhs *UnregisterHANASecondary) rollback(ctx context.Context) error {
78+
return nil
79+
}
80+
81+
func (uhs *UnregisterHANASecondary) operationDiff(ctx context.Context) map[string]any {
82+
return map[string]any{
83+
"instance_number": uhs.parsedArguments.instanceNumber,
84+
}
85+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
SAPCONTROL-OK: <begin>
2+
online=true
3+
mode=sync
4+
operation mode=logreplay
5+
site id=2
6+
site name=Site2
7+
isSource=false
8+
isConsumer=true
9+
hasConsumers=false
10+
isTakeoverActive=false
11+
isPrimarySuspended=false
12+
isTimetravelEnabled=false
13+
replayMode=auto
14+
active primary site=1
15+
primary masters=node-vmhana01
16+
mapping/node-vmhana02=Site2/node-vmhana02
17+
mapping/node-vmhana02=Site1/node-vmhana01
18+
siteTier/Site1=1
19+
siteTier/Site2=2
20+
siteReplicationMode/Site1=primary
21+
siteReplicationMode/Site2=sync
22+
siteOperationMode/Site1=primary
23+
siteOperationMode/Site2=logreplay
24+
siteMapping/Site1=Site2
25+
SAPCONTROL-OK: <end>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SAPCONTROL-OK: <begin>
2+
online=true
3+
mode=primary
4+
operation mode=primary
5+
site id=1
6+
site name=Site1
7+
isSource=true
8+
isConsumer=false
9+
hasConsumers=true
10+
isTakeoverActive=false
11+
isPrimarySuspended=false
12+
mapping/node-vmhana01=Site2/node-vmhana02
13+
mapping/node-vmhana01=Site1/node-vmhana01
14+
siteTier/Site1=1
15+
siteTier/Site2=2
16+
siteReplicationMode/Site1=primary
17+
siteReplicationMode/Site2=sync
18+
siteOperationMode/Site1=primary
19+
siteOperationMode/Site2=logreplay
20+
siteMapping/Site1=Site2
21+
SAPCONTROL-OK: <end>
22+
done.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SAPCONTROL-OK: <begin>
2+
online=false
3+
nameserver node-vmhana02:30001 not responding.
4+
nameserver node-vmhana02:30001 not responding.
5+
mode=sync
6+
operation mode=unknown
7+
site id=2
8+
site name=Site2
9+
nameserver node-vmhana02:30001 not responding.
10+
nameserver node-vmhana02:30001 not responding.
11+
isSource=unknown
12+
isConsumer=true
13+
hasConsumers=unknown
14+
isTakeoverActive=false
15+
isPrimarySuspended=false
16+
isTimetravelEnabled=false
17+
replayMode=auto
18+
active primary site=1
19+
primary masters=node-vmhana01
20+
SAPCONTROL-OK: <end>
21+
done.

test/fixtures/saptune/revert_not_applied_solution.output

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11

2-
WARNING: Perf Bias settings not supported by the system
3-
WARNING: Governor settings not supported by the system
4-
Parameters tuned by the notes referred by the SAP solution have been successfully reverted.
5-
fab-vmhana01:~ # saptune solution revert HANA
6-
72
WARNING: noteID '941735' not found in configuration 'NoteApplyOrder'
83
WARNING: noteID '1771258' not found in configuration 'NoteApplyOrder'
94
WARNING: noteID '1868829' not found in configuration 'NoteApplyOrder'

0 commit comments

Comments
 (0)