Skip to content

Commit 28568e6

Browse files
author
Vijayendra Bhamidipati
committed
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description: This is work in progress. This set of changes will not compile. Checking in for team wide code sync up. Changes are underway to test if VMWareResource can be leveraged to talk to the VSM, instead of creating a new resource for the VSM, like we've been doing up until now.
1 parent b0facd1 commit 28568e6

5 files changed

Lines changed: 169 additions & 185 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
//
12+
13+
package com.cloud.network.resource;
14+
15+
import java.util.Map;
16+
import javax.naming.ConfigurationException;
17+
import com.cloud.agent.IAgentControl;
18+
import com.cloud.agent.api.Answer;
19+
import com.cloud.agent.api.Command;
20+
import com.cloud.agent.api.PingCommand;
21+
import com.cloud.agent.api.StartupCommand;
22+
import com.cloud.agent.api.StartupExternalLoadBalancerCommand;
23+
import com.cloud.api.ApiConstants;
24+
import com.cloud.host.Host;
25+
import com.cloud.host.Host.Type;
26+
import com.cloud.resource.ServerResource;
27+
import com.cloud.serializer.GsonHelper;
28+
import com.cloud.utils.NumbersUtil;
29+
import com.google.gson.Gson;
30+
31+
import com.cloud.utils.ssh.*;
32+
import com.cloud.utils.cisco.n1kv.vsm.CiscoNexusVSMService;
33+
import com.cloud.utils.exception.CloudRuntimeException;
34+
35+
import org.apache.log4j.Logger;
36+
37+
class VSMError {
38+
static final int VSM_RESOURCE_EXISTS = 89901;
39+
static final int VSM_RESOURCE_NOT_EXISTS= 89902;
40+
static final int VSM_NO_SERIVCE = 89903;
41+
static final int VSM_OPERATION_NOT_PERMITTED = 89904;
42+
}
43+
44+
public class CiscoNexusVSM {
45+
46+
// deployment configuration
47+
private String vsmIpaddr;
48+
private String vsmUsername;
49+
private String vsmPassword;
50+
private String vsmSubsystem;
51+
com.trilead.ssh2.Connection sshConnection;
52+
private String _helloClientCmd = "<?xml version=\"1.0\"?><nc:hello xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><nc:capabilities><nc:capability>urn:ietf:params:xml:ns:netconf:base:1.0</nc:capability></nc:capabilities></nc:hello>]]>]]>";
53+
private String _clientCmd1 = "<?xml version=\"1.0\"?><nc:rpc message-id=\"1\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"xmlns=\"http://www.cisco.com/nxos:1.0:xml\"><nc:get><nc:filter type=\"subtree\"><show><xml><server><status/></server></xml></show></nc:filter></nc:get></nc:rpc>]]>]]>";
54+
55+
private static final Logger s_logger = Logger.getLogger(CiscoNexusVSM.class);
56+
57+
// interface to interact with Cisco Nexus VSM devices
58+
CiscoNexusVSMService _vsmService;
59+
60+
Long _timeout = new Long(100000);
61+
//base_response apiCallResult;
62+
63+
// We need to store the result of the XML-RPC command sent to
64+
// the VSM. For now it's a string. We should make this the appropriate XSD object.
65+
String xml_rpc_response;
66+
67+
public void setVsmIpaddr(String ipaddr) {
68+
this.vsmIpaddr = ipaddr;
69+
}
70+
71+
public void setVsmUsername(String username) {
72+
this.vsmUsername = username;
73+
}
74+
75+
public void setVsmPassword(String password) {
76+
this.vsmPassword = password;
77+
}
78+
79+
public void setVsmSubsystem(String subsystem) {
80+
this.vsmSubsystem = subsystem;
81+
}
82+
83+
public CiscoNexusVSM() {
84+
this.vsmSubsystem = "xmlagent";
85+
}
86+
87+
public String getVsmIpaddr() {
88+
return vsmIpaddr;
89+
}
90+
91+
public String getvsmUsername() {
92+
return vsmUsername;
93+
}
94+
95+
public String getvsmPassword() {
96+
return vsmPassword;
97+
}
98+
99+
public String getvsmSubsystem() {
100+
return vsmSubsystem;
101+
}
102+
103+
public CiscoNexusVSM(String username, String ipaddr, String password) {
104+
105+
}
106+
107+
public boolean connectToVSM() {
108+
sshConnection = SSHCmdHelper.acquireAuthorizedConnection(this.vsmIpaddr, this.vsmUsername, this.vsmPassword);
109+
if (sshConnection == null) {
110+
return false;
111+
}
112+
return true;
113+
}
114+
115+
}

core/src/com/cloud/network/resource/CiscoNexusVSMResource.java

Lines changed: 0 additions & 173 deletions
This file was deleted.

server/src/com/cloud/api/commands/AddCiscoNexusVSMCmd.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class AddCiscoNexusVSMCmd extends BaseAsyncCmd {
5454
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required = true, description="IP Address of the Cisco Nexus 1000v VSM appliance.")
5555
private String ipaddr;
5656

57-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.STRING, required = true, description="Id of the zone in which the Cisco Nexus 1000v VSM appliance.")
58-
private long zoneId;
57+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required = true, description="Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
58+
private long clusterId;
5959

6060
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="username to reach the Cisco Nexus 1000v VSM device")
6161
private String username;
@@ -86,14 +86,17 @@ public String getVSMName() {
8686
return vsmName;
8787
}
8888

89-
public long getZoneId() {
90-
return zoneId;
89+
public long getClusterId() {
90+
return clusterId;
9191
}
9292

9393
/////////////////////////////////////////////////////
9494
/////////////// API Implementation///////////////////
9595
/////////////////////////////////////////////////////
9696

97+
// NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
98+
// automagically gets translated to the corresponding db id before this execute() method
99+
// is invoked. That's the reason why we don't have any uuid-dbid translation code here.
97100
@Override
98101
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
99102
try {

0 commit comments

Comments
 (0)