1) Add host_master table for tracking VMWare vShpere servers

2) Add SynchronizationEvent for in-process event synchronization
3) Move VMware files out of FOSS code base
This commit is contained in:
Kelven Yang 2010-08-18 17:30:11 -07:00
parent b3cf83c94e
commit 792fdf91b8
7 changed files with 109 additions and 210 deletions

View File

@ -1,130 +0,0 @@
package com.cloud.hypervisor.vmware.resource;
import java.util.Map;
import javax.naming.ConfigurationException;
import com.cloud.agent.IAgentControl;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.PingCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.storage.CopyVolumeAnswer;
import com.cloud.agent.api.storage.CopyVolumeCommand;
import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.storage.ShareAnswer;
import com.cloud.agent.api.storage.ShareCommand;
import com.cloud.host.Host.Type;
import com.cloud.resource.ServerResource;
import com.cloud.storage.resource.StoragePoolResource;
public class VmwareResource implements StoragePoolResource, ServerResource {
private boolean _isRemoteAgent = false;
@Override
public DownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public Answer execute(DestroyCommand cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public ShareAnswer execute(ShareCommand cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public CreateAnswer execute(CreateCommand cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public void disconnected() {
// TODO Auto-generated method stub
}
@Override
public Answer executeRequest(Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public IAgentControl getAgentControl() {
// TODO Auto-generated method stub
return null;
}
@Override
public PingCommand getCurrentStatus(long id) {
// TODO Auto-generated method stub
return null;
}
@Override
public Type getType() {
// TODO Auto-generated method stub
return null;
}
@Override
public StartupCommand[] initialize() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setAgentControl(IAgentControl agentControl) {
// TODO Auto-generated method stub
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return true;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean start() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public boolean IsRemoteAgent() {
return _isRemoteAgent;
}
public void setRemoteAgent(boolean remote) {
_isRemoteAgent = remote;
}
}

View File

@ -778,6 +778,12 @@ public class TestVMWare {
"dvPortGroup-vlan26", vNicSpec);
}
private void createDatacenter() throws Exception {
cb.getServiceConnection3().getService().createDatacenter(
cb.getServiceConnection3().getRootFolder(),
"cloud.dc.test");
}
public static void main(String[] args) throws Exception {
setupLog4j();
TestVMWare client = new TestVMWare();
@ -800,8 +806,10 @@ public class TestVMWare {
// client.createSnapshot();
// client.registerTemplate();
// client.createVmFromTemplate();
client.addNic();
// client.addNic();
// client.addNicToNetwork();
client.createDatacenter();
cb.disConnect();
} catch (Exception e) {
e.printStackTrace();

View File

@ -1,40 +0,0 @@
package com.cloud.hypervisor.vmware.discoverer;
import java.net.URI;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.exception.DiscoveryException;
import com.cloud.host.HostVO;
import com.cloud.resource.Discoverer;
import com.cloud.resource.DiscovererBase;
import com.cloud.resource.ServerResource;
@Local(value=Discoverer.class)
public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer {
@Override
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
String username, String password) throws DiscoveryException {
// ???
return null;
}
@Override
public void postDiscovery(List<HostVO> hosts, long msId) {
//do nothing
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params);
// TODO
return true;
}
}

View File

@ -250,3 +250,6 @@ ALTER TABLE `cloud`.`network_group_vm_map` ADD CONSTRAINT `fk_network_group_vm_m
ALTER TABLE `cloud`.`op_nwgrp_work` ADD INDEX `i_op_nwgrp_work__instance_id`(`instance_id`);
ALTER TABLE `cloud`.`op_nwgrp_work` ADD INDEX `i_op_nwgrp_work__mgmt_server_id`(`mgmt_server_id`);
ALTER TABLE `cloud`.`host_master` ADD UNIQUE `i_host_master__service_address`(`service_address`);

View File

@ -76,6 +76,7 @@ DROP TABLE IF EXISTS `cloud`.`cluster`;
DROP TABLE IF EXISTS `cloud`.`nics`;
DROP TABLE IF EXISTS `cloud`.`network_profiles`;
DROP TABLE IF EXISTS `cloud`.`network_offerings`;
DROP TABLE IF EXISTS `cloud`.`host_master`;
CREATE TABLE `cloud`.`network_profiles` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
@ -1044,4 +1045,13 @@ CREATE TABLE `cloud`.`op_vm_ruleset_log` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`host_master` (
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
`type` varchar(32) NOT NULL,
`service_address` varchar(255) NOT NULL,
`admin` varchar(32) NOT NULL,
`password` varchar(32),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET foreign_key_checks = 1;

View File

@ -0,0 +1,86 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.utils.concurrency;
import org.apache.log4j.Logger;
public class SynchronizationEvent {
protected final static Logger s_logger = Logger.getLogger(SynchronizationEvent.class);
private boolean signalled;
public SynchronizationEvent() {
signalled = false;
}
public SynchronizationEvent(boolean signalled) {
this.signalled = signalled;
}
public void setEvent() {
synchronized(this) {
signalled = true;
notifyAll();
}
}
public void resetEvent() {
synchronized(this) {
signalled = false;
}
}
public boolean waitEvent() {
synchronized(this) {
if(signalled)
return true;
while(true) {
try {
wait();
assert(signalled);
return signalled;
} catch (InterruptedException e) {
s_logger.debug("unexpected awaken signal in wait()");
}
}
}
}
public boolean waitEvent(long timeOutMiliseconds) {
synchronized(this) {
if(signalled)
return true;
try {
wait(timeOutMiliseconds);
return signalled;
} catch (InterruptedException e) {
// TODO, we don't honor time out semantics when the waiting thread is interrupted
s_logger.debug("unexpected awaken signal in wait(...)");
return false;
}
}
}
public boolean isSignalled() {
synchronized(this) {
return signalled;
}
}
}

View File

@ -41,16 +41,6 @@ import com.cloud.utils.Profiler;
// }
// lock.releaseRef();
//
//
// GlobalLock.Auto lock = GlobalLock.getAutoInternLock("some table name" + rowId);
// if(lock.lock()) {
// try {
// do something
// } finally {
// lock.unlock();
// }
// }
//
public class GlobalLock {
protected final static Logger s_logger = Logger.getLogger(GlobalLock.class);
@ -93,10 +83,6 @@ public class GlobalLock {
return refCount;
}
public static GlobalLock.Auto getAutoInternLock(String name) {
return new GlobalLock.Auto(getInternLock(name));
}
public static GlobalLock getInternLock(String name) {
synchronized(s_lockMap) {
if(s_lockMap.containsKey(name)) {
@ -203,28 +189,4 @@ public class GlobalLock {
public String getName() {
return name;
}
public static class Auto {
private GlobalLock lock;
public Auto(GlobalLock lock) {
this.lock = lock;
}
protected void finalize() throws Throwable {
try {
lock.releaseRef();
} finally {
super.finalize();
}
}
public boolean lock(int timeoutSeconds) {
return lock.lock(timeoutSeconds);
}
public boolean unlock() {
return lock.unlock();
}
}
}