mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
d49d6a529f
|
|
@ -0,0 +1,60 @@
|
|||
This document describes how to set up and configure a single server CloudStack installation so that you can quickly start play around the CloudStack platform. The easiest way is to deploy CloudStack from RPM package, building CloudStack from source is for advanced user. This guide is all about building CloudStack from the source and installing directly from there . This guide is suitable for you if you want to develop the CloudStack.
|
||||
|
||||
I have tested this procedure on Fedora Core 14
|
||||
|
||||
Step 1: Install the tools and dependencies:
|
||||
For fedora the package names are ant ant-devel, openjdk, openjdk-devel
|
||||
|
||||
Tools:
|
||||
yum install ant ant-devel openjdk openjdk-devel mysql mysql-server tomcat
|
||||
|
||||
Dependencies:
|
||||
yum install jakarta-commons-collections jakarta-commons-dbcp.noarch apache-commons-logging.noarch jakarta-commons-pool jakarta-commons-httpclient.noarch ws-commons-util.noarch glibc-devel gcc python MySQL-python openssh-clients
|
||||
|
||||
Step 2: Configuration
|
||||
|
||||
Start the MySQL service :
|
||||
|
||||
# service mysqld start
|
||||
|
||||
Step 3: Get the source
|
||||
|
||||
$ git clone https://github.com/CloudStack/CloudStack.git
|
||||
|
||||
For subsequent pulls, do:
|
||||
$ git pull
|
||||
|
||||
Step 4: Building, testing, and deploying CloudStack using Ant :
|
||||
|
||||
Ant is a Java-based build tool designed to be cross-platform, easy to use, extensible, and scalable. Ant is controlled by providing a text file that tells how to perform all the stages of building, testing, and deploying a project. These files are build files, and every project that uses Ant must have at least one named as build.xml. You can see build.xml in your CloudStack source.
|
||||
|
||||
Type to build CloudStack :
|
||||
$ ant clean-all build-all
|
||||
|
||||
Type to deploy mgt server :
|
||||
$ ant deploy-server
|
||||
|
||||
Type to deploy database :
|
||||
$ ant deploydb
|
||||
|
||||
Type to run mgt server:
|
||||
$ ant debug
|
||||
|
||||
If all of the above process is successful. You are done the single server CloudStack installation.Now your Cloud.com Management Server is running.
|
||||
|
||||
Open your browser and type the bellow url in address bar:
|
||||
|
||||
http://localhost:8080/client/
|
||||
|
||||
OR
|
||||
|
||||
http://management-server-ip-address:8080/client
|
||||
|
||||
You can see CloudStack Management Console page via a web browser. It will show you management consle login page. You can use the default username and password and leave domain as blank.
|
||||
|
||||
The default credentials are “admin” for user and “password” for password. The domain field should be left blank. A blank
|
||||
domain field is defaulted to the ROOT domain.
|
||||
|
||||
NOTE : This document is very basic CloudStack installation. If you are very new to CloudStack and want to feel the power of CloudStack very quickly in RPM based distro, this document will guide very clear step to get it done. Since I am new to CloudStack, I doing this documentation by learning from community. I will keet update new information in this guide to make it more valuable resource.
|
||||
|
||||
|
||||
|
|
@ -8,17 +8,12 @@
|
|||
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/agent"/>
|
||||
<classpathentry kind="lib" path="/deps/cloud-gson.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core-premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/agent-premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-proxy"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-viewer"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/setup"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/test"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/thirdparty"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/tools"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/ui"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/usage"/>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
############################################################
|
||||
# guava uses nfs storage, before setting up make sure
|
||||
# * optionally turn off stats collectors
|
||||
# * expunge.delay and expunge.interval are 60s
|
||||
############################################################
|
||||
'''
|
||||
|
||||
from optparse import OptionParser
|
||||
from configGenerator import *
|
||||
import random
|
||||
|
||||
|
||||
def getGlobalSettings():
|
||||
global_settings = {'expunge.delay': '60',
|
||||
'expunge.interval': '60',
|
||||
'expunge.workers': '3',
|
||||
'workers': '10',
|
||||
'use.user.concentrated.pod.allocation': 'true',
|
||||
'vm.allocation.algorithm': 'random',
|
||||
'vm.op.wait.interval': '5',
|
||||
'guest.domain.suffix': 'guava.simulator',
|
||||
'instance.name': 'TEST',
|
||||
'direct.agent.load.size': '1000',
|
||||
'default.page.size': '10000',
|
||||
'linkLocalIp.nums': '10',
|
||||
'check.pod.cidrs': 'false',
|
||||
}
|
||||
for k, v in global_settings.iteritems():
|
||||
cfg = configuration()
|
||||
cfg.name = k
|
||||
cfg.value = v
|
||||
yield cfg
|
||||
|
||||
|
||||
def describeGuavaResources(dbnode='localhost', mshost='localhost'):
|
||||
zs = cloudstackConfiguration()
|
||||
numberofpods = 1
|
||||
|
||||
clustersPerPod = 100
|
||||
hostsPerCluster = 10
|
||||
|
||||
z = zone()
|
||||
z.dns1 = '4.2.2.2'
|
||||
z.dns2 = '192.168.110.254'
|
||||
z.internaldns1 = '10.91.28.6'
|
||||
z.internaldns2 = '192.168.110.254'
|
||||
z.name = 'Guava'
|
||||
z.networktype = 'Advanced'
|
||||
z.guestcidraddress = '10.1.1.0/24'
|
||||
z.vlan='100-3000'
|
||||
|
||||
p = pod()
|
||||
p.name = 'POD1'
|
||||
p.gateway = '172.1.2.1'
|
||||
p.startip = '172.1.2.2'
|
||||
p.endip = '172.1.255.252'
|
||||
p.netmask = '255.255.0.0'
|
||||
|
||||
v = iprange()
|
||||
v.vlan = 'untagged'
|
||||
v.startip = '172.2.1.2'
|
||||
v.endip = '172.2.255.252'
|
||||
v.gateway = '172.2.1.1'
|
||||
v.netmask = '255.255.0.0'
|
||||
|
||||
curhost = 1
|
||||
for i in range(1, clustersPerPod + 1):
|
||||
c = cluster()
|
||||
c.clustername = 'POD1-CLUSTER' + str(i)
|
||||
c.hypervisor = 'Simulator'
|
||||
c.clustertype = 'CloudManaged'
|
||||
|
||||
for j in range(1, hostsPerCluster + 1):
|
||||
h = host()
|
||||
h.username = 'root'
|
||||
h.password = 'password'
|
||||
h.url = 'http://sim/test-%d'%(curhost)
|
||||
c.hosts.append(h)
|
||||
curhost = curhost + 1
|
||||
|
||||
ps = primaryStorage()
|
||||
ps.name = 'spool'+str(i)
|
||||
ps.url = 'nfs://172.16.24.32/export/path/'+str(i)
|
||||
c.primaryStorages.append(ps)
|
||||
p.clusters.append(c)
|
||||
|
||||
|
||||
secondary = secondaryStorage()
|
||||
secondary.url = 'nfs://172.16.25.32/secondary/path'
|
||||
|
||||
z.pods.append(p)
|
||||
z.ipranges.append(v)
|
||||
z.secondaryStorages.append(secondary)
|
||||
zs.zones.append(z)
|
||||
|
||||
'''Add mgt server'''
|
||||
mgt = managementServer()
|
||||
mgt.mgtSvrIp = mshost
|
||||
zs.mgtSvr.append(mgt)
|
||||
|
||||
'''Add a database'''
|
||||
db = dbServer()
|
||||
db.dbSvr = opts.dbnode
|
||||
zs.dbSvr = db
|
||||
|
||||
'''Add some configuration'''
|
||||
[zs.globalConfig.append(cfg) for cfg in getGlobalSettings()]
|
||||
|
||||
''''add loggers'''
|
||||
testClientLogger = logger()
|
||||
testClientLogger.name = 'TestClient'
|
||||
testClientLogger.file = '/var/log/testclient.log'
|
||||
|
||||
testCaseLogger = logger()
|
||||
testCaseLogger.name = 'TestCase'
|
||||
testCaseLogger.file = '/var/log/testcase.log'
|
||||
|
||||
zs.logger.append(testClientLogger)
|
||||
zs.logger.append(testCaseLogger)
|
||||
return zs
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option('-o', '--output', action='store', default='./guavaCfg', dest='output', help='the path where the json config file generated')
|
||||
parser.add_option('-d', '--dbnode', dest='dbnode', help='hostname/ip of the database node', action='store')
|
||||
parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store')
|
||||
|
||||
(opts, args) = parser.parse_args()
|
||||
cfg = describeGuavaResources(opts.dbnode, opts.mshost)
|
||||
generate_setup_config(cfg, opts.output)
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env python
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import random
|
||||
import hashlib
|
||||
from cloudstackTestCase import *
|
||||
|
||||
class Provision(cloudstackTestCase):
|
||||
'''
|
||||
'''
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
def test_createAccounts(self, numberOfAccounts=5):
|
||||
'''
|
||||
Create a bunch of user accounts
|
||||
'''
|
||||
mdf = hashlib.md5()
|
||||
mdf.update('password')
|
||||
mdf_pass = mdf.hexdigest()
|
||||
api = self.testClient.getApiClient()
|
||||
for i in range(1, numberOfAccounts + 1):
|
||||
acct = createAccount.createAccountCmd()
|
||||
acct.accounttype = 0
|
||||
acct.firstname = 'user' + str(i)
|
||||
acct.lastname = 'user' + str(i)
|
||||
acct.password = mdf_pass
|
||||
acct.username = 'user' + str(i)
|
||||
acct.email = 'user@example.com'
|
||||
acct.account = 'user' + str(i)
|
||||
acct.domainid = 1
|
||||
acctResponse = api.createAccount(acct)
|
||||
self.debug("successfully created account: %s, user: %s, id: %s"%(acctResponse.account, acctResponse.username, acctResponse.id))
|
||||
|
||||
|
||||
def deployCmd(self, account):
|
||||
deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd()
|
||||
deployVmCmd.zoneid = 1
|
||||
deployVmCmd.hypervisor='Simulator'
|
||||
deployVmCmd.account=account
|
||||
deployVmCmd.domainid=1
|
||||
deployVmCmd.templateid=10
|
||||
deployVmCmd.serviceofferingid=7
|
||||
return deployVmCmd
|
||||
|
||||
|
||||
def listVmsInAccountCmd(self, acct):
|
||||
api = self.testClient.getApiClient()
|
||||
listVmCmd = listVirtualMachines.listVirtualMachinesCmd()
|
||||
listVmCmd.account = acct
|
||||
listVmCmd.zoneid = 1
|
||||
listVmCmd.domainid = 1
|
||||
listVmResponse = api.listVirtualMachines(listVmCmd)
|
||||
self.debug(listVmResponse)
|
||||
return listVmResponse
|
||||
|
||||
|
||||
def destroyVmCmd(self, key):
|
||||
api = self.testClient.getApiClient()
|
||||
destroyVmCmd = destroyVirtualMachine.destroyVirtualMachineCmd()
|
||||
destroyVmCmd.id = key
|
||||
api.destroyVirtualMachine(destroyVmCmd)
|
||||
|
||||
|
||||
def test_stressDeploy(self):
|
||||
'''
|
||||
Deploy 20 Vms in each account
|
||||
'''
|
||||
api = self.testClient.getApiClient()
|
||||
for acct in range(1, 5):
|
||||
[api.deployVirtualMachine(self.deployCmd('user'+str(acct))) for x in range(0,20)]
|
||||
|
||||
def test_stressDestroy(self):
|
||||
'''
|
||||
Cleanup all Vms in every account
|
||||
'''
|
||||
api = self.testClient.getApiClient()
|
||||
for acct in range(1, 6):
|
||||
for vm in self.listVmsInAccountCmd('user'+str(acct)):
|
||||
self.destroyVmCmd(vm.id)
|
||||
|
||||
def test_combineStress(self):
|
||||
for i in range(0, 5):
|
||||
self.test_stressDestroy()
|
||||
self.test_stressDeploy()
|
||||
|
||||
def deployN(self,nargs=300,batchsize=0):
|
||||
'''
|
||||
Deploy Nargs number of VMs concurrently in batches of size {batchsize}.
|
||||
When batchsize is 0 all Vms are deployed in one batch
|
||||
VMs will be deployed in 5:2:6 ratio
|
||||
'''
|
||||
cmds = []
|
||||
|
||||
if batchsize == 0:
|
||||
self.testClient.submitCmdsAndWait(cmds)
|
||||
else:
|
||||
while len(z) > 0:
|
||||
try:
|
||||
newbatch = [cmds.pop() for b in range(batchsize)] #pop batchsize items
|
||||
self.testClient.submitCmdsAndWait(newbatch)
|
||||
except IndexError:
|
||||
break
|
||||
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
############################################################
|
||||
# Kumquat uses nfs storage, before setting up make sure
|
||||
# * optionally turn off stats collectors
|
||||
# * expunge.delay and expunge.interval are 60s
|
||||
############################################################
|
||||
'''
|
||||
|
||||
from optparse import OptionParser
|
||||
from configGenerator import *
|
||||
import random
|
||||
|
||||
|
||||
def getGlobalSettings():
|
||||
global_settings = {'expunge.delay': '60',
|
||||
'expunge.interval': '60',
|
||||
'capacity.skipcounting.hours': '2',
|
||||
'cpu.overprovisioning.factor': '1.5',
|
||||
'expunge.workers': '3',
|
||||
'workers': '10',
|
||||
'use.user.concentrated.pod.allocation': 'true',
|
||||
'vm.allocation.algorithm': 'random',
|
||||
'vm.op.wait.interval': '5',
|
||||
'guest.domain.suffix': 'kumquat.simulator',
|
||||
'instance.name': 'KIM',
|
||||
'direct.agent.load.size': '16',
|
||||
'default.page.size': '500',
|
||||
'linkLocalIp.nums': '10',
|
||||
'check.pod.cidrs': 'false',
|
||||
'max.account.public.ips': '10000',
|
||||
'max.account.snapshots': '10000',
|
||||
'max.account.templates': '10000',
|
||||
'max.account.user.vms': '10000',
|
||||
'max.account.volumes': '10000',
|
||||
}
|
||||
for k, v in global_settings.iteritems():
|
||||
cfg = configuration()
|
||||
cfg.name = k
|
||||
cfg.value = v
|
||||
yield cfg
|
||||
|
||||
|
||||
def podIpRangeGenerator():
|
||||
x=1
|
||||
y=2
|
||||
while 1:
|
||||
if y == 255:
|
||||
x=x+1
|
||||
if x == 255:
|
||||
x=1
|
||||
break
|
||||
|
||||
y=1
|
||||
|
||||
y=y+1
|
||||
#pod mangement network
|
||||
yield ('172.'+str(x)+'.'+str(y)+'.129', '172.'+str(x)+'.'+str(y)+'.130', '172.'+str(x)+'.'+str(y)+'.189')
|
||||
|
||||
|
||||
def vlanIpRangeGenerator():
|
||||
x=1
|
||||
y=2
|
||||
while 1:
|
||||
if y == 255:
|
||||
x=x+1
|
||||
if x==255:
|
||||
x=1
|
||||
break
|
||||
|
||||
y=1
|
||||
|
||||
y=y+1
|
||||
#vlan ip range
|
||||
yield ('172.'+str(x)+'.'+str(y)+'.129', '172.'+str(x)+'.'+str(y)+'.190', '172.'+str(x)+'.'+str(y)+'.249')
|
||||
|
||||
|
||||
def describeKumquatResources(dbnode='localhost', mshost='localhost'):
|
||||
zs = cloudstackConfiguration()
|
||||
numberofpods = 15
|
||||
|
||||
clustersPerPod = 2
|
||||
hostsPerCluster = 8
|
||||
|
||||
curpod = 0
|
||||
curhost = 0
|
||||
|
||||
z = zone()
|
||||
z.dns1 = '4.2.2.2'
|
||||
z.dns2 = '192.168.110.254'
|
||||
z.internaldns1 = '10.91.28.6'
|
||||
z.internaldns2 = '192.168.110.254'
|
||||
z.name = 'Kumquat'
|
||||
z.networktype = 'Advanced'
|
||||
z.guestcidraddress = '10.1.1.0/24'
|
||||
z.vlan='100-3000'
|
||||
|
||||
for podRange,vlanRange in zip(podIpRangeGenerator(), vlanIpRangeGenerator()):
|
||||
p = pod()
|
||||
curpod=curpod+1
|
||||
p.name = 'POD'+str(curpod)
|
||||
p.gateway=podRange[0]
|
||||
p.startip=podRange[1]
|
||||
p.endip=podRange[2]
|
||||
p.netmask='255.255.255.128'
|
||||
|
||||
for i in range(1,clustersPerPod+1):
|
||||
c = cluster()
|
||||
c.clustername = 'POD'+str(curpod)+'-CLUSTER'+str(i)
|
||||
c.hypervisor = 'Simulator'
|
||||
c.clustertype = 'CloudManaged'
|
||||
|
||||
ps = primaryStorage()
|
||||
ps.name = 'spool'+str(i)
|
||||
ps.url = 'nfs://172.16.24.32/export/path/'+str(curpod)+'/'+str(i)
|
||||
c.primaryStorages.append(ps)
|
||||
|
||||
for i in range(1, hostsPerCluster + 1):
|
||||
h = host()
|
||||
h.username = 'root'
|
||||
h.password = 'password'
|
||||
h.url = "http://sim/test-%d"%(curhost)
|
||||
c.hosts.append(h)
|
||||
curhost=curhost+1
|
||||
|
||||
p.clusters.append(c)
|
||||
|
||||
z.pods.append(p)
|
||||
if curpod == numberofpods:
|
||||
break
|
||||
|
||||
v = iprange()
|
||||
v.vlan = 'untagged'
|
||||
v.gateway='172.2.1.1'
|
||||
v.startip='172.2.1.2'
|
||||
v.endip='172.2.255.252'
|
||||
v.netmask="255.255.0.0"
|
||||
z.ipranges.append(v)
|
||||
|
||||
secondary = secondaryStorage()
|
||||
secondary.url = 'nfs://172.16.25.32/secondary/path'
|
||||
z.secondaryStorages.append(secondary)
|
||||
zs.zones.append(z)
|
||||
|
||||
'''Add mgt server'''
|
||||
mgt = managementServer()
|
||||
mgt.mgtSvrIp = mshost
|
||||
zs.mgtSvr.append(mgt)
|
||||
|
||||
'''Add a database'''
|
||||
db = dbServer()
|
||||
db.dbSvr = opts.dbnode
|
||||
zs.dbSvr = db
|
||||
|
||||
'''Add some configuration'''
|
||||
[zs.globalConfig.append(cfg) for cfg in getGlobalSettings()]
|
||||
|
||||
''''add loggers'''
|
||||
testClientLogger = logger()
|
||||
testClientLogger.name = 'TestClient'
|
||||
testClientLogger.file = '/var/log/testclient.log'
|
||||
|
||||
testCaseLogger = logger()
|
||||
testCaseLogger.name = 'TestCase'
|
||||
testCaseLogger.file = '/var/log/testcase.log'
|
||||
|
||||
zs.logger.append(testClientLogger)
|
||||
zs.logger.append(testCaseLogger)
|
||||
return zs
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option('-o', '--output', action='store', default='./KumquatCfg', dest='output', help='the path where the json config file generated')
|
||||
parser.add_option('-d', '--dbnode', dest='dbnode', help='hostname/ip of the database node', action='store')
|
||||
parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store')
|
||||
|
||||
(opts, args) = parser.parse_args()
|
||||
cfg = describeKumquatResources(opts.dbnode, opts.mshost)
|
||||
generate_setup_config(cfg, opts.output)
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/env python
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import random
|
||||
import hashlib
|
||||
from cloudstackTestCase import *
|
||||
|
||||
class Provision(cloudstackTestCase):
|
||||
'''
|
||||
'''
|
||||
|
||||
so = '10' #default
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skip("already done")
|
||||
def test_createAccounts(self, numberOfAccounts=850):
|
||||
'''
|
||||
Create a bunch of user accounts
|
||||
'''
|
||||
mdf = hashlib.md5()
|
||||
mdf.update('password')
|
||||
mdf_pass = mdf.hexdigest()
|
||||
api = self.testClient.getApiClient()
|
||||
for i in range(1, numberOfAccounts + 1):
|
||||
acct = createAccount.createAccountCmd()
|
||||
acct.accounttype = 0
|
||||
acct.firstname = 'user' + str(i)
|
||||
acct.lastname = 'user' + str(i)
|
||||
acct.password = mdf_pass
|
||||
acct.username = 'user' + str(i)
|
||||
acct.email = 'user@example.com'
|
||||
acct.account = 'user' + str(i)
|
||||
acct.domainid = 1
|
||||
acctResponse = api.createAccount(acct)
|
||||
self.debug(acctResponse)
|
||||
|
||||
|
||||
def test_setupServiceOffering(self):
|
||||
socreate = createServiceOffering.createServiceOfferingCmd()
|
||||
socreate.cpunumber = 1
|
||||
socreate.cpuspeed = 100
|
||||
socreate.displaytext = 'Sample SO'
|
||||
socreate.memory = 128
|
||||
socreate.name = 'Sample SO'
|
||||
api = self.testClient.getApiClient()
|
||||
soresponse = api.createServiceOffering(socreate)
|
||||
self.so = soresponse.id
|
||||
|
||||
def deployCmd(self, acct):
|
||||
deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd()
|
||||
deployVmCmd.zoneid = 1
|
||||
deployVmCmd.hypervisor='Simulator'
|
||||
deployVmCmd.account=acct
|
||||
deployVmCmd.domainid=1
|
||||
deployVmCmd.templateid=2
|
||||
deployVmCmd.serviceofferingid=self.so
|
||||
return deployVmCmd
|
||||
|
||||
|
||||
def test_stressDeploy(self):
|
||||
'''
|
||||
Deploy 5 Vms in each account
|
||||
'''
|
||||
api = self.testClient.getApiClient()
|
||||
for acct in range(122, 850):
|
||||
[api.deployVirtualMachine(self.deployCmd('user'+str(acct))) for x in range(0, 5)]
|
||||
|
||||
|
||||
def deployN(self,nargs=300,batchsize=0):
|
||||
'''
|
||||
Deploy Nargs number of VMs concurrently in batches of size {batchsize}.
|
||||
When batchsize is 0 all Vms are deployed in one batch
|
||||
VMs will be deployed in 5:2:6 ratio
|
||||
'''
|
||||
cmds = []
|
||||
|
||||
if batchsize == 0:
|
||||
self.testClient.submitCmdsAndWait(cmds)
|
||||
else:
|
||||
while len(z) > 0:
|
||||
try:
|
||||
newbatch = [cmds.pop() for b in range(batchsize)] #pop batchsize items
|
||||
self.testClient.submitCmdsAndWait(newbatch)
|
||||
except IndexError:
|
||||
break
|
||||
|
|
@ -44,18 +44,18 @@ def getGlobalSettings():
|
|||
'use.user.concentrated.pod.allocation':'false',
|
||||
'vm.allocation.algorithm':'firstfit',
|
||||
'capacity.check.period':'0',
|
||||
'host.stats.interval':'-1',
|
||||
'vm.stats.interval':'-1',
|
||||
'storage.stats.interval':'-1',
|
||||
'router.stats.interval':'-1',
|
||||
# 'host.stats.interval':'-1',
|
||||
# 'vm.stats.interval':'-1',
|
||||
# 'storage.stats.interval':'-1',
|
||||
# 'router.stats.interval':'-1',
|
||||
'vm.op.wait.interval':'5',
|
||||
'xen.public.network.device':'10.10.10.10', #only a dummy for the simulator
|
||||
'guest.domain.suffix':'zcloud.simulator',
|
||||
'guest.domain.suffix':'zucchini.simulator',
|
||||
'instance.name':'ZIM',
|
||||
'direct.agent.load.size':'1000',
|
||||
'default.page.size':'10000',
|
||||
'linkLocalIp.nums':'4',
|
||||
'systemvm.use.local.storage':'true',
|
||||
'system.vm.use.local.storage':'true',
|
||||
'use.local.storage':'true',
|
||||
'check.pod.cidrs':'false',
|
||||
}
|
||||
|
|
@ -201,7 +201,8 @@ if __name__=="__main__":
|
|||
(opts, args) = parser.parse_args()
|
||||
mandatories = ['mshost', 'dbnode', 'agents']
|
||||
for m in mandatories:
|
||||
if not opts.__dict__[m]:
|
||||
print "mandatory option missing"
|
||||
cfg = describeZucchiniResources(int(opts.agents), opts.dbnode, opts.mshost, opts.randomize)
|
||||
generate_setup_config(cfg, opts.output)
|
||||
if not opts.__dict__[m]:
|
||||
print "mandatory option missing"
|
||||
|
||||
cfg = describeZucchiniResources(int(opts.agents), opts.dbnode, opts.mshost, opts.randomize)
|
||||
generate_setup_config(cfg, opts.output)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
'''
|
||||
List Virtual Machine tests
|
||||
'''
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import timeit
|
||||
import random
|
||||
from cloudstackAPI import *
|
||||
from cloudstackTestCase import *
|
||||
|
||||
class ListVmTests(cloudstackTestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_listAllVm(self):
|
||||
numVms = 0
|
||||
def time_listAllVm():
|
||||
api = self.testClient.getApiClient()
|
||||
listVmCmd = listVirtualMachines.listVirtualMachinesCmd()
|
||||
listVmCmd.account = 'admin'
|
||||
listVmCmd.zoneid = 1
|
||||
listVmCmd.domainid = 1
|
||||
numVms = len(api.listVirtualMachines(listVmCmd))
|
||||
|
||||
t = timeit.Timer(time_listAllVm)
|
||||
l = t.repeat(5, 5)
|
||||
self.debug("Number of VMs: " + str(len(numVms)) + ", time for last 5 listVM calls : " + str(l))
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/tools"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
|
|
@ -13,5 +18,6 @@
|
|||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -386,6 +387,31 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
protected String getDefaultStorageScriptsDir() {
|
||||
return "scripts/storage/qcow2";
|
||||
}
|
||||
|
||||
private void saveProperties(Map<String, Object> params) throws ConfigurationException {
|
||||
final File file = PropertiesUtil.findConfigFile("agent.properties");
|
||||
if (file == null) {
|
||||
throw new ConfigurationException("Unable to find agent.properties.");
|
||||
}
|
||||
|
||||
s_logger.info("agent.properties found at " + file.getAbsolutePath());
|
||||
|
||||
try {
|
||||
Properties _properties = new Properties();
|
||||
_properties.load(new FileInputStream(file));
|
||||
Set<String> names = _properties.stringPropertyNames();
|
||||
for (String key : params.keySet()) {
|
||||
if (!names.contains(key)) {
|
||||
_properties.setProperty(key, (String)params.get(key));
|
||||
}
|
||||
}
|
||||
_properties.store(new FileOutputStream(file), "");
|
||||
} catch (final FileNotFoundException ex) {
|
||||
throw new CloudRuntimeException("Cannot find the file: " + file.getAbsolutePath(), ex);
|
||||
} catch (final IOException ex) {
|
||||
throw new CloudRuntimeException("IOException in reading " + file.getAbsolutePath(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
|
|
@ -560,8 +586,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
_localStoragePath = (String)params.get("local.storage.path");
|
||||
if (_localStoragePath == null) {
|
||||
_localStoragePath = "/var/lib/libvirt/images/";
|
||||
|
|
@ -569,7 +593,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
_localStorageUUID = (String)params.get("local.storage.uuid");
|
||||
if (_localStorageUUID == null) {
|
||||
throw new ConfigurationException("Can't find local.storage.uuid");
|
||||
_localStorageUUID = UUID.randomUUID().toString();
|
||||
params.put("local.storage.uuid", _localStorageUUID);
|
||||
}
|
||||
|
||||
value = (String)params.get("scripts.timeout");
|
||||
|
|
@ -663,6 +688,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
_storageResource = new LibvirtStorageResource(this, _storage, _createvmPath, _timeout, _mountPoint, _monitor);
|
||||
|
||||
saveProperties(params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -903,7 +929,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
} else if (cmd instanceof CopyVolumeCommand) {
|
||||
return execute((CopyVolumeCommand)cmd);
|
||||
} else {
|
||||
s_logger.warn("Unsupported command ");
|
||||
s_logger.warn("Unsupported command :"+cmd.toString());
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
|
|
@ -1596,7 +1622,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
cmd.stringifyRules(), vif, brname);
|
||||
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
|
||||
s_logger.warn("Failed to program Ingress network rules for vm " + cmd.getVmName());
|
||||
return new SecurityIngressRuleAnswer(cmd, false, "programming network rules failed");
|
||||
} else {
|
||||
s_logger.debug("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ", numrules=" + cmd.getRuleSet().length);
|
||||
|
|
@ -1624,7 +1650,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
cmd.stringifyRules(), vif, brname);
|
||||
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
|
||||
s_logger.warn("Failed to program Egress network rules for vm " + cmd.getVmName());
|
||||
return new SecurityEgressRuleAnswer(cmd, false, "programming network rules failed");
|
||||
} else {
|
||||
s_logger.debug("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ", numrules=" + cmd.getRuleSet().length);
|
||||
|
|
@ -3490,7 +3516,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
cmd.add("--vmid", vmId);
|
||||
cmd.add("--vmip", guestIP);
|
||||
/* type of the rule : ingress or egress */
|
||||
cmd.add("--type", type);
|
||||
cmd.add("--ruletype", type);
|
||||
cmd.add("--sig", sig);
|
||||
cmd.add("--seq", seq);
|
||||
cmd.add("--vmmac", mac);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ public class BackupSnapshotCommand extends SnapshotCommand {
|
|||
String prevSnapshotUuid,
|
||||
String prevBackupUuid,
|
||||
boolean isVolumeInactive,
|
||||
String vmName)
|
||||
String vmName,
|
||||
int wait)
|
||||
{
|
||||
super(primaryStoragePoolNameLabel, secondaryStoragePoolURL, snapshotUuid, snapshotName, dcId, accountId, volumeId);
|
||||
this.snapshotId = snapshotId;
|
||||
|
|
@ -74,6 +75,7 @@ public class BackupSnapshotCommand extends SnapshotCommand {
|
|||
this.vmName = vmName;
|
||||
this.pool = new StorageFilerTO(pool);
|
||||
setVolumePath(volumePath);
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
public String getPrevSnapshotUuid() {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ package com.cloud.agent.api;
|
|||
|
||||
public class CheckHealthCommand extends Command {
|
||||
|
||||
public CheckHealthCommand() {}
|
||||
|
||||
public CheckHealthCommand() {
|
||||
setWait(50);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class CheckOnHostCommand extends Command {
|
|||
|
||||
public CheckOnHostCommand(Host host) {
|
||||
this.host = new HostTO(host);
|
||||
setWait(20);
|
||||
}
|
||||
|
||||
public HostTO getHost() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class CheckVirtualMachineCommand extends Command {
|
|||
|
||||
public CheckVirtualMachineCommand(String vmName) {
|
||||
this.vmName = vmName;
|
||||
setWait(20);
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
|
|
|
|||
|
|
@ -28,13 +28,23 @@ import com.cloud.agent.api.LogLevel.Log4jLevel;
|
|||
* all of the methods that needs to be implemented by the children classes.
|
||||
*
|
||||
*/
|
||||
public abstract class Command {
|
||||
public abstract class Command {
|
||||
|
||||
// allow command to carry over hypervisor or other environment related context info
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
protected Map<String, String> contextMap = new HashMap<String, String>();
|
||||
private int wait; //in second
|
||||
|
||||
protected Command() {
|
||||
this.wait = 0;
|
||||
}
|
||||
|
||||
public int getWait() {
|
||||
return wait;
|
||||
}
|
||||
|
||||
public void setWait(int wait) {
|
||||
this.wait = wait;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -52,12 +52,14 @@ public class CreatePrivateTemplateFromSnapshotCommand extends SnapshotCommand {
|
|||
String backedUpSnapshotName,
|
||||
String origTemplateInstallPath,
|
||||
Long newTemplateId,
|
||||
String templateName)
|
||||
String templateName,
|
||||
int wait)
|
||||
{
|
||||
super(primaryStoragePoolNameLabel, secondaryStoragePoolURL, backedUpSnapshotUuid, backedUpSnapshotName, dcId, accountId, volumeId);
|
||||
this.origTemplateInstallPath = origTemplateInstallPath;
|
||||
this.newTemplateId = newTemplateId;
|
||||
this.templateName = templateName;
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,14 +31,15 @@ public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
|
|||
|
||||
public CreatePrivateTemplateFromVolumeCommand() {}
|
||||
|
||||
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath, String vmName) {
|
||||
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath, String vmName, int wait) {
|
||||
_secondaryStorageURL = secondaryStorageURL;
|
||||
_templateId = templateId;
|
||||
_accountId = accountId;
|
||||
_userSpecifiedName = userSpecifiedName;
|
||||
_uniqueName = uniqueName;
|
||||
_volumePath = volumePath;
|
||||
_vmName = vmName;
|
||||
_vmName = vmName;
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ public class CreateVolumeFromSnapshotCommand extends SnapshotCommand {
|
|||
Long accountId,
|
||||
Long volumeId,
|
||||
String backedUpSnapshotUuid,
|
||||
String backedUpSnapshotName)
|
||||
String backedUpSnapshotName,
|
||||
int wait)
|
||||
{
|
||||
super(primaryStoragePoolNameLabel, secondaryStoragePoolURL, backedUpSnapshotUuid, backedUpSnapshotName, dcId, accountId, volumeId);
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,9 +19,10 @@ package com.cloud.agent.api;
|
|||
|
||||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
@LogLevel(Log4jLevel.Debug)
|
||||
public class NetworkUsageAnswer extends Answer {
|
||||
Long bytesSent;
|
||||
String routerName;
|
||||
Long bytesSent;
|
||||
Long bytesReceived;
|
||||
|
||||
protected NetworkUsageAnswer() {
|
||||
|
|
@ -31,6 +32,7 @@ public class NetworkUsageAnswer extends Answer {
|
|||
super(cmd, true, details);
|
||||
this.bytesReceived = bytesReceived;
|
||||
this.bytesSent = bytesSent;
|
||||
routerName = cmd.getDomRName();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -49,4 +51,8 @@ public class NetworkUsageAnswer extends Answer {
|
|||
public Long getBytesSent() {
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
public String getRouterName() {
|
||||
return routerName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@ public class PingTestCommand extends Command {
|
|||
public PingTestCommand() {}
|
||||
|
||||
public PingTestCommand(String computingHostIp) {
|
||||
_computingHostIp = computingHostIp;
|
||||
_computingHostIp = computingHostIp;
|
||||
setWait(20);
|
||||
}
|
||||
|
||||
public PingTestCommand(String routerIp, String privateIp) {
|
||||
_routerIp = routerIp;
|
||||
_privateIp = privateIp;
|
||||
_privateIp = privateIp;
|
||||
setWait(20);
|
||||
}
|
||||
|
||||
public String getComputingHostIp() {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
String pool;
|
||||
HypervisorType hypervisorType;
|
||||
Map<String, String> hostDetails; //stuff like host os, cpu capabilities
|
||||
String hypervisorVersion;
|
||||
|
||||
public StartupRoutingCommand() {
|
||||
super(Host.Type.Routing);
|
||||
|
|
@ -59,7 +60,7 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
long speed,
|
||||
long memory,
|
||||
|
|
@ -71,7 +72,7 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms);
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
long speed,
|
||||
long memory,
|
||||
|
|
@ -82,50 +83,55 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, new HashMap<String,String>(), new HashMap<String, VmState>());
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
long speed,
|
||||
long memory,
|
||||
long dom0MinMemory,
|
||||
final String caps,
|
||||
final HypervisorType hypervisorType,
|
||||
final Map<String, String> hostDetails,
|
||||
Map<String, VmState> vms) {
|
||||
super(Host.Type.Routing);
|
||||
this.cpus = cpus;
|
||||
this.speed = speed;
|
||||
this.memory = memory;
|
||||
this.dom0MinMemory = dom0MinMemory;
|
||||
this.vms = vms;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.hostDetails = hostDetails;
|
||||
this.caps = caps;
|
||||
this.poolSync = false;
|
||||
long speed,
|
||||
long memory,
|
||||
long dom0MinMemory,
|
||||
final String caps,
|
||||
final HypervisorType hypervisorType,
|
||||
final Map<String, String> hostDetails,
|
||||
Map<String, VmState> vms) {
|
||||
super(Host.Type.Routing);
|
||||
this.cpus = cpus;
|
||||
this.speed = speed;
|
||||
this.memory = memory;
|
||||
this.dom0MinMemory = dom0MinMemory;
|
||||
this.vms = vms;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.hostDetails = hostDetails;
|
||||
this.caps = caps;
|
||||
this.poolSync = false;
|
||||
}
|
||||
|
||||
|
||||
public StartupRoutingCommand(int cpus2, long speed2, long memory2,
|
||||
long dom0MinMemory2, String caps2, HypervisorType hypervisorType2,
|
||||
Map<String, VmState> vms2) {
|
||||
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String,String>(), vms2);
|
||||
}
|
||||
|
||||
public void setChanges(Map<String, VmState> vms) {
|
||||
long dom0MinMemory2, String caps2, HypervisorType hypervisorType2,
|
||||
Map<String, VmState> vms2) {
|
||||
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String,String>(), vms2);
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType, final Map<String, String> hostDetails, Map<String, VmState> vms, String hypervisorVersion) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, hostDetails, vms);
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public void setChanges(Map<String, VmState> vms) {
|
||||
this.vms = vms;
|
||||
}
|
||||
|
||||
public void setStateChanges(Map<String, State> vms) {
|
||||
for( String vm_name : vms.keySet() ) {
|
||||
if( this.vms == null ) {
|
||||
this.vms = new HashMap<String, VmState>();
|
||||
}
|
||||
this.vms.put(vm_name, new VmState(vms.get(vm_name), null));
|
||||
}
|
||||
}
|
||||
|
||||
public void setStateChanges(Map<String, State> vms) {
|
||||
for( String vm_name : vms.keySet() ) {
|
||||
if( this.vms == null ) {
|
||||
this.vms = new HashMap<String, VmState>();
|
||||
}
|
||||
this.vms.put(vm_name, new VmState(vms.get(vm_name), null));
|
||||
}
|
||||
}
|
||||
|
||||
public int getCpus() {
|
||||
return cpus;
|
||||
}
|
||||
|
||||
|
||||
public String getCapabilities() {
|
||||
return caps;
|
||||
}
|
||||
|
|
@ -145,36 +151,36 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
public Map<String, VmState> getVmStates() {
|
||||
return vms;
|
||||
}
|
||||
|
||||
|
||||
public void setSpeed(long speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
|
||||
public void setCpus(int cpus) {
|
||||
this.cpus = cpus;
|
||||
}
|
||||
|
||||
|
||||
public void setMemory(long memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
|
||||
public void setDom0MinMemory(long dom0MinMemory) {
|
||||
this.dom0MinMemory = dom0MinMemory;
|
||||
}
|
||||
|
||||
|
||||
public void setCaps(String caps) {
|
||||
this.caps = caps;
|
||||
}
|
||||
|
||||
|
||||
public String getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
public void setPool(String pool) {
|
||||
this.pool = pool;
|
||||
return pool;
|
||||
}
|
||||
|
||||
public boolean isPoolSync() {
|
||||
public void setPool(String pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public boolean isPoolSync() {
|
||||
return poolSync;
|
||||
}
|
||||
|
||||
|
|
@ -183,19 +189,27 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
}
|
||||
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
|
||||
public Map<String, String> getHostDetails() {
|
||||
return hostDetails;
|
||||
}
|
||||
public Map<String, String> getHostDetails() {
|
||||
return hostDetails;
|
||||
}
|
||||
|
||||
public void setHostDetails(Map<String, String> hostDetails) {
|
||||
this.hostDetails = hostDetails;
|
||||
}
|
||||
public void setHostDetails(Map<String, String> hostDetails) {
|
||||
this.hostDetails = hostDetails;
|
||||
}
|
||||
|
||||
public String getHypervisorVersion() {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,15 +34,16 @@ public class CopyVolumeCommand extends Command {
|
|||
public CopyVolumeCommand() {
|
||||
}
|
||||
|
||||
public CopyVolumeCommand(long volumeId, String volumePath, StoragePool pool, String secondaryStorageURL, boolean toSecondaryStorage) {
|
||||
public CopyVolumeCommand(long volumeId, String volumePath, StoragePool pool, String secondaryStorageURL, boolean toSecondaryStorage, int wait) {
|
||||
this.volumeId = volumeId;
|
||||
this.volumePath = volumePath;
|
||||
this.pool = new StorageFilerTO(pool);
|
||||
this.secondaryStorageURL = secondaryStorageURL;
|
||||
this.toSecondaryStorage = toSecondaryStorage;
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,15 +32,16 @@ public class PrimaryStorageDownloadCommand extends AbstractDownloadCommand {
|
|||
String secondaryStorageUrl;
|
||||
String primaryStorageUrl;
|
||||
|
||||
protected PrimaryStorageDownloadCommand() {
|
||||
protected PrimaryStorageDownloadCommand() {
|
||||
}
|
||||
|
||||
public PrimaryStorageDownloadCommand(String name, String url, ImageFormat format, long accountId, long poolId, String poolUuid) {
|
||||
public PrimaryStorageDownloadCommand(String name, String url, ImageFormat format, long accountId, long poolId, String poolUuid, int wait) {
|
||||
super(name, url, format, accountId);
|
||||
this.poolId = poolId;
|
||||
this.poolUuid = poolUuid;
|
||||
setWait(wait);
|
||||
}
|
||||
|
||||
|
||||
public String getPoolUuid() {
|
||||
return poolUuid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,4 +257,7 @@ public class ApiConstants {
|
|||
public static final String KEYBOARD="keyboard";
|
||||
public static final String OPEN_FIREWALL="openfirewall";
|
||||
public static final String TEMPLATE_TAG = "templatetag";
|
||||
public static final String HYPERVISOR_VERSION = "hypervisorversion";
|
||||
public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.api.response.ExtractResponse;
|
|||
import com.cloud.api.response.FirewallResponse;
|
||||
import com.cloud.api.response.FirewallRuleResponse;
|
||||
import com.cloud.api.response.HostResponse;
|
||||
import com.cloud.api.response.HypervisorCapabilitiesResponse;
|
||||
import com.cloud.api.response.IPAddressResponse;
|
||||
import com.cloud.api.response.InstanceGroupResponse;
|
||||
import com.cloud.api.response.IpForwardingRuleResponse;
|
||||
|
|
@ -72,6 +73,7 @@ import com.cloud.dc.Vlan;
|
|||
import com.cloud.domain.Domain;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
|
|
@ -81,8 +83,8 @@ import com.cloud.network.rules.FirewallRule;
|
|||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.security.IngressRule;
|
||||
import com.cloud.network.security.EgressRule;
|
||||
import com.cloud.network.security.IngressRule;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityGroupRules;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
|
|
@ -162,20 +164,20 @@ public interface ResponseGenerator {
|
|||
Account findAccountByNameDomain(String accountName, Long domainId);
|
||||
|
||||
VirtualMachineTemplate findTemplateById(Long templateId);
|
||||
|
||||
|
||||
Host findHostById(Long hostId);
|
||||
|
||||
|
||||
List<TemplateResponse> createTemplateResponses(long templateId, long zoneId, boolean readyOnly);
|
||||
|
||||
|
||||
VpnUsersResponse createVpnUserResponse(VpnUser user);
|
||||
|
||||
RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
|
||||
List<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly);
|
||||
|
||||
List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly);
|
||||
|
||||
|
||||
ListResponse<SecurityGroupResponse> createSecurityGroupResponses(List<? extends SecurityGroupRules> networkGroups);
|
||||
|
||||
|
||||
SecurityGroupResponse createSecurityGroupResponseFromIngressRule(List<? extends IngressRule> ingressRules);
|
||||
|
||||
SecurityGroupResponse createSecurityGroupResponseFromEgressRule(List<? extends EgressRule> egressRules);
|
||||
|
|
@ -197,25 +199,27 @@ public interface ResponseGenerator {
|
|||
TemplatePermissionsResponse createTemplatePermissionsResponse(List<String> accountNames, Long id, boolean isAdmin);
|
||||
|
||||
AsyncJobResponse queryJobResult(QueryAsyncJobResultCmd cmd);
|
||||
|
||||
|
||||
NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering);
|
||||
|
||||
|
||||
NetworkResponse createNetworkResponse(Network network);
|
||||
|
||||
UserResponse createUserResponse(User user);
|
||||
UserResponse createUserResponse(User user);
|
||||
|
||||
AccountResponse createUserAccountResponse(UserAccount user);
|
||||
|
||||
Long getSecurityGroupId(String groupName, long accountId);
|
||||
AccountResponse createUserAccountResponse(UserAccount user);
|
||||
|
||||
Long getSecurityGroupId(String groupName, long accountId);
|
||||
|
||||
List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
|
||||
|
||||
ProjectResponse createProjectResponse(Project project);
|
||||
|
||||
|
||||
List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly);
|
||||
|
||||
List<TemplateResponse> createTemplateResponses(long templateId, Long vmId);
|
||||
|
||||
List<TemplateResponse> createTemplateResponses(long templateId, Long vmId);
|
||||
|
||||
FirewallResponse createFirewallResponse(FirewallRule fwRule);
|
||||
|
||||
HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
|
||||
if (networks.size() == 0) {
|
||||
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domainId=" + getDomainId() + " doesn't have virtual networks in zone " + getZoneId());
|
||||
String domain = _accountService.getDomain(getDomainId()).getName();
|
||||
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
|
||||
}
|
||||
assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete";
|
||||
return networks.get(0).getId();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* 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.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.HypervisorCapabilitiesResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
|
||||
@Implementation(description="Lists all hypervisor capabilities.", responseObject=HypervisorCapabilitiesResponse.class)
|
||||
public class ListHypervisorCapabilitiesCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListHypervisorCapabilitiesCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listhypervisorcapabilitiesresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="ID of the hypervisor capability")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor for which to restrict the search")
|
||||
private String hypervisor;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisor() {
|
||||
if(hypervisor != null){
|
||||
return HypervisorType.getType(hypervisor);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends HypervisorCapabilities> hpvCapabilities = _mgr.listHypervisorCapabilities(getId(), getHypervisor(), this.getStartIndex(), this.getPageSizeVal());
|
||||
ListResponse<HypervisorCapabilitiesResponse> response = new ListResponse<HypervisorCapabilitiesResponse>();
|
||||
List<HypervisorCapabilitiesResponse> hpvCapabilitiesResponses = new ArrayList<HypervisorCapabilitiesResponse>();
|
||||
for (HypervisorCapabilities capability : hpvCapabilities) {
|
||||
HypervisorCapabilitiesResponse hpvCapabilityResponse = _responseGenerator.createHypervisorCapabilitiesResponse(capability);
|
||||
hpvCapabilityResponse.setObjectName("hypervisorCapabilities");
|
||||
hpvCapabilitiesResponses.add(hpvCapabilityResponse);
|
||||
}
|
||||
|
||||
response.setResponses(hpvCapabilitiesResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
* 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.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.HypervisorCapabilitiesResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@Implementation(description="Updates a hypervisor capabilities.", responseObject=ServiceOfferingResponse.class)
|
||||
public class UpdateHypervisorCapabilitiesCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateHypervisorCapabilitiesCmd.class.getName());
|
||||
private static final String s_name = "updatehypervisorcapabilitiesresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="ID of the hypervisor capability")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="set true to enable security group for this hypervisor.")
|
||||
private Boolean securityGroupEnabled;
|
||||
|
||||
@Parameter(name=ApiConstants.MAX_GUESTS_LIMIT, type=CommandType.LONG, description="the max number of Guest VMs per host for this hypervisor.")
|
||||
private Long maxGuestsLimit;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Boolean getSecurityGroupEnabled() {
|
||||
return securityGroupEnabled;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getMaxGuestsLimit() {
|
||||
return maxGuestsLimit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
HypervisorCapabilities result = _mgr.updateHypervisorCapabilities(getId(), getMaxGuestsLimit(), getSecurityGroupEnabled());
|
||||
if (result != null){
|
||||
HypervisorCapabilitiesResponse response = _responseGenerator.createHypervisorCapabilitiesResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ public class HostResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("cpuused") @Param(description="the amount of the host's CPU currently used")
|
||||
private String cpuUsed;
|
||||
|
||||
|
||||
@SerializedName("cpuwithoverprovisioning") @Param(description="the amount of the host's CPU after applying the cpu.overprovisioning.factor ")
|
||||
private String cpuWithOverprovisioning;
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class HostResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("clustername") @Param(description="the cluster name of the host")
|
||||
private String clusterName;
|
||||
|
||||
|
||||
@SerializedName("clustertype") @Param(description="the cluster type of the cluster that host belongs to")
|
||||
private String clusterType;
|
||||
|
||||
|
|
@ -137,28 +137,31 @@ public class HostResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("events") @Param(description="events available for the host")
|
||||
private String events;
|
||||
|
||||
|
||||
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the host")
|
||||
private Long jobId;
|
||||
|
||||
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
|
||||
private Integer jobStatus;
|
||||
|
||||
|
||||
@SerializedName("hosttags") @Param(description="comma-separated list of tags for the host")
|
||||
private String hostTags;
|
||||
|
||||
|
||||
@SerializedName("hasEnoughCapacity") @Param(description="true if this host has enough CPU and RAM capacity to migrate a VM to it, false otherwise")
|
||||
private Boolean hasEnoughCapacity;
|
||||
|
||||
|
||||
@SerializedName("allocationstate") @Param(description="the allocation state of the host")
|
||||
private String allocationState;
|
||||
|
||||
@SerializedName(ApiConstants.HYPERVISOR_VERSION) @Param(description="the hypervisor version")
|
||||
private String hypervisorVersion;
|
||||
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getJobId() {
|
||||
return jobId;
|
||||
|
|
@ -168,7 +171,7 @@ public class HostResponse extends BaseResponse {
|
|||
public void setJobId(Long jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
|
|
@ -426,13 +429,13 @@ public class HostResponse extends BaseResponse {
|
|||
public void setClusterName(String clusterName) {
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
|
||||
public String getClusterType() {
|
||||
return clusterType;
|
||||
return clusterType;
|
||||
}
|
||||
|
||||
|
||||
public void setClusterType(String clusterType) {
|
||||
this.clusterType = clusterType;
|
||||
this.clusterType = clusterType;
|
||||
}
|
||||
|
||||
public Boolean isLocalStorageActive() {
|
||||
|
|
@ -466,7 +469,7 @@ public class HostResponse extends BaseResponse {
|
|||
public void setEvents(String events) {
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
|
||||
public String getHostTags() {
|
||||
return hostTags;
|
||||
}
|
||||
|
|
@ -474,7 +477,7 @@ public class HostResponse extends BaseResponse {
|
|||
public void setHostTags(String hostTags) {
|
||||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
|
||||
public Boolean hasEnoughCapacity() {
|
||||
return hasEnoughCapacity;
|
||||
}
|
||||
|
|
@ -482,20 +485,29 @@ public class HostResponse extends BaseResponse {
|
|||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
||||
}
|
||||
|
||||
|
||||
public String getAllocationState() {
|
||||
return allocationState;
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setAllocationState(String allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
this.allocationState = allocationState;
|
||||
}
|
||||
|
||||
|
||||
public String getCpuWithOverprovisioning() {
|
||||
return cpuWithOverprovisioning;
|
||||
}
|
||||
|
||||
public void setCpuWithOverprovisioning(String cpuWithOverprovisioning) {
|
||||
this.cpuWithOverprovisioning = cpuWithOverprovisioning;
|
||||
}
|
||||
}
|
||||
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public String getHypervisorVersion() {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* 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.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class HypervisorCapabilitiesResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the hypervisor capabilities row")
|
||||
private Long id;
|
||||
|
||||
@SerializedName(ApiConstants.HYPERVISOR_VERSION) @Param(description="the hypervisor version")
|
||||
private String hypervisorVersion;
|
||||
|
||||
@SerializedName(ApiConstants.HYPERVISOR) @Param(description="the hypervisor type")
|
||||
private HypervisorType hypervisor;
|
||||
|
||||
@SerializedName(ApiConstants.MAX_GUESTS_LIMIT) @Param(description="the maximum number of guest vms recommended for this hypervisor")
|
||||
private Long maxGuestsLimit;
|
||||
|
||||
@SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is supported")
|
||||
private boolean isSecurityGroupEnabled;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getHypervisorVersion() {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
public void setHypervisor(HypervisorType hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
|
||||
public Long getMaxGuestsLimit() {
|
||||
return maxGuestsLimit;
|
||||
}
|
||||
|
||||
public void setMaxGuestsLimit(Long maxGuestsLimit) {
|
||||
this.maxGuestsLimit = maxGuestsLimit;
|
||||
}
|
||||
|
||||
public Boolean getIsSecurityGroupEnabled() {
|
||||
return this.isSecurityGroupEnabled;
|
||||
}
|
||||
|
||||
public void setIsSecurityGroupEnabled(Boolean sgEnabled) {
|
||||
this.isSecurityGroupEnabled = sgEnabled;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ public interface Host {
|
|||
ExternalLoadBalancer(false),
|
||||
PxeServer(false),
|
||||
TrafficMonitor(false),
|
||||
|
||||
|
||||
ExternalDhcp(false),
|
||||
SecondaryStorageVM(true),
|
||||
LocalSecondaryStorage(false);
|
||||
|
|
@ -44,11 +44,11 @@ public interface Host {
|
|||
private Type(boolean virtual) {
|
||||
_virtual = virtual;
|
||||
}
|
||||
|
||||
|
||||
public boolean isVirtual() {
|
||||
return _virtual;
|
||||
}
|
||||
|
||||
|
||||
public static String[] toStrings(Host.Type... types) {
|
||||
String[] strs = new String[types.length];
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
|
|
@ -57,27 +57,27 @@ public interface Host {
|
|||
return strs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum HostAllocationState {
|
||||
Disabled,
|
||||
Enabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return id of the host.
|
||||
*/
|
||||
long getId();
|
||||
|
||||
|
||||
/**
|
||||
* @return name of the machine.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
|
||||
/**
|
||||
* @return the type of host.
|
||||
*/
|
||||
Type getType();
|
||||
|
||||
|
||||
/**
|
||||
* @return the date the host first registered
|
||||
*/
|
||||
|
|
@ -87,32 +87,32 @@ public interface Host {
|
|||
* @return current state of this machine.
|
||||
*/
|
||||
Status getStatus();
|
||||
|
||||
|
||||
/**
|
||||
* @return the ip address of the host.
|
||||
*/
|
||||
String getPrivateIpAddress();
|
||||
|
||||
|
||||
/**
|
||||
* @return the ip address of the host attached to the storage network.
|
||||
*/
|
||||
String getStorageIpAddress();
|
||||
|
||||
|
||||
/**
|
||||
* @return the mac address of the host.
|
||||
*/
|
||||
String getGuid();
|
||||
|
||||
|
||||
/**
|
||||
* @return total amount of memory.
|
||||
*/
|
||||
Long getTotalMemory();
|
||||
|
||||
|
||||
/**
|
||||
* @return # of cores in a machine. Note two cpus with two cores each returns 4.
|
||||
*/
|
||||
Integer getCpus();
|
||||
|
||||
|
||||
/**
|
||||
* @return speed of each cpu in mhz.
|
||||
*/
|
||||
|
|
@ -122,32 +122,32 @@ public interface Host {
|
|||
* @return the proxy port that is being listened at the agent host
|
||||
*/
|
||||
Integer getProxyPort();
|
||||
|
||||
|
||||
/**
|
||||
* @return the pod.
|
||||
*/
|
||||
Long getPodId();
|
||||
|
||||
|
||||
/**
|
||||
* @return availability zone.
|
||||
*/
|
||||
long getDataCenterId();
|
||||
|
||||
|
||||
/**
|
||||
* @return parent path. only used for storage server.
|
||||
*/
|
||||
String getParent();
|
||||
|
||||
|
||||
/**
|
||||
* @return storage ip address.
|
||||
*/
|
||||
String getStorageIpAddressDeux();
|
||||
|
||||
|
||||
/**
|
||||
* @return type of hypervisor
|
||||
*/
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
|
||||
/**
|
||||
* @return disconnection date
|
||||
*/
|
||||
|
|
@ -176,27 +176,29 @@ public interface Host {
|
|||
*@return removal date
|
||||
*/
|
||||
Date getRemoved();
|
||||
|
||||
|
||||
Long getClusterId();
|
||||
|
||||
|
||||
String getPublicIpAddress();
|
||||
|
||||
|
||||
String getPublicNetmask();
|
||||
|
||||
|
||||
String getPrivateNetmask();
|
||||
|
||||
|
||||
String getStorageNetmask();
|
||||
|
||||
|
||||
String getStorageMacAddress();
|
||||
|
||||
|
||||
String getPublicMacAddress();
|
||||
|
||||
|
||||
String getPrivateMacAddress();
|
||||
|
||||
|
||||
String getStorageNetmaskDeux();
|
||||
|
||||
|
||||
String getStorageMacAddressDeux();
|
||||
|
||||
|
||||
HostAllocationState getHostAllocationState();
|
||||
|
||||
|
||||
String getHypervisorVersion();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,15 +180,18 @@ public enum Status {
|
|||
s_fsm.addTransition(Status.Disconnected, Event.WaitedTooLong, Status.Alert);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.HypervisorVersionChanged, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.AgentDisconnected, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Down, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
||||
s_fsm.addTransition(Status.Down, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Down, Event.ManagementServerDown, Status.Down);
|
||||
s_fsm.addTransition(Status.Down, Event.AgentDisconnected, Status.Down);
|
||||
s_fsm.addTransition(Status.Alert, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
||||
s_fsm.addTransition(Status.Alert, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
||||
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
||||
s_fsm.addTransition(Status.Alert, Event.AgentDisconnected, Status.Alert);
|
||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceFailed, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceCompleted, Status.Connecting);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,50 +20,51 @@ package com.cloud.hypervisor;
|
|||
public class Hypervisor {
|
||||
|
||||
public static enum HypervisorType {
|
||||
None, //for storage hosts
|
||||
Xen,
|
||||
XenServer,
|
||||
KVM,
|
||||
VMware,
|
||||
Hyperv,
|
||||
VirtualBox,
|
||||
Parralels,
|
||||
BareMetal,
|
||||
Simulator,
|
||||
Ovm,
|
||||
|
||||
Any; /*If you don't care about the hypervisor type*/
|
||||
None, //for storage hosts
|
||||
Xen,
|
||||
XenServer,
|
||||
KVM,
|
||||
VMware,
|
||||
Hyperv,
|
||||
VirtualBox,
|
||||
Parralels,
|
||||
BareMetal,
|
||||
Simulator,
|
||||
Ovm,
|
||||
|
||||
public static HypervisorType getType(String hypervisor) {
|
||||
if (hypervisor == null) {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
Any; /*If you don't care about the hypervisor type*/
|
||||
|
||||
if (hypervisor.equalsIgnoreCase("Xen")) {
|
||||
return HypervisorType.Xen;
|
||||
} else if (hypervisor.equalsIgnoreCase("XenServer")) {
|
||||
return HypervisorType.XenServer;
|
||||
} else if (hypervisor.equalsIgnoreCase("KVM")) {
|
||||
return HypervisorType.KVM;
|
||||
} else if (hypervisor.equalsIgnoreCase("VMware")) {
|
||||
return HypervisorType.VMware;
|
||||
} else if (hypervisor.equalsIgnoreCase("Hyperv")) {
|
||||
return HypervisorType.Hyperv;
|
||||
} else if (hypervisor.equalsIgnoreCase("VirtualBox")) {
|
||||
return HypervisorType.VirtualBox;
|
||||
} else if (hypervisor.equalsIgnoreCase("Parralels")) {
|
||||
return HypervisorType.Parralels;
|
||||
}else if (hypervisor.equalsIgnoreCase("BareMetal")) {
|
||||
return HypervisorType.BareMetal;
|
||||
} else if (hypervisor.equalsIgnoreCase("Simulator")) {
|
||||
return HypervisorType.Simulator;
|
||||
} else if (hypervisor.equalsIgnoreCase("Ovm")) {
|
||||
return HypervisorType.Ovm;
|
||||
} else if (hypervisor.equalsIgnoreCase("Any")) {
|
||||
return HypervisorType.Any;
|
||||
} else {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
}
|
||||
public static HypervisorType getType(String hypervisor) {
|
||||
if (hypervisor == null) {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
|
||||
if (hypervisor.equalsIgnoreCase("Xen")) {
|
||||
return HypervisorType.Xen;
|
||||
} else if (hypervisor.equalsIgnoreCase("XenServer")) {
|
||||
return HypervisorType.XenServer;
|
||||
} else if (hypervisor.equalsIgnoreCase("KVM")) {
|
||||
return HypervisorType.KVM;
|
||||
} else if (hypervisor.equalsIgnoreCase("VMware")) {
|
||||
return HypervisorType.VMware;
|
||||
} else if (hypervisor.equalsIgnoreCase("Hyperv")) {
|
||||
return HypervisorType.Hyperv;
|
||||
} else if (hypervisor.equalsIgnoreCase("VirtualBox")) {
|
||||
return HypervisorType.VirtualBox;
|
||||
} else if (hypervisor.equalsIgnoreCase("Parralels")) {
|
||||
return HypervisorType.Parralels;
|
||||
}else if (hypervisor.equalsIgnoreCase("BareMetal")) {
|
||||
return HypervisorType.BareMetal;
|
||||
} else if (hypervisor.equalsIgnoreCase("Simulator")) {
|
||||
return HypervisorType.Simulator;
|
||||
} else if (hypervisor.equalsIgnoreCase("Ovm")) {
|
||||
return HypervisorType.Ovm;
|
||||
} else if (hypervisor.equalsIgnoreCase("Any")) {
|
||||
return HypervisorType.Any;
|
||||
} else {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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.hypervisor;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
|
||||
/**
|
||||
* HypervisorCapability represents one particular hypervisor version's capabilities.
|
||||
*/
|
||||
public interface HypervisorCapabilities {
|
||||
/**
|
||||
* @return id of the host.
|
||||
*/
|
||||
long getId();
|
||||
|
||||
/**
|
||||
* @return type of hypervisor
|
||||
*/
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
|
||||
String getHypervisorVersion();
|
||||
|
||||
boolean isSecurityGroupEnabled();
|
||||
|
||||
/**
|
||||
* @return the maxGuestslimit
|
||||
*/
|
||||
Long getMaxGuestsLimit();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -91,6 +91,7 @@ public interface Network extends ControlledEntity {
|
|||
public static final Provider DhcpServer = new Provider("DhcpServer");
|
||||
public static final Provider JuniperSRX = new Provider("JuniperSRX");
|
||||
public static final Provider F5BigIp = new Provider("F5BigIp");
|
||||
public static final Provider NetscalerMPX = new Provider("NetscalerMPX");
|
||||
public static final Provider ExternalDhcpServer = new Provider("ExternalDhcpServer");
|
||||
public static final Provider ExternalGateWay = new Provider("ExternalGateWay");
|
||||
public static final Provider ElasticLoadBalancerVm = new Provider("ElasticLoadBalancerVm");
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ import com.cloud.exception.InternalErrorException;
|
|||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
|
|
@ -307,7 +309,7 @@ public interface ManagementService {
|
|||
* @return List of capacities
|
||||
*/
|
||||
List<? extends Capacity> listCapacityByType(ListCapacityByTypeCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* List the permissions on a template. This will return a list of account names that have been granted permission to launch
|
||||
* instances from the template.
|
||||
|
|
@ -508,5 +510,9 @@ public interface ManagementService {
|
|||
Pair<List<? extends Host>, List<Long>> listHostsForMigrationOfVM(UserVm vm, Long startIndex, Long pageSize);
|
||||
|
||||
String[] listEventTypes();
|
||||
|
||||
|
||||
List<? extends HypervisorCapabilities> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, Long startIndex, Long pageSizeVal);
|
||||
|
||||
HypervisorCapabilities updateHypervisorCapabilities(Long id, Long maxGuestsLimit, Boolean securityGroupEnabled);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ package com.cloud.storage;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
public interface Snapshot {
|
||||
public interface Snapshot extends ControlledEntity{
|
||||
public enum Type {
|
||||
MANUAL,
|
||||
RECURRING,
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import com.cloud.utils.fsm.StateObject;
|
|||
*/
|
||||
public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject<VirtualMachine.State> {
|
||||
|
||||
public static final String PARAM_KEY_KEYBOARD = "keyboard";
|
||||
|
||||
public enum State {
|
||||
Starting(true, "VM is being started. At this state, you should find host id filled which means it's being started on that host."),
|
||||
Running(false, "VM is running. host id has the host that it is running on."),
|
||||
|
|
|
|||
|
|
@ -25,4 +25,5 @@
|
|||
<import file="${base.dir}/build/build-tests.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/package.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/developer.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/build-usage.xml" optional="false"/>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
-->
|
||||
<dirname property="base.dir" file="${ant.file.Cloud Stack}/.." />
|
||||
<property name="build.dir" location="${base.dir}/build" />
|
||||
<property name="test.classes.dir" location="${test.target.dir}/classes" />
|
||||
|
||||
<!-- Import anything that the user wants to set-->
|
||||
<!-- Import properties files and environment variables here -->
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
<property name="build.log" location="${target.dir}/ant_verbose.txt" />
|
||||
|
||||
<property name="deps.dir" location="${base.dir}/deps" />
|
||||
<property name="tools.jar.dir" location="${base.dir}/tools/tooljars" />
|
||||
|
||||
<!-- directories for client compilation-->
|
||||
<property name="client.dir" location="${base.dir}/client" />
|
||||
|
|
@ -145,17 +147,27 @@
|
|||
<path id="src.classpath">
|
||||
</path>
|
||||
|
||||
<path id="compile.deps.classpath">
|
||||
<fileset dir="${tools.jar.dir}" erroronmissingdir="true">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="deps.classpath">
|
||||
<!--filelist files="${deps.classpath}" /-->
|
||||
<fileset dir="${deps.dir}" erroronmissingdir="false">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
<path refid="compile.deps.classpath" />
|
||||
</path>
|
||||
|
||||
<path id="dist.classpath">
|
||||
<fileset dir="${target.dir}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${target.dir}/jar">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="test.classpath">
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@
|
|||
<!-- directories for the test client code compilation-->
|
||||
<property name="testclient.dir" location="${base.dir}/test" />
|
||||
<property name="testclient.dist.dir" location="${dist.dir}/test" />
|
||||
<property name="tools.dist.dir" location="${dist.dir}/cloudapitools" />
|
||||
<property name="tools.dist.dir" location="${dist.dir}/cloudapitools" />
|
||||
|
||||
<property name="test.target.dir" location="${target.dir}/test" />
|
||||
<property name="test.classes.dir" location="${test.target.dir}/classes" />
|
||||
|
||||
<property name="agent-simulator.jar" value="cloud-agent-simulator.jar" />
|
||||
<property name="testclient.jar" value="cloud-test.jar" />
|
||||
|
||||
|
||||
<!-- =================== Agent Simulator ==================== -->
|
||||
<path id="agent-simulator.classpath">
|
||||
<path refid="deps.classpath" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2008 Cloud, Inc. All Rights Reserved -->
|
||||
<project name="Cloud Stack Usage Server" default="help" basedir=".">
|
||||
<description>
|
||||
Cloud Stack Usage server build
|
||||
</description>
|
||||
<property name="base.dir" location="${ant.file.Cloud Stack Usage Server}/../../.."/>
|
||||
<property name="oss.build.dir" location="${base.dir}/build"/>
|
||||
<property name="usage.jar" value="cloud-usage.jar" />
|
||||
<dirname property="proprietary.dir" file="${ant.file.Cloud Stack Usage Server}/../"/>
|
||||
|
||||
<import file="${oss.build.dir}/build-cloud.xml" optional="false"/>
|
||||
<property name="usage.dir" location="${base.dir}/usage" />
|
||||
<property name="usage.dist.dir" location="${dist.dir}/usage" />
|
||||
|
||||
<!-- ===================== Usage.Jar ===================== -->
|
||||
<path id="usage.classpath">
|
||||
<path refid="deps.classpath" />
|
||||
<path refid="dist.classpath" />
|
||||
</path>
|
||||
<target name="compile-usage" depends="-init, compile-utils, compile-core, compile-server" description="Compile the usage server">
|
||||
<compile-java jar.name="${usage.jar}" top.dir="${usage.dir}" classpath="usage.classpath" />
|
||||
</target>
|
||||
|
||||
<target name="build-usage" depends="build-all, compile-usage">
|
||||
<mkdir dir="${usage.dist.dir}/bin" />
|
||||
<mkdir dir="${usage.dist.dir}/conf" />
|
||||
|
||||
<copy todir="${usage.dist.dir}/bin">
|
||||
<fileset dir="${usage.dir}/scripts">
|
||||
<include name="usageserver.sh" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy overwrite="true" todir="${usage.dist.dir}/lib">
|
||||
<fileset dir="${jar.dir}">
|
||||
<include name="${usage.jar}" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
<property name="unittest.dir" location="${base.dir}/unittest"/>
|
||||
<property name="unittest.target.dir" location="${unittest.dir}/classes"/>
|
||||
<property name="unittest.jar.dir" location="${unittest.dir}/jar"/>
|
||||
<property name="ovm.dir" location="${base.dir}/ovm" />
|
||||
<property name="ovm-scripts.dir" location="${ovm.dir}/scripts" />
|
||||
|
||||
|
||||
<!-- directories for api doc -->
|
||||
<property name="api.docs.dir" location="${dist.dir}/apidocs" />
|
||||
|
|
@ -143,8 +146,16 @@
|
|||
<unzip src="${deploy.work.dir}/usage.zip" dest="${deploy.work.dir}/usage"/>
|
||||
</target>
|
||||
|
||||
<target name="deploy-server" depends="deploy-common" >
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.iso" />
|
||||
<target name="deploy-ovm" >
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts">
|
||||
<fileset dir="${ovm-scripts.dir}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="deploy-server" depends="deploy-common, deploy-ovm" >
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.iso" />
|
||||
</target>
|
||||
|
||||
<target name="deploy-common" >
|
||||
|
|
|
|||
|
|
@ -189,12 +189,12 @@
|
|||
<include name="cloud-ws-commons-util-1.0.2.jar" />
|
||||
<include name="cloud-log4j.jar" />
|
||||
<include name="cloud-apache-log4j-extras-1.0.jar" />
|
||||
<include name="cloud-gson.jar" />
|
||||
<include name="cloud-google-gson-1.7.1.jar" />
|
||||
<include name="cloud-commons-httpclient-3.1.jar" />
|
||||
<include name="cloud-commons-logging-1.1.1.jar" />
|
||||
<include name="cloud-commons-collections-3.2.1.jar" />
|
||||
<include name="cloud-commons-codec-1.4.jar" />
|
||||
<include name="cloud-commons-pool-1.4.jar" />
|
||||
<include name="cloud-commons-codec-1.5.jar" />
|
||||
<include name="cloud-commons-pool-1.5.6.jar" />
|
||||
<include name="cloud-cglib.jar" />
|
||||
<include name="cloud-axis.jar" />
|
||||
<include name="cloud-commons-discovery.jar" />
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
|
|
@ -13,5 +18,6 @@
|
|||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
|
||||
#Labels
|
||||
label.ocfs2=OCFS2
|
||||
|
||||
label.action.edit.host=Edit Host
|
||||
|
||||
network.rate=Network Rate
|
||||
|
|
@ -66,7 +68,6 @@ label.PING.CIFS.username=PING CIFS username
|
|||
label.PING.CIFS.password=PING CIFS password
|
||||
label.CPU.cap=CPU Cap
|
||||
|
||||
label.network.domain=Network Domain
|
||||
|
||||
label.action.enable.zone=Enable Zone
|
||||
label.action.enable.zone.processing=Enabling Zone....
|
||||
|
|
@ -387,7 +388,6 @@ label.full=Full
|
|||
label.gateway=Gateway
|
||||
label.general.alerts=General Alerts
|
||||
label.generating.url=Generating URL
|
||||
label.generating.url=Generating URL
|
||||
label.go.step.2=Go to Step 2
|
||||
label.go.step.3=Go to Step 3
|
||||
label.go.step.4=Go to Step 4
|
||||
|
|
@ -563,7 +563,6 @@ label.private.ips=Private IP Addresses
|
|||
label.private.port=Private Port
|
||||
label.private.zone=Private Zone
|
||||
label.protocol=Protocol
|
||||
label.protocol=Protocol
|
||||
label.public.interface=Public Interface
|
||||
label.public.ip=Public IP Address
|
||||
label.public.ips=Public IP Addresses
|
||||
|
|
@ -635,7 +634,6 @@ label.succeeded=Succeeded
|
|||
label.sunday=Sunday
|
||||
label.system.capacity=System Wide Capacity
|
||||
label.system.vm.type=System VM Type
|
||||
label.system.vm.type=System VM Type
|
||||
label.system.vm=System VM
|
||||
label.system.vms=System VMs
|
||||
label.tagged=Tagged
|
||||
|
|
@ -738,7 +736,6 @@ message.action.destroy.instance=Please confirm that you want to destroy this ins
|
|||
message.action.destroy.systemvm=Please confirm that you want to destroy this System VM.
|
||||
message.action.disable.static.NAT=Please confirm that you want to disable static NAT.
|
||||
message.action.enable.maintenance=Your host has been successfully prepared for maintenance. This process can take up to several minutes or longer depending on how many VMs are currently on this host.
|
||||
message.action.force.reconnect=Please confirm that you want to force a reconnection for this host.
|
||||
message.action.force.reconnect=Your host has been successfully forced to reconnect. This process can take up to several minutes.
|
||||
message.action.host.enable.maintenance.mode=Enabling maintenance mode will cause a live migration of all running instances on this host to any available host.
|
||||
message.action.instance.reset.password=Please confirm that you want to change the ROOT password for this virtual machine.
|
||||
|
|
@ -842,4 +839,4 @@ error.login=Your username/password does not match our records.
|
|||
error.menu.select=Unable to perform action due to no items being selected.
|
||||
error.mgmt.server.inaccessible=The Management Server is unaccessible. Please try again later.
|
||||
error.session.expired=Your session has expired.
|
||||
error.unresolved.internet.name=Your internet name cannot be resolved.
|
||||
error.unresolved.internet.name=Your internet name cannot be resolved.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
|
||||
#Labels
|
||||
label.ocfs2=OCFS2
|
||||
|
||||
label.action.edit.host=edición Anfitrión
|
||||
|
||||
network.rate=Tasa de red
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
|
||||
#Labels
|
||||
label.ocfs2=OCFS2
|
||||
|
||||
label.action.edit.host=ホストを編集する
|
||||
|
||||
network.rate=ネットワーク速度
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
|
||||
#Labels
|
||||
label.ocfs2=OCFS2
|
||||
|
||||
label.action.edit.host=编辑主机
|
||||
|
||||
network.rate=网络速率
|
||||
|
|
|
|||
|
|
@ -4,10 +4,17 @@ from cloudutils.utilities import initLoging
|
|||
from cloudutils.cloudException import CloudRuntimeException, CloudInternalException
|
||||
from cloudutils.globalEnv import globalEnv
|
||||
from cloudutils.serviceConfigServer import cloudManagementConfig
|
||||
from optparse import OptionParser
|
||||
if __name__ == '__main__':
|
||||
initLoging("/var/log/cloud/setupManagement.log")
|
||||
glbEnv = globalEnv()
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("--https", action="store_true", dest="https", help="Enable HTTPs connection of management server")
|
||||
(options, args) = parser.parse_args()
|
||||
if options.https:
|
||||
glbEnv.svrMode = "HttpsServer"
|
||||
|
||||
glbEnv.mode = "Server"
|
||||
|
||||
print "Starting to configure CloudStack Management Server:"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -274,4 +274,7 @@ listProjects=com.cloud.api.commands.ListProjectsCmd;15
|
|||
createFirewallRule=com.cloud.api.commands.CreateFirewallRuleCmd;15
|
||||
deleteFirewallRule=com.cloud.api.commands.DeleteFirewallRuleCmd;15
|
||||
listFirewallRules=com.cloud.api.commands.ListFirewallRulesCmd;15
|
||||
|
||||
|
||||
#### hypervisor capabilities commands
|
||||
updateHypervisorCapabilities=com.cloud.api.commands.UpdateHypervisorCapabilitiesCmd;1
|
||||
listHypervisorCapabilities=com.cloud.api.commands.ListHypervisorCapabilitiesCmd;1
|
||||
|
|
@ -31,7 +31,8 @@
|
|||
</adapters>
|
||||
<adapters key="com.cloud.network.element.NetworkElement">
|
||||
<adapter name="ExternalFirewall" class="com.cloud.network.element.ExternalFirewallElement"/>
|
||||
<adapter name="ExternalLoadBalancer" class="com.cloud.network.element.ExternalLoadBalancerElement"/>
|
||||
<adapter name="NetscalerExternalLoadBalancer" class="com.cloud.network.element.NetscalerExternalLoadBalancerElement"/>
|
||||
<adapter name="F5ExternalLoadBalancer" class="com.cloud.network.element.F5ExternalLoadBalancerElement"/>
|
||||
<adapter name="DomainRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="Dhcp" class="com.cloud.network.element.DhcpElement"/>
|
||||
<adapter name="Ovs" class="com.cloud.network.element.OvsElement"/>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,14 @@ db.cloud.logAbandoned=true
|
|||
db.cloud.poolPreparedStatements=false
|
||||
db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true
|
||||
|
||||
# Cloud.com database SSL settings
|
||||
db.cloud.useSSL=false
|
||||
db.cloud.keyStore=
|
||||
db.cloud.keyStorePassword=
|
||||
db.cloud.trustStore=
|
||||
db.cloud.trustStorePassword=
|
||||
|
||||
|
||||
# usage database settings
|
||||
db.usage.username=@DBUSER@
|
||||
db.usage.password=@DBPW@
|
||||
|
|
|
|||
|
|
@ -0,0 +1,157 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
-->
|
||||
<!-- Note: A "Server" is not itself a "Container", so you may not
|
||||
define subcomponents such as "Valves" at this level.
|
||||
Documentation at /docs/config/server.html
|
||||
-->
|
||||
<Server port="8005" shutdown="SHUTDOWN">
|
||||
|
||||
<!--APR library loader. Documentation at /docs/apr.html -->
|
||||
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
|
||||
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
|
||||
<Listener className="org.apache.catalina.core.JasperListener" />
|
||||
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
|
||||
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
|
||||
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
|
||||
|
||||
<!-- Global JNDI resources
|
||||
Documentation at /docs/jndi-resources-howto.html
|
||||
-->
|
||||
<GlobalNamingResources>
|
||||
<!-- Editable user database that can also be used by
|
||||
UserDatabaseRealm to authenticate users
|
||||
-->
|
||||
<Resource name="UserDatabase" auth="Container"
|
||||
type="org.apache.catalina.UserDatabase"
|
||||
description="User database that can be updated and saved"
|
||||
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
|
||||
pathname="conf/tomcat-users.xml" />
|
||||
</GlobalNamingResources>
|
||||
|
||||
<!-- A "Service" is a collection of one or more "Connectors" that share
|
||||
a single "Container" Note: A "Service" is not itself a "Container",
|
||||
so you may not define subcomponents such as "Valves" at this level.
|
||||
Documentation at /docs/config/service.html
|
||||
-->
|
||||
<Service name="Catalina">
|
||||
|
||||
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
|
||||
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
|
||||
maxThreads="150" minSpareThreads="25"/>
|
||||
|
||||
|
||||
<!-- A "Connector" represents an endpoint by which requests are received
|
||||
and responses are returned. Documentation at :
|
||||
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
|
||||
Java AJP Connector: /docs/config/ajp.html
|
||||
APR (HTTP/AJP) Connector: /docs/apr.html
|
||||
Define a non-SSL HTTP/1.1 Connector on port 8080
|
||||
-->
|
||||
<!--
|
||||
<Connector port="8080" protocol="HTTP/1.1"
|
||||
connectionTimeout="20000"
|
||||
redirectPort="8443" />
|
||||
-->
|
||||
<!-- A "Connector" using the shared thread pool-->
|
||||
<!--
|
||||
<Connector executor="tomcatThreadPool"
|
||||
port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
|
||||
connectionTimeout="20000" disableUploadTimeout="true"
|
||||
acceptCount="150" enableLookups="false" maxThreads="150"
|
||||
maxHttpHeaderSize="8192" redirectPort="8443" />
|
||||
-->
|
||||
<!-- Define a SSL HTTP/1.1 Connector on port 8443
|
||||
This connector uses the JSSE configuration, when using APR, the
|
||||
connector should be using the OpenSSL style configuration
|
||||
described in the APR documentation -->
|
||||
<!--
|
||||
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
|
||||
maxThreads="150" scheme="https" secure="true"
|
||||
clientAuth="false" sslProtocol="TLS"
|
||||
keystoreType="PKCS12"
|
||||
keystoreFile="conf\cloud-localhost.pk12"
|
||||
keystorePass="password"
|
||||
/>
|
||||
-->
|
||||
|
||||
<!-- Listen on 6443 instead of 8443 because tomcat6 will change 8443 to a random one when CATALINA_HOME is not /usr/share/tomcat6 -->
|
||||
<Connector port="6443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
|
||||
maxThreads="150" scheme="https" secure="true"
|
||||
clientAuth="false" sslProtocol="TLS"
|
||||
keystoreType="JKS"
|
||||
keystoreFile="/etc/cloud/management/cloudmanagementserver.keystore"
|
||||
keystorePass="vmops.com"/>
|
||||
|
||||
<!-- Define an AJP 1.3 Connector on port 20400 -->
|
||||
<Connector port="20400" protocol="AJP/1.3" redirectPort="6443" />
|
||||
|
||||
|
||||
<!-- An Engine represents the entry point (within Catalina) that processes
|
||||
every request. The Engine implementation for Tomcat stand alone
|
||||
analyzes the HTTP headers included with the request, and passes them
|
||||
on to the appropriate Host (virtual host).
|
||||
Documentation at /docs/config/engine.html -->
|
||||
|
||||
<!-- You should set jvmRoute to support load-balancing via AJP ie :
|
||||
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
|
||||
-->
|
||||
<Engine name="Catalina" defaultHost="localhost">
|
||||
|
||||
<!--For clustering, please take a look at documentation at:
|
||||
/docs/cluster-howto.html (simple how to)
|
||||
/docs/config/cluster.html (reference documentation) -->
|
||||
<!--
|
||||
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
|
||||
-->
|
||||
|
||||
<!-- The request dumper valve dumps useful debugging information about
|
||||
the request and response data received and sent by Tomcat.
|
||||
Documentation at: /docs/config/valve.html -->
|
||||
<!--
|
||||
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
|
||||
-->
|
||||
|
||||
<!-- This Realm uses the UserDatabase configured in the global JNDI
|
||||
resources under the key "UserDatabase". Any edits
|
||||
that are performed against this UserDatabase are immediately
|
||||
available for use by the Realm. -->
|
||||
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
|
||||
resourceName="UserDatabase"/>
|
||||
|
||||
<!-- Define the default virtual host
|
||||
Note: XML Schema validation will not work with Xerces 2.2.
|
||||
-->
|
||||
<Host name="localhost" appBase="webapps"
|
||||
unpackWARs="true" autoDeploy="true"
|
||||
xmlValidation="false" xmlNamespaceAware="false">
|
||||
|
||||
<!-- SingleSignOn valve, share authentication between web applications
|
||||
Documentation at: /docs/config/valve.html -->
|
||||
<!--
|
||||
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
|
||||
-->
|
||||
|
||||
<!-- Access log processes all example.
|
||||
Documentation at: /docs/config/valve.html -->
|
||||
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve" directory="logs"
|
||||
prefix="access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
|
||||
|
||||
</Host>
|
||||
</Engine>
|
||||
</Service>
|
||||
</Server>
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# System-wide configuration file for tomcat6 services
|
||||
# This will be sourced by tomcat6 and any secondary service
|
||||
# Values will be overridden by service-specific configuration
|
||||
# files in /etc/sysconfig
|
||||
#
|
||||
# Use this one to change default values for all services
|
||||
# Change the service specific ones to affect only one service
|
||||
# (see, for instance, /etc/sysconfig/tomcat6)
|
||||
#
|
||||
|
||||
# Where your java installation lives
|
||||
#JAVA_HOME="/usr/lib/jvm/java"
|
||||
|
||||
# Where your tomcat installation lives
|
||||
CATALINA_BASE="@MSENVIRON@"
|
||||
CATALINA_HOME="@MSENVIRON@"
|
||||
JASPER_HOME="@MSENVIRON@"
|
||||
CATALINA_TMPDIR="@MSENVIRON@/temp"
|
||||
|
||||
# You can pass some parameters to java here if you wish to
|
||||
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
|
||||
|
||||
# Use JAVA_OPTS to set java.library.path for libtcnative.so
|
||||
#JAVA_OPTS="-Djava.library.path=/usr/lib64"
|
||||
JAVA_OPTS="-Djava.awt.headless=true -Djavax.net.ssl.trustStore=/etc/cloud/management/cloudmanagementserver.keystore -Djavax.net.ssl.trustStorePassword=vmops.com -Dcom.sun.management.jmxremote.port=45219 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=@MSLOGDIR@ -XX:PermSize=128M"
|
||||
|
||||
# What user should run tomcat
|
||||
TOMCAT_USER="@MSUSER@"
|
||||
# Do not remove the following line
|
||||
TOMCAT6_USER="$TOMCAT_USER"
|
||||
|
||||
TOMCAT_LOG="@MSLOGDIR@/catalina.out"
|
||||
|
||||
# You can change your tomcat locale here
|
||||
#LANG="en_US"
|
||||
|
||||
# Run tomcat under the Java Security Manager
|
||||
SECURITY_MANAGER="false"
|
||||
|
||||
# Time to wait in seconds, before killing process
|
||||
SHUTDOWN_WAIT="30"
|
||||
|
||||
# Whether to annoy the user with "attempting to shut down" messages or not
|
||||
SHUTDOWN_VERBOSE="false"
|
||||
|
||||
# Set the TOMCAT_PID location
|
||||
CATALINA_PID="@PIDDIR@/@PACKAGE@-management.pid"
|
||||
|
||||
# Connector port is 8080 for this tomcat6 instance
|
||||
#CONNECTOR_PORT="8080"
|
||||
|
||||
# We pick up the classpath in the next line
|
||||
|
||||
dummy=1 ; . @MSCONF@/classpath.conf
|
||||
96
cloud.spec
96
cloud.spec
|
|
@ -108,7 +108,6 @@ CloudStack uses.
|
|||
Summary: Cloud.com library dependencies
|
||||
Requires: java >= 1.6.0
|
||||
Obsoletes: vmops-deps < %{version}-%{release}
|
||||
Obsoletes: cloud-premium-deps < %{version}-%{release}
|
||||
Group: System Environment/Libraries
|
||||
%description deps
|
||||
This package contains a number of third-party dependencies
|
||||
|
|
@ -228,6 +227,7 @@ Group: System Environment/Libraries
|
|||
|
||||
%if 0%{?rhel} >= 6
|
||||
Requires: cloud-kvm
|
||||
Requires: cloud-qemu-img
|
||||
%else
|
||||
Requires: kvm
|
||||
%endif
|
||||
|
|
@ -237,10 +237,6 @@ Requires: cloud-qemu-kvm
|
|||
Requires: cloud-qemu-img
|
||||
%endif
|
||||
|
||||
%if 0%{?rhel} >= 6
|
||||
Requires: cloud-qemu-img
|
||||
%endif
|
||||
|
||||
%if 0%{?rhel} >= 5
|
||||
Requires: qemu-img
|
||||
%endif
|
||||
|
|
@ -311,24 +307,19 @@ The Cloud.com test package contains a suite of automated tests
|
|||
that the very much appreciated QA team at Cloud.com constantly
|
||||
uses to help increase the quality of the Cloud.com Stack.
|
||||
|
||||
%package usage
|
||||
Summary: Cloud.com usage monitor
|
||||
Obsoletes: vmops-usage < %{version}-%{release}
|
||||
Requires: java >= 1.6.0
|
||||
Requires: %{name}-utils = %{version}, %{name}-core = %{version}, %{name}-deps = %{version}, %{name}-server = %{version}, %{name}-daemonize = %{version}
|
||||
Requires: %{name}-setup = %{version}
|
||||
Requires: %{name}-client = %{version}
|
||||
License: CSL 1.1
|
||||
Group: System Environment/Libraries
|
||||
%description usage
|
||||
The Cloud.com usage monitor provides usage accounting across the entire cloud for
|
||||
cloud operators to charge based on usage parameters.
|
||||
|
||||
#%if %{_premium}
|
||||
#
|
||||
#
|
||||
#%package usage
|
||||
#Summary: Cloud.com usage monitor
|
||||
#Obsoletes: vmops-usage < %{version}-%{release}
|
||||
#Requires: java >= 1.6.0
|
||||
#Requires: %{name}-utils = %{version}, %{name}-core = %{version}, %{name}-deps = %{version}, %{name}-server = %{version}, %{name}-premium = %{version}, %{name}-daemonize = %{version}
|
||||
#Requires: %{name}-setup = %{version}
|
||||
#Requires: %{name}-client = %{version}
|
||||
#License: CSL 1.1
|
||||
#Group: System Environment/Libraries
|
||||
#%description usage
|
||||
#The Cloud.com usage monitor provides usage accounting across the entire cloud for
|
||||
#cloud operators to charge based on usage parameters.
|
||||
#
|
||||
#%endif
|
||||
|
||||
%prep
|
||||
|
||||
|
|
@ -390,36 +381,29 @@ if [ "$1" == "1" ] ; then
|
|||
/sbin/chkconfig --level 345 %{name}-management on > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
%preun usage
|
||||
if [ "$1" == "0" ] ; then
|
||||
/sbin/chkconfig --del %{name}-usage > /dev/null 2>&1 || true
|
||||
/sbin/service %{name}-usage stop > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
%pre usage
|
||||
id %{name} > /dev/null 2>&1 || /usr/sbin/useradd -M -c "Cloud.com unprivileged user" \
|
||||
-r -s /bin/sh -d %{_sharedstatedir}/%{name}/management %{name}|| true
|
||||
# user harcoded here, also hardcoded on wscript
|
||||
|
||||
#%if %{_premium}
|
||||
#
|
||||
#%preun usage
|
||||
#if [ "$1" == "0" ] ; then
|
||||
# /sbin/chkconfig --del %{name}-usage > /dev/null 2>&1 || true
|
||||
# /sbin/service %{name}-usage stop > /dev/null 2>&1 || true
|
||||
#fi
|
||||
#
|
||||
#%pre usage
|
||||
#id %{name} > /dev/null 2>&1 || /usr/sbin/useradd -M -c "Cloud.com unprivileged user" \
|
||||
# -r -s /bin/sh -d %{_sharedstatedir}/%{name}/management %{name}|| true
|
||||
## user harcoded here, also hardcoded on wscript
|
||||
#
|
||||
#%post usage
|
||||
#if [ "$1" == "1" ] ; then
|
||||
# /sbin/chkconfig --add %{name}-usage > /dev/null 2>&1 || true
|
||||
# /sbin/chkconfig --level 345 %{name}-usage on > /dev/null 2>&1 || true
|
||||
#else
|
||||
# /sbin/service %{name}-usage condrestart >/dev/null 2>&1 || true
|
||||
#fi
|
||||
#
|
||||
#%endif
|
||||
%post usage
|
||||
if [ "$1" == "1" ] ; then
|
||||
/sbin/chkconfig --add %{name}-usage > /dev/null 2>&1 || true
|
||||
/sbin/chkconfig --level 345 %{name}-usage on > /dev/null 2>&1 || true
|
||||
else
|
||||
/sbin/service %{name}-usage condrestart >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
%pre agent-scripts
|
||||
id %{name} > /dev/null 2>&1 || /usr/sbin/useradd -M -c "Cloud.com unprivileged user" \
|
||||
-r -s /bin/sh -d %{_sharedstatedir}/%{name}/management %{name}|| true
|
||||
|
||||
|
||||
%preun agent
|
||||
if [ "$1" == "0" ] ; then
|
||||
/sbin/chkconfig --del %{name}-agent > /dev/null 2>&1 || true
|
||||
|
|
@ -484,12 +468,15 @@ fi
|
|||
|
||||
%files deps
|
||||
%defattr(0644,root,root,0755)
|
||||
%{_javadir}/%{name}-commons-codec-1.4.jar
|
||||
%{_javadir}/%{name}-commons-codec-1.5.jar
|
||||
%{_javadir}/%{name}-commons-dbcp-1.4.jar
|
||||
%{_javadir}/%{name}-commons-pool-1.5.6.jar
|
||||
%{_javadir}/%{name}-google-gson-1.7.1.jar
|
||||
%{_javadir}/%{name}-netscaler.jar
|
||||
%{_javadir}/%{name}-log4j-extras.jar
|
||||
%{_javadir}/%{name}-backport-util-concurrent-3.0.jar
|
||||
%{_javadir}/%{name}-ehcache.jar
|
||||
%{_javadir}/%{name}-email.jar
|
||||
%{_javadir}/%{name}-gson.jar
|
||||
%{_javadir}/%{name}-httpcore-4.0.jar
|
||||
%{_javadir}/%{name}-libvirt-0.4.5.jar
|
||||
%{_javadir}/%{name}-log4j.jar
|
||||
|
|
@ -512,8 +499,6 @@ fi
|
|||
%{_javadir}/vmware*.jar
|
||||
%{_javadir}/%{name}-jnetpcap.jar
|
||||
%{_javadir}/%{name}-junit.jar
|
||||
%{_javadir}/%{name}-selenium-java-client-driver.jar
|
||||
%{_javadir}/%{name}-selenium-server.jar
|
||||
|
||||
|
||||
%files core
|
||||
|
|
@ -612,20 +597,15 @@ fi
|
|||
%{_libdir}/%{name}/test/*
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/test/*
|
||||
|
||||
#%if %{_premium}
|
||||
#
|
||||
#
|
||||
#%files usage
|
||||
#%defattr(0644,root,root,0775)
|
||||
%files usage
|
||||
%defattr(0644,root,root,0775)
|
||||
#%{_javadir}/%{name}-usage.jar
|
||||
#%attr(0755,root,root) %{_initrddir}/%{name}-usage
|
||||
#%attr(0755,root,root) %{_libexecdir}/usage-runner
|
||||
%attr(0755,root,root) %{_initrddir}/%{name}-usage
|
||||
%attr(0755,root,root) %{_libexecdir}/usage-runner
|
||||
#%dir %attr(0770,root,%{name}) %{_localstatedir}/log/%{name}/usage
|
||||
#%{_sysconfdir}/%{name}/usage/usage-components.xml
|
||||
#%config(noreplace) %{_sysconfdir}/%{name}/usage/log4j-%{name}_usage.xml
|
||||
#%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/usage/db.properties
|
||||
#
|
||||
#%endif
|
||||
|
||||
%changelog
|
||||
* Mon May 3 2010 Manuel Amador (Rudd-O) <manuel@vmops.com> 1.9.12
|
||||
|
|
|
|||
|
|
@ -198,12 +198,14 @@ KeyboardMapper.prototype = {
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class AjaxViewer
|
||||
//
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight, rawKeyboard) {
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight, rawKeyboard, linuxGuest) {
|
||||
// logging is disabled by default so that it won't have negative impact on performance
|
||||
// however, a back door key-sequence can trigger to open the logger window, it is designed to help
|
||||
// trouble-shooting
|
||||
g_logger = new Logger();
|
||||
g_logger.enable(false);
|
||||
g_logger.enable(true);
|
||||
// g_logger.open();
|
||||
// g_logger.log(Logger.LEVEL_INFO, 'rawKeyboard: ' + rawKeyboard);
|
||||
|
||||
var ajaxViewer = this;
|
||||
this.rawKeyboard = rawKeyboard;
|
||||
|
|
@ -226,6 +228,8 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
|
|||
|
||||
this.currentKeyboard = 0;
|
||||
this.keyboardMappers = [];
|
||||
|
||||
this.linuxGuest = linuxGuest;
|
||||
|
||||
this.timer = 0;
|
||||
this.eventQueue = [];
|
||||
|
|
@ -620,21 +624,110 @@ AjaxViewer.prototype = {
|
|||
var charCodeMap = [];
|
||||
var shiftedCharCodeMap = [];
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
if(this.linuxGuest) {
|
||||
// for LINUX guest OSes
|
||||
|
||||
shiftedKeyCodeMap[50] = { code: 222, shift: 1 } ; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[64] = { code: 34, shift: 1 };
|
||||
|
||||
shiftedKeyCodeMap[54] = { code: 55, shift : 1 }; // JP SHIFT + 6 -> &
|
||||
shiftedCharCodeMap[94] = { code: 38, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0 }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[38] = { code: 39, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[56] = { code: 57, shift : 1 }; // JP SHIFT + 8 -> (
|
||||
shiftedCharCodeMap[42] = { code: 40, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[57] = { code: 48, shift : 1 }; // JP SHIFT + 9 -> )
|
||||
shiftedCharCodeMap[40] = { code: 41, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
shiftedKeyCodeMap[48] = { code: 192, shift : 1 }; // JP SHIFT + 0 -> ~
|
||||
shiftedCharCodeMap[41] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
|
||||
shiftedKeyCodeMap[109] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Firefox
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
shiftedKeyCodeMap[189] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Chrome/Safari/MSIE
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 192, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 126, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[107] = { code: 107, shift : 1, defer : true }; // JP NUM +, keycode/charcode (107, 43) from Firefox
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
charCodeMap[61] = { code: 94, shift : 0, keyCode: 94 }; // JP (~^), keycode/charcode (107, 61) from Firefox
|
||||
|
||||
shiftedKeyCodeMap[107] = { code: 192, shift : 1 }; // JP SHIFT + (!^)
|
||||
shiftedCharCodeMap[43] = { code: 126, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 54, shift: 1, defer: true }; // JP ~^
|
||||
charCodeMap[61] = { code: 94, shift: 0, keyCode: 94 };
|
||||
|
||||
shiftedKeyCodeMap[187] = { code: 192, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[43] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 107, shift : 0, defer: true }; // JP NUM +, keycode/charcode(107, 43)
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
}
|
||||
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift : 1, charCode: 124 }; // JP (|-, key before backspace), Japanese Yen mark
|
||||
|
||||
keyCodeMap[219] = { code: 192, shift : 0 }; // JP @`
|
||||
charCodeMap[91] = { code: 96, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 50, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[123] = { code: 64, shift : 1 };
|
||||
|
||||
keyCodeMap[221] = { code: 219, shift : 0 }; // JP [{
|
||||
charCodeMap[93] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 219, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 123, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
shiftedKeyCodeMap[59] = { code: 107, shift : 1, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[58] = { code: 43, shift : 1, keyCode: 43 };
|
||||
} else {
|
||||
shiftedKeyCodeMap[186] = { code: 107, shift : 1, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[58] = { code: 43, shift : 1, keyCode: 43 };
|
||||
}
|
||||
|
||||
keyCodeMap[222] = { code: 59, shift : 0, defer : true }; // JP :*
|
||||
charCodeMap[39] = { code: 59, shift : 0, keyCode: 58 };
|
||||
shiftedKeyCodeMap[222] = { code: 56, shift : 1 };
|
||||
shiftedCharCodeMap[34] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[220] = { code: 221, shift : 0 }; // JP ]}
|
||||
charCodeMap[92] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[220] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[124] = { code: 125, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1, defer: true }; // JP NUM *
|
||||
charCodeMap[42] = { code: 42, shift : 1, keyCode: 42 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
|
||||
} else {
|
||||
// for windows guest OSes
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
}
|
||||
this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_JAPAN_EN_OS_TO_JP_VM] = new KeyboardMapper(false, keyCodeMap, shiftedKeyCodeMap,
|
||||
charCodeMap, shiftedCharCodeMap);
|
||||
},
|
||||
|
|
@ -645,76 +738,136 @@ AjaxViewer.prototype = {
|
|||
var charCodeMap = [];
|
||||
var shiftedCharCodeMap = [];
|
||||
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 0, shift : 1, keyCode: 50 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 0, shift : 1, keyCode: 55 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0 }; // JP ~^
|
||||
charCodeMap[94] = { code: 59, shift: 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 107, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 43, shift : 1 };
|
||||
|
||||
keyCodeMap[192] = { code: 219, shift : 0 }; // JP @`
|
||||
charCodeMap[64] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[192] = { code: 219, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 123, shift : 1 };
|
||||
|
||||
keyCodeMap[219] = { code: 221, shift : 0 }; // JP [{
|
||||
charCodeMap[91] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[123] = { code: 125, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
// keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1, keyCode: 59 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
}
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[59] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[59] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[186] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[186] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
}
|
||||
|
||||
keyCodeMap[221] = { code: 220, shift : 0 }; // JP ]}
|
||||
charCodeMap[93] = { code: 92, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 220, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 124, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
if(this.linuxGuest) {
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 34, shift : 1, keyCode: 34 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
shiftedKeyCodeMap[54] = { code: 55, shift : 1 }; // JP SHIFT + 6 -> &
|
||||
shiftedCharCodeMap[94] = { code: 38, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 39, shift : 1, keyCode: 39 };
|
||||
|
||||
shiftedKeyCodeMap[56] = { code: 57, shift : 1 }; // JP SHIFT + 8 -> (
|
||||
shiftedCharCodeMap[42] = { code: 40, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[57] = { code: 48, shift : 1 }; // JP SHIFT + 9 -> )
|
||||
shiftedCharCodeMap[40] = { code: 41, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[48] = { code: 192, shift : 1 }; // JP SHIFT + 0 -> ~
|
||||
shiftedCharCodeMap[41] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0, defer: true }; // JP ~^
|
||||
charCodeMap[94] = { code: 94, shift: 0, keyCode: 94 };
|
||||
shiftedKeyCodeMap[222] = { code: 192, shift : 1, defer: true }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 126, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[192] = { code: 50, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 64, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
shiftedKeyCodeMap[109] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Firefox
|
||||
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 }; // JP NUM +
|
||||
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
|
||||
keyCodeMap[59] = { code: 59, shift : 0, defer : true }; // JP :*
|
||||
charCodeMap[58] = { code: 58, shift : 0, keyCode: 58 };
|
||||
} else {
|
||||
shiftedKeyCodeMap[189] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Chrome/Safari/MSIE
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1, defer: true };
|
||||
shiftedCharCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP NUM +
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43};
|
||||
|
||||
keyCodeMap[186] = { code: 59, shift : 0, defer: true }; // JP :*
|
||||
charCodeMap[58] = { code: 58, shift : 0, keyCode: 58 };
|
||||
}
|
||||
|
||||
keyCodeMap[226] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[226] = { code: 189, shift: 1 };
|
||||
|
||||
} else {
|
||||
// windows guest
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 0, shift : 1, keyCode: 50 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 0, shift : 1, keyCode: 55 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0 }; // JP ~^
|
||||
charCodeMap[94] = { code: 59, shift: 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 107, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 43, shift : 1 };
|
||||
|
||||
keyCodeMap[192] = { code: 219, shift : 0 }; // JP @`
|
||||
charCodeMap[64] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[192] = { code: 219, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 123, shift : 1 };
|
||||
|
||||
keyCodeMap[219] = { code: 221, shift : 0 }; // JP [{
|
||||
charCodeMap[91] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[123] = { code: 125, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 0 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 0 };
|
||||
|
||||
charCodeMap[43] = { code: 42, shift : 1, keyCode: 59 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
}
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[59] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[59] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[186] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[186] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
}
|
||||
|
||||
keyCodeMap[221] = { code: 220, shift : 0 }; // JP ]}
|
||||
charCodeMap[93] = { code: 92, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 220, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 124, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
}
|
||||
this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_JAPAN_JP_OS_TO_JP_VM] = new KeyboardMapper(false, keyCodeMap, shiftedKeyCodeMap,
|
||||
charCodeMap, shiftedCharCodeMap);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
String tag = queryMap.get("tag");
|
||||
String ticket = queryMap.get("ticket");
|
||||
String ajaxSessionIdStr = queryMap.get("sess");
|
||||
String eventStr = queryMap.get("event");
|
||||
String eventStr = queryMap.get("event");
|
||||
|
||||
if(tag == null)
|
||||
tag = "";
|
||||
|
||||
|
|
@ -171,8 +172,9 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Ajax request indicates a fresh client start");
|
||||
|
||||
String title = queryMap.get("t");
|
||||
handleClientStart(t, viewer, title != null ? title : "");
|
||||
String title = queryMap.get("t");
|
||||
String guest = queryMap.get("guest");
|
||||
handleClientStart(t, viewer, title != null ? title : "", guest);
|
||||
} else {
|
||||
|
||||
if(s_logger.isTraceEnabled())
|
||||
|
|
@ -392,9 +394,9 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleClientStart(HttpExchange t, ConsoleProxyViewer viewer, String title) throws IOException {
|
||||
private void handleClientStart(HttpExchange t, ConsoleProxyViewer viewer, String title, String guest) throws IOException {
|
||||
List<String> languages = t.getRequestHeaders().get("Accept-Language");
|
||||
String response = viewer.onAjaxClientStart(title, languages);
|
||||
String response = viewer.onAjaxClientStart(title, languages, guest);
|
||||
|
||||
Headers hds = t.getResponseHeaders();
|
||||
hds.set("Content-Type", "text/html");
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
js2javaCodeMap.put(new Integer(18), new Integer(0xffe9));
|
||||
|
||||
// for SHIFT transaction at proxy side
|
||||
shiftedKeyCharMap = new HashMap<Integer, Integer>();
|
||||
shiftedKeyCharMap = new HashMap<Integer, Integer>();
|
||||
shiftedKeyCharMap.put(new Integer('1'), new Integer('!'));
|
||||
shiftedKeyCharMap.put(new Integer('2'), new Integer('@'));
|
||||
shiftedKeyCharMap.put(new Integer('3'), new Integer('#'));
|
||||
|
|
@ -190,7 +190,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
shiftedKeyCharMap.put(new Integer('9'), new Integer('('));
|
||||
shiftedKeyCharMap.put(new Integer('0'), new Integer(')'));
|
||||
shiftedKeyCharMap.put(new Integer('-'), new Integer('_'));
|
||||
shiftedKeyCharMap.put(new Integer('='), new Integer('+'));
|
||||
//shiftedKeyCharMap.put(new Integer('='), new Integer('+'));
|
||||
shiftedKeyCharMap.put(new Integer('`'), new Integer('~'));
|
||||
shiftedKeyCharMap.put(new Integer('['), new Integer('{'));
|
||||
shiftedKeyCharMap.put(new Integer(']'), new Integer('}'));
|
||||
|
|
@ -239,7 +239,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
return vkCode.intValue();
|
||||
}
|
||||
|
||||
public int getJvmKeyCode(int jsKeyCode) {
|
||||
public int getJvmKeyCode(int jsKeyCode) {
|
||||
Integer code = js2javaCodeMap.get(jsKeyCode);
|
||||
if(code != null)
|
||||
return code.intValue();
|
||||
|
|
|
|||
|
|
@ -924,7 +924,7 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
"</p></div></body></html>";
|
||||
}
|
||||
|
||||
public String onAjaxClientStart(String title, List<String> languages) {
|
||||
public String onAjaxClientStart(String title, List<String> languages, String guest) {
|
||||
if(!waitForViewerReady())
|
||||
return onAjaxClientConnectFailed();
|
||||
|
||||
|
|
@ -1005,11 +1005,11 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
*/
|
||||
return getAjaxViewerPageContent(sbTileSequence.toString(), imgUrl,
|
||||
updateUrl, width, height, tileWidth, tileHeight, title,
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages);
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest);
|
||||
}
|
||||
|
||||
private String getAjaxViewerPageContent(String tileSequence, String imgUrl, String updateUrl, int width,
|
||||
int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages) {
|
||||
int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages, String guest) {
|
||||
|
||||
StringBuffer sbLanguages = new StringBuffer("");
|
||||
if(languages != null) {
|
||||
|
|
@ -1020,6 +1020,10 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
sbLanguages.append(lang);
|
||||
}
|
||||
}
|
||||
|
||||
boolean linuxGuest = true;
|
||||
if(guest != null && guest.equalsIgnoreCase("windows"))
|
||||
linuxGuest = false;
|
||||
|
||||
String[] content = new String[] {
|
||||
"<html>",
|
||||
|
|
@ -1066,7 +1070,8 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
"var acceptLanguages = '" + sbLanguages.toString() + "';",
|
||||
"var tileMap = [ " + tileSequence + " ];",
|
||||
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', tileMap, ",
|
||||
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ", " + (rawKeyboard ? "true" : "false") + ");",
|
||||
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight)
|
||||
+ ", " + (rawKeyboard ? "true" : "false") + ", " + (linuxGuest ? "true" : "false") + ");",
|
||||
|
||||
"$(function() {",
|
||||
"ajaxViewer.start();",
|
||||
|
|
@ -1276,13 +1281,13 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendClientRawKeyboardEvent(int event, int code, int modifiers) {
|
||||
code = ConsoleProxyAjaxKeyMapper.getInstance().getJvmKeyCode(code);
|
||||
switch(event) {
|
||||
case 4 : // Key press
|
||||
//
|
||||
// special handling for ' and " (keycode: 222, char code : 39 and 34
|
||||
// special handling for ' and " (keycode: 222, char code : 39 and 34)
|
||||
//
|
||||
if(code == 39 || code == 34) {
|
||||
writeKeyboardEvent(KeyEvent.KEY_PRESSED, 222, (char)code, getAwtModifiers(modifiers));
|
||||
|
|
@ -1307,8 +1312,33 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public void sendClientRawKeyboardEvent(int event, int code, int modifiers) {
|
||||
// code = ConsoleProxyAjaxKeyMapper.getInstance().getJvmKeyCode(code);
|
||||
switch(event) {
|
||||
case 4 : // Key press
|
||||
break;
|
||||
|
||||
case 5 : // Key down
|
||||
if((modifiers & ConsoleProxyViewer.CTRL_KEY_MASK) != 0 && (modifiers & ConsoleProxyViewer.ALT_KEY_MASK) != 0 && code == KeyEvent.VK_INSERT) {
|
||||
code = KeyEvent.VK_DELETE;
|
||||
}
|
||||
|
||||
writeKeyboardEvent(KeyEvent.KEY_PRESSED, code,
|
||||
(char)code,
|
||||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
|
||||
case 6 : // Key Up
|
||||
writeKeyboardEvent(KeyEvent.KEY_RELEASED, code,
|
||||
(char)code,
|
||||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
public void sendClientKeyboardEvent(int event, int code, int modifiers) {
|
||||
int vkCode;
|
||||
switch(event) {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/tools"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/vmware-base"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
|||
|
|
@ -50,15 +50,15 @@ public class HostVO implements Host {
|
|||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
private long id;
|
||||
|
||||
@Column(name="disconnected")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date disconnectedOn;
|
||||
|
||||
|
||||
@Column(name="name", nullable=false)
|
||||
private String name = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
/**
|
||||
* Note: There is no setter for status because it has to be set in the dao code.
|
||||
*/
|
||||
|
|
@ -68,76 +68,78 @@ public class HostVO implements Host {
|
|||
@Column(name="type", updatable = true, nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private Type type;
|
||||
|
||||
|
||||
@Column(name="private_ip_address", nullable=false)
|
||||
private String privateIpAddress;
|
||||
|
||||
private String privateIpAddress;
|
||||
|
||||
@Column(name="private_mac_address", nullable=false)
|
||||
private String privateMacAddress;
|
||||
|
||||
|
||||
@Column(name="private_netmask", nullable=false)
|
||||
private String privateNetmask;
|
||||
|
||||
|
||||
@Column(name="public_netmask")
|
||||
private String publicNetmask;
|
||||
|
||||
|
||||
@Column(name="public_ip_address")
|
||||
private String publicIpAddress;
|
||||
|
||||
|
||||
@Column(name="public_mac_address")
|
||||
private String publicMacAddress;
|
||||
|
||||
|
||||
@Column(name="storage_ip_address")
|
||||
private String storageIpAddress;
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Column(name="storage_netmask")
|
||||
private String storageNetmask;
|
||||
|
||||
|
||||
@Column(name="storage_mac_address")
|
||||
private String storageMacAddress;
|
||||
|
||||
|
||||
@Column(name="storage_ip_address_2")
|
||||
private String storageIpAddressDeux;
|
||||
|
||||
|
||||
@Column(name="storage_netmask_2")
|
||||
private String storageNetmaskDeux;
|
||||
|
||||
|
||||
@Column(name="storage_mac_address_2")
|
||||
private String storageMacAddressDeux;
|
||||
|
||||
|
||||
@Column(name="hypervisor_type", updatable = true, nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
|
||||
@Column(name="proxy_port")
|
||||
private Integer proxyPort;
|
||||
|
||||
|
||||
@Column(name="resource")
|
||||
private String resource;
|
||||
|
||||
|
||||
@Column(name="fs_type")
|
||||
private StoragePoolType fsType;
|
||||
|
||||
|
||||
@Column(name="available")
|
||||
private boolean available = true;
|
||||
|
||||
|
||||
@Column(name="setup")
|
||||
private boolean setup = false;
|
||||
|
||||
|
||||
@Column(name="allocation_state", nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private HostAllocationState hostAllocationState;
|
||||
|
||||
@Column(name="hypervisor_version")
|
||||
private String hypervisorVersion;
|
||||
|
||||
// This is a delayed load value. If the value is null,
|
||||
// then this field has not been loaded yet.
|
||||
// Call host dao to load it.
|
||||
@Transient
|
||||
Map<String, String> details;
|
||||
|
||||
|
||||
// This is a delayed load value. If the value is null,
|
||||
// then this field has not been loaded yet.
|
||||
// Call host dao to load it.
|
||||
|
|
@ -146,41 +148,41 @@ public class HostVO implements Host {
|
|||
|
||||
@Override
|
||||
public String getStorageIpAddressDeux() {
|
||||
return storageIpAddressDeux;
|
||||
}
|
||||
return storageIpAddressDeux;
|
||||
}
|
||||
|
||||
public void setStorageIpAddressDeux(String deuxStorageIpAddress) {
|
||||
this.storageIpAddressDeux = deuxStorageIpAddress;
|
||||
}
|
||||
public void setStorageIpAddressDeux(String deuxStorageIpAddress) {
|
||||
this.storageIpAddressDeux = deuxStorageIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getStorageNetmaskDeux() {
|
||||
return storageNetmaskDeux;
|
||||
}
|
||||
return storageNetmaskDeux;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public void setStorageNetmaskDeux(String deuxStorageNetmask) {
|
||||
this.storageNetmaskDeux = deuxStorageNetmask;
|
||||
}
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStorageNetmaskDeux(String deuxStorageNetmask) {
|
||||
this.storageNetmaskDeux = deuxStorageNetmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageMacAddressDeux() {
|
||||
return storageMacAddressDeux;
|
||||
}
|
||||
return storageMacAddressDeux;
|
||||
}
|
||||
|
||||
public void setStorageMacAddressDeux(String duexStorageMacAddress) {
|
||||
this.storageMacAddressDeux = duexStorageMacAddress;
|
||||
}
|
||||
public void setStorageMacAddressDeux(String duexStorageMacAddress) {
|
||||
this.storageMacAddressDeux = duexStorageMacAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getPrivateMacAddress() {
|
||||
return privateMacAddress;
|
||||
}
|
||||
|
|
@ -188,11 +190,11 @@ public class HostVO implements Host {
|
|||
public void setPrivateMacAddress(String privateMacAddress) {
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
|
@ -255,11 +257,11 @@ public class HostVO implements Host {
|
|||
public String getStorageMacAddress() {
|
||||
return storageMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSetup() {
|
||||
return setup;
|
||||
}
|
||||
|
||||
|
||||
public void setSetup(boolean setup) {
|
||||
this.setup = setup;
|
||||
}
|
||||
|
|
@ -267,31 +269,31 @@ public class HostVO implements Host {
|
|||
public void setStorageMacAddress(String storageMacAddress) {
|
||||
this.storageMacAddress = storageMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
|
||||
public String getDetail(String name) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
|
||||
return details != null ? details.get(name) : null;
|
||||
}
|
||||
|
||||
|
||||
public void setDetail(String name, String value) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
|
||||
details.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
|
@ -299,59 +301,59 @@ public class HostVO implements Host {
|
|||
public List<String> getHostTags() {
|
||||
return hostTags;
|
||||
}
|
||||
|
||||
|
||||
public void setHostTags(List<String> hostTags) {
|
||||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
@Column(name="data_center_id", nullable=false)
|
||||
private long dataCenterId;
|
||||
|
||||
|
||||
@Column(name="pod_id")
|
||||
private Long podId;
|
||||
|
||||
private Long podId;
|
||||
|
||||
@Column(name="cpus")
|
||||
private Integer cpus;
|
||||
|
||||
|
||||
@Column(name="url")
|
||||
private String storageUrl;
|
||||
|
||||
@Column(name="speed")
|
||||
private Long speed;
|
||||
|
||||
|
||||
@Column(name="ram")
|
||||
private long totalMemory;
|
||||
|
||||
|
||||
@Column(name="parent", nullable=false)
|
||||
private String parent;
|
||||
|
||||
|
||||
@Column(name="guid", updatable=true, nullable=false)
|
||||
private String guid;
|
||||
|
||||
@Column(name="capabilities")
|
||||
@Column(name="capabilities")
|
||||
private String caps;
|
||||
|
||||
|
||||
@Column(name="total_size")
|
||||
private Long totalSize;
|
||||
|
||||
|
||||
@Column(name="last_ping")
|
||||
private long lastPinged;
|
||||
|
||||
|
||||
@Column(name="mgmt_server_id")
|
||||
private Long managementServerId;
|
||||
|
||||
|
||||
@Column(name="dom0_memory")
|
||||
private long dom0MinMemory;
|
||||
|
||||
|
||||
@Column(name="version")
|
||||
private String version;
|
||||
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
|
||||
public HostVO(String guid) {
|
||||
this.guid = guid;
|
||||
this.status = Status.Up;
|
||||
|
|
@ -359,70 +361,70 @@ public class HostVO implements Host {
|
|||
this.dom0MinMemory = 0;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
}
|
||||
|
||||
|
||||
protected HostVO() {
|
||||
}
|
||||
|
||||
public HostVO(long id,
|
||||
String name,
|
||||
Type type,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
String privateMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
String publicMacAddress,
|
||||
String storageIpAddress,
|
||||
String storageNetmask,
|
||||
String storageMacAddress,
|
||||
String deuxStorageIpAddress,
|
||||
String duxStorageNetmask,
|
||||
String deuxStorageMacAddress,
|
||||
String guid,
|
||||
Status status,
|
||||
String version,
|
||||
String iqn,
|
||||
Date disconnectedOn,
|
||||
long dcId,
|
||||
Long podId,
|
||||
long serverId,
|
||||
long ping,
|
||||
String parent,
|
||||
long totalSize,
|
||||
StoragePoolType fsType) {
|
||||
this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
|
||||
this.parent = parent;
|
||||
this.totalSize = totalSize;
|
||||
this.fsType = fsType;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
}
|
||||
|
||||
|
||||
public HostVO(long id,
|
||||
String name,
|
||||
Type type,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
String privateMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
String publicMacAddress,
|
||||
String storageIpAddress,
|
||||
String storageNetmask,
|
||||
String storageMacAddress,
|
||||
String guid,
|
||||
Status status,
|
||||
String version,
|
||||
String url,
|
||||
Date disconnectedOn,
|
||||
long dcId,
|
||||
Long podId,
|
||||
long serverId,
|
||||
long ping,
|
||||
Integer cpus,
|
||||
Long speed,
|
||||
Long totalMemory,
|
||||
long dom0MinMemory,
|
||||
String caps) {
|
||||
String name,
|
||||
Type type,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
String privateMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
String publicMacAddress,
|
||||
String storageIpAddress,
|
||||
String storageNetmask,
|
||||
String storageMacAddress,
|
||||
String deuxStorageIpAddress,
|
||||
String duxStorageNetmask,
|
||||
String deuxStorageMacAddress,
|
||||
String guid,
|
||||
Status status,
|
||||
String version,
|
||||
String iqn,
|
||||
Date disconnectedOn,
|
||||
long dcId,
|
||||
Long podId,
|
||||
long serverId,
|
||||
long ping,
|
||||
String parent,
|
||||
long totalSize,
|
||||
StoragePoolType fsType) {
|
||||
this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
|
||||
this.parent = parent;
|
||||
this.totalSize = totalSize;
|
||||
this.fsType = fsType;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
}
|
||||
|
||||
public HostVO(long id,
|
||||
String name,
|
||||
Type type,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
String privateMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
String publicMacAddress,
|
||||
String storageIpAddress,
|
||||
String storageNetmask,
|
||||
String storageMacAddress,
|
||||
String guid,
|
||||
Status status,
|
||||
String version,
|
||||
String url,
|
||||
Date disconnectedOn,
|
||||
long dcId,
|
||||
Long podId,
|
||||
long serverId,
|
||||
long ping,
|
||||
Integer cpus,
|
||||
Long speed,
|
||||
Long totalMemory,
|
||||
long dom0MinMemory,
|
||||
String caps) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
|
|
@ -454,28 +456,28 @@ public class HostVO implements Host {
|
|||
this.storageUrl = url;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
}
|
||||
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
|
||||
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
|
||||
public void setDataCenterId(long dcId) {
|
||||
this.dataCenterId = dcId;
|
||||
}
|
||||
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public void setStorageUrl(String url) {
|
||||
this.storageUrl = url;
|
||||
}
|
||||
|
||||
|
||||
public void setDisconnectedOn(Date disconnectedOn) {
|
||||
this.disconnectedOn = disconnectedOn;
|
||||
}
|
||||
|
||||
|
||||
public String getStorageUrl() {
|
||||
return storageUrl;
|
||||
}
|
||||
|
|
@ -524,32 +526,32 @@ public class HostVO implements Host {
|
|||
public long getLastPinged() {
|
||||
return lastPinged;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCapabilities() {
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version;
|
||||
|
|
@ -558,66 +560,66 @@ public class HostVO implements Host {
|
|||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getManagementServerId() {
|
||||
return managementServerId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Date getDisconnectedOn() {
|
||||
return disconnectedOn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPrivateIpAddress() {
|
||||
return privateIpAddress;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCpus() {
|
||||
return cpus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getTotalMemory() {
|
||||
return totalMemory;
|
||||
|
|
@ -625,17 +627,17 @@ public class HostVO implements Host {
|
|||
|
||||
@Override
|
||||
public Integer getProxyPort() {
|
||||
return proxyPort;
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
|
||||
public void setProxyPort(Integer port) {
|
||||
proxyPort = port;
|
||||
proxyPort = port;
|
||||
}
|
||||
|
||||
|
||||
public StoragePoolType getFsType() {
|
||||
return fsType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
|
|
@ -645,36 +647,46 @@ public class HostVO implements Host {
|
|||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof HostVO) {
|
||||
return ((HostVO)obj).getId() == this.getId();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof HostVO) {
|
||||
return ((HostVO)obj).getId() == this.getId();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("Host[").append("-").append(id).append("-").append(type).append("]").toString();
|
||||
return new StringBuilder("Host[").append("-").append(id).append("-").append(type).append("]").toString();
|
||||
}
|
||||
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAllocationState getHostAllocationState() {
|
||||
return hostAllocationState;
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HostAllocationState getHostAllocationState() {
|
||||
return hostAllocationState;
|
||||
}
|
||||
|
||||
public void setHostAllocationState(HostAllocationState hostAllocationState) {
|
||||
this.hostAllocationState = hostAllocationState;
|
||||
this.hostAllocationState = hostAllocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHypervisorVersion() {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
* 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.hypervisor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
|
||||
@Entity
|
||||
@Table(name="hypervisor_capabilities")
|
||||
public class HypervisorCapabilitiesVO implements HypervisorCapabilities{
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="hypervisor_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name="hypervisor_version")
|
||||
private String hypervisorVersion;
|
||||
|
||||
@Column(name="max_guests_limit")
|
||||
private Long maxGuestsLimit;
|
||||
|
||||
@Column(name="security_group_enabled")
|
||||
private boolean securityGroupEnabled;
|
||||
|
||||
|
||||
protected HypervisorCapabilitiesVO() {
|
||||
}
|
||||
|
||||
public HypervisorCapabilitiesVO(HypervisorType hypervisorType, String hypervisorVersion, Long maxGuestsLimit, boolean securityGroupEnabled) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
this.maxGuestsLimit = maxGuestsLimit;
|
||||
this.securityGroupEnabled = securityGroupEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hypervisorType the hypervisorType to set
|
||||
*/
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the hypervisorType
|
||||
*/
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hypervisorVersion the hypervisorVersion to set
|
||||
*/
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hypervisorVersion
|
||||
*/
|
||||
@Override
|
||||
public String getHypervisorVersion() {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
|
||||
public void setSecurityGroupEnabled(Boolean securityGroupEnabled) {
|
||||
this.securityGroupEnabled = securityGroupEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the securityGroupSupport
|
||||
*/
|
||||
@Override
|
||||
public boolean isSecurityGroupEnabled() {
|
||||
return securityGroupEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxGuests the maxGuests to set
|
||||
*/
|
||||
public void setMaxGuestsLimit(Long maxGuestsLimit) {
|
||||
this.maxGuestsLimit = maxGuestsLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxGuests
|
||||
*/
|
||||
@Override
|
||||
public Long getMaxGuestsLimit() {
|
||||
return maxGuestsLimit;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof HypervisorCapabilitiesVO) {
|
||||
return ((HypervisorCapabilitiesVO)obj).getId() == this.getId();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -146,6 +146,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO;
|
|||
import com.cloud.hypervisor.vmware.mo.HostVirtualNicType;
|
||||
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
||||
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
||||
|
|
@ -178,6 +179,7 @@ import com.cloud.vm.DiskProfile;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmDetailConstants;
|
||||
import com.google.gson.Gson;
|
||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||
import com.vmware.vim25.ComputeResourceSummary;
|
||||
|
|
@ -770,8 +772,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
|
||||
|
||||
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
VirtualDevice nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), mgr.getGuestNicDeviceType(),
|
||||
|
||||
// Note: public NIC is plugged inside system VM
|
||||
VirtualDevice nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), VirtualEthernetCardType.Vmxnet3,
|
||||
networkInfo.second(), vifMacAddress, -1, 1, true, true);
|
||||
vmMo.plugDevice(nic);
|
||||
}
|
||||
|
|
@ -1057,8 +1060,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
|
||||
VirtualMachineTO vmSpec = cmd.getVirtualMachine();
|
||||
String vmName = vmSpec.getName();
|
||||
|
||||
String vmName = vmSpec.getName();
|
||||
|
||||
State state = State.Stopped;
|
||||
VmwareContext context = getServiceContext();
|
||||
try {
|
||||
|
|
@ -1068,7 +1071,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
synchronized (_vms) {
|
||||
_vms.put(vmName, State.Starting);
|
||||
}
|
||||
|
||||
|
||||
VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.valueOf(vmSpec.getDetails().get(VmDetailConstants.NIC_ADAPTER));
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("VM " + vmName + " will be started with NIC device type: " + nicDeviceType);
|
||||
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
VolumeTO[] disks = validateDisks(vmSpec.getDisks());
|
||||
assert (disks.length > 0);
|
||||
|
|
@ -1269,14 +1276,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
|
||||
VirtualDevice nic;
|
||||
int nicDeviceNumber = -1;
|
||||
for (NicTO nicTo : sortNicsByDeviceId(nics)) {
|
||||
s_logger.info("Prepare NIC device based on NicTO: " + _gson.toJson(nicTo));
|
||||
|
||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
||||
|
||||
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), mgr.getGuestNicDeviceType(), networkInfo.second(), nicTo.getMac(), nicDeviceNumber, i + 1, true, true);
|
||||
nicDeviceNumber = nic.getUnitNumber() + 1;
|
||||
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i, i + 1, true, true);
|
||||
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
||||
deviceConfigSpecArray[i].setDevice(nic);
|
||||
deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
|
||||
|
|
@ -1290,14 +1295,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
vmConfigSpec.setDeviceChange(deviceConfigSpecArray);
|
||||
|
||||
// pass boot arguments through machine.id
|
||||
OptionValue[] machineIdOptions = new OptionValue[1];
|
||||
OptionValue[] machineIdOptions = new OptionValue[2];
|
||||
machineIdOptions[0] = new OptionValue();
|
||||
machineIdOptions[0].setKey("machine.id");
|
||||
machineIdOptions[0].setValue(vmSpec.getBootArgs());
|
||||
|
||||
machineIdOptions[1] = new OptionValue();
|
||||
machineIdOptions[1].setKey("devices.hotplug");
|
||||
machineIdOptions[1].setValue("true");
|
||||
|
||||
String keyboardLayout = null;
|
||||
if(vmSpec.getDetails() != null)
|
||||
keyboardLayout = vmSpec.getDetails().get(VirtualMachine.PARAM_KEY_KEYBOARD);
|
||||
keyboardLayout = vmSpec.getDetails().get(VmDetailConstants.KEYBOARD);
|
||||
vmConfigSpec.setExtraConfig(configureVnc(machineIdOptions, hyperHost, vmName, vmSpec.getVncPassword(), keyboardLayout));
|
||||
|
||||
if (!vmMo.configureVm(vmConfigSpec)) {
|
||||
|
|
@ -3178,8 +3187,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
if (isVmInCluster(vm)) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM " + vm + " is now missing from host report but we detected that it might be migrated to other host by vCenter");
|
||||
}
|
||||
_vms.remove(vm);
|
||||
}
|
||||
|
||||
if(oldState != State.Starting && oldState != State.Migrating) {
|
||||
s_logger.debug("VM " + vm + " is now missing from host report and VM is not at starting/migrating state, remove it from host VM-sync map, oldState: " + oldState);
|
||||
_vms.remove(vm);
|
||||
} else {
|
||||
s_logger.debug("VM " + vm + " is missing from host report, but we will ignore VM " + vm + " in transition state " + oldState);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,8 @@ public class CitrixHelper {
|
|||
_xcpGuestOsMap.put("Windows Vista (32-bit)", "Windows Vista (32-bit)");
|
||||
_xcpGuestOsMap.put("Ubuntu 10.04 (32-bit)", "Ubuntu Lucid Lynx 10.04 (32-bit) (experimental)");
|
||||
_xcpGuestOsMap.put("Ubuntu 10.04 (64-bit)", "Ubuntu Lucid Lynx 10.04 (64-bit) (experimental)");
|
||||
_xcpGuestOsMap.put("Other install media", "Other install media");
|
||||
_xcpGuestOsMap.put("Other Linux (32-bit)", "Other install media");
|
||||
_xcpGuestOsMap.put("Other Linux (64-bit)", "Other install media");
|
||||
_xcpGuestOsMap.put("Other PV (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xcpGuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)");
|
||||
}
|
||||
|
|
@ -172,7 +173,8 @@ public class CitrixHelper {
|
|||
_xenServerGuestOsMap.put("Windows Vista (32-bit)", "Windows Vista (32-bit)");
|
||||
_xenServerGuestOsMap.put("Windows XP SP2 (32-bit)", "Windows XP SP2 (32-bit)");
|
||||
_xenServerGuestOsMap.put("Windows XP SP3 (32-bit)", "Windows XP SP3 (32-bit)");
|
||||
_xenServerGuestOsMap.put("Other install media", "Other install media");
|
||||
_xenServerGuestOsMap.put("Other Linux (32-bit)", "Other install media");
|
||||
_xenServerGuestOsMap.put("Other Linux (64-bit)", "Other install media");
|
||||
_xenServerGuestOsMap.put("Other PV (32-bit)", "CentOS 5.4 (32-bit)");
|
||||
_xenServerGuestOsMap.put("Other PV (64-bit)", "CentOS 5.4 (64-bit)");
|
||||
}
|
||||
|
|
@ -247,11 +249,87 @@ public class CitrixHelper {
|
|||
_xenServer56FP1GuestOsMap.put("Windows XP SP3 (32-bit)", "Windows XP SP3 (32-bit)");
|
||||
_xenServer56FP1GuestOsMap.put("Ubuntu 10.04 (32-bit)", "Ubuntu Lucid Lynx 10.04 (32-bit) (experimental)");
|
||||
_xenServer56FP1GuestOsMap.put("Ubuntu 10.04 (64-bit)", "Ubuntu Lucid Lynx 10.04 (64-bit) (experimental)");
|
||||
_xenServer56FP1GuestOsMap.put("Other install media", "Other install media");
|
||||
_xenServer56FP1GuestOsMap.put("Other Linux (32-bit)", "Other install media");
|
||||
_xenServer56FP1GuestOsMap.put("Other Linux (64-bit)", "Other install media");
|
||||
_xenServer56FP1GuestOsMap.put("Other PV (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP1GuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)");
|
||||
}
|
||||
|
||||
static {
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 4.5 (32-bit)", "CentOS 4.5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 4.6 (32-bit)", "CentOS 4.6 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 4.7 (32-bit)", "CentOS 4.7 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 4.8 (32-bit)", "CentOS 4.8 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.0 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.0 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.1 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.1 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.2 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.2 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.3 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.3 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.4 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.4 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.5 (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("CentOS 5.5 (64-bit)", "CentOS 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Debian GNU/Linux 5.0 (32-bit)", "Debian Lenny 5.0 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Debian GNU/Linux 6(32-bit)", "Debian Squeeze 6.0 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Debian GNU/Linux 6(64-bit)", "Debian Squeeze 6.0 (64-bit) (experimental)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.0 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.0 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.1 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.1 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.2 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.2 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.3 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.3 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.4 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.4 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.5 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Oracle Enterprise Linux 5.5 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 4.5 (32-bit)", "Red Hat Enterprise Linux 4.5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 4.6 (32-bit)", "Red Hat Enterprise Linux 4.6 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 4.7 (32-bit)", "Red Hat Enterprise Linux 4.7 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 4.8 (32-bit)", "Red Hat Enterprise Linux 4.8 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.0 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.0 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.1 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.1 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.2 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.2 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.3 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.3 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.4 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.4 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.5 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 5.5 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 6.0 (32-bit)", "Red Hat Enterprise Linux 6 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Red Hat Enterprise Linux 6.0 (64-bit)", "Red Hat Enterprise Linux 6 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 9 SP4 (32-bit)", "SUSE Linux Enterprise Server 9 SP4 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 10 SP1 (32-bit)", "SUSE Linux Enterprise Server 10 SP1 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 10 SP1 (64-bit)", "SUSE Linux Enterprise Server 10 SP1 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 10 SP2 (32-bit)", "SUSE Linux Enterprise Server 10 SP2 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 10 SP2 (64-bit)", "SUSE Linux Enterprise Server 10 SP2 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 10 SP3 (64-bit)", "SUSE Linux Enterprise Server 10 SP3 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 11 (32-bit)", "SUSE Linux Enterprise Server 11 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("SUSE Linux Enterprise Server 11 (64-bit)", "SUSE Linux Enterprise Server 11 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows 7 (32-bit)", "Windows 7 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows 7 (64-bit)", "Windows 7 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Server 2003 (32-bit)", "Windows Server 2003 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Server 2003 (64-bit)", "Windows Server 2003 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Server 2008 (32-bit)", "Windows Server 2008 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Server 2008 (64-bit)", "Windows Server 2008 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Server 2008 R2 (64-bit)", "Windows Server 2008 R2 (64-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows Vista (32-bit)", "Windows Vista (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Windows XP SP3 (32-bit)", "Windows XP SP3 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Ubuntu 10.04 (32-bit)", "Ubuntu Lucid Lynx 10.04 (32-bit) (experimental)");
|
||||
_xenServer56FP2GuestOsMap.put("Ubuntu 10.04 (64-bit)", "Ubuntu Lucid Lynx 10.04 (64-bit) (experimental)");
|
||||
_xenServer56FP2GuestOsMap.put("Other Linux (32-bit)", "Other install media");
|
||||
_xenServer56FP2GuestOsMap.put("Other Linux (64-bit)", "Other install media");
|
||||
_xenServer56FP2GuestOsMap.put("Other PV (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer56FP2GuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)");
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
_xenServer60GuestOsMap.put("CentOS 4.5 (32-bit)", "CentOS 4.5 (32-bit)");
|
||||
|
|
@ -339,7 +417,8 @@ public class CitrixHelper {
|
|||
_xenServer60GuestOsMap.put("Ubuntu 10.04 (64-bit)", "Ubuntu Lucid Lynx 10.04 (64-bit)");
|
||||
_xenServer60GuestOsMap.put("Ubuntu 10.10 (32-bit)", "Ubuntu Maverick Meerkat 10.10 (32-bit) (experimental)");
|
||||
_xenServer60GuestOsMap.put("Ubuntu 10.10 (64-bit)", "Ubuntu Maverick Meerkat 10.10 (64-bit) (experimental)");
|
||||
_xenServer60GuestOsMap.put("Other install media", "Other install media");
|
||||
_xenServer60GuestOsMap.put("Other Linux (32-bit)", "Other install media");
|
||||
_xenServer60GuestOsMap.put("Other Linux (64-bit)", "Other install media");
|
||||
_xenServer60GuestOsMap.put("Other PV (32-bit)", "CentOS 5 (32-bit)");
|
||||
_xenServer60GuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
protected String _storageNetworkName2;
|
||||
protected String _guestNetworkName;
|
||||
protected int _wait;
|
||||
protected int _migratewait;
|
||||
protected String _instance; //instance name (default is usually "VM")
|
||||
static final Random _rand = new Random(System.currentTimeMillis());
|
||||
|
||||
|
|
@ -325,7 +326,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
try {
|
||||
vm.destroy(conn);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Catch Exception " + e.getClass().getName() + ": unable to destroy VM " + vmRec.nameLabel + " due to " + e.toString());
|
||||
s_logger.warn("Catch Exception " + e.getClass().getName() + ": unable to destroy VM " + vmRec.nameLabel + " due to ", e);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -481,6 +482,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return execute((CheckSshCommand)cmd);
|
||||
} else if (clazz == SecurityIngressRulesCmd.class) {
|
||||
return execute((SecurityIngressRulesCmd) cmd);
|
||||
} else if (clazz == SecurityEgressRulesCmd.class) {
|
||||
return execute((SecurityEgressRulesCmd) cmd);
|
||||
} else if (clazz == OvsCreateGreTunnelCommand.class) {
|
||||
return execute((OvsCreateGreTunnelCommand)cmd);
|
||||
} else if (clazz == OvsSetTagAndFlowCommand.class) {
|
||||
|
|
@ -622,6 +625,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
protected Network getNetwork(Connection conn, NicTO nic) throws XenAPIException, XmlRpcException {
|
||||
String[] tags = nic.getTags();
|
||||
XsLocalNetwork network = getNativeNetworkForTraffic(conn, nic.getType(), tags != null && tags.length > 0 ? tags[0] : null);
|
||||
if (network == null) {
|
||||
s_logger.error("Network is not configured on the backend for nic " + nic.toString());
|
||||
throw new CloudRuntimeException("Network for the backend is not configured correctly for network broadcast domain: " + nic.getBroadcastUri());
|
||||
}
|
||||
if (nic.getBroadcastUri() != null && nic.getBroadcastUri().toString().contains("untagged")) {
|
||||
return network.getNetwork();
|
||||
} else if (nic.getBroadcastType() == BroadcastDomainType.Vlan) {
|
||||
|
|
@ -1910,7 +1917,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
stats = getVmStatsRawXML(conn);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
s_logger.warn("Error whilst collecting raw stats from plugin:" + e1);
|
||||
s_logger.warn("Error whilst collecting raw stats from plugin: ", e1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -1929,7 +1936,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
try {
|
||||
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(statsSource);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Exception caught whilst processing the document via document factory:"+e);
|
||||
s_logger.warn("Exception caught whilst processing the document via document factory:", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -2161,9 +2168,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
String copy_vhd_to_secondarystorage(Connection conn, String mountpoint, String vdiuuid, String sruuid) {
|
||||
private String copy_vhd_to_secondarystorage(Connection conn, String mountpoint, String vdiuuid, String sruuid, int wait) {
|
||||
String results = callHostPluginAsync(conn, "vmopspremium", "copy_vhd_to_secondarystorage",
|
||||
2 * 60 * 60 * 1000, "mountpoint", mountpoint, "vdiuuid", vdiuuid, "sruuid", sruuid);
|
||||
wait, "mountpoint", mountpoint, "vdiuuid", vdiuuid, "sruuid", sruuid);
|
||||
|
||||
if (results == null || results.isEmpty()) {
|
||||
String msg = "copy_vhd_to_secondarystorage return null";
|
||||
|
|
@ -2182,7 +2189,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
String upgradeSnapshot(Connection conn, String templatePath, String snapshotPath) {
|
||||
String results = callHostPluginAsync(conn, "vmopspremium", "upgrade_snapshot",
|
||||
2 * 60 * 60 * 1000, "templatePath", templatePath, "snapshotPath", snapshotPath);
|
||||
2 * 60 * 60, "templatePath", templatePath, "snapshotPath", snapshotPath);
|
||||
|
||||
if (results == null || results.isEmpty()) {
|
||||
String msg = "upgrade_snapshot return null";
|
||||
|
|
@ -2199,9 +2206,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
String createTemplateFromSnapshot(Connection conn, String templatePath, String snapshotPath) {
|
||||
String createTemplateFromSnapshot(Connection conn, String templatePath, String snapshotPath, int wait) {
|
||||
String results = callHostPluginAsync(conn, "vmopspremium", "create_privatetemplate_from_snapshot",
|
||||
2 * 60 * 60 * 1000, "templatePath", templatePath, "snapshotPath", snapshotPath);
|
||||
wait, "templatePath", templatePath, "snapshotPath", snapshotPath);
|
||||
|
||||
if (results == null || results.isEmpty()) {
|
||||
String msg = "create_privatetemplate_from_snapshot return null";
|
||||
|
|
@ -2218,9 +2225,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
String copy_vhd_from_secondarystorage(Connection conn, String mountpoint, String sruuid) {
|
||||
String copy_vhd_from_secondarystorage(Connection conn, String mountpoint, String sruuid, int wait) {
|
||||
String results = callHostPluginAsync(conn, "vmopspremium", "copy_vhd_from_secondarystorage",
|
||||
2 * 60 * 60 * 1000, "mountpoint", mountpoint, "sruuid", sruuid);
|
||||
wait, "mountpoint", mountpoint, "sruuid", sruuid);
|
||||
|
||||
if (results == null || results.isEmpty()) {
|
||||
String msg = "copy_vhd_from_secondarystorage return null";
|
||||
|
|
@ -2240,6 +2247,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
public PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) {
|
||||
String tmplturl = cmd.getUrl();
|
||||
String poolName = cmd.getPoolUuid();
|
||||
int wait = cmd.getWait();
|
||||
try {
|
||||
URI uri = new URI(tmplturl);
|
||||
String tmplpath = uri.getHost() + ":" + uri.getPath();
|
||||
|
|
@ -2255,7 +2263,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
String pUuid = poolsr.getUuid(conn);
|
||||
boolean isISCSI = IsISCSI(poolsr.getType(conn));
|
||||
String uuid = copy_vhd_from_secondarystorage(conn, tmplpath, pUuid);
|
||||
String uuid = copy_vhd_from_secondarystorage(conn, tmplpath, pUuid, wait);
|
||||
VDI tmpl = getVDIbyUuid(conn, uuid);
|
||||
VDI snapshotvdi = tmpl.snapshot(conn, new HashMap<String, String>());
|
||||
String snapshotUuid = snapshotvdi.getUuid(conn);
|
||||
|
|
@ -2444,9 +2452,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
break;
|
||||
}
|
||||
}
|
||||
Map<String, String> other = new HashMap<String, String>();
|
||||
other.put("live", "true");
|
||||
vm.poolMigrate(conn, dsthost, other);
|
||||
migrateVM(conn, dsthost, vm, vmName);
|
||||
vm.setAffinity(conn, dsthost);
|
||||
state = State.Stopping;
|
||||
}
|
||||
|
|
@ -2779,7 +2785,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
vm.hardShutdown(conn);
|
||||
} catch (Exception e) {
|
||||
String msg = "VM hardshutdown failed due to " + e.toString();
|
||||
s_logger.warn(msg);
|
||||
s_logger.warn(msg, e);
|
||||
}
|
||||
}
|
||||
if (vm.getPowerState(conn) == VmPowerState.HALTED) {
|
||||
|
|
@ -2787,12 +2793,12 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
vm.destroy(conn);
|
||||
} catch (Exception e) {
|
||||
String msg = "VM destroy failed due to " + e.toString();
|
||||
s_logger.warn(msg);
|
||||
s_logger.warn(msg, e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String msg = "VM getPowerState failed due to " + e.toString();
|
||||
s_logger.warn(msg);
|
||||
s_logger.warn(msg, e);
|
||||
}
|
||||
}
|
||||
if (mounts != null) {
|
||||
|
|
@ -2803,7 +2809,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
vbds = vdi.getVBDs(conn);
|
||||
} catch (Exception e) {
|
||||
String msg = "VDI getVBDS failed due to " + e.toString();
|
||||
s_logger.warn(msg);
|
||||
s_logger.warn(msg, e);
|
||||
continue;
|
||||
}
|
||||
for (VBD vbd : vbds) {
|
||||
|
|
@ -2812,7 +2818,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
vbd.destroy(conn);
|
||||
} catch (Exception e) {
|
||||
String msg = "VBD destroy failed due to " + e.toString();
|
||||
s_logger.warn(msg);
|
||||
s_logger.warn(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2984,13 +2990,50 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected VDI cloudVDIcopy(Connection conn, VDI vdi, SR sr) throws XenAPIException, XmlRpcException {
|
||||
|
||||
private
|
||||
void migrateVM(Connection conn, Host destHost, VM vm, String vmName) throws XmlRpcException {
|
||||
Task task = null;
|
||||
try {
|
||||
Map<String, String> other = new HashMap<String, String>();
|
||||
other.put("live", "true");
|
||||
task = vm.poolMigrateAsync(conn, destHost, other);
|
||||
try {
|
||||
// poll every 1 seconds
|
||||
long timeout = (long)(_migratewait) * 1000L;
|
||||
waitForTask(conn, task, 1000, timeout);
|
||||
checkForSuccess(conn, task);
|
||||
} catch (Types.HandleInvalid e) {
|
||||
if (vm.getResidentOn(conn).equals(destHost)) {
|
||||
task = null;
|
||||
return;
|
||||
}
|
||||
throw new CloudRuntimeException("migrate VM catch HandleInvalid and VM is not running on dest host");
|
||||
}
|
||||
} catch (XenAPIException e) {
|
||||
String msg = "Unable to migrate VM(" + vmName + ") from host(" + _host.uuid +") due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}finally {
|
||||
if( task != null) {
|
||||
try {
|
||||
task.destroy(conn);
|
||||
} catch (Exception e1) {
|
||||
s_logger.debug("unable to destroy task(" + task.toString() + ") on host(" + _host.uuid +") due to " + e1.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected VDI cloudVDIcopy(Connection conn, VDI vdi, SR sr, int wait) throws XenAPIException, XmlRpcException {
|
||||
Task task = null;
|
||||
if ( wait == 0 ) {
|
||||
wait = 2 * 60 * 60;
|
||||
}
|
||||
try {
|
||||
task = vdi.copyAsync(conn, sr);
|
||||
// poll every 1 seconds , timeout after 2 hours
|
||||
waitForTask(conn, task, 1000, 2 * 60 * 60 * 1000);
|
||||
waitForTask(conn, task, 1000, wait * 1000);
|
||||
checkForSuccess(conn, task);
|
||||
VDI dvdi = Types.toVDI(task, conn);
|
||||
return dvdi;
|
||||
|
|
@ -2999,8 +3042,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
try {
|
||||
task.destroy(conn);
|
||||
} catch (Exception e1) {
|
||||
s_logger.warn("unable to destroy task(" + task.toString() + ") on host(" + _host.uuid + ") due to "
|
||||
+ e1.toString());
|
||||
s_logger.warn("unable to destroy task(" + task.toString() + ") on host(" + _host.uuid + ") due to ", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3009,7 +3051,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
boolean swiftDownload(Connection conn, SwiftTO swift, String rfilename, String lfilename) {
|
||||
String result = null;
|
||||
try {
|
||||
result = callHostPluginAsync(conn, "swift", "swift", 60 * 60 * 1000,
|
||||
result = callHostPluginAsync(conn, "swift", "swift", 60 * 60,
|
||||
"op", "download", "hostname", swift.getHostName(), "account", swift.getAccount(),
|
||||
"username", swift.getUserName(), "token", swift.getToken(), "rfilename", rfilename,
|
||||
"lfilename", lfilename);
|
||||
|
|
@ -3017,7 +3059,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("swift download failed due to " + e.toString());
|
||||
s_logger.warn("swift download failed due to ", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3025,7 +3067,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
boolean swiftUpload(Connection conn, SwiftTO swift, String rfilename, String lfilename) {
|
||||
String result = null;
|
||||
try {
|
||||
result = callHostPluginAsync(conn, "swift", "swift", 60 * 60 * 1000,
|
||||
result = callHostPluginAsync(conn, "swift", "swift", 60 * 60,
|
||||
"op", "upload", "hostname", swift.getHostName(), "account", swift.getAccount(),
|
||||
"username", swift.getUserName(), "token", swift.getToken(), "rfilename", rfilename,
|
||||
"lfilename", lfilename);
|
||||
|
|
@ -3033,7 +3075,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("swift download failed due to " + e.toString());
|
||||
s_logger.warn("swift download failed due to ", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3048,7 +3090,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("swift download failed due to " + e.toString());
|
||||
s_logger.warn("swift download failed due to ", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3059,7 +3101,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
|
||||
protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, Long dcId, Long accountId,
|
||||
Long volumeId, String secondaryStorageMountPath, String snapshotUuid, String prevBackupUuid, Boolean isISCSI) {
|
||||
Long volumeId, String secondaryStorageMountPath, String snapshotUuid, String prevBackupUuid, Boolean isISCSI, int wait) {
|
||||
String backupSnapshotUuid = null;
|
||||
|
||||
if (prevBackupUuid == null) {
|
||||
|
|
@ -3068,7 +3110,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
// Each argument is put in a separate line for readability.
|
||||
// Using more lines does not harm the environment.
|
||||
String results = callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", 60 * 60 * 1000,
|
||||
String results = callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", wait,
|
||||
"primaryStorageSRUuid", primaryStorageSRUuid, "dcId", dcId.toString(), "accountId", accountId
|
||||
.toString(), "volumeId", volumeId.toString(), "secondaryStorageMountPath",
|
||||
secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevBackupUuid", prevBackupUuid, "isISCSI",
|
||||
|
|
@ -3099,7 +3141,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return backupSnapshotUuid;
|
||||
}
|
||||
|
||||
protected String callHostPluginAsync(Connection conn, String plugin, String cmd, int timeout, String... params) {
|
||||
protected String callHostPluginAsync(Connection conn, String plugin, String cmd, int wait, String... params) {
|
||||
int timeout = wait * 1000;
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
Task task = null;
|
||||
try {
|
||||
|
|
@ -3133,8 +3176,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
try {
|
||||
task.destroy(conn);
|
||||
} catch (Exception e1) {
|
||||
s_logger.warn("unable to destroy task(" + task.toString() + ") on host(" + _host.uuid + ") due to "
|
||||
+ e1.toString());
|
||||
s_logger.warn("unable to destroy task(" + task.toString() + ") on host(" + _host.uuid + ") due to ", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3813,7 +3855,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
try {
|
||||
Connection conn = getConnection();
|
||||
if (!pingXenServer()) {
|
||||
Thread.sleep(1000);
|
||||
if (!pingXenServer()) {
|
||||
|
|
@ -3821,6 +3862,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return null;
|
||||
}
|
||||
}
|
||||
Connection conn = getConnection();
|
||||
HashMap<String, State> newStates = deltaSync(conn);
|
||||
if (newStates == null) {
|
||||
s_logger.warn("Unable to get current status from sync");
|
||||
|
|
@ -4091,7 +4133,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
sr = pbd.getSR(conn);
|
||||
srRec = sr.getRecord(conn);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("pbd.getSR get Exception due to " + e.toString());
|
||||
s_logger.warn("pbd.getSR get Exception due to ", e);
|
||||
continue;
|
||||
}
|
||||
String type = srRec.type;
|
||||
|
|
@ -4104,7 +4146,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
pbd.destroy(conn);
|
||||
sr.forget(conn);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("forget SR catch Exception due to " + e.toString());
|
||||
s_logger.warn("forget SR catch Exception due to ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4971,6 +5013,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
String value = (String) params.get("wait");
|
||||
_wait = NumbersUtil.parseInt(value, 600);
|
||||
|
||||
value = (String) params.get("migratewait");
|
||||
_migratewait = NumbersUtil.parseInt(value, 3600);
|
||||
|
||||
if (_pod == null) {
|
||||
throw new ConfigurationException("Unable to get the pod");
|
||||
|
|
@ -5422,6 +5467,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
StorageFilerTO poolTO = cmd.getPool();
|
||||
String secondaryStorageURL = cmd.getSecondaryStorageURL();
|
||||
boolean toSecondaryStorage = cmd.toSecondaryStorage();
|
||||
int wait = cmd.getWait();
|
||||
try {
|
||||
URI uri = new URI(secondaryStorageURL);
|
||||
String remoteVolumesMountPath = uri.getHost() + ":" + uri.getPath() + "/volumes/";
|
||||
|
|
@ -5444,20 +5490,20 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
// Look up the volume on the source primary storage pool
|
||||
VDI srcVolume = getVDIbyUuid(conn, volumeUUID);
|
||||
// Copy the volume to secondary storage
|
||||
VDI destVolume = cloudVDIcopy(conn, srcVolume, secondaryStorage);
|
||||
VDI destVolume = cloudVDIcopy(conn, srcVolume, secondaryStorage, wait);
|
||||
String destVolumeUUID = destVolume.getUuid(conn);
|
||||
return new CopyVolumeAnswer(cmd, true, null, null, destVolumeUUID);
|
||||
} finally {
|
||||
removeSR(conn, secondaryStorage);
|
||||
}
|
||||
} else {
|
||||
String uuid = copy_vhd_to_secondarystorage(conn, mountpoint, volumeUUID, srUuid);
|
||||
String uuid = copy_vhd_to_secondarystorage(conn, mountpoint, volumeUUID, srUuid, wait);
|
||||
return new CopyVolumeAnswer(cmd, true, null, null, uuid);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
String volumePath = mountpoint + "/" + volumeUUID + ".vhd";
|
||||
String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid);
|
||||
String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait );
|
||||
return new CopyVolumeAnswer(cmd, true, null, srUuid, uuid);
|
||||
} finally {
|
||||
deleteSecondaryStorageFolder(conn, remoteVolumesMountPath, volumeFolder);
|
||||
|
|
@ -5752,7 +5798,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
Long accountId = cmd.getAccountId();
|
||||
String userSpecifiedName = cmd.getTemplateName();
|
||||
Long templateId = cmd.getTemplateId();
|
||||
|
||||
int wait = cmd.getWait();
|
||||
String details = null;
|
||||
SR tmpltSR = null;
|
||||
boolean result = false;
|
||||
|
|
@ -5773,7 +5819,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
tmpltSR = createNfsSRbyURI(conn, tmpltURI, false);
|
||||
|
||||
// copy volume to template SR
|
||||
VDI tmpltVDI = cloudVDIcopy(conn, volume, tmpltSR);
|
||||
VDI tmpltVDI = cloudVDIcopy(conn, volume, tmpltSR, wait);
|
||||
// scan makes XenServer pick up VDI physicalSize
|
||||
tmpltSR.scan(conn);
|
||||
if (userSpecifiedName != null) {
|
||||
|
|
@ -5842,6 +5888,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
||||
Long newTemplateId = cmd.getNewTemplateId();
|
||||
String userSpecifiedName = cmd.getTemplateName();
|
||||
int wait = cmd.getWait();
|
||||
// By default, assume failure
|
||||
String details = null;
|
||||
boolean result = false;
|
||||
|
|
@ -5857,7 +5904,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
String templatePath = secondaryStorageMountPath + "/" + installPath;
|
||||
// create snapshot SR
|
||||
String snapshotPath = secondaryStorageMountPath + "/snapshots/" + accountId + "/" + volumeId + "/" + backedUpSnapshotUuid + ".vhd";
|
||||
String results = createTemplateFromSnapshot(conn, templatePath, snapshotPath);
|
||||
String results = createTemplateFromSnapshot(conn, templatePath, snapshotPath, wait);
|
||||
String[] tmp = results.split("#");
|
||||
String tmpltUuid = tmp[1];
|
||||
long physicalSize = Long.parseLong(tmp[2]);
|
||||
|
|
@ -5918,6 +5965,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
String snapshotUuid = cmd.getSnapshotUuid(); // not null: Precondition.
|
||||
String prevBackupUuid = cmd.getPrevBackupUuid();
|
||||
String prevSnapshotUuid = cmd.getPrevSnapshotUuid();
|
||||
int wait = cmd.getWait();
|
||||
// By default assume failure
|
||||
String details = null;
|
||||
boolean success = false;
|
||||
|
|
@ -5960,7 +6008,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
SR snapshotSr = null;
|
||||
try {
|
||||
snapshotSr = createNfsSRbyURI(conn, new URI(snapshotMountpoint), false);
|
||||
VDI backedVdi = cloudVDIcopy(conn, snapshotVdi, snapshotSr);
|
||||
VDI backedVdi = cloudVDIcopy(conn, snapshotVdi, snapshotSr, wait);
|
||||
snapshotBackupUuid = backedVdi.getUuid(conn);
|
||||
if( cmd.getSwift() != null ) {
|
||||
try {
|
||||
|
|
@ -5983,7 +6031,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
snapshotBackupUuid = filename;
|
||||
success = true;
|
||||
} else {
|
||||
snapshotBackupUuid = backupSnapshot(conn, primaryStorageSRUuid, dcId, accountId, volumeId, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI);
|
||||
snapshotBackupUuid = backupSnapshot(conn, primaryStorageSRUuid, dcId, accountId, volumeId, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait);
|
||||
success = (snapshotBackupUuid != null);
|
||||
}
|
||||
}
|
||||
|
|
@ -6010,7 +6058,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
Long volumeId = cmd.getVolumeId();
|
||||
String secondaryStoragePoolURL = cmd.getSecondaryStoragePoolURL();
|
||||
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
||||
|
||||
int wait = cmd.getWait();
|
||||
boolean result = false;
|
||||
// Generic error message.
|
||||
String details = null;
|
||||
|
|
@ -6031,7 +6079,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
URI snapshotURI = new URI(secondaryStoragePoolURL + "/snapshots/" + accountId + "/" + volumeId );
|
||||
String snapshotPath = snapshotURI.getHost() + ":" + snapshotURI.getPath() + "/" + backedUpSnapshotUuid + ".vhd";
|
||||
String srUuid = primaryStorageSR.getUuid(conn);
|
||||
volumeUUID = copy_vhd_from_secondarystorage(conn, snapshotPath, srUuid);
|
||||
volumeUUID = copy_vhd_from_secondarystorage(conn, snapshotPath, srUuid, wait);
|
||||
result = true;
|
||||
} catch (XenAPIException e) {
|
||||
details += " due to " + e.toString();
|
||||
|
|
|
|||
|
|
@ -277,8 +277,8 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
|
||||
@Override
|
||||
protected CheckOnHostAnswer execute(CheckOnHostCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
try {
|
||||
Connection conn = getConnection();
|
||||
String result = callHostPluginPremium(conn, "check_heartbeat", "host", cmd.getHost().getGuid(), "interval",
|
||||
Integer.toString(_heartbeatInterval * 2));
|
||||
if (result == null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,812 @@
|
|||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, 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.network.resource;
|
||||
|
||||
import java.net.URL;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.ExternalNetworkResourceUsageAnswer;
|
||||
import com.cloud.agent.api.ExternalNetworkResourceUsageCommand;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.ReadyAnswer;
|
||||
import com.cloud.agent.api.ReadyCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupExternalLoadBalancerCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.DestinationTO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import com.citrix.netscaler.nitro.service.nitro_service;
|
||||
import com.citrix.netscaler.nitro.resource.base.base_response;
|
||||
import com.citrix.netscaler.nitro.exception.nitro_exception;
|
||||
import com.citrix.netscaler.nitro.resource.config.ns.nsconfig;
|
||||
import com.citrix.netscaler.nitro.resource.config.lb.lbvserver;
|
||||
import com.citrix.netscaler.nitro.resource.config.basic.service;
|
||||
import com.citrix.netscaler.nitro.resource.config.network.*;
|
||||
import com.citrix.netscaler.nitro.resource.config.ns.*;
|
||||
import com.citrix.netscaler.nitro.resource.config.basic.server_service_binding;
|
||||
import org.apache.axis.types.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
class NitroError {
|
||||
static final int NS_RESOURCE_EXISTS = 273;
|
||||
static final int NS_RESOURCE_NOT_EXISTS=258;
|
||||
static final int NS_NO_SERIVCE = 344;
|
||||
}
|
||||
|
||||
public class NetscalerMPXResource implements ServerResource {
|
||||
|
||||
// deployment configuration
|
||||
private String _name;
|
||||
private String _zoneId;
|
||||
private String _ip;
|
||||
private String _username;
|
||||
private String _password;
|
||||
private String _publicInterface;
|
||||
private String _privateInterface;
|
||||
private Integer _numRetries;
|
||||
private String _guid;
|
||||
private boolean _inline;
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NetscalerMPXResource.class);
|
||||
protected Gson _gson;
|
||||
private String _objectNamePathSep = "-";
|
||||
|
||||
nitro_service nsService ;
|
||||
Long timeout = new Long(100000);
|
||||
base_response apiCallResult;
|
||||
|
||||
public NetscalerMPXResource () {
|
||||
_gson = GsonHelper.getGsonLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
try {
|
||||
_name = (String) params.get("name");
|
||||
if (_name == null) {
|
||||
throw new ConfigurationException("Unable to find name");
|
||||
}
|
||||
|
||||
_zoneId = (String) params.get("zoneId");
|
||||
if (_zoneId == null) {
|
||||
throw new ConfigurationException("Unable to find zone");
|
||||
}
|
||||
|
||||
_ip = (String) params.get("ip");
|
||||
if (_ip == null) {
|
||||
throw new ConfigurationException("Unable to find IP");
|
||||
}
|
||||
|
||||
_username = (String) params.get("username");
|
||||
if (_username == null) {
|
||||
throw new ConfigurationException("Unable to find username");
|
||||
}
|
||||
|
||||
_password = (String) params.get("password");
|
||||
if (_password == null) {
|
||||
throw new ConfigurationException("Unable to find password");
|
||||
}
|
||||
|
||||
_publicInterface = (String) params.get("publicInterface");
|
||||
if (_publicInterface == null) {
|
||||
throw new ConfigurationException("Unable to find public interface");
|
||||
}
|
||||
|
||||
_privateInterface = (String) params.get("privateInterface");
|
||||
if (_privateInterface == null) {
|
||||
throw new ConfigurationException("Unable to find private interface");
|
||||
}
|
||||
|
||||
_numRetries = NumbersUtil.parseInt((String) params.get("numRetries"), 1);
|
||||
|
||||
_guid = (String)params.get("guid");
|
||||
if (_guid == null) {
|
||||
throw new ConfigurationException("Unable to find the guid");
|
||||
}
|
||||
|
||||
_inline = Boolean.parseBoolean((String) params.get("inline"));
|
||||
|
||||
if (!login()) {
|
||||
throw new ExecutionException("Failed to login to the Netscaler device.");
|
||||
}
|
||||
|
||||
if (!enableNetScalerLoadBalancing()) {
|
||||
throw new ExecutionException("Failed to enable load balancing feature on the Netscaler device.");
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean login() {
|
||||
try {
|
||||
nsService = new nitro_service(_ip, "https");
|
||||
apiCallResult = nsService.login(_username, _password, timeout);
|
||||
if (apiCallResult.errorcode == 0) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.debug("Failed to log in to Netscaler device at " + _ip + " due to " + apiCallResult.message);
|
||||
return false;
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
s_logger.debug("Failed to log in to Netscaler device at " + _ip + " due to " + e.response[0].message);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to log in to Netscaler device at " + _ip + " due to " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean enableNetScalerLoadBalancing() {
|
||||
try {
|
||||
String[] feature = new String[1];
|
||||
feature[0] = "LB";
|
||||
nsService.enable_features(feature);
|
||||
return true;
|
||||
} catch (nitro_exception e) {
|
||||
System.out.println("Enabling netscaler load balancing feature failed errorcode="+e.getErrorCode()+",message="+ e.getMessage());
|
||||
} catch (Exception e) {
|
||||
System.out.println("Enabling netscaler load balancing feature failed due to "+e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
StartupExternalLoadBalancerCommand cmd = new StartupExternalLoadBalancerCommand();
|
||||
cmd.setName(_name);
|
||||
cmd.setDataCenter(_zoneId);
|
||||
cmd.setPod("");
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer executeRequest(Command cmd) {
|
||||
return executeRequest(cmd, _numRetries);
|
||||
}
|
||||
|
||||
private Answer executeRequest(Command cmd, int numRetries) {
|
||||
if (cmd instanceof ReadyCommand) {
|
||||
return execute((ReadyCommand) cmd);
|
||||
} else if (cmd instanceof MaintainCommand) {
|
||||
return execute((MaintainCommand) cmd);
|
||||
} else if (cmd instanceof IpAssocCommand) {
|
||||
return execute((IpAssocCommand) cmd, numRetries);
|
||||
} else if (cmd instanceof LoadBalancerConfigCommand) {
|
||||
return execute((LoadBalancerConfigCommand) cmd, numRetries);
|
||||
} else if (cmd instanceof ExternalNetworkResourceUsageCommand) {
|
||||
return execute((ExternalNetworkResourceUsageCommand) cmd);
|
||||
} else if (cmd instanceof MaintainCommand) {
|
||||
return execute((MaintainCommand) cmd);
|
||||
} else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
private Answer execute(ReadyCommand cmd) {
|
||||
return new ReadyAnswer(cmd);
|
||||
}
|
||||
|
||||
protected Answer execute(MaintainCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource MaintainCommand");
|
||||
}
|
||||
return new MaintainAnswer(cmd, "Put host in maintaince");
|
||||
}
|
||||
|
||||
private synchronized Answer execute(IpAssocCommand cmd, int numRetries) {
|
||||
String[] results = new String[cmd.getIpAddresses().length];
|
||||
int i = 0;
|
||||
try {
|
||||
IpAddressTO[] ips = cmd.getIpAddresses();
|
||||
for (IpAddressTO ip : ips) {
|
||||
long guestVlanTag = Long.valueOf(ip.getVlanId());
|
||||
String vlanSelfIp = ip.getVlanGateway();
|
||||
String vlanNetmask = ip.getVlanNetmask();
|
||||
|
||||
// Check and delete any existing guest VLAN with this tag, self IP, and netmask
|
||||
deleteGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask);
|
||||
|
||||
if (ip.isAdd()) {
|
||||
// Add a new guest VLAN and its subnet and bind it to private interface
|
||||
addGuestVlanAndSubnet(guestVlanTag, vlanSelfIp, vlanNetmask);
|
||||
}
|
||||
|
||||
saveConfiguration();
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.error("Failed to execute IPAssocCommand due to " + e);
|
||||
|
||||
if (shouldRetry(numRetries)) {
|
||||
return retry(cmd, numRetries);
|
||||
} else {
|
||||
results[i++] = IpAssocAnswer.errorResult;
|
||||
}
|
||||
}
|
||||
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
}
|
||||
|
||||
private synchronized Answer execute(LoadBalancerConfigCommand cmd, int numRetries) {
|
||||
try {
|
||||
String lbProtocol;
|
||||
String lbMethod;
|
||||
LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
|
||||
|
||||
for (LoadBalancerTO loadBalancer : loadBalancers) {
|
||||
|
||||
if (loadBalancer.getProtocol() == null) {
|
||||
lbProtocol = "TCP";
|
||||
} else if (loadBalancer.getProtocol().equals(NetUtils.TCP_PROTO)){
|
||||
lbProtocol = "TCP";
|
||||
} else if (loadBalancer.getProtocol().equals(NetUtils.UDP_PROTO)) {
|
||||
lbProtocol = "UDP";
|
||||
} else {
|
||||
throw new ExecutionException("Got invalid protocol: " + loadBalancer.getProtocol());
|
||||
}
|
||||
|
||||
if (loadBalancer.getAlgorithm().equals("roundrobin")) {
|
||||
lbMethod = "ROUNDROBIN";
|
||||
} else if (loadBalancer.getAlgorithm().equals("leastconn")) {
|
||||
lbMethod = "LEASTCONNECTION";
|
||||
} else {
|
||||
throw new ExecutionException("Got invalid load balancing algorithm: " + loadBalancer.getAlgorithm());
|
||||
}
|
||||
|
||||
String srcIp = loadBalancer.getSrcIp();
|
||||
int srcPort = loadBalancer.getSrcPort();
|
||||
String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort, lbProtocol);
|
||||
|
||||
boolean destinationsToAdd = false;
|
||||
for (DestinationTO destination : loadBalancer.getDestinations()) {
|
||||
if (!destination.isRevoked()) {
|
||||
destinationsToAdd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loadBalancer.isRevoked() && destinationsToAdd) {
|
||||
|
||||
// create a load balancing virtual server
|
||||
addLBVirtualServer(nsVirtualServerName, srcIp, srcPort, lbMethod, lbProtocol);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Created load balancing virtual server " + nsVirtualServerName + " on the Netscaler device");
|
||||
}
|
||||
|
||||
List<String> activePoolMembers = new ArrayList<String>();
|
||||
for (DestinationTO destination : loadBalancer.getDestinations()) {
|
||||
|
||||
String nsServerName = generateNSServerName(destination.getDestIp());
|
||||
String nsServiceName = generateNSServiceName(destination.getDestIp(), destination.getDestPort());
|
||||
|
||||
if (!destination.isRevoked()) {
|
||||
// add a new destination to deployed load balancing rule
|
||||
|
||||
// add a new server
|
||||
if (!nsServerExists(nsServerName)) {
|
||||
com.citrix.netscaler.nitro.resource.config.basic.server nsServer = new com.citrix.netscaler.nitro.resource.config.basic.server();
|
||||
nsServer.set_name(nsServerName);
|
||||
nsServer.set_ipaddress(destination.getDestIp());
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.add(nsService, nsServer);
|
||||
if ((apiCallResult.errorcode != 0) && (apiCallResult.errorcode != NitroError.NS_RESOURCE_EXISTS)) {
|
||||
throw new ExecutionException("Failed to add server " + destination.getDestIp() + " due to" + apiCallResult.message);
|
||||
}
|
||||
}
|
||||
|
||||
// create a new service using the server added
|
||||
if (!nsServiceExists(nsServiceName)) {
|
||||
com.citrix.netscaler.nitro.resource.config.basic.service newService = new com.citrix.netscaler.nitro.resource.config.basic.service();
|
||||
newService.set_name(nsServiceName);
|
||||
newService.set_port(destination.getDestPort());
|
||||
newService.set_servername(nsServerName);
|
||||
newService.set_state("ENABLED");
|
||||
newService.set_servicetype(lbProtocol);
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.service.add(nsService, newService);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to create service " + nsServiceName + " using server " + nsServerName + " due to" + apiCallResult.message);
|
||||
}
|
||||
}
|
||||
|
||||
//bind service to load balancing virtual server
|
||||
if (!nsServiceBindingExists(nsVirtualServerName, nsServiceName)) {
|
||||
com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding svcBinding = new com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding();
|
||||
svcBinding.set_name(nsVirtualServerName);
|
||||
svcBinding.set_servicename(nsServiceName);
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.add(nsService, svcBinding);
|
||||
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to bind service: " + nsServiceName + " to the lb virtual server: " + nsVirtualServerName + " on Netscaler device");
|
||||
}
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully added LB destination: " + destination.getDestIp() + ":" + destination.getDestPort() + " to load balancer " + srcIp + ":" + srcPort);
|
||||
}
|
||||
} else {
|
||||
// remove a destination from the deployed load balancing rule
|
||||
com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(nsService, nsVirtualServerName);
|
||||
if (serviceBindings != null) {
|
||||
for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
|
||||
if (nsServiceName.equalsIgnoreCase(binding.get_servicename())) {
|
||||
// delete the binding
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(nsService, binding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to delete the binding between the virtual server: " + nsVirtualServerName + " and service:" + nsServiceName);
|
||||
}
|
||||
|
||||
// delete the service
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.service.delete(nsService, nsServiceName);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to delete service: " + nsServiceName);
|
||||
}
|
||||
|
||||
// delete the server if there is no associated services
|
||||
server_service_binding[] services = server_service_binding.get(nsService, nsServerName);
|
||||
if ((services == null) || (services.length == 0)) {
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(nsService, nsServerName);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove server:" + nsServerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// delete the implemented load balancing rule and its destinations
|
||||
lbvserver lbserver = lbvserver.get(nsService, nsVirtualServerName);
|
||||
if (lbserver == null) {
|
||||
throw new ExecutionException("Failed to find virtual server with name:" + nsVirtualServerName);
|
||||
}
|
||||
//unbind the all services associated with this virtual server
|
||||
com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(nsService, nsVirtualServerName);
|
||||
|
||||
if (serviceBindings != null) {
|
||||
for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
|
||||
String serviceName = binding.get_servicename();
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(nsService, binding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to unbind servic from the lb virtual server: " + nsVirtualServerName);
|
||||
}
|
||||
|
||||
com.citrix.netscaler.nitro.resource.config.basic.service svc = com.citrix.netscaler.nitro.resource.config.basic.service.get(nsService, serviceName);
|
||||
String nsServerName = svc.get_servername();
|
||||
|
||||
// delete the service
|
||||
com.citrix.netscaler.nitro.resource.config.basic.service.delete(nsService, serviceName);
|
||||
|
||||
//delete the server if no more services attached
|
||||
server_service_binding[] services = server_service_binding.get(nsService, nsServerName);
|
||||
if ((services == null) || (services.length == 0)) {
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(nsService, nsServerName);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove server:" + nsServerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeLBVirtualServer(nsVirtualServerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Successfully executed resource LoadBalancerConfigCommand: " + _gson.toJson(cmd));
|
||||
}
|
||||
|
||||
saveConfiguration();
|
||||
return new Answer(cmd);
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.error("Failed to execute LoadBalancerConfigCommand due to " + e.getMessage());
|
||||
if (shouldRetry(numRetries)) {
|
||||
return retry(cmd, numRetries);
|
||||
} else {
|
||||
return new Answer(cmd, e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Failed to execute LoadBalancerConfigCommand due to " + e.getMessage());
|
||||
if (shouldRetry(numRetries)) {
|
||||
return retry(cmd, numRetries);
|
||||
} else {
|
||||
return new Answer(cmd, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized ExternalNetworkResourceUsageAnswer execute(ExternalNetworkResourceUsageCommand cmd) {
|
||||
try {
|
||||
return getPublicIpBytesSentAndReceived(cmd);
|
||||
} catch (ExecutionException e) {
|
||||
return new ExternalNetworkResourceUsageAnswer(cmd, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addGuestVlanAndSubnet(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||
org.apache.axis.types.UnsignedInt result;
|
||||
|
||||
try {
|
||||
String vlanName = generateVlanName(vlanTag);
|
||||
if (!nsVlanExists(vlanTag)) {
|
||||
// add new vlan
|
||||
vlan vlanObj = new vlan();
|
||||
vlanObj.set_id(vlanTag);
|
||||
apiCallResult = vlan.add(nsService, vlanObj);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to add new vlan with tag:" + vlanTag + "due to" + apiCallResult.message);
|
||||
}
|
||||
|
||||
// add self-ip and subnet to the Netscaler
|
||||
nsip selfIp = new nsip();
|
||||
selfIp.set_ipaddress(vlanSelfIp);
|
||||
selfIp.set_netmask(vlanNetmask);
|
||||
selfIp.set_type("SNIP");
|
||||
apiCallResult = nsip.add(nsService, selfIp);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to add new self-ip due to "+ apiCallResult.message);
|
||||
}
|
||||
|
||||
//bind the vlan to guest subnet
|
||||
vlan_nsip_binding ipVlanBinding = new vlan_nsip_binding();
|
||||
ipVlanBinding.set_id(vlanTag);
|
||||
ipVlanBinding.set_ipaddress(vlanSelfIp);
|
||||
ipVlanBinding.set_netmask(vlanNetmask);
|
||||
apiCallResult = vlan_nsip_binding.add(nsService, ipVlanBinding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to bind vlan with tag:" + vlanTag + " to the subnet due to" + apiCallResult.message);
|
||||
}
|
||||
|
||||
// bind vlan to the private interface
|
||||
vlan_interface_binding vlanBinding = new vlan_interface_binding();
|
||||
vlanBinding.set_ifnum(_privateInterface);
|
||||
vlanBinding.set_tagged(true);
|
||||
vlanBinding.set_id(vlanTag);
|
||||
apiCallResult = vlan_interface_binding.add(nsService, vlanBinding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to bind vlan with tag:" + vlanTag + " with the interface " + _privateInterface + " due to " + apiCallResult.message);
|
||||
}
|
||||
} else {
|
||||
throw new ExecutionException("Failed to configure Netscaler device for vlan with tag " + vlanTag + " as vlan already exisits");
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
throw new ExecutionException("Failed to implement guest network on the Netscaler device");
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Failed to implement guest network on the Netscaler device");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||
org.apache.axis.types.UnsignedInt result;
|
||||
|
||||
try {
|
||||
if (nsVlanExists(vlanTag)) {
|
||||
|
||||
// Delete all servers and associated services from this guest VLAN
|
||||
deleteServersInGuestVlan(vlanTag, vlanSelfIp, vlanNetmask);
|
||||
|
||||
// unbind vlan to the private interface
|
||||
vlan_interface_binding vlanIfBinding = new vlan_interface_binding();
|
||||
vlanIfBinding.set_id(vlanTag);
|
||||
vlanIfBinding.set_ifnum(_privateInterface);
|
||||
vlanIfBinding.set_tagged(true);
|
||||
apiCallResult = vlan_interface_binding.delete(nsService, vlanIfBinding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the private interface due to " + apiCallResult.message);
|
||||
}
|
||||
|
||||
//unbind the vlan to subnet
|
||||
vlan_nsip_binding vlanSnipBinding = new vlan_nsip_binding();
|
||||
vlanSnipBinding.set_netmask(vlanNetmask);
|
||||
vlanSnipBinding.set_ipaddress(vlanSelfIp);
|
||||
vlanSnipBinding.set_id(vlanTag);
|
||||
apiCallResult = vlan_nsip_binding.delete(nsService, vlanSnipBinding);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the subnet due to " + apiCallResult.message);
|
||||
}
|
||||
|
||||
// remove subnet IP
|
||||
nsip subnetIp = nsip.get(nsService, vlanSelfIp);
|
||||
apiCallResult = nsip.delete(nsService, subnetIp);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove subnet ip:" + vlanTag + " to the subnet due to" + apiCallResult.message);
|
||||
}
|
||||
|
||||
// remove vlan
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.network.vlan.delete(nsService, vlanTag);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove vlan with tag:" + vlanTag + "due to" + apiCallResult.message);
|
||||
}
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
throw new ExecutionException("Failed to delete guest vlan network on the Netscaler device");
|
||||
} catch (Exception e) {
|
||||
s_logger.error(e);
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean nsVlanExists(long vlanTag) {// throws ExecutionException {
|
||||
try {
|
||||
if (vlan.get(nsService, new Long(vlanTag)) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean nsServerExists(String serverName) throws ExecutionException {
|
||||
try {
|
||||
if (com.citrix.netscaler.nitro.resource.config.basic.server.get(nsService, serverName) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
|
||||
return false;
|
||||
} else {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean nsServiceExists(String serviceName) throws ExecutionException {
|
||||
try {
|
||||
if (com.citrix.netscaler.nitro.resource.config.basic.service.get(nsService, serviceName) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
if (e.getErrorCode() == NitroError.NS_NO_SERIVCE) {
|
||||
return false;
|
||||
} else {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean nsServiceBindingExists(String lbVirtualServer, String serviceName) throws ExecutionException {
|
||||
try {
|
||||
com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(nsService, lbVirtualServer);
|
||||
if (serviceBindings != null) {
|
||||
for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
|
||||
if (serviceName.equalsIgnoreCase(binding.get_servicename())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (nitro_exception e) {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteServersInGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||
try {
|
||||
com.citrix.netscaler.nitro.resource.config.basic.server[] serverList = com.citrix.netscaler.nitro.resource.config.basic.server.get(nsService);
|
||||
|
||||
if (serverList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove the server and services associated with guest vlan
|
||||
for (com.citrix.netscaler.nitro.resource.config.basic.server server : serverList) {
|
||||
// check if server belong to same subnet as one associated with vlan
|
||||
if (NetUtils.sameSubnet(vlanSelfIp, server.get_ipaddress(), vlanNetmask)) {
|
||||
// first remove services associated with this server
|
||||
com.citrix.netscaler.nitro.resource.config.basic.service serveicesList[] = com.citrix.netscaler.nitro.resource.config.basic.service.get(nsService);
|
||||
if (serveicesList != null) {
|
||||
for (com.citrix.netscaler.nitro.resource.config.basic.service svc : serveicesList) {
|
||||
if (svc.get_servername().equals(server.get_ipaddress())) {
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.service.delete(nsService, svc.get_name());
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove service:" + svc.get_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove the server
|
||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(nsService, server.get_name());
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove server:" + server.get_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Failed to delete server and services in the guest vlan:" + vlanTag + " on the Netscaler device due to: "+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void addLBVirtualServer(String virtualServerName, String srcIp, int srcPort, String lbMethod, String lbProtocol) throws ExecutionException {
|
||||
try {
|
||||
lbvserver vserver = new lbvserver();
|
||||
vserver.set_name(virtualServerName);
|
||||
vserver.set_ipv46(srcIp);
|
||||
vserver.set_port(srcPort);
|
||||
vserver.set_servicetype(lbProtocol);
|
||||
vserver.set_lbmethod(lbMethod);
|
||||
apiCallResult = lbvserver.add(nsService,vserver);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to create new virtual server:" + virtualServerName);
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
if (e.getErrorCode() != NitroError.NS_RESOURCE_EXISTS) {
|
||||
throw new ExecutionException("Failed to create new virtual server:" + virtualServerName + " due to " + e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Failed to create new virtual server:" + virtualServerName + " due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLBVirtualServer (String virtualServerName) throws ExecutionException {
|
||||
try {
|
||||
lbvserver vserver = lbvserver.get(nsService, virtualServerName);
|
||||
if (vserver == null) {
|
||||
throw new ExecutionException("Failed to find virtual server with name:" + virtualServerName);
|
||||
}
|
||||
apiCallResult = lbvserver.delete(nsService, vserver);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName);
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
throw new ExecutionException("Failed remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Failed remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void saveConfiguration() throws ExecutionException {
|
||||
try {
|
||||
apiCallResult = nsconfig.save(nsService);
|
||||
if (apiCallResult.errorcode != 0) {
|
||||
throw new ExecutionException("Error occured while saving configuration changes to Netscaler device due to error:" + apiCallResult.errorcode);
|
||||
}
|
||||
} catch (nitro_exception e) {
|
||||
throw new ExecutionException("Failed to save configuration changes to Netscaler device due to " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Failed to save configuration changes to Netscaler device due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private ExternalNetworkResourceUsageAnswer getPublicIpBytesSentAndReceived(ExternalNetworkResourceUsageCommand cmd) throws ExecutionException {
|
||||
ExternalNetworkResourceUsageAnswer answer = new ExternalNetworkResourceUsageAnswer(cmd);
|
||||
|
||||
try {
|
||||
//TODO: add the stats collection
|
||||
} catch (Exception e) {
|
||||
s_logger.error(e);
|
||||
throw new ExecutionException(e.getMessage());
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
private Answer retry(Command cmd, int numRetries) {
|
||||
int numRetriesRemaining = numRetries - 1;
|
||||
s_logger.error("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetriesRemaining);
|
||||
return executeRequest(cmd, numRetriesRemaining);
|
||||
}
|
||||
|
||||
private boolean shouldRetry(int numRetries) {
|
||||
return (numRetries > 0 && login());
|
||||
}
|
||||
|
||||
private String generateVlanName(long vlanTag) {
|
||||
return genObjectName("cloud-vlan", String.valueOf(vlanTag));
|
||||
}
|
||||
|
||||
private String generateNSVirtualServerName(String srcIp, long srcPort, String protocol) {
|
||||
return genObjectName("cloud-VirtualServer", protocol, srcIp, srcPort);
|
||||
}
|
||||
|
||||
private String generateNSServerName(String serverIP) {
|
||||
return genObjectName("cloud-server", serverIP);
|
||||
}
|
||||
|
||||
private String generateNSServiceName(String ip, long port) {
|
||||
return genObjectName("cloud-Service", ip, port);
|
||||
}
|
||||
|
||||
private String genObjectName(Object... args) {
|
||||
String objectName = "";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
objectName += args[i];
|
||||
if (i != args.length -1) {
|
||||
objectName += _objectNamePathSep;
|
||||
}
|
||||
}
|
||||
return objectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAgentControl getAgentControl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
return new PingCommand(Host.Type.ExternalLoadBalancer, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Host.Type.ExternalLoadBalancer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAgentControl(IAgentControl agentControl) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,9 +47,6 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
|||
|
||||
transient String password;
|
||||
|
||||
@Transient
|
||||
Map<String, String> details;
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
|
|
@ -119,11 +116,6 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
|||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail(String name) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
|
@ -131,18 +123,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
|||
return details != null ? details.get(name) : null;
|
||||
}
|
||||
|
||||
public void setDetail(String name, String value) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
details.put(name, value);
|
||||
}
|
||||
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId){
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import javax.persistence.Table;
|
|||
import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -140,6 +141,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||
@Column(name="hypervisor_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
protected HypervisorType hypervisorType;
|
||||
|
||||
@Transient
|
||||
Map<String, String> details;
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
|
|
@ -396,9 +400,19 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||
return this.reservationId;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return null;
|
||||
}
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetail(String name, String value) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
details.put(name, value);
|
||||
}
|
||||
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
transient String toString;
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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.vm;
|
||||
|
||||
public interface VmDetailConstants {
|
||||
public static final String KEYBOARD = "keyboard";
|
||||
public static final String NIC_ADAPTER = "nic_adapter";
|
||||
}
|
||||
|
|
@ -48,12 +48,11 @@
|
|||
<classpathentry exported="true" kind="lib" path="vmware-vim25.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-jnetpcap.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-junit.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-selenium-java-client-driver.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-selenium-server.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-commons-codec-1.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-commons-dbcp-1.4.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-commons-pool-1.5.6.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-google-gson-1.7.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-httpclient-4.1.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-commons-httpclient-3.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="cloud-netscaler.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/vmware-base"/>
|
||||
<classpathentry kind="src" path="/agent-simulator"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/agent"/>
|
||||
<classpathentry exported="true" kind="lib" path="/deps/cloud-xmlrpc-common-3.1.3.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ovm</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/OVSXUtility.py b/OVSXUtility.py
|
||||
index 4a98bc8..1053ef7 100644
|
||||
--- a/OVSXUtility.py
|
||||
+++ b/OVSXUtility.py
|
||||
@@ -160,7 +160,7 @@ def get_storage_repos():
|
||||
l = parse_storage_repos()
|
||||
for sr in l:
|
||||
d = get_storage_free_space(sr)
|
||||
- if d:
|
||||
+ if len(d) > 0:
|
||||
d_repos_space[sr] = d[sr]
|
||||
|
||||
if not d_repos_space:
|
||||
|
|
@ -23,6 +23,7 @@ HEARTBEAT_TIMESTAMP_FORMAT='<timestamp>%s</timestamp>'
|
|||
HEARTBEAT_TIMESTAMP_PATTERN='(\<timestamp\>\d+.\d+<\/timestamp\>)'
|
||||
HEARTBEAT_DIR='heart_beat'
|
||||
ETC_HOSTS='/etc/hosts'
|
||||
HOSTNAME_FILE='/etc/sysconfig/network'
|
||||
|
||||
logger = OvmLogger('OvmCommon')
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ class OvmHost(OvmObject):
|
|||
return vmPath
|
||||
|
||||
def _vmNameToPath(self, vmName):
|
||||
return successToMap(xen_get_vm_path(vmName))['path']
|
||||
# the xen_get_vm_path always sucks!!!
|
||||
#return successToMap((vmName))['path']
|
||||
return self._getVmPathFromPrimaryStorage(vmName)
|
||||
|
||||
def _getAllDomains(self):
|
||||
stdout = timeout_command(["xm", "list"])
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from OvmCommonModule import *
|
|||
from OVSSiteSR import sp_create, sr_create, sr_do
|
||||
from OVSParser import parse_ocfs2_cluster_conf
|
||||
from OVSXCluster import clusterm_set_ocfs2_cluster_conf, clusterm_start_o2cb_service
|
||||
from OVSSiteRMServer import get_master_ip
|
||||
import re
|
||||
|
||||
class OvmStoragePoolDecoder(json.JSONDecoder):
|
||||
|
|
@ -241,6 +242,33 @@ class OvmStoragePool(OvmObject):
|
|||
fd = open(ETC_HOSTS, "w")
|
||||
fd.write(orignalConf)
|
||||
fd.close()
|
||||
|
||||
def configureHostName(nodes):
|
||||
myIp = successToMap(get_master_ip())['ip']
|
||||
nodeName = None
|
||||
for n in nodes:
|
||||
if myIp == n["ip_address"]:
|
||||
nodeName = n["name"]
|
||||
break
|
||||
|
||||
if nodeName == None: raise Exception("Cannot find node equals to my ip address:%s"%myIp)
|
||||
if not exists(HOSTNAME_FILE):
|
||||
originalConf = ""
|
||||
else:
|
||||
fd = open(HOSTNAME_FILE, "r")
|
||||
originalConf = fd.read()
|
||||
fd.close()
|
||||
|
||||
pattern = r"HOSTNAME=(.*)"
|
||||
# remove any old hostname
|
||||
originalConf = re.sub(pattern, "", originalConf)
|
||||
# remove extra empty lines
|
||||
originalConf = re.sub(r"\n\s*\n*", "\n", originalConf) + "\n" + "HOSTNAME=%s"%nodeName
|
||||
logger.debug(OvmStoragePool.prepareOCFS2Nodes, "Configure %s:%s\n"%(HOSTNAME_FILE,originalConf))
|
||||
fd = open(HOSTNAME_FILE, "w")
|
||||
fd.write(originalConf)
|
||||
fd.close()
|
||||
doCmd(['hostname', nodeName])
|
||||
|
||||
try:
|
||||
nodeString = nodeString.strip(";")
|
||||
|
|
@ -273,10 +301,12 @@ class OvmStoragePool(OvmObject):
|
|||
lines.append("\tname = %s\n" % clusterName)
|
||||
lines.append("\n")
|
||||
conf = "".join(lines)
|
||||
|
||||
configureHostName(nodes)
|
||||
configureEtcHosts(nodes)
|
||||
clusterm_set_ocfs2_cluster_conf(conf)
|
||||
clusterm_start_o2cb_service()
|
||||
logger.debug(OvmStoragePool.prepareOCFS2Nodes, "Configure cluster.conf to:\n%s"%conf)
|
||||
configureEtcHosts(nodes)
|
||||
rs = SUCC()
|
||||
return rs
|
||||
|
||||
|
|
|
|||
|
|
@ -63,10 +63,13 @@ applyPatch() {
|
|||
}
|
||||
|
||||
postSetup() {
|
||||
openPortOnIptables 7777 tcp
|
||||
openPortOnIptables 7777 udp
|
||||
openPortOnIptables 7777 tcp # for OCFS2, maybe tcp only
|
||||
openPortOnIptables 7777 udp
|
||||
openPortOnIptables 3260 tcp # for ISCSI, maybe tcp only
|
||||
openPortOnIptables 3260 udp
|
||||
applyPatch "/opt/ovs-agent-latest/OvmPatch.patch" 2
|
||||
applyPatch "/opt/ovs-agent-latest/OvmDontTouchOCFS2ClusterWhenAgentStart.patch" 1
|
||||
applyPatch "/opt/ovs-agent-latest/Fixget_storage_reposExceptionDueToWrongReturnValueCheck.patch" 1
|
||||
|
||||
stopHeartbeat
|
||||
|
||||
|
|
|
|||
|
|
@ -216,12 +216,16 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
/* set to false so each time ModifyStoragePoolCommand will re-setup heartbeat*/
|
||||
_isHeartBeat = false;
|
||||
|
||||
/*
|
||||
try {
|
||||
_canBridgeFirewall = canBridgeFirewall();
|
||||
} catch (XmlRpcException e) {
|
||||
s_logger.error("Failed to detect whether the host supports security groups.", e);
|
||||
_canBridgeFirewall = false;
|
||||
}
|
||||
*/
|
||||
|
||||
_canBridgeFirewall = false;
|
||||
|
||||
s_logger.debug(_canBridgeFirewall ? "OVM host supports security groups." : "OVM host doesn't support security groups.");
|
||||
|
||||
|
|
|
|||
|
|
@ -225,6 +225,8 @@ setup_common() {
|
|||
hostname $NAME
|
||||
|
||||
#Nameserver
|
||||
sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries
|
||||
sed -i -e "/^nameserver.*$/d" /etc/dnsmasq-resolv.conf # remove previous entries
|
||||
if [ -n "$internalNS1" ]
|
||||
then
|
||||
echo "nameserver $internalNS1" > /etc/dnsmasq-resolv.conf
|
||||
|
|
|
|||
|
|
@ -587,6 +587,7 @@ class cloudAgentConfig(serviceCfgBase):
|
|||
cfo.save()
|
||||
|
||||
self.syscfg.svo.stopService("cloud-agent")
|
||||
bash("sleep 30")
|
||||
self.syscfg.svo.enableService("cloud-agent")
|
||||
return True
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -61,6 +61,26 @@ class cloudManagementConfig(serviceCfgBase):
|
|||
|
||||
cfo = configFileOps("/etc/cloud/management/tomcat6.conf", self)
|
||||
cfo.add_lines("JAVA_OPTS+=\" -Djavax.net.ssl.trustStore=%s \""%keyPath)
|
||||
elif self.syscfg.env.svrMode == "HttpsServer":
|
||||
if not os.path.exists("/etc/cloud/management/server-ssl.xml") or not os.path.exists("/etc/cloud/management/tomcat6-ssl.conf"):
|
||||
raise CloudRuntimeException("Cannot find /etc/cloud/management/server-ssl.xml or /etc/cloud/management/tomcat6-ssl.conf, https enables failed")
|
||||
if os.path.exists("/etc/cloud/management/server.xml"):
|
||||
bash("rm -f /etc/cloud/management/server.xml")
|
||||
if os.path.exists("/etc/cloud/management/tomcat6.conf"):
|
||||
bash("rm -f /etc/cloud/management/tomcat6.conf")
|
||||
bash("ln -s /etc/cloud/management/server-ssl.xml /etc/cloud/management/server.xml")
|
||||
bash("ln -s /etc/cloud/management/tomcat6-ssl.conf /etc/cloud/management/tomcat6.conf")
|
||||
if not bash("iptables-save |grep PREROUTING | grep 6443").isSuccess():
|
||||
bash("iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-port 6443")
|
||||
else:
|
||||
if not os.path.exists("/etc/cloud/management/server-nonssl.xml") or not os.path.exists("/etc/cloud/management/tomcat6-nonssl.conf"):
|
||||
raise CloudRuntimeException("Cannot find /etc/cloud/management/server-nonssl.xml or /etc/cloud/management/tomcat6-nonssl.conf, https enables failed")
|
||||
if os.path.exists("/etc/cloud/management/server.xml"):
|
||||
bash("rm -f /etc/cloud/management/server.xml")
|
||||
if os.path.exists("/etc/cloud/management/tomcat6.conf"):
|
||||
bash("rm -f /etc/cloud/management/tomcat6.conf")
|
||||
bash("ln -s /etc/cloud/management/server-nonssl.xml /etc/cloud/management/server.xml")
|
||||
bash("ln -s /etc/cloud/management/tomcat6-nonssl.conf /etc/cloud/management/tomcat6.conf")
|
||||
|
||||
try:
|
||||
self.syscfg.svo.disableService("tomcat6")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ class sysConfigFactory:
|
|||
return sysConfigAgentFactory.getAgent(glbEnv)
|
||||
elif glbEnv.mode == "Server":
|
||||
return sysConfigServerFactory.getServer(glbEnv)
|
||||
elif glbEnv.mode == "HttpsServer":
|
||||
return sysConfigServerFactory.getServer(glbEnv)
|
||||
elif glbEnv.mode == "Db":
|
||||
return sysConfigDbFactory.getDb(glbEnv)
|
||||
else:
|
||||
|
|
@ -69,6 +71,9 @@ class sysConfig(object):
|
|||
return True
|
||||
|
||||
class sysConfigAgent(sysConfig):
|
||||
def __init__(self, env):
|
||||
super(sysConfigServer, self).__init__(env)
|
||||
|
||||
def check(self):
|
||||
if self.env.debug:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -88,11 +88,9 @@ class Distribution:
|
|||
|
||||
if os.path.exists("/etc/fedora-release"):
|
||||
self.distro = "Fedora"
|
||||
elif os.path.exists("/etc/centos-release"):
|
||||
self.distro = "CentOS"
|
||||
elif os.path.exists("/etc/redhat-release"):
|
||||
version = file("/etc/redhat-release").readline()
|
||||
if version.find("Red Hat Enterprise Linux Server release 6") != -1 or version.find("Scientific Linux release 6") != -1 or version.find("CentOS release 6") != -1:
|
||||
if version.find("Red Hat Enterprise Linux Server release 6") != -1 or version.find("Scientific Linux release 6") != -1 or version.find("CentOS Linux release 6") != -1:
|
||||
self.distro = "RHEL6"
|
||||
elif version.find("CentOS release") != -1:
|
||||
self.distro = "CentOS"
|
||||
|
|
|
|||
|
|
@ -101,9 +101,7 @@ create_from_file() {
|
|||
local tmpltimg=$2
|
||||
local tmpltname=$3
|
||||
|
||||
|
||||
#copy the file to the disk
|
||||
cp $tmpltimg /$tmpltfs/$tmpltname
|
||||
$qemu_img convert -f qcow2 -O qcow2 $tmpltimg /$tmpltfs/$tmpltname >& /dev/null
|
||||
|
||||
if [ "$cleanup" == "true" ]
|
||||
then
|
||||
|
|
|
|||
|
|
@ -889,7 +889,7 @@ def cleanup_rules(session, args):
|
|||
instance = 'VM'
|
||||
|
||||
try:
|
||||
chainscmd = "iptables-save | grep '^:' | awk '{print $1}' | cut -d':' -f2 | sed 's/-def/-%s/'|sort|uniq" % instance
|
||||
chainscmd = "iptables-save | grep '^:' | awk '{print $1}' | cut -d':' -f2 | sed 's/-def/-%s/' | sed 's/-egress//' |sort|uniq" % instance
|
||||
chains = util.pread2(['/bin/bash', '-c', chainscmd]).split('\n')
|
||||
cleaned = 0
|
||||
cleanup = []
|
||||
|
|
@ -897,9 +897,11 @@ def cleanup_rules(session, args):
|
|||
if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-', 'l-'] ]:
|
||||
vm = session.xenapi.VM.get_by_name_label(chain)
|
||||
if len(vm) != 1:
|
||||
util.SMlog("chain " + chain + " does not correspond to a vm, cleaning up")
|
||||
cleanup.append(chain)
|
||||
continue
|
||||
vm = session.xenapi.VM.get_by_name_label(chain + "-untagged")
|
||||
if len(vm) != 1:
|
||||
util.SMlog("chain " + chain + " does not correspond to a vm, cleaning up")
|
||||
cleanup.append(chain)
|
||||
continue
|
||||
vm_rec = session.xenapi.VM.get_record(vm[0])
|
||||
state = vm_rec.get('power_state')
|
||||
if state != 'Running' and state != 'Paused':
|
||||
|
|
@ -1053,14 +1055,23 @@ def network_rules(session, args):
|
|||
util.SMlog(" failed to create ipset for rule " + str(tokens))
|
||||
|
||||
if protocol == 'all':
|
||||
iptables = ['iptables', '-I', vmchain, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
if type == 'egress':
|
||||
iptables = ['iptables', '-I', vmchain, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'dst', '-j', 'ACCEPT']
|
||||
else:
|
||||
iptables = ['iptables', '-I', vmchain, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
elif protocol != 'icmp':
|
||||
iptables = ['iptables', '-I', vmchain, '-p', protocol, '-m', protocol, '--dport', range, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
if type == 'egress':
|
||||
iptables = ['iptables', '-I', vmchain, '-p', protocol, '-m', protocol, '--dport', range, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'dst', '-j', 'ACCEPT']
|
||||
else:
|
||||
iptables = ['iptables', '-I', vmchain, '-p', protocol, '-m', protocol, '--dport', range, '-m', 'state', '--state', 'NEW', '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
else:
|
||||
range = start + "/" + end
|
||||
if start == "-1":
|
||||
range = "any"
|
||||
iptables = ['iptables', '-I', vmchain, '-p', 'icmp', '--icmp-type', range, '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
if type == 'egress':
|
||||
iptables = ['iptables', '-I', vmchain, '-p', 'icmp', '--icmp-type', range, '-m', 'set', '--match-set', ipsetname, 'dst', '-j', 'ACCEPT']
|
||||
else:
|
||||
iptables = ['iptables', '-I', vmchain, '-p', 'icmp', '--icmp-type', range, '-m', 'set', '--match-set', ipsetname, 'src', '-j', 'ACCEPT']
|
||||
util.pread2(iptables)
|
||||
util.SMlog(iptables)
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ def ipset(ipsetname, proto, start, end, ips):
|
|||
|
||||
def destroy_network_rules_for_vm(vm_name, vif=None):
|
||||
vmchain = vm_name
|
||||
vmchain_egress = vm_name + "-egress"
|
||||
vmchain_default = None
|
||||
|
||||
delete_rules_for_vm_in_bridge_firewall_chain(vm_name)
|
||||
|
|
@ -111,7 +112,19 @@ def destroy_network_rules_for_vm(vm_name, vif=None):
|
|||
execute("iptables -X " + vmchain)
|
||||
except:
|
||||
logging.debug("Ignoring failure to delete chain " + vmchain)
|
||||
|
||||
|
||||
try:
|
||||
execute("iptables -F " + vmchain_egress)
|
||||
except:
|
||||
logging.debug("Ignoring failure to delete chain " + vmchain_egress)
|
||||
|
||||
try:
|
||||
execute("iptables -X " + vmchain_egress)
|
||||
except:
|
||||
logging.debug("Ignoring failure to delete chain " + vmchain_egress)
|
||||
|
||||
|
||||
if vif is not None:
|
||||
try:
|
||||
dnats = execute("iptables -t nat -S | grep " + vif + " | sed 's/-A/-D/'").split("\n")
|
||||
|
|
@ -246,6 +259,7 @@ def default_network_rules(vm_name, vm_id, vm_ip, vm_mac, vif, brname):
|
|||
domID = getvmId(vm_name)
|
||||
delete_rules_for_vm_in_bridge_firewall_chain(vmName)
|
||||
vmchain = vm_name
|
||||
vmchain_egress = vm_name +"-egress"
|
||||
vmchain_default = '-'.join(vmchain.split('-')[:-1]) + "-def"
|
||||
|
||||
destroy_ebtables_rules(vmName, vif)
|
||||
|
|
@ -254,7 +268,12 @@ def default_network_rules(vm_name, vm_id, vm_ip, vm_mac, vif, brname):
|
|||
execute("iptables -N " + vmchain)
|
||||
except:
|
||||
execute("iptables -F " + vmchain)
|
||||
|
||||
|
||||
try:
|
||||
execute("iptables -N " + vmchain_egress)
|
||||
except:
|
||||
execute("iptables -F " + vmchain_egress)
|
||||
|
||||
try:
|
||||
execute("iptables -N " + vmchain_default)
|
||||
except:
|
||||
|
|
@ -270,7 +289,7 @@ def default_network_rules(vm_name, vm_id, vm_ip, vm_mac, vif, brname):
|
|||
|
||||
#don't let vm spoof its ip address
|
||||
if vm_ip is not None:
|
||||
execute("iptables -A " + vmchain_default + " -m physdev --physdev-is-bridged --physdev-in " + vif + " --source " + vm_ip + " -j ACCEPT")
|
||||
execute("iptables -A " + vmchain_default + " -m physdev --physdev-is-bridged --physdev-in " + vif + " --source " + vm_ip + " -j " + vmchain_egress)
|
||||
execute("iptables -A " + vmchain_default + " -j " + vmchain)
|
||||
execute("iptables -A " + vmchain + " -j DROP")
|
||||
except:
|
||||
|
|
@ -468,7 +487,7 @@ def cleanup_rules_for_dead_vms():
|
|||
def cleanup_rules():
|
||||
try:
|
||||
|
||||
chainscmd = "iptables-save | grep '^:' | grep -v '.*-def' | awk '{print $1}' | cut -d':' -f2"
|
||||
chainscmd = "iptables-save | grep '^:' | grep -v '.*-def' | grep -v '.*-egress' | awk '{print $1}' | cut -d':' -f2"
|
||||
chains = execute(chainscmd).split('\n')
|
||||
cleaned = 0
|
||||
cleanup = []
|
||||
|
|
@ -552,12 +571,17 @@ def remove_rule_log_for_vm(vmName):
|
|||
|
||||
return result
|
||||
|
||||
def add_network_rules(vm_name, vm_id, vm_ip, signature, seqno, vmMac, rules, vif, brname):
|
||||
def add_network_rules(vm_name, vm_id, vm_ip, signature, seqno, vmMac, rules, vif, brname,ruletype):
|
||||
try:
|
||||
vmName = vm_name
|
||||
domId = getvmId(vmName)
|
||||
vmchain = vm_name
|
||||
|
||||
if ruletype == 'egress':
|
||||
vmchain = vm_name + "-egress"
|
||||
else:
|
||||
vmchain = vm_name
|
||||
|
||||
|
||||
changes = []
|
||||
changes = check_rule_log_for_vm(vmName, vm_id, vm_ip, domId, signature, seqno)
|
||||
|
||||
|
|
@ -596,16 +620,25 @@ def add_network_rules(vm_name, vm_id, vm_ip, signature, seqno, vmMac, rules, vif
|
|||
if ips:
|
||||
if protocol == 'all':
|
||||
for ip in ips:
|
||||
execute("iptables -I " + vmchain + " -m state --state NEW -s " + ip + " -j ACCEPT")
|
||||
if ruletype == 'egress':
|
||||
execute("iptables -I " + vmchain + " -m state --state NEW -d " + ip + " -j ACCEPT")
|
||||
else:
|
||||
execute("iptables -I " + vmchain + " -m state --state NEW -s " + ip + " -j ACCEPT")
|
||||
elif protocol != 'icmp':
|
||||
for ip in ips:
|
||||
execute("iptables -I " + vmchain + " -p " + protocol + " -m " + protocol + " --dport " + range + " -m state --state NEW -s " + ip + " -j ACCEPT")
|
||||
if ruletype == 'egress':
|
||||
execute("iptables -I " + vmchain + " -p " + protocol + " -m " + protocol + " --dport " + range + " -m state --state NEW -d " + ip + " -j ACCEPT")
|
||||
else:
|
||||
execute("iptables -I " + vmchain + " -p " + protocol + " -m " + protocol + " --dport " + range + " -m state --state NEW -s " + ip + " -j ACCEPT")
|
||||
else:
|
||||
range = start + "/" + end
|
||||
if start == "-1":
|
||||
range = "any"
|
||||
for ip in ips:
|
||||
execute("iptables -I " + vmchain + " -p icmp --icmp-type " + range + " -s " + ip + " -j ACCEPT")
|
||||
if ruletype == 'egress':
|
||||
execute("iptables -I " + vmchain + " -p icmp --icmp-type " + range + " -d " + ip + " -j ACCEPT")
|
||||
else:
|
||||
execute("iptables -I " + vmchain + " -p icmp --icmp-type " + range + " -s " + ip + " -j ACCEPT")
|
||||
|
||||
if allow_any and protocol != 'all':
|
||||
if protocol != 'icmp':
|
||||
|
|
@ -704,6 +737,7 @@ if __name__ == '__main__':
|
|||
parser.add_option("--vmid", dest="vmID")
|
||||
parser.add_option("--vmmac", dest="vmMAC")
|
||||
parser.add_option("--vif", dest="vif")
|
||||
parser.add_option("--ruletype", dest="ruletype")
|
||||
parser.add_option("--sig", dest="sig")
|
||||
parser.add_option("--seq", dest="seq")
|
||||
parser.add_option("--rules", dest="rules")
|
||||
|
|
@ -724,7 +758,7 @@ if __name__ == '__main__':
|
|||
elif cmd == "get_rule_logs_for_vms":
|
||||
get_rule_logs_for_vms()
|
||||
elif cmd == "add_network_rules":
|
||||
add_network_rules(option.vmName, option.vmID, option.vmIP, option.sig, option.seq, option.vmMAC, option.rules, option.vif, option.brname)
|
||||
add_network_rules(option.vmName, option.vmID, option.vmIP, option.sig, option.seq, option.vmMAC, option.rules, option.vif, option.brname,option.ruletype)
|
||||
elif cmd == "cleanup_rules":
|
||||
cleanup_rules()
|
||||
elif cmd == "post_default_network_rules":
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public interface AgentManager extends Manager {
|
|||
* command
|
||||
* @return an Answer
|
||||
*/
|
||||
Answer send(Long hostId, Command cmd, int timeout) throws AgentUnavailableException, OperationTimedoutException;
|
||||
|
||||
Answer send(Long hostId, Command cmd) throws AgentUnavailableException, OperationTimedoutException;
|
||||
|
||||
|
|
@ -245,8 +244,6 @@ public interface AgentManager extends Manager {
|
|||
|
||||
public boolean reconnect(final long hostId) throws AgentUnavailableException;
|
||||
|
||||
Answer easySend(Long hostId, Command cmd, int timeout);
|
||||
|
||||
boolean isHostNativeHAEnabled(long hostId);
|
||||
|
||||
Answer sendTo(Long dcId, HypervisorType type, Command cmd);
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
_pingInterval = NumbersUtil.parseInt(value, 60);
|
||||
|
||||
value = configs.get("wait");
|
||||
_wait = NumbersUtil.parseInt(value, 1800) * 1000;
|
||||
_wait = NumbersUtil.parseInt(value, 1800);
|
||||
|
||||
value = configs.get("alert.wait");
|
||||
_alertWait = NumbersUtil.parseInt(value, 1800);
|
||||
|
|
@ -797,10 +797,10 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Answer send(Long hostId, Command cmd, int timeout) throws AgentUnavailableException, OperationTimedoutException {
|
||||
public Answer send(Long hostId, Command cmd) throws AgentUnavailableException, OperationTimedoutException {
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
cmds.addCommand(cmd);
|
||||
send(hostId, cmds, timeout);
|
||||
send(hostId, cmds, cmd.getWait());
|
||||
Answer[] answers = cmds.getAnswers();
|
||||
if (answers != null && !(answers[0] instanceof UnsupportedAnswer)) {
|
||||
return answers[0];
|
||||
|
|
@ -856,21 +856,13 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
s_logger.debug("checking if agent (" + hostId + ") is alive");
|
||||
}
|
||||
|
||||
try {
|
||||
Request req = new Request(hostId, _nodeId, new CheckHealthCommand(), true);
|
||||
req.setSequence(agent.getNextSequence());
|
||||
Answer[] answers = agent.send(req, 50 * 1000);
|
||||
if (answers != null && answers[0] != null && answers[0].getResult()) {
|
||||
Status status = Status.Up;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status);
|
||||
}
|
||||
return status;
|
||||
Answer answer = easySend(hostId, new CheckHealthCommand());
|
||||
if (answer != null && answer.getResult()) {
|
||||
Status status = Status.Up;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status);
|
||||
}
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.debug("Agent is unavailable so we move on. Error: " + e.getMessage());
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Timed Out " + e.getMessage());
|
||||
return status;
|
||||
}
|
||||
|
||||
return _haMgr.investigate(hostId);
|
||||
|
|
@ -1201,75 +1193,86 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected boolean loadDirectlyConnectedHost(HostVO host, boolean forRebalance) {
|
||||
String resourceName = host.getResource();
|
||||
boolean initialized = false;
|
||||
ServerResource resource = null;
|
||||
try {
|
||||
Class<?> clazz = Class.forName(resourceName);
|
||||
Constructor constructor = clazz.getConstructor();
|
||||
resource = (ServerResource) constructor.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.warn("Unable to find class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InstantiationException e) {
|
||||
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.warn("Illegal access " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (SecurityException e) {
|
||||
s_logger.warn("Security error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (NoSuchMethodException e) {
|
||||
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InvocationTargetException e) {
|
||||
s_logger.warn("InvocationTargetException error on " + host.getResource(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
_hostDao.loadDetails(host);
|
||||
|
||||
HashMap<String, Object> params = new HashMap<String, Object>(host.getDetails().size() + 5);
|
||||
params.putAll(host.getDetails());
|
||||
|
||||
params.put("guid", host.getGuid());
|
||||
params.put("zone", Long.toString(host.getDataCenterId()));
|
||||
if (host.getPodId() != null) {
|
||||
params.put("pod", Long.toString(host.getPodId()));
|
||||
}
|
||||
if (host.getClusterId() != null) {
|
||||
params.put("cluster", Long.toString(host.getClusterId()));
|
||||
String guid = null;
|
||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||
if (cluster.getGuid() == null) {
|
||||
guid = host.getDetail("pool");
|
||||
} else {
|
||||
guid = cluster.getGuid();
|
||||
}
|
||||
if (guid != null && !guid.isEmpty()) {
|
||||
params.put("pool", guid);
|
||||
}
|
||||
}
|
||||
|
||||
params.put("ipaddress", host.getPrivateIpAddress());
|
||||
params.put("secondary.storage.vm", "false");
|
||||
params.put("max.template.iso.size", _configDao.getValue("max.template.iso.size"));
|
||||
|
||||
try {
|
||||
resource.configure(host.getName(), params);
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
s_logger.warn("Unable to configure resource due to ", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resource.start()) {
|
||||
s_logger.warn("Unable to start the resource");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
String resourceName = host.getResource();
|
||||
try {
|
||||
Class<?> clazz = Class.forName(resourceName);
|
||||
Constructor constructor = clazz.getConstructor();
|
||||
resource = (ServerResource) constructor.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.warn("Unable to find class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InstantiationException e) {
|
||||
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.warn("Illegal access " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (SecurityException e) {
|
||||
s_logger.warn("Security error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (NoSuchMethodException e) {
|
||||
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InvocationTargetException e) {
|
||||
s_logger.warn("InvocationTargetException error on " + host.getResource(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
_hostDao.loadDetails(host);
|
||||
|
||||
HashMap<String, Object> params = new HashMap<String, Object>(host.getDetails().size() + 5);
|
||||
params.putAll(host.getDetails());
|
||||
|
||||
params.put("guid", host.getGuid());
|
||||
params.put("zone", Long.toString(host.getDataCenterId()));
|
||||
if (host.getPodId() != null) {
|
||||
params.put("pod", Long.toString(host.getPodId()));
|
||||
}
|
||||
if (host.getClusterId() != null) {
|
||||
params.put("cluster", Long.toString(host.getClusterId()));
|
||||
String guid = null;
|
||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||
if (cluster.getGuid() == null) {
|
||||
guid = host.getDetail("pool");
|
||||
} else {
|
||||
guid = cluster.getGuid();
|
||||
}
|
||||
if (guid != null && !guid.isEmpty()) {
|
||||
params.put("pool", guid);
|
||||
}
|
||||
}
|
||||
|
||||
params.put("ipaddress", host.getPrivateIpAddress());
|
||||
params.put("secondary.storage.vm", "false");
|
||||
params.put("max.template.iso.size", _configDao.getValue(Config.MaxTemplateAndIsoSize.toString()));
|
||||
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
|
||||
|
||||
try {
|
||||
resource.configure(host.getName(), params);
|
||||
} catch (ConfigurationException e) {
|
||||
s_logger.warn("Unable to configure resource due to ", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resource.start()) {
|
||||
s_logger.warn("Unable to start the resource");
|
||||
return false;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
} finally {
|
||||
if(!initialized) {
|
||||
if (host != null) {
|
||||
_hostDao.updateStatus(host, Event.AgentDisconnected, _nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forRebalance) {
|
||||
AgentAttache attache = simulateStart(host.getId(), resource, host.getDetails(), false, null, null, true);
|
||||
|
|
@ -1464,11 +1467,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
|
||||
@Override
|
||||
public Answer easySend(final Long hostId, final Command cmd) {
|
||||
return easySend(hostId, cmd, _wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer easySend(final Long hostId, final Command cmd, int timeout) {
|
||||
try {
|
||||
Host h = _hostDao.findById(hostId);
|
||||
if (h == null || h.getRemoved() != null) {
|
||||
|
|
@ -1479,7 +1477,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
if (!status.equals(Status.Up) && !status.equals(Status.Connecting)) {
|
||||
return null;
|
||||
}
|
||||
final Answer answer = send(hostId, cmd, timeout);
|
||||
final Answer answer = send(hostId, cmd);
|
||||
if (answer == null) {
|
||||
s_logger.warn("send returns null answer");
|
||||
return null;
|
||||
|
|
@ -1503,14 +1501,18 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer send(final Long hostId, final Command cmd) throws AgentUnavailableException, OperationTimedoutException {
|
||||
return send(hostId, cmd, _wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer[] send(final Long hostId, Commands cmds) throws AgentUnavailableException, OperationTimedoutException {
|
||||
return send(hostId, cmds, _wait);
|
||||
int wait = 0;
|
||||
for( Command cmd : cmds ) {
|
||||
if ( cmd.getWait() > wait ) {
|
||||
wait = cmd.getWait();
|
||||
}
|
||||
}
|
||||
if ( wait == 0 ) {
|
||||
wait = _wait;
|
||||
}
|
||||
return send(hostId, cmds, wait);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2134,7 +2136,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
host.setSpeed(scc.getSpeed());
|
||||
HypervisorType hyType = scc.getHypervisorType();
|
||||
host.setHypervisorType(hyType);
|
||||
|
||||
host.setHypervisorVersion(scc.getHypervisorVersion());
|
||||
} else if (startup instanceof StartupStorageCommand) {
|
||||
final StartupStorageCommand ssc = (StartupStorageCommand) startup;
|
||||
host.setParent(ssc.getParent());
|
||||
|
|
|
|||
|
|
@ -878,6 +878,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
// if the thread:
|
||||
// 1) timed out waiting for the host to reconnect
|
||||
// 2) recipient management server is not active any more
|
||||
// 3) if the management server doesn't own the host any more
|
||||
// remove the host from re-balance list and delete from op_host_transfer DB
|
||||
// no need to do anything with the real attache as we haven't modified it yet
|
||||
Date cutTime = DateUtil.currentGMTTime();
|
||||
|
|
@ -886,7 +887,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
iterator.remove();
|
||||
_hostTransferDao.completeAgentTransfer(hostId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (attache.forForward()) {
|
||||
s_logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host");
|
||||
iterator.remove();
|
||||
_hostTransferDao.completeAgentTransfer(hostId);
|
||||
continue;
|
||||
}
|
||||
|
||||
HostTransferMapVO transferMap = _hostTransferDao.findByIdAndCurrentOwnerId(hostId, _nodeId);
|
||||
|
||||
|
|
@ -1017,9 +1025,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
logD(requestToTransfer.getBytes(), "Failed to route request to peer");
|
||||
}
|
||||
|
||||
requestToTransfer = forwardAttache.getRequestToTransfer();
|
||||
}
|
||||
s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance");
|
||||
requestToTransfer = forwardAttache.getRequestToTransfer();
|
||||
}
|
||||
|
||||
s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId);
|
||||
|
||||
} else {
|
||||
failRebalance(hostId);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class SynchronousListener implements Listener {
|
|||
return waitFor(-1);
|
||||
}
|
||||
|
||||
public synchronized Answer[] waitFor(int ms) throws InterruptedException {
|
||||
public synchronized Answer[] waitFor(int s) throws InterruptedException {
|
||||
if (_disconnected) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -108,9 +108,10 @@ public class SynchronousListener implements Listener {
|
|||
|
||||
Profiler profiler = new Profiler();
|
||||
profiler.start();
|
||||
if (ms <= 0) {
|
||||
if (s <= 0) {
|
||||
wait();
|
||||
} else {
|
||||
int ms = s * 1000;
|
||||
wait(ms);
|
||||
}
|
||||
profiler.stop();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import com.cloud.host.Host.Type;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
|
|
@ -55,6 +57,7 @@ import com.cloud.vm.dao.ConsoleProxyDao;
|
|||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
/**
|
||||
* An allocator that tries to find a fit on a computing host. This allocator does not care whether or not the host supports routing.
|
||||
|
|
@ -73,6 +76,8 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
@Inject ConfigurationDao _configDao = null;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
@Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao = null;
|
||||
@Inject VMInstanceDao _vmInstanceDao = null;
|
||||
float _factor = 1;
|
||||
protected String _allocationAlgorithm = "random";
|
||||
@Inject CapacityManager _capacityMgr;
|
||||
|
|
@ -189,6 +194,16 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//find number of guest VMs occupying capacity on this host.
|
||||
Long vmCount = _vmInstanceDao.countRunningByHostId(host.getId());
|
||||
Long maxGuestLimit = getHostMaxGuestLimit(host);
|
||||
if (vmCount.longValue() == maxGuestLimit.longValue()){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" already has max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + " , skipping this and trying other available hosts");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean numCpusGood = host.getCpus().intValue() >= offering.getCpu();
|
||||
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
||||
|
|
@ -327,6 +342,14 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
return guestOSCategory.getName();
|
||||
}
|
||||
|
||||
protected Long getHostMaxGuestLimit(HostVO host) {
|
||||
HypervisorType hypervisorType = host.getHypervisorType();
|
||||
String hypervisorVersion = host.getHypervisorVersion();
|
||||
|
||||
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
|
||||
return maxGuestLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue