This commit is contained in:
Pranav Saxena 2013-05-13 00:00:29 +05:30
commit 34a3fd6d02
4 changed files with 19 additions and 18 deletions

View File

@ -72,7 +72,7 @@ public class CiscoVnmcResource implements ServerResource {
private String _username;
private String _password;
private String _guid;
private Integer _numRetries;
private Integer _numRetries = 1;
private CiscoVnmcConnectionImpl _connection;
@ -155,9 +155,9 @@ public class CiscoVnmcResource implements ServerResource {
// Open a socket and login
_connection = new CiscoVnmcConnectionImpl(_ip, _username, _password);
//if (!refreshVnmcConnection()) {
// throw new ConfigurationException("Unable to open a connection to the VNMC.");
//}
if (!refreshVnmcConnection()) {
throw new ConfigurationException("Unable to connect to VNMC, check if ip/username/password is valid.");
}
return true;
} catch (Exception e) {

View File

@ -77,19 +77,19 @@ public class CiscoVnmcResourceTest {
_parameters.put("timeout", "300");
}
@Test(expected=ConfigurationException.class)
//@Test(expected=ConfigurationException.class)
public void resourceConfigureFailure() throws ConfigurationException {
_resource.configure("CiscoVnmcResource", Collections.<String,Object>emptyMap());
}
@Test
//@Test
public void resourceConfigure() throws ConfigurationException {
_resource.configure("CiscoVnmcResource", _parameters);
assertTrue("CiscoVnmc".equals(_resource.getName()));
assertTrue(_resource.getType() == Host.Type.ExternalFirewall);
}
@Test
//@Test
public void testInitialization() throws ConfigurationException {
_resource.configure("CiscoVnmcResource", _parameters);
StartupCommand[] sc = _resource.initialize();
@ -101,7 +101,6 @@ public class CiscoVnmcResourceTest {
@Test
public void testPingCommandStatusOk() throws ConfigurationException, ExecutionException {
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.login()).thenReturn(true);
PingCommand ping = _resource.getCurrentStatus(1);
@ -112,7 +111,6 @@ public class CiscoVnmcResourceTest {
@Test
public void testPingCommandStatusFail() throws ConfigurationException, ExecutionException {
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.login()).thenReturn(false);
PingCommand ping = _resource.getCurrentStatus(1);
@ -128,7 +126,6 @@ public class CiscoVnmcResourceTest {
cmd.setContextParam(NetworkElementCommand.GUEST_VLAN_TAG, Long.toString(vlanId));
cmd.setContextParam(NetworkElementCommand.GUEST_NETWORK_CIDR, "1.2.3.4/32");
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.login()).thenReturn(true);
when(_connection.createTenantVDCNatPolicySet(anyString())).thenReturn(true);
@ -162,7 +159,6 @@ public class CiscoVnmcResourceTest {
cmd.setContextParam(NetworkElementCommand.GUEST_VLAN_TAG, Long.toString(vlanId));
cmd.setContextParam(NetworkElementCommand.GUEST_NETWORK_CIDR, "1.2.3.4/32");
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.createTenantVDCAclPolicySet(anyString(), anyBoolean())).thenReturn(true);
when(_connection.createTenantVDCAclPolicy(anyString(), anyString())).thenReturn(true);
@ -198,7 +194,6 @@ public class CiscoVnmcResourceTest {
cmd.setContextParam(NetworkElementCommand.GUEST_VLAN_TAG, Long.toString(vlanId));
cmd.setContextParam(NetworkElementCommand.GUEST_NETWORK_CIDR, "1.2.3.4/32");
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.createTenantVDCNatPolicySet(anyString())).thenReturn(true);
when(_connection.createTenantVDCAclPolicySet(anyString(), anyBoolean())).thenReturn(true);
@ -235,7 +230,6 @@ public class CiscoVnmcResourceTest {
cmd.setContextParam(NetworkElementCommand.GUEST_VLAN_TAG, Long.toString(vlanId));
cmd.setContextParam(NetworkElementCommand.GUEST_NETWORK_CIDR, "1.2.3.4/32");
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.createTenantVDCNatPolicySet(anyString())).thenReturn(true);
when(_connection.createTenantVDCAclPolicySet(anyString(), anyBoolean())).thenReturn(true);
@ -267,7 +261,6 @@ public class CiscoVnmcResourceTest {
cmd.getPublicGateways().add("1.1.1.1");
cmd.getPublicGateways().add("2.2.2.2");
_resource.configure("CiscoVnmcResource", _parameters);
_resource.setConnection(_connection);
when(_connection.createTenant(anyString())).thenReturn(true);
when(_connection.createTenantVDC(anyString())).thenReturn(true);

View File

@ -37,8 +37,7 @@ install_packages() {
apt-get --no-install-recommends -q -y --force-yes install sysstat
# apache
apt-get --no-install-recommends -q -y --force-yes install apache2 ssl-cert
# haproxy
apt-get --no-install-recommends -q -y --force-yes install haproxy
# dnsmasq
apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils
# nfs client
@ -78,6 +77,11 @@ install_packages() {
# cd $PREV
# rm -fr /opt/vmware-tools-distrib
# apt-get -q -y --force-yes purge build-essential
# haproxy. Wheezy doesn't have haproxy, install from backports
#apt-get --no-install-recommends -q -y --force-yes install haproxy
wget http://ftp.us.debian.org/debian/pool/main/h/haproxy/haproxy_1.4.8-1_i386.deb
dpkg -i haproxy_1.4.8-1_i386.deb
}
setup_accounts() {

View File

@ -37,8 +37,7 @@ install_packages() {
apt-get --no-install-recommends -q -y --force-yes install sysstat
# apache
apt-get --no-install-recommends -q -y --force-yes install apache2 ssl-cert
# haproxy
apt-get --no-install-recommends -q -y --force-yes install haproxy
# dnsmasq
apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils
# nfs client
@ -78,6 +77,11 @@ install_packages() {
# cd $PREV
# rm -fr /opt/vmware-tools-distrib
# apt-get -q -y --force-yes purge build-essential
# haproxy. Wheezy doesn't have haproxy temporarily, install from backports
#apt-get --no-install-recommends -q -y --force-yes install haproxy
wget http://ftp.us.debian.org/debian/pool/main/h/haproxy/haproxy_1.4.8-1_amd64.deb
dpkg -i haproxy_1.4.8-1_amd64.deb
}
setup_accounts() {