Skip to content

Commit a1e8778

Browse files
First piece of the refactor of the CitrisResourceBase
- The same pattern will be used by the other subclasses of the ServerResource interface.
1 parent ed979b1 commit a1e8778

7 files changed

Lines changed: 304 additions & 74 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.resource;
21+
22+
import com.cloud.agent.api.Answer;
23+
import com.cloud.agent.api.Command;
24+
25+
26+
public abstract class CommandWrapper<T extends Command, A extends Answer, R extends ServerResource> {
27+
28+
/**
29+
* @param T is the command to be used.
30+
* @param R is the resource base to be used.
31+
* @return A and the Answer from the command.
32+
*/
33+
public abstract A execute(T command, R serverResource);
34+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.resource;
21+
22+
import com.cloud.agent.api.Answer;
23+
import com.cloud.agent.api.Command;
24+
25+
public abstract class RequestWrapper {
26+
27+
/**
28+
* @param command to be executed.
29+
* @return an Answer for the executed command.
30+
*/
31+
public abstract Answer execute(Command command, ServerResource serverResource);
32+
}

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ protected MaintainAnswer execute(final MaintainCommand cmd) {
20472047
}
20482048
}
20492049

2050-
protected String networkUsage(final Connection conn, final String privateIpAddress, final String option, final String vif) {
2050+
public String networkUsage(final Connection conn, final String privateIpAddress, final String option, final String vif) {
20512051
if (option.equals("get")) {
20522052
return "0:0";
20532053
}
@@ -3096,7 +3096,7 @@ public RebootAnswer execute(final RebootCommand cmd) {
30963096
}
30973097
}
30983098

3099-
protected Answer execute(final RebootRouterCommand cmd) {
3099+
public Answer execute(final RebootRouterCommand cmd) {
31003100
final Connection conn = getConnection();
31013101
final RebootAnswer answer = execute((RebootCommand)cmd);
31023102
if (answer.getResult()) {
@@ -3630,7 +3630,7 @@ protected String connect(final Connection conn, final String vmName, final Strin
36303630
return msg;
36313631
}
36323632

3633-
protected String connect(final Connection conn, final String vmname, final String ipAddress) {
3633+
public String connect(final Connection conn, final String vmname, final String ipAddress) {
36343634
return connect(conn, vmname, ipAddress, 3922);
36353635
}
36363636

0 commit comments

Comments
 (0)