From 3aef381b37cfe639bee0a11ba8ce77d160e6eb5e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 15 Nov 2011 16:32:54 -0800 Subject: [PATCH] NaaS: Add service provider to server-setup.xml --- server/src/com/cloud/test/DatabaseConfig.java | 100 ++- setup/db/server-setup.xml | 841 +++++++++--------- 2 files changed, 534 insertions(+), 407 deletions(-) diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index 09ff8521699..12f9caed325 100755 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -105,6 +105,8 @@ public class DatabaseConfig { objectNames.add("configuration"); objectNames.add("privateIpAddresses"); objectNames.add("publicIpAddresses"); + objectNames.add("physicalNetworkServiceProvider"); + objectNames.add("virtualRouterProvider"); // initialize the fieldNames ArrayList fieldNames.add("id"); @@ -157,6 +159,19 @@ public class DatabaseConfig { fieldNames.add("networktype"); fieldNames.add("clusterId"); fieldNames.add("physicalNetworkId"); + fieldNames.add("destPhysicalNetworkId"); + fieldNames.add("providerName"); + fieldNames.add("vpn"); + fieldNames.add("dhcp"); + fieldNames.add("dns"); + fieldNames.add("firewall"); + fieldNames.add("sourceNat"); + fieldNames.add("loadBalance"); + fieldNames.add("staticNat"); + fieldNames.add("portForwarding"); + fieldNames.add("userData"); + fieldNames.add("securityGroup"); + fieldNames.add("nspId"); s_configurationDescriptions.put("host.stats.interval", "the interval in milliseconds when host stats are retrieved from agents"); s_configurationDescriptions.put("storage.stats.interval", "the interval in milliseconds when storage stats (per host) are retrieved from agents"); @@ -452,7 +467,11 @@ public class DatabaseConfig { saveSecondaryStorage(); } else if ("cluster".equals(_currentObjectName)) { saveCluster(); - } + } else if ("physicalNetworkServiceProvider".equals(_currentObjectName)) { + savePhysicalNetworkServiceProvider(); + } else if ("virtualRouterProvider".equals(_currentObjectName)) { + saveVirtualRouterProvider(); + } _currentObjectParams = null; } @@ -664,6 +683,85 @@ public class DatabaseConfig { } + private void savePhysicalNetworkServiceProvider() { + long id = Long.parseLong(_currentObjectParams.get("id")); + long physicalNetworkId = Long.parseLong(_currentObjectParams.get("physicalNetworkId")); + String providerName = _currentObjectParams.get("providerName"); + long destPhysicalNetworkId = Long.parseLong(_currentObjectParams.get("destPhysicalNetworkId")); + String uuid = UUID.randomUUID().toString(); + + int vpn = Integer.parseInt(_currentObjectParams.get("vpn")); + int dhcp = Integer.parseInt(_currentObjectParams.get("dhcp")); + int dns = Integer.parseInt(_currentObjectParams.get("dns")); + int gateway = Integer.parseInt(_currentObjectParams.get("gateway")); + int firewall = Integer.parseInt(_currentObjectParams.get("firewall")); + int sourceNat = Integer.parseInt(_currentObjectParams.get("sourceNat")); + int lb = Integer.parseInt(_currentObjectParams.get("loadBalance")); + int staticNat = Integer.parseInt(_currentObjectParams.get("staticNat")); + int pf =Integer.parseInt(_currentObjectParams.get("portForwarding")); + int userData =Integer.parseInt(_currentObjectParams.get("userData")); + int securityGroup =Integer.parseInt(_currentObjectParams.get("securityGroup")); + + String insertSql1 = "INSERT INTO `physical_network_service_providers` (`id`, `uuid`, `physical_network_id` , `provider_name`, `state` ," + + "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," + + "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," + + "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + Transaction txn = Transaction.currentTxn(); + try { + PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql1); + stmt.setLong(1, id); + stmt.setString(2, uuid); + stmt.setLong(3, physicalNetworkId); + stmt.setString(4, providerName); + stmt.setString(5, "Enabled"); + stmt.setLong(6, destPhysicalNetworkId); + stmt.setInt(7, vpn); + stmt.setInt(8, dhcp); + stmt.setInt(9, dns); + stmt.setInt(10, gateway); + stmt.setInt(11, firewall); + stmt.setInt(12, sourceNat); + stmt.setInt(13, lb); + stmt.setInt(14, staticNat); + stmt.setInt(15, pf); + stmt.setInt(16, userData); + stmt.setInt(17, securityGroup); + stmt.executeUpdate(); + } catch (SQLException ex) { + System.out.println("Error creating physical network service provider: " + ex.getMessage()); + s_logger.error("error creating physical network service provider", ex); + return; + } + + } + + private void saveVirtualRouterProvider() { + long id = Long.parseLong(_currentObjectParams.get("id")); + long nspId = Long.parseLong(_currentObjectParams.get("nspId")); + String uuid = UUID.randomUUID().toString(); + String type = _currentObjectParams.get("type"); + + String insertSql1 = "INSERT INTO `virtual_router_providers` (`id`, `nsp_id`, `uuid` , `type` , `enabled`) " + + "VALUES (?,?,?,?,?)"; + + Transaction txn = Transaction.currentTxn(); + try { + PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql1); + stmt.setLong(1, id); + stmt.setLong(2, nspId); + stmt.setString(3, uuid); + stmt.setString(4, type); + stmt.setInt(5, 1); + stmt.executeUpdate(); + } catch (SQLException ex) { + System.out.println("Error creating virtual router provider: " + ex.getMessage()); + s_logger.error("error creating virtual router provider ", ex); + return; + } + + } + private void saveVlan() { String zoneId = _currentObjectParams.get("zoneId"); String physicalNetworkIdStr = _currentObjectParams.get("physicalNetworkId"); diff --git a/setup/db/server-setup.xml b/setup/db/server-setup.xml index 7c5fe160b3e..df00b52d4f2 100755 --- a/setup/db/server-setup.xml +++ b/setup/db/server-setup.xml @@ -1,406 +1,435 @@ - - - - - 2.0 - - - - - - - - - - - - - - - - 1 - Small Instance - Small Instance [500MHZ CPU, 512MB MEM, 16GB Disk] - $0.10 per hour - 1 - 512 - 500 - - - 2 - Medium Instance - Medium Instance [2GHZ CPU, 2GB MEM, 32GB Disk] - $0.20 per hour - 1 - 2048 - 2000 - - - 3 - Large Instance - Large Instance [2GHZ CPU, 4GB MEM, 64GB Disk] - $0.30 per hour - 2 - 4096 - 2000 - - - - - - 1 - 1 - Small Disk - Small Disk [16GB Disk] - 16384 - - - 2 - 1 - Medium Disk - Medium Disk [32GB Disk] - 32768 - - - 3 - 1 - Large Disk - Large Disk [64GB Disk] - 65536 - - - - - - - 2 - admin - password - Admin - User - admin@mailprovider.com - - - - - - - - - default.zone - ZONE1 - - - guest.domain.suffix - qatest-vmops.com - - - - instance.name - TEST - - - - integration.api.port - 8096 - - - - memory.capacity.threshold - 0.85 - - - - cpu.capacity.threshold - 0.85 - - - - storage.capacity.threshold - 0.85 - - - storage.allocated.capacity.threshold - 0.85 - - - - public.ip.capacity.threshold - 0.85 - - - private.ip.capacity.threshold - 0.85 - - - - capacity.check.period - 300000 - - - - expunge.interval - 86400 - - - - wait - 1800 - - - - - upgrade.url - http://example.com:8080/client/agent/update.zip - - - - - network.throttling.rate - 200 - - - multicast.throttling.rate - 10 - - - secstorage.encrypt.copy - false - - - - - usage.aggregation.timezone - GMT - - - usage.stats.job.exec.time - 00:15 - - - system.vm.local.storage.required - false - - - - secondary.storage.vm - false - - - - - - - - + + + + + 2.0 + + + + + + + + + + + + + + + 1 + Small Instance + Small Instance [500MHZ CPU, 512MB MEM, 16GB Disk] - $0.10 per hour + 1 + 512 + 500 + + + 2 + Medium Instance + Medium Instance [2GHZ CPU, 2GB MEM, 32GB Disk] - $0.20 per hour + 1 + 2048 + 2000 + + + 3 + Large Instance + Large Instance [2GHZ CPU, 4GB MEM, 64GB Disk] - $0.30 per hour + 2 + 4096 + 2000 + + + + + + 1 + 1 + Small Disk + Small Disk [16GB Disk] + 16384 + + + 2 + 1 + Medium Disk + Medium Disk [32GB Disk] + 32768 + + + 3 + 1 + Large Disk + Large Disk [64GB Disk] + 65536 + + + + + + + 2 + admin + password + Admin + User + admin@mailprovider.com + + + + + + + + + default.zone + ZONE1 + + + guest.domain.suffix + qatest-vmops.com + + + + instance.name + TEST + + + + integration.api.port + 8096 + + + + memory.capacity.threshold + 0.85 + + + + cpu.capacity.threshold + 0.85 + + + + storage.capacity.threshold + 0.85 + + + storage.allocated.capacity.threshold + 0.85 + + + + public.ip.capacity.threshold + 0.85 + + + private.ip.capacity.threshold + 0.85 + + + + capacity.check.period + 300000 + + + + expunge.interval + 86400 + + + + wait + 1800 + + + + + upgrade.url + http://example.com:8080/client/agent/update.zip + + + + + network.throttling.rate + 200 + + + multicast.throttling.rate + 10 + + + secstorage.encrypt.copy + false + + + + + usage.aggregation.timezone + GMT + + + usage.stats.job.exec.time + 00:15 + + + system.vm.local.storage.required + false + + + + secondary.storage.vm + false + + + + + + + +