mirror of https://github.com/apache/cloudstack.git
AutoScale. Adding default counters
This commit is contained in:
parent
266b8e5ee8
commit
d4e43846f8
|
|
@ -8,7 +8,7 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.server;
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
// store the public and private keys in the database
|
||||
updateKeyPairs();
|
||||
|
||||
|
||||
// generate a random password for system vm
|
||||
updateSystemvmPassword();
|
||||
|
||||
|
|
@ -294,6 +294,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
_identityDao.initializeDefaultUuid("virtual_router_providers");
|
||||
_identityDao.initializeDefaultUuid("networks");
|
||||
_identityDao.initializeDefaultUuid("user_ip_address");
|
||||
_identityDao.initializeDefaultUuid("counter");
|
||||
}
|
||||
|
||||
private String getMountParent() {
|
||||
|
|
@ -372,7 +373,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
// now insert the user
|
||||
insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created) " +
|
||||
"VALUES (" + id + ",'" + username + "','" + sb.toString() + "', 2, '" + firstname + "','" + lastname + "',now())";
|
||||
"VALUES (" + id + ",'" + username + "','" + sb.toString() + "', 2, '" + firstname + "','" + lastname + "',now())";
|
||||
|
||||
txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
|
@ -399,10 +400,10 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
// save default security group
|
||||
if (tableName.equals("security_group")) {
|
||||
insertSql = "INSERT INTO " + tableName + " (name, description, account_id, domain_id) " +
|
||||
"VALUES ('default', 'Default Security Group', 2, 1)";
|
||||
"VALUES ('default', 'Default Security Group', 2, 1)";
|
||||
} else {
|
||||
insertSql = "INSERT INTO " + tableName + " (name, description, account_id, domain_id, account_name) " +
|
||||
"VALUES ('default', 'Default Security Group', 2, 1, 'admin')";
|
||||
"VALUES ('default', 'Default Security Group', 2, 1, 'admin')";
|
||||
}
|
||||
|
||||
txn = Transaction.currentTxn();
|
||||
|
|
@ -421,7 +422,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
protected void updateCloudIdentifier() {
|
||||
// Creates and saves a UUID as the cloud identifier
|
||||
ConfigurationVO cloudIdentifier = _configDao.findByName("cloud.identifier");
|
||||
ConfigurationVO cloudIdentifier = _configDao.findByName("cloud.identifier");
|
||||
String currentCloudIdentifier = cloudIdentifier.getValue();
|
||||
if (currentCloudIdentifier == null || currentCloudIdentifier.isEmpty()) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
|
@ -549,29 +550,29 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
if (!userid.startsWith("cloud")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Boolean.valueOf(_configDao.getValue("system.vm.random.password"))) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
String already = _configDao.getValue("system.vm.password");
|
||||
if (already == null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
String rpassword = PasswordGenerator.generatePresharedKey(8);
|
||||
String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) "
|
||||
+ "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword
|
||||
+ "','randmon password generated each management server starts for system vm')";
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
|
||||
stmt.executeUpdate(wSql);
|
||||
s_logger.info("Updated systemvm password in database");
|
||||
} catch (SQLException e) {
|
||||
s_logger.error("Cannot retrieve systemvm password", e);
|
||||
}
|
||||
}
|
||||
String already = _configDao.getValue("system.vm.password");
|
||||
if (already == null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
String rpassword = PasswordGenerator.generatePresharedKey(8);
|
||||
String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) "
|
||||
+ "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword
|
||||
+ "','randmon password generated each management server starts for system vm')";
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
|
||||
stmt.executeUpdate(wSql);
|
||||
s_logger.info("Updated systemvm password in database");
|
||||
} catch (SQLException e) {
|
||||
s_logger.error("Cannot retrieve systemvm password", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void updateKeyPairs() {
|
||||
|
|
@ -585,17 +586,17 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
String already = _configDao.getValue("ssh.privatekey");
|
||||
String homeDir = null;
|
||||
if (devel) {
|
||||
homeDir = Script.runSimpleBashScript("echo ~");
|
||||
if (homeDir == null) {
|
||||
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
|
||||
}
|
||||
homeDir = Script.runSimpleBashScript("echo ~");
|
||||
if (homeDir == null) {
|
||||
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
|
||||
}
|
||||
} else {
|
||||
homeDir = Script.runSimpleBashScript("echo ~cloud");
|
||||
if (homeDir == null) {
|
||||
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
|
||||
}
|
||||
homeDir = Script.runSimpleBashScript("echo ~cloud");
|
||||
if (homeDir == null) {
|
||||
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Processing updateKeyPairs");
|
||||
}
|
||||
|
|
@ -634,9 +635,9 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
String publicKey = new String(arr2).trim();
|
||||
|
||||
String insertSql1 = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','ssh.privatekey', '" + DBEncryptionUtil.encrypt(privateKey) + "','Private key for the entire CloudStack')";
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','ssh.privatekey', '" + DBEncryptionUtil.encrypt(privateKey) + "','Private key for the entire CloudStack')";
|
||||
String insertSql2 = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','ssh.publickey', '" + DBEncryptionUtil.encrypt(publicKey) + "','Public key for the entire CloudStack')";
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','ssh.publickey', '" + DBEncryptionUtil.encrypt(publicKey) + "','Public key for the entire CloudStack')";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
|
@ -672,11 +673,11 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
}
|
||||
s_logger.info("Going to update systemvm iso with generated keypairs if needed");
|
||||
try {
|
||||
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
|
||||
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
|
||||
} catch (CloudRuntimeException e) {
|
||||
if (!devel) {
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
if (!devel) {
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -748,7 +749,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
String password = PasswordGenerator.generateRandomPassword(12);
|
||||
|
||||
String insertSql1 = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','secstorage.copy.password', '" + DBEncryptionUtil.encrypt(password) + "','Password used to authenticate zone-to-zone template copy requests')";
|
||||
"VALUES ('Hidden','DEFAULT', 'management-server','secstorage.copy.password', '" + DBEncryptionUtil.encrypt(password) + "','Password used to authenticate zone-to-zone template copy requests')";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
|
@ -875,16 +876,16 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
@DB
|
||||
protected void createDefaultNetworkOfferings() {
|
||||
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork,
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork,
|
||||
TrafficType.Public, true);
|
||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork,
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork,
|
||||
TrafficType.Management, false);
|
||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork,
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork,
|
||||
TrafficType.Control, false);
|
||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork,
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork,
|
||||
TrafficType.Storage, true);
|
||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||
NetworkOfferingVO privateGatewayNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPrivateGatewayNetworkOffering, GuestType.Isolated);
|
||||
|
|
@ -939,7 +940,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled);
|
||||
defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering);
|
||||
|
||||
|
||||
for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
|
|
@ -976,7 +977,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
|
||||
(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
|
@ -1014,7 +1015,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
// Offering #6
|
||||
NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
|
|
@ -1025,7 +1026,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks);
|
||||
|
||||
|
||||
Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
|
|
@ -1037,14 +1038,14 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
defaultVpcNetworkOfferingProviders.put(Service.StaticNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter);
|
||||
|
||||
|
||||
for (Service service : defaultVpcNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
|
||||
(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
// Offering #7
|
||||
NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
|
||||
|
|
@ -1055,7 +1056,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
|
||||
defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB);
|
||||
|
||||
|
||||
Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProvidersNoLB = new HashMap<Network.Service, Network.Provider>();
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
|
|
@ -1066,16 +1067,16 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.StaticNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.PortForwarding, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Vpn, Provider.VPCVirtualRouter);
|
||||
|
||||
|
||||
for (Service service : defaultVpcNetworkOfferingProvidersNoLB.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service));
|
||||
(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2443,5 +2443,10 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_policy_map` (
|
|||
CONSTRAINT `fk_autoscale_vmgroup_policy_map__policy_id` FOREIGN KEY `fk_autoscale_vmgroup_policy_map__policy_id` (`policy_id`) REFERENCES `autoscale_policies` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (1,'snmp','Linux User CPU Time(%)', '.1.3.6.1.4.1.2021.11.9.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (2,'snmp','Linux System CPU Time(%)', '.1.3.6.1.4.1.2021.11.10.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (3,'snmp','Linux CPU Idle Time(%)', '.1.3.6.1.4.1.2021.11.11.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','ResponseTime(in ms)', 'RESPTIME', now());
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -280,6 +280,11 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_policy_map` (
|
|||
CONSTRAINT `fk_autoscale_vmgroup_policy_map__policy_id` FOREIGN KEY `fk_autoscale_vmgroup_policy_map__policy_id` (`policy_id`) REFERENCES `autoscale_policies` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (1,'snmp','Linux User CPU Time(%)', '.1.3.6.1.4.1.2021.11.9.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (2,'snmp','Linux System CPU Time(%)', '.1.3.6.1.4.1.2021.11.10.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (3,'snmp','Linux CPU Idle Time(%)', '.1.3.6.1.4.1.2021.11.11.0', now());
|
||||
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','ResponseTime(in ms)', 'RESPTIME', now());
|
||||
|
||||
CREATE TABLE `cloud`.`s2s_vpn_gateway` (
|
||||
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
|
||||
`uuid` varchar(40),
|
||||
|
|
@ -333,3 +338,4 @@ CREATE TABLE `cloud`.`s2s_vpn_connection` (
|
|||
CONSTRAINT `uc_s2s_vpn_connection__uuid` UNIQUE (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue