diff --git a/plugins/hypervisors/ovm3/pom.xml b/plugins/hypervisors/ovm3/pom.xml
deleted file mode 100644
index 22c9fe0a3b6..00000000000
--- a/plugins/hypervisors/ovm3/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
- 4.0.0
- cloud-plugin-hypervisor-ovm3
- Apache CloudStack Plugin - Hypervisor OracleVM3
-
- org.apache.cloudstack
- cloudstack-plugins
- 4.4.0-SNAPSHOT
- ../../pom.xml
-
-
-
- org.apache.cloudstack
- xapi
- ${cs.xapi.version}
-
-
-
diff --git a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/module.properties b/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/module.properties
deleted file mode 100644
index 69e64692ef9..00000000000
--- a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/module.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-name=ovm3-compute
-parent=compute
diff --git a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/spring-ovm3-compute-context.xml b/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/spring-ovm3-compute-context.xml
deleted file mode 100644
index 42230c92434..00000000000
--- a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-compute/spring-ovm3-compute-context.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/module.properties b/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/module.properties
deleted file mode 100644
index 025d4cf11c0..00000000000
--- a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/module.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-name=ovm3-discoverer
-parent=discoverer
diff --git a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/spring-ovm3-discoverer-context.xml b/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/spring-ovm3-discoverer-context.xml
deleted file mode 100644
index aa7627124af..00000000000
--- a/plugins/hypervisors/ovm3/resources/META-INF/cloudstack/ovm3-discoverer/spring-ovm3-discoverer-context.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/plugins/hypervisors/ovm3/scripts/clean_master.sh b/plugins/hypervisors/ovm3/scripts/clean_master.sh
deleted file mode 100755
index bbf1cd0f518..00000000000
--- a/plugins/hypervisors/ovm3/scripts/clean_master.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"`
-do
- xm destroy $i
-done
-rm /etc/ovs-agent/db/server
-rm /etc/ovs-agent/db/repository
-rm /etc/ocfs2/cluster.conf
-rm /nfsmnt/*/*.img
-rm /nfsmnt/*/.ovspoolfs
-rm /nfsmnt/*/.generic_fs_stamp
-rm /OVS/Repositories/*/.generic_fs_stamp
-rm /OVS/Repositories/*/.ovsrepo
-/etc/init.d/ovs-agent restart
-/etc/init.d/ocfs2 restart
-for i in `mount | grep cs-mgmt | awk '{ print $1 }'`
-do
- umount $i
-done
-rm -rf /OVS/Repositories/*
-rm -rf /nfsmnt/*
-ip addr del 192.168.1.230 dev c0a80100
-ip addr del 192.168.1.161 dev c0a80100
-rm /etc/sysconfig/network-scripts/ifcfg-control0
-reboot
diff --git a/plugins/hypervisors/ovm3/scripts/clean_slave.sh b/plugins/hypervisors/ovm3/scripts/clean_slave.sh
deleted file mode 100755
index 6d46859806e..00000000000
--- a/plugins/hypervisors/ovm3/scripts/clean_slave.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"`
-do
- xm destroy $i
-done
-rm /etc/ovs-agent/db/server
-rm /etc/ovs-agent/db/repository
-rm /etc/ocfs2/cluster.conf
-/etc/init.d/ovs-agent restart
-/etc/init.d/ocfs2 restart
-for i in `mount | grep cs-mgmt | awk '{ print $1 }'`
-do
- umount $i
-done
-
diff --git a/plugins/hypervisors/ovm3/scripts/create_pool_cluster.py b/plugins/hypervisors/ovm3/scripts/create_pool_cluster.py
deleted file mode 100755
index 15c9a970667..00000000000
--- a/plugins/hypervisors/ovm3/scripts/create_pool_cluster.py
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import os, sys, subprocess
-from xml.dom.minidom import parseString
-
-from xmlrpclib import ServerProxy, Error
-
-server = ServerProxy("http://localhost:8899")
-
-pooledFs = 1
-normalRepo = 0
-
-try:
- if normalRepo:
- print "normal repo"
- # this litterally throws EVERYTHING away on the repo
- repoDom = parseString(server.discover_repository_db())
- for node in repoDom.getElementsByTagName('Repository'):
- repoUuid = node.attributes['Uuid']
- remoteMount = node.getElementsByTagName('Fs_location')[0].firstChild.nodeValue
- localMount = node.getElementsByTagName('Mount_point')[0].firstChild.nodeValue
-
- # there is a "strong" relation between repo's and VMs
- # onfortunately there is no reference in the vm.cfg
- # or any known info in the configuration of the VM
- # in which repo it lives....
- for dirname, dirnames, filenames in os.walk('%s/VirtualMachines/' % localMount):
- for vm in dirnames:
- print "Destroying vm: %s on repo %s" % (vm, repoUuid.value)
- try:
- mVm = server.list_vm(repoUuid.value, vm)
- if mVm != None:
- print server.stop_vm(repoUuid.value, vm)
- print server.delete_vm(repoUuid.value, vm)
- else:
- print "%s already not in repo %s" % (repoUuid.value, vm)
- except Error, v:
- print "Unable to destroy: %s" % (v)
- continue
-
- # VMs = server.list_vms()
- # for vm in VMs:
- # if vm['domid'] != '0':
- # print vm
- # print server.delete_vm(repoUuid.value, vm['uuid'])
-
- rc = server.delete_repository(repoUuid.value, True)
- # Set to false if you want to keep data: ^^^^
- print "Repository: %s" % repoUuid.value
- if (rc == None):
- print "Ok repo: %s destroyed!" % repoUuid.value
- # now unmount the FS
- # print server.unmount_repository_fs(localMount)
- else:
- print "Failed repo: %s not destroyed!" % repoUuid.value
-
- # for now only treat NFS stuff as we're testing with that..
- nfsHost='cs-mgmt'
- nfsDom = server.storage_plugin_listMountPoints(
- 'oracle.generic.NFSPlugin.GenericNFSPlugin',
- { 'status': '',
- 'admin_user': '',
- 'admin_host': '',
- 'uuid': '',
- 'total_sz': 0,
- 'admin_passwd': '',
- 'free_sz': 0,
- 'name': '',
- 'access_host': nfsHost,
- 'storage_type': 'FileSys',
- 'alloc_sz': 0,
- 'access_grps': [],
- 'used_sz': 0,
- 'storage_desc': ''
- })
- for node in nfsDom:
- props = {'status': node['status'],
- 'uuid': '',
- 'access_host': nfsHost,
- 'storage_type': 'FileSys',
- 'name': '' }
- extprops = {'status': node['status'],
- 'uuid': node['fs_uuid'],
- 'ss_uuid': '',
- 'size': 0,
- 'free_sz': '',
- 'state': 1,
- 'access_grp_names': [],
- 'access_path': nfsHost + ':' + '/volumes/cs-data/secondary',
- 'name': ''}
- # rc = server.storage_plugin_unmount('oracle.generic.NFSPlugin.GenericNFSPlugin', props, extprops, nfsMnt, True)
- # print rc
-
- nfsDom = parseString(server.discover_mounted_file_systems('nfs'))
- for node in nfsDom.getElementsByTagName('Mount'):
- nfsMnt = node.attributes['Dir'].value
- print 'Mountpoint: %s' % (nfsMnt)
- fsStamp = '%s/.generic_fs_stamp' % nfsMnt
- # remove this so we don't cock up next run
- if os.path.isfile(fsStamp):
- print "Stamp found: %s" % fsStamp
- os.unlink(fsStamp)
-
- rc = server.storage_plugin_unmount('oracle.generic.NFSPlugin.GenericNFSPlugin', props, extprops, nfsMnt, True)
- print rc
-
-
- if pooledFs:
- print "pooling"
- # pool stuff
- poolalias="ItsMyPool"
- poolmvip="192.168.1.161"
- poolfirsthost = {
- 'ip': "192.168.1.64",
- 'hn': "ovm-1",
- 'id': 0,
- 'role': 'utility,xen'
- }
- fstype="nfs"
- fstarget="cs-mgmt:/volumes/cs-data/primary"
- poolid="0004fb0000020000ba9aaf00ae5e2d73"
- clusterid="ba9aaf00ae5e2d72"
- poolfsuuid="0004fb0000050000e70fbddeb802208f"
- poolfsnfsbaseuuid="b8ca41cb-3469-4f74-a086-dddffe37dc2d"
- manageruuid="0004fb00000100000af70d20dcce7d65"
- pooluuid="0004fb0000020000ba9aaf00ae5e2d73"
- blocksize=""
- clustersize=""
- journalesize=""
-
- # o2cb is the problem.... /etc/init.d/o2cb
- # sets it's config in /etc/sysconfig/o2cb (can be removed)
- # dmsetup requires the stopping of o2cb first,
- # then the removal of the config, after which dmsetup
- # can remove the device from /dev/mapper/
- # eventually cluster cleanup can be done by removing
- # stuff from /etc/ovs-agent/db
- # also clean /etc/ocfs2/cluster.conf
- print server.create_pool_filesystem(
- fstype,
- fstarget,
- clusterid,
- poolfsuuid,
- poolfsnfsbaseuuid,
- manageruuid,
- pooluuid
- )
-
- # poolDom = server.discover_server_pool()
- # print poolDom
- # poolDom = parseString(server.discover_server_pool())
- # if poolDom.getElementsByTagName('Server_Pool'):
- # get unique id
- cluster = server.is_cluster_online()
- if cluster == True:
- print "clean up pool"
- # print server.destroy_cluster(poolfsuuid)
- # deconfigure cluster
- # print server.destroy_server_pool(poolid)
-
- if cluster == False:
- print "create_server_pool"
- # first take ownership. without an owner nothing happens
- print server.take_ownership(manageruuid, "")
- # we need to add the first host first to the pool....
- poolDom = server.discover_server_pool()
- print poolDom
- poolDom = parseString(server.discover_server_pool())
- if poolDom.getElementsByTagName('Server_Pool'):
- print server.destroy_server_pool(pooluuid)
-
- print server.create_pool_filesystem(
- fstype,
- fstarget,
- clusterid,
- poolfsuuid,
- poolfsnfsbaseuuid,
- manageruuid,
- pooluuid
- )
- print server.create_server_pool(poolalias,
- pooluuid,
- poolmvip,
- poolfirsthost['id'],
- poolfirsthost['hn'],
- poolfirsthost['ip'],
- poolfirsthost['role'])
-
- print "configure_virtual_ip"
- server.configure_virtual_ip(poolmvip, poolfirsthost['ip'])
- server.set_pool_member_ip_list(['192.168.1.64','192.168.1.65'],)
- print "configure for cluster"
- server.configure_server_for_cluster(
- {
- 'O2CB_HEARTBEAT_THRESHOLD': '61',
- 'O2CB_RECONNECT_DELAY_MS': '2000',
- 'O2CB_KEEPALIVE_DELAY_MS': '2000',
- 'O2CB_BOOTCLUSTER': clusterid,
- 'O2CB_IDLE_TIMEOUT_MS': '60000',
- 'O2CB_ENABLED': 'true',
- 'O2CB_STACK': 'o2cb'
- },
- {
- 'node': [
- {
- 'ip_port': 7777,
- 'cluster': clusterid,
- 'ip_address': poolfirsthost['ip'],
- 'name': poolfirsthost['hn'],
- 'number': poolfirsthost['id']
- }
- ],
- 'heartbeat': [
- {
- 'cluster': clusterid,
- # uppercase poolfsuuid
- 'region': '0004FB0000050000E70FBDDEB802208F'
- }
- ],
- 'cluster': [
- {
- 'heartbeat_mode': 'global',
- 'node_count': 1,
- 'name': clusterid
- }
- ]
- },
- 'nfs',
- 'cs-mgmt:/volumes/cs-data/primary',
- poolfsuuid,
- poolfsnfsbaseuuid
- )
- print "create cluster"
- server.create_cluster(poolfsuuid,)
-
- poolDom = parseString(server.discover_server_pool())
- for node in poolDom.getElementsByTagName('Server_Pool'):
- id = node.getElementsByTagName('Unique_Id')[0].firstChild.nodeValue
- alias = node.getElementsByTagName('Pool_Alias')[0].firstChild.nodeValue
- mvip = node.getElementsByTagName('Master_Virtual_Ip')[0].firstChild.nodeValue
- print "pool: %s, %s, %s" % (id, mvip, alias)
- members = node.getElementsByTagName('Member')
- for member in members:
- mip = member.getElementsByTagName('Registered_IP')[0].firstChild.nodeValue
- print "member: %s" % (mip)
-
- print server.is_cluster_online()
- print server.discover_cluster()
- print server.discover_pool_filesystem()
- print server.discover_server_pool()
- # server.destroy_server_pool(pooluuid)
-
-except Error, v:
- print "ERROR", v
diff --git a/plugins/hypervisors/ovm3/scripts/info.py b/plugins/hypervisors/ovm3/scripts/info.py
deleted file mode 100755
index 518aaf12e35..00000000000
--- a/plugins/hypervisors/ovm3/scripts/info.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import os, sys, subprocess, socket,fcntl, struct
-from socket import gethostname
-import errno
-from socket import error as socket_error
-from xml.dom.minidom import parseString
-
-from xmlrpclib import ServerProxy, Error
-
-def spCon(proto, auth, host, port):
- print "trying %s on %s@%s:%s" % (proto, auth, host, port)
- try:
- x=ServerProxy("%s://%s@%s:%s" % (proto, auth, host, port))
- x.echo(proto)
- return x
- except Error, v:
- return
- except socket_error, serr:
- return
-
-def getCon(auth, host, port):
- try:
- server = spCon("http", auth, host, port)
- if server:
- return server
- else:
- server = spCon("https", auth, host, port)
- except Error, v:
- print "ERROR", v
- return server
-
-def get_ip_address(ifname):
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- return socket.inet_ntoa(fcntl.ioctl(
- s.fileno(),
- 0x8915, # SIOCGIFADDR
- struct.pack('256s', ifname[:15])
- )[20:24])
-
-def is_it_up(host, port):
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(1)
- s.connect((host, port))
- s.close()
- except:
- print "host: %s:%s DOWN" % (host, port)
- return False
-
- print "host: %s:%s UP" % (host, port)
- return True
-
-# hmm master actions don't apply to a slave
-master="192.168.1.161"
-port=8899
-user = "oracle"
-password = "test123"
-auth = "%s:%s" % (user, password)
-server = getCon(auth, 'localhost', port)
-mserver = getCon(auth, master, port)
-poolNode=True
-interface = "c0a80100"
-role='xen,utility'
-hostname=gethostname()
-ip = get_ip_address(interface)
-poolMembers = []
-xserver = server
-poolCount = 0
-
-try:
- print server.discover_pool_filesystem()
- print
- print server.discover_server_pool()
- poolDom = parseString(server.discover_server_pool())
- for node in poolDom.getElementsByTagName('Server_Pool'):
- id = node.getElementsByTagName('Unique_Id')[0].firstChild.nodeValue
- alias = node.getElementsByTagName('Pool_Alias')[0].firstChild.nodeValue
- mvip = node.getElementsByTagName('Master_Virtual_Ip')[0].firstChild.nodeValue
- print "pool: %s, %s, %s" % (id, mvip, alias)
- members = node.getElementsByTagName('Member')
- for member in members:
- poolCount = poolCount + 1
- mip = member.getElementsByTagName('Registered_IP')[0].firstChild.nodeValue
- print "member: %s" % (mip)
- if mip == ip:
- pooled = True
- else:
- poolMembers.append(mip)
-
- # print server.discover_server()
-
-except Error, v:
- print "ERROR", v
diff --git a/plugins/hypervisors/ovm3/scripts/ovs_agent_plugin/cloudstack.py b/plugins/hypervisors/ovm3/scripts/ovs_agent_plugin/cloudstack.py
deleted file mode 100644
index f6557600538..00000000000
--- a/plugins/hypervisors/ovm3/scripts/ovs_agent_plugin/cloudstack.py
+++ /dev/null
@@ -1,344 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import logging
-import time
-import re
-import os.path
-import paramiko
-import subprocess
-import socket
-
-from xen.util.xmlrpcclient import ServerProxy
-from xmlrpclib import Error
-from xen.xend import XendClient
-from agent.api.base import Agent
-from agent.lib.settings import get_api_version
-from xen.xend import sxp
-
-class CloudStack(Agent):
- """
- Cloudstack plugin for OVM3.2.x.
- """
-
- # exposed services
- def get_services(self, version=None):
- return {
- 'call': call,
- 'get_vncport': getVncPort,
- 'exec_domr': domrExec,
- 'check_domr_port': domrCheckPort,
- 'check_domr_ssh': domrCheckSsh,
- 'ovs_control_interface': ovsControlInterface,
- 'ovs_mkdir': ovsMkdir,
- 'ovs_check_file': ovsCheckFile,
- 'ovs_upload_ssh_key': ovsUploadSshKey,
- 'ovs_dom0_stats': ovsDom0Stats,
- 'ovs_domU_stats': ovsDomUStats,
- 'get_module_version': getModuleVersion,
- 'ping': ping,
-# 'ovs_agent_set_ssl': ovsAgentSetSsl,
-# 'ovs_agent_set_port': ovsAgentSetPort,
-# 'ovs_restart_agent': ovsRestartAgent,
- }
-
- def getName(self):
- return self.__class__.__name__
-
-# which version are we intended for?
-def getModuleVersion():
- return "0.1"
-
-# call test
-def call(msg):
- return msg
-
-# execute something on domr
-def domrExec(ip, cmd, timeout=10, username="root", port=3922, keyfile="~/.ssh/id_rsa.cloud"):
- ssh = paramiko.SSHClient()
- ssh.load_system_host_keys()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- privatekeyfile = os.path.expanduser(keyfile)
- key = paramiko.RSAKey.from_private_key_file(privatekeyfile)
- ssh.connect(ip, port, username, pkey=key, timeout=timeout)
- ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd)
- exit_status = ssh_stdout.channel.recv_exit_status()
- ssh.close()
- return { "rc": exit_status,
- "out": ''.join(ssh_stdout.readlines()),
- "err": ''.join(ssh_stderr.readlines()) };
-
-# check a port on domr
-def domrPort(ip, port=3922, timeout=3):
- return domrCheckPort(ip, port, timeout=timeout)
-
-# check a port on domr
-def domrCheckPort(ip, port=3922, timeout=3):
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(timeout)
- s.connect((ip, port))
- s.close()
- return True
- except:
- return False
-
-# check ssh
-def domrCheckSsh(ip, port=3922, timeout=10):
- x = domrExec(ip, "", port=port, timeout=timeout)
- if (x.get("rc") == 0):
- return True
- return False
-
-def _ovsIni(setting, set):
- ini="/etc/ovs-agent/agent.ini"
- replaced=False
- if os.path.isfile(ini):
- import fileinput
- for line in fileinput.FileInput(ini, inplace=1):
- line=line.rstrip('\n')
- if re.search("%s=" % setting, line):
- line="%s=%s" % (setting, set)
- replaced=True
- print line
- return replaced
-
-# enable/disable ssl for the agent
-def ovsAgentSetSsl(state):
- ena="disable"
- if state and state != "disable" and state.lower() != "false":
- ena="enable"
- return _ovsIni("ssl", ena)
-
-def ovsAgentSetPort(port):
- return _ovsIni("port", port)
-
-def ovsRestartAgent():
- return restartService("ovs-agent")
-
-# replace with popen
-def restartService(service):
- command = ['service', service, 'restart'];
- subprocess.call(command, shell=False)
- return True
-
-# sets the control interface and removes the route net entry
-def ovsControlInterface(dev, ipmask):
- command = ['route', 'del', '-net', ipmask];
- subprocess.call(command, shell=False)
- command = ['ifconfig', dev, 'arp']
- subprocess.call(command, shell=False)
- return True
-
-# create a dir if we need it
-def ovsMkdir(dir, mode=0700):
- if not os.path.exists(dir):
- return os.makedirs(dir, mode)
- return True
-
-# if a file exists, easy
-def ovsCheckFile(file):
- if os.path.isfile(file):
- return True
- return False
-
-# upload keys
-def ovsUploadSshKey(keyfile, content):
- keydir=os.path.expanduser("~/.ssh")
- key="%s/%s" % (keydir, keyfile)
- try:
- ovsMkdir(os.path.expanduser(keydir))
- except Error, v:
- print "was already there %s" % keydir
-
- try:
- text_file = open("%s" % key, "w")
- text_file.write("%s" % content)
- text_file.close()
- except Error, v:
- print "something went wrong %s" % v
- return False
- return True
-
-
-# older python,
-def ovsDom0Stats(bridge):
- stats={}
- stats['cpu'] = "%s" % (100 - float(os.popen("top -b -n 1 | grep Cpu\(s\): | cut -d% -f4|cut -d, -f2").read()))
- stats['free'] = "%s" % (1048576 * int(os.popen("xm info | grep free_memory | awk '{ print $3 }'").read()))
- stats['total'] = "%s" % (1048576 * int(os.popen("xm info | grep total_memory | awk '{ print $3 }'").read()))
- stats['tx'] = os.popen("netstat -in | grep %s | head -1 | awk '{print $4 }'" % bridge).read()
- stats['rx'] = os.popen("netstat -in | grep %s | head -1 | awk '{print $8 }'" % bridge).read()
- return stats
-
-def getVncPort(domain):
- port = "0"
- if re.search("\w-(\d+-)?\d+-VM", domain):
- server=ServerProxy(XendClient.uri)
- dom=server.xend.domain(domain, 1)
- devices = [child for child in sxp.children(dom)
- if len(child) > 0 and child[0] == "device"]
- vfbs_sxp = map(lambda x: x[1], [device for device in devices
- if device[1][0] == "vfb"])[0]
- loc=[child for child in vfbs_sxp
- if child[0] == "location"][0][1]
- listner, port = loc.split(":")
- else:
- print "no valid domain: %s" % domain
- return port
-
-def get_child_by_name(exp, childname, default = None):
- try:
- return [child for child in sxp.children(exp)
- if child[0] == childname][0][1]
- except:
- return default
-
-def ovsDomUStats(domain):
- _rd_bytes=0
- _wr_bytes=0
- _rd_ops=0
- _wr_ops=0
- _tx_bytes=0
- _rx_bytes=0
- stats={}
- server=ServerProxy(XendClient.uri)
- dominfo=server.xend.domain(domain, 1)
- domid=get_child_by_name(dominfo, "domid")
-
- # vbds
- devs = server.xend.domain.getDeviceSxprs(domain, 'vbd')
- devids = [dev[0] for dev in devs]
- for dev in devids:
- sys_path="/sys/devices/%s-%s-%s/statistics" % ("vbd", domid, dev)
- _rd_bytes += long(open("%s/rd_sect" % sys_path).readline().strip())
- _wr_bytes += long(open("%s/wr_sect" % sys_path).readline().strip())
- _rd_ops += long(open("%s/rd_req" % sys_path).readline().strip())
- _wr_ops += long(open("%s/wr_req" % sys_path).readline().strip())
-
- # vifs
- devs = server.xend.domain.getDeviceSxprs(domain, 'vif')
- devids = [dev[0] for dev in devs]
- for dev in devids:
- vif="vif%s.%s" % (domid, dev)
- sys_path="/sys/devices/%s-%s-%s/net/%s/statistics" % ("vif", domid, dev, vif)
- _tx_bytes += long(open("%s/tx_bytes" % sys_path).readline().strip())
- _rx_bytes += long(open("%s/rx_bytes" % sys_path).readline().strip())
-
- epoch=time.time()
- stats['rd_bytes'] = "%s" % (_rd_bytes * 512)
- stats['wr_bytes'] = "%s" % (_wr_bytes * 512)
- stats['rd_ops'] = "%s" % (_rd_ops)
- stats['wr_ops'] = "%s" % (_wr_ops)
- stats['tx_bytes'] = "%s" % (_tx_bytes)
- stats['rx_bytes'] = "%s" % (_rx_bytes)
- stats['cputime']= "%s" % get_child_by_name(dominfo, "cpu_time")
- stats['uptime']= "%s" % (epoch - get_child_by_name(dominfo, "start_time"))
- stats['vcpus']= "%s" % get_child_by_name(dominfo, "online_vcpus")
- return stats
-
-def ping(host, count=3):
- if os.system("ping -c %s %s " % (count, host)) == 0:
- return True
- return False
-
-# add SystemVM stuff here....
-#
-
-#
-# Self deploy and integration, not de-integration
-# should return False if fails
-#
-# install us if we are missing in:
-# /usr/lib64/python2.4/site-packages/agent/api
-# and add our hooks in:
-# /usr/lib64/python2.4/site-packages/agent/target/api.py
-if __name__ == '__main__':
- from distutils.sysconfig import get_python_lib
- from agent.target.api import MODULES
- from shutil import copyfile
- import inspect, os, hashlib, getopt, sys
-
- # default vars
- exist=False
- agentpath="%s/agent" % (get_python_lib(1))
- api="%s/target/api.py" % (agentpath)
- modpath="%s/api" % (agentpath)
- ssl="disable"
- port=0
-
- # get options
- try:
- opts, args = getopt.getopt(sys.argv[1:], "sp::",
- [ 'port=','ssl='])
- except getopt.GetoptError:
- print "Available Options: --port=, --ssl="
- sys.exit()
-
- for o, a in opts:
- if o in ('-s', '--ssl'):
- ssl = a
- if o in ('-p', '--port'):
- port = int(a)
-
- # check if we're in the modules already
- cs = CloudStack()
- for mod in MODULES:
- if re.search(cs.getName(), "%s" % (mod)):
- exist=True
-
- # if we're not:
- if not exist:
- if os.path.isfile(api):
- import fileinput
- for line in fileinput.FileInput(api, inplace=1):
- line=line.rstrip('\n')
- if re.search("import common", line):
- line="%s, cloudstack" % (line)
- if re.search("MODULES", line):
- n=cs.getName()
- line="%s\n\t%s.%s," % (line, n.lower(), n)
- print line
- print "Api inserted, %s in %s" % (cs.getName(), api)
- else:
- print "Api missing, %s" % (api)
- else:
- print "Api present, %s in %s" % (cs.getName(), api)
-
- # either way check our version and install if checksum differs
- modfile="%s/%s.py" % (modpath, cs.getName().lower())
- me=os.path.abspath(__file__)
- if os.path.isfile(modfile):
- if hashlib.md5(open(me).read()).hexdigest() != hashlib.md5(open(modfile).read()).hexdigest():
- print "Module copy, %s" % (modfile)
- copyfile(me, modfile)
- else:
- print "Module correct, %s" % (modfile)
- else:
- print "Module copy, %s" % (modfile)
- copyfile(me, modfile)
-
- # setup ssl and port
- if ssl:
- ovsAgentSetSsl(ssl)
- if port > 1024:
- ovsAgentSetPort(port)
-
- # restart either way
- ovsRestartAgent()
diff --git a/plugins/hypervisors/ovm3/scripts/password.py b/plugins/hypervisors/ovm3/scripts/password.py
deleted file mode 100755
index 25404a9bdaa..00000000000
--- a/plugins/hypervisors/ovm3/scripts/password.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import os, sys, subprocess, socket,fcntl, struct
-from socket import gethostname
-from xml.dom.minidom import parseString
-
-from xmlrpclib import ServerProxy, Error
-
-def spCon(proto, host, port):
- print "trying %s on %s:%s" % (proto, host, port)
- try:
- x=ServerProxy("%s://%s:%s" % (proto, host, port))
- x.echo(proto)
- return x
- except Error, v:
- print "ERROR", v
- return
-
-def getCon(host, port):
- try:
- server = spCon("http", host, port)
- except Error, v:
- print "ERROR", v
- server = spCon("https", host, port)
-
- return server
-
-# hmm master actions don't apply to a slave
-port=8899
-user = "oracle"
-password = "test123"
-auth = "%s:%s" % (user, password)
-host = "localhost"
-
-print "setting up password"
-try:
- con = getCon(host, port)
- print con.update_agent_password(user, password)
-except Error, v:
- print "ERROR", v
diff --git a/plugins/hypervisors/ovm3/scripts/repo_pool.py b/plugins/hypervisors/ovm3/scripts/repo_pool.py
deleted file mode 100755
index 71feca8c7a2..00000000000
--- a/plugins/hypervisors/ovm3/scripts/repo_pool.py
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import os, sys, subprocess, socket,fcntl, struct
-from socket import gethostname
-from xml.dom.minidom import parseString
-
-from xmlrpclib import ServerProxy, Error
-
-def get_ip_address(ifname):
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- return socket.inet_ntoa(fcntl.ioctl(
- s.fileno(),
- 0x8915, # SIOCGIFADDR
- struct.pack('256s', ifname[:15])
- )[20:24])
-
-def is_it_up(host, port):
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(1)
- s.connect((host, port))
- s.close()
- except:
- print "host: %s:%s DOWN" % (host, port)
- return False
-
- print "host: %s:%s UP" % (host, port)
- return True
-
-# hmm master actions don't apply to a slave
-master="192.168.1.161"
-port=8899
-user = "oracle"
-password = "*******"
-auth = "%s:%s" % (user, password)
-server = ServerProxy("http://%s:%s" % ("localhost", port))
-mserver = ServerProxy("http://%s@%s:%s" % (auth, master, port))
-poolNode=True
-interface = "c0a80100"
-role='xen,utility'
-hostname=gethostname()
-ip = get_ip_address(interface)
-poolMembers = []
-xserver = server
-
-print "setting up password"
-server.update_agent_password(user, password)
-
-if (is_it_up(master, port)):
- print "master seems to be up, slaving"
- xserver = mserver
-else:
- print "no master yet, will become master"
-
-# other mechanism must be used to make interfaces equal...
-try:
- # pooling related same as primary storage!
- poolalias="Pool 0"
- poolid="0004fb0000020000ba9aaf00ae5e2d73"
- poolfsnfsbaseuuid="7718562d-872f-47a7-b454-8f9cac4ffa3a"
- pooluuid=poolid
- poolfsuuid=poolid
- clusterid="ba9aaf00ae5e2d72"
- mgr="d1a749d4295041fb99854f52ea4dea97"
- poolmvip=master
-
- poolfsnfsbaseuuid="6824e646-5908-48c9-ba44-bb1a8a778084"
- repoid="6824e646590848c9ba44bb1a8a778084"
- poolid=repoid
- repo="/OVS/Repositories/%s" % (repoid)
- repomount="cs-mgmt:/volumes/cs-data/secondary"
-
- # primary
- primuuid="7718562d872f47a7b4548f9cac4ffa3a"
- ssuuid="7718562d-872f-47a7-b454-8f9cac4ffa3a"
- fshost="cs-mgmt"
- fstarget="/volumes/cs-data/primary"
- fstype="nfs"
- fsname="Primary storage"
- fsmntpoint="%s:%s" % (fshost, fstarget)
- fsmnt="/nfsmnt/%s" % (ssuuid)
- fsplugin="oracle.generic.NFSPlugin.GenericNFSPlugin"
-
- # set the basics we require to "operate"
- print server.take_ownership(mgr, '')
- print server.update_server_roles(role,)
-
- # if we're pooling pool...
- if (poolNode == True):
- poolCount = 0
- pooled = False
-
- # check pooling
- try:
- poolDom = parseString(xserver.discover_server_pool())
- print xserver.discover_server_pool()
- for node in poolDom.getElementsByTagName('Server_Pool'):
- id = node.getElementsByTagName('Unique_Id')[0].firstChild.nodeValue
- alias = node.getElementsByTagName('Pool_Alias')[0].firstChild.nodeValue
- mvip = node.getElementsByTagName('Master_Virtual_Ip')[0].firstChild.nodeValue
- print "pool: %s, %s, %s" % (id, mvip, alias)
- members = node.getElementsByTagName('Member')
- for member in members:
- poolCount = poolCount + 1
- mip = member.getElementsByTagName('Registered_IP')[0].firstChild.nodeValue
- print "member: %s" % (mip)
- if mip == ip:
- pooled = True
- else:
- poolMembers.append(mip)
-
- except Error,v:
- print "no master will become master, %s" % v
-
- if (pooled == False):
- # setup the repository
- print "setup repo"
- print server.mount_repository_fs(repomount, repo)
- try:
- print "adding repo"
- print server.add_repository(repomount, repo)
- except Error, v:
- print "will create the repo, as it's not there", v
- print server.create_repository(repomount, repo, repoid, "repo")
-
- print "not pooled!"
- if (poolCount == 0):
- print "no pool yet, create it"
- # check if a pool exists already if not create
- # pool if so add us to the pool
- print "create pool fs"
- print server.create_pool_filesystem(
- fstype,
- "%s/VirtualMachines/" % repomount,
- clusterid,
- poolfsuuid,
- poolfsnfsbaseuuid,
- mgr,
- pooluuid
- )
- print "create pool"
- print server.create_server_pool(poolalias,
- pooluuid,
- poolmvip,
- poolCount,
- hostname,
- ip,
- role
- )
- else:
- print "join the pool"
- print server.join_server_pool(poolalias,
- pooluuid,
- poolmvip,
- poolCount,
- hostname,
- ip,
- role
- )
-
- # add member to ip list ?
- poolMembers.append(ip)
- print "mambers for pool: %s" % poolMembers
- print xserver.set_pool_member_ip_list(poolMembers)
-
- print server.discover_server_pool()
-
-except Error, v:
- print "ERROR", v
diff --git a/plugins/hypervisors/ovm3/scripts/simple_pool.py b/plugins/hypervisors/ovm3/scripts/simple_pool.py
deleted file mode 100755
index 756de93cf7a..00000000000
--- a/plugins/hypervisors/ovm3/scripts/simple_pool.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-import os, sys, subprocess, socket,fcntl, struct
-from socket import gethostname
-from xml.dom.minidom import parseString
-import errno
-from socket import error as socket_error
-
-from xmlrpclib import ServerProxy, Error
-
-def spCon(proto, auth, host, port):
- print "trying %s on %s@%s:%s" % (proto, auth, host, port)
- try:
- x=ServerProxy("%s://%s@%s:%s" % (proto, auth, host, port))
- x.echo(proto)
- return x
- except Error, v:
- return
- except socket_error, serr:
- return
-
-def getCon(auth, host, port):
- try:
- server = spCon("http", auth, host, port)
- if server:
- return server
- else:
- server = spCon("https", auth, host, port)
- except Error, v:
- print "ERROR", v
- return server
-
-def get_ip_address(ifname):
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- return socket.inet_ntoa(fcntl.ioctl(
- s.fileno(),
- 0x8915, # SIOCGIFADDR
- struct.pack('256s', ifname[:15])
- )[20:24])
-
-# hmm master actions don't apply to a slave
-master="192.168.1.161"
-port=8899
-passw='test123'
-user='oracle'
-auth="%s:%s" % (user, passw)
-server = getCon(auth, "localhost", port)
-mserver = getCon(auth, master, port)
-try:
- mserver.echo("test")
-except AttributeError, v:
- print "no mserver, becoming mserver"
- mserver=server
-
-poolNode=True
-interface = "c0a80100"
-role='xen,utility'
-hostname=gethostname()
-ip = get_ip_address(interface)
-nodes=[]
-
-try:
- # pooling related same as primary storage!
- poolalias="Pool 0"
- clusterid="ba9aaf00ae5e2d72"
- mgr="d1a749d4295041fb99854f52ea4dea97"
- poolmvip=master
-
- # primary
- primuuid="7718562d872f47a7b4548f9cac4ffa3a"
- ssuuid="7718562d-872f-47a7-b454-8f9cac4ffa3a"
- fshost="cs-mgmt"
- fstarget="/volumes/cs-data/primary/ovm"
- fstype="nfs"
- fsname="Primary storage"
- fsmntpoint="%s:%s" % (fshost, fstarget)
- fsmntpoint2="%s:%s" % (fshost, "/volumes/cs-data/secondary")
- fsmntpoint="%s/VirtualMachines" % (fsmntpoint2)
- fsmnt="/nfsmnt/%s" % (ssuuid)
- fsplugin="oracle.generic.NFSPlugin.GenericNFSPlugin"
- repo="/OVS/Repositories/%s" % (primuuid)
-
- # set the basics we require to "operate"
- print server.take_ownership(mgr, '')
- print server.update_server_roles(role,)
-
- # setup the repository
- print server.mount_repository_fs(fsmntpoint2, repo)
- try:
- print server.add_repository(fsmntpoint2, repo)
- except Error, v:
- print "will create the repo, as it's not there", v
- print server.create_repository(fsmntpoint2, repo, primuuid, "A repository")
-
- # if we're pooling pool...
- if (poolNode == True):
- poolCount = 0
- pooled = False
-
- # check pooling
- poolDom = parseString(mserver.discover_server_pool())
- for node in poolDom.getElementsByTagName('Server_Pool'):
- id = node.getElementsByTagName('Unique_Id')[0].firstChild.nodeValue
- alias = node.getElementsByTagName('Pool_Alias')[0].firstChild.nodeValue
- mvip = node.getElementsByTagName('Master_Virtual_Ip')[0].firstChild.nodeValue
- print "pool: %s, %s, %s" % (id, mvip, alias)
- members = node.getElementsByTagName('Member')
- for member in members:
- poolCount = poolCount + 1
- mip = member.getElementsByTagName('Registered_IP')[0].firstChild.nodeValue
- if (mip == ip):
- pooled = True
- else:
- nodes.append(mip)
- print "member: %s" % (mip)
-
- # if (pooled == False):
- try:
- if (poolCount == 0):
- print "master"
- # check if a pool exists already if not create
- # pool if so add us to the pool
- print server.configure_virtual_ip(master, ip)
- print server.create_pool_filesystem(
- fstype,
- fsmntpoint,
- clusterid,
- primuuid,
- ssuuid,
- mgr,
- primuuid
- )
- print server.create_server_pool(poolalias,
- primuuid,
- poolmvip,
- poolCount,
- hostname,
- ip,
- role
- )
- else:
- try:
- print "slave"
- print server.join_server_pool(poolalias,
- primuuid,
- poolmvip,
- poolCount,
- hostname,
- ip,
- role
- )
- except Error, v:
- print "host already part of pool?: %s" % (v)
-
- nodes.append(ip)
- for node in nodes:
- # con = getCon(auth, node, port)
- # print con.set_pool_member_ip_list(nodes);
- print mserver.dispatch("http://%s@%s:%s/api/3" % (auth, node, port), "set_pool_member_ip_list", nodes)
- # print server.configure_virtual_ip(master, ip)
- except Error, e:
- print "something went wrong: %s" % (e)
-
- # sys.exit()
- # mount the primary fs
- print server.storage_plugin_mount(
- fsplugin,
- {
- 'uuid': primuuid,
- 'storage_desc': fsname,
- 'access_host': fshost,
- 'storage_type': 'FileSys',
- 'name':primuuid
- },
- {
- 'status': '',
- 'uuid': ssuuid,
- 'ss_uuid': primuuid,
- 'size': 0,
- 'state': 1,
- 'access_grp_names': [],
- 'access_path': fsmntpoint,
- 'name': fsname
- },
- fsmnt,
- '',
- True,
- []
- )
-
-except Error, v:
- print "ERROR", v
diff --git a/plugins/hypervisors/ovm3/scripts/socat.sh b/plugins/hypervisors/ovm3/scripts/socat.sh
deleted file mode 100755
index c3fbc44a53a..00000000000
--- a/plugins/hypervisors/ovm3/scripts/socat.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-CERT="/etc/ovs-agent/cert"
-socat OPENSSL-LISTEN:8899,reuseaddr,fork,verify=0,key=$CERT/key.pem,cert=$CERT/certificate.pem TCP:localhost:8898 &
diff --git a/plugins/hypervisors/ovm3/scripts/tail.sh b/plugins/hypervisors/ovm3/scripts/tail.sh
deleted file mode 100755
index fe88bc02076..00000000000
--- a/plugins/hypervisors/ovm3/scripts/tail.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-cd /var/log
-tail -f ovm-consoled.log devmon.log messages ovs-agent.log ovmwatch.log
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/ha/Ovm3Investigator.java b/plugins/hypervisors/ovm3/src/com/cloud/ha/Ovm3Investigator.java
deleted file mode 100644
index 980fa1ffeab..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/ha/Ovm3Investigator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-package com.cloud.ha;
-
-import java.util.List;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckOnHostCommand;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.resource.ResourceManager;
-import com.cloud.utils.component.AdapterBase;
-
-@Local(value = Investigator.class)
-public class Ovm3Investigator extends AdapterBase implements Investigator {
- private final static Logger s_logger = Logger.getLogger(Ovm3Investigator.class);
- @Inject
- HostDao _hostDao;
- @Inject
- AgentManager _agentMgr;
- @Inject
- ResourceManager _resourceMgr;
-
- @Override
- public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) {
- Status status = isAgentAlive(host);
- if (status == null) {
- return null;
- }
- return status == Status.Up ? true : null;
- }
-
- @Override
- public Status isAgentAlive(Host agent) {
- if (agent.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) {
- return null;
- }
- CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
- List neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up);
- for (HostVO neighbor : neighbors) {
- if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) {
- continue;
- }
- try {
- Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
- if (answer != null) {
- return answer.getResult() ? Status.Down : Status.Up;
- }
- } catch (Exception e) {
- s_logger.debug("Failed to send command to host: " + neighbor.getId());
- }
- }
-
- return null;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Discoverer.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Discoverer.java
deleted file mode 100755
index bd1d90d043f..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Discoverer.java
+++ /dev/null
@@ -1,411 +0,0 @@
-// 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.
-package com.cloud.hypervisor.ovm3.hypervisor;
-
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.apache.xmlrpc.XmlRpcException;
-
-import com.cloud.agent.Listener;
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.AgentControlAnswer;
-import com.cloud.agent.api.AgentControlCommand;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.host.Status;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.configuration.Config;
-import com.cloud.dc.ClusterVO;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.dc.ClusterDetailsDao;
-// import com.cloud.exception.DiscoveryException;
-import com.cloud.host.HostInfo;
-import com.cloud.host.HostVO;
-import com.cloud.host.Host;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.ovm3.object.Linux;
-import com.cloud.hypervisor.ovm3.object.Connection;
-import com.cloud.resource.Discoverer;
-import com.cloud.resource.DiscovererBase;
-import com.cloud.resource.ResourceManager;
-import com.cloud.resource.ResourceStateAdapter;
-import com.cloud.resource.ServerResource;
-import com.cloud.resource.UnableDeleteHostException;
-import com.cloud.utils.db.QueryBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.ssh.SSHCmdHelper;
-
-@Local(value = Discoverer.class)
-public class Ovm3Discoverer extends DiscovererBase implements Discoverer,
- Listener, ResourceStateAdapter {
- private static final Logger s_logger = Logger
- .getLogger(Ovm3Discoverer.class);
- protected String _publicNetworkDevice;
- protected String _privateNetworkDevice;
- protected String _guestNetworkDevice;
- protected String _storageNetworkDevice;
- private String _ovsAgentPath = "/etc/ovs-agent/agent.ini";
-
- @Inject
- ClusterDao _clusterDao;
- @Inject
- ClusterDetailsDao _clusterDetailsDao;
- @Inject
- ResourceManager _resourceMgr;
- @Inject
- AgentManager _agentMgr;
- @Inject
- HostDao _hostDao = null;
-
- @Override
- public boolean configure(String name, Map params)
- throws ConfigurationException {
- super.configure(name, params);
- /* these are in Config.java */
- _publicNetworkDevice = _params.get(Config.Ovm3PublicNetwork.key());
- _privateNetworkDevice = _params.get(Config.Ovm3PrivateNetwork.key());
- _guestNetworkDevice = _params.get(Config.Ovm3GuestNetwork.key());
- _storageNetworkDevice = _params.get(Config.Ovm3StorageNetwork.key());
- _resourceMgr.registerResourceStateAdapter(this.getClass()
- .getSimpleName(), this);
- return true;
- }
-
- protected Ovm3Discoverer() {
- }
-
- @Override
- public boolean stop() {
- _resourceMgr.unregisterResourceStateAdapter(this.getClass()
- .getSimpleName());
- return super.stop();
- }
-
- private boolean checkIfExisted(String guid) {
- QueryBuilder sc = QueryBuilder.create(HostVO.class);
- sc.and(sc.entity().getGuid(), SearchCriteria.Op.EQ, guid);
- sc.and(sc.entity().getHypervisorType(), SearchCriteria.Op.EQ,
- HypervisorType.Ovm3);
- List hosts = sc.list();
- return !hosts.isEmpty();
- }
-
- @Override
- public Map extends ServerResource, Map> find(long dcId,
- Long podId, Long clusterId, URI url, String username,
- String password, List hostTags)
- throws CloudRuntimeException {
- Connection c = null;
-
- if (url.getScheme().equals("http") || url.getScheme().equals("https")) {
- String msg = "Discovering " + url
- + ": " + _params;
- s_logger.debug(msg);
- } else {
- String msg = "urlString is not http(s) so we're not taking care of the discovery for this: "
- + url;
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg);
- }
-
- if (clusterId == null) {
- String msg = "must specify cluster Id when add host";
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg);
- }
-
- if (podId == null) {
- String msg = "must specify pod Id when add host";
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg);
- }
-
- ClusterVO cluster = _clusterDao.findById(clusterId);
- if (cluster == null
- || (cluster.getHypervisorType() != HypervisorType.Ovm3)) {
- String msg = "invalid cluster id or cluster is not for Ovm3 hypervisors";
- s_logger.info(msg);
- throw new CloudRuntimeException(msg);
- } else {
- s_logger.info("cluster: " + cluster);
- }
-
- String agentUsername = _params.get("agentusername");
- if (agentUsername == null) {
- String msg = "Agent user name must be specified";
- s_logger.info(msg);
- throw new CloudRuntimeException(msg);
- }
-
- String agentPassword = _params.get("agentpassword");
- if (agentPassword == null) {
- String msg = "Agent password must be specified";
- s_logger.info(msg);
- throw new CloudRuntimeException(msg);
- }
-
- String agentPort = _params.get("agentport");
- if (agentPort == null) {
- String msg = "Agent port must be specified";
- s_logger.info(msg);
- throw new CloudRuntimeException(msg);
- }
-
- try {
- String hostname = url.getHost();
- /* port = url.getPort(); */
-
- InetAddress ia = InetAddress.getByName(hostname);
- String hostIp = ia.getHostAddress();
- String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();
-
- if (checkIfExisted(guid)) {
- String msg = "The host " + hostIp + " has been added before";
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg);
- }
-
- s_logger.debug("Ovm3 discover is going to disover host having guid "
- + guid);
-
- ClusterVO clu = _clusterDao.findById(clusterId);
- if (clu.getGuid() == null) {
- clu.setGuid(UUID.randomUUID().toString());
- }
- _clusterDao.update(clusterId, clu);
- Map clusterDetails = _clusterDetailsDao
- .findDetails(clusterId);
- String ovm3vip = (clusterDetails.get("ovm3vip") == null) ? ""
- : clusterDetails.get("ovm3vip");
- String ovm3pool = (clusterDetails.get("ovm3pool") == null) ? "false"
- : clusterDetails.get("ovm3pool");
- String ovm3cluster = (clusterDetails.get("ovm3cluster") == null) ? "false"
- : clusterDetails.get("ovm3cluster");
-
- /* should perhaps only make this connect to the agent port ? */
- com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(
- hostIp, 22);
- sshConnection.connect(null, 60000, 60000);
- sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp,
- username, password);
- if (sshConnection == null) {
- String msg = String.format("Cannot connect to Ovm3 host(IP=%1$s, username=%2$s, password=*******), discovery failed",
- hostIp, username);
- s_logger.warn(msg);
- throw new CloudRuntimeException(msg);
- }
-
- Map details = new HashMap();
- Ovm3ResourceBase ovmResource = new Ovm3ResourceBase();
- details.put("ip", hostIp);
- details.put("host", hostname);
- details.put("username", username);
- details.put("password", password);
- details.put("zone", Long.toString(dcId));
- details.put("guid", guid);
- details.put("pod", Long.toString(podId));
- details.put("cluster", Long.toString(clusterId));
- details.put("agentusername", agentUsername);
- details.put("agentpassword", agentPassword);
- details.put("agentport", agentPort.toString());
- details.put("ovm3vip", ovm3vip);
- details.put("ovm3pool", ovm3pool);
- details.put("ovm3cluster", ovm3cluster);
-
- if (_publicNetworkDevice != null) {
- details.put("public.network.device", _publicNetworkDevice);
- }
- if (_privateNetworkDevice != null) {
- details.put("private.network.device", _privateNetworkDevice);
- }
- if (_guestNetworkDevice != null) {
- details.put("guest.network.device", _guestNetworkDevice);
- }
- if (_storageNetworkDevice != null) {
- details.put("storage.network.device", _storageNetworkDevice);
- }
- s_logger.warn("network devices: " + _guestNetworkDevice + " "
- + _privateNetworkDevice + " " + _publicNetworkDevice + " "
- + _storageNetworkDevice);
-
- Map params = new HashMap();
- params.putAll(details);
-
- ovmResource.configure(hostname, params);
- ovmResource.start();
-
- try {
- c = new Connection(hostIp, Integer.parseInt(agentPort), agentUsername, agentPassword);
- } catch (Exception e) {
- String msg = String.format("Cannot connect to Ovm3 agent(IP=%1$s, Port=%1$, username=%3$s, password=*******), discovery failed",
- hostIp, agentPort, agentUsername);
- s_logger.warn(msg);
- throw new CloudRuntimeException(msg);
- }
- /* After resource start, we are able to execute our agent api */
- Linux host = new Linux(c);
- details.put("agentVersion", host.getAgentVersion());
- details.put(HostInfo.HOST_OS_KERNEL_VERSION,
- host.getHostKernelRelease());
- details.put(HostInfo.HOST_OS, host.getHostOs());
- details.put(HostInfo.HOST_OS_VERSION, host.getHostOsVersion());
- details.put(HostInfo.HYPERVISOR_VERSION,
- host.getHypervisorVersion());
-
- Map> resources = new HashMap>();
- resources.put(ovmResource, details);
- return resources;
- } catch (XmlRpcException e) {
- s_logger.debug("XmlRpc exception, Unable to discover Ovm3 host: " + url.getHost(),
- e);
- return null;
- } catch (UnknownHostException e) {
- s_logger.debug(
- "Host name resolve failed exception, Unable to discover Ovm3 host: "
- + url.getHost(), e);
- return null;
- } catch (ConfigurationException e) {
- s_logger.debug(
- "Configure resource failed, Unable to discover Ovm3 host: " + url.getHost(),
- e);
- return null;
- } catch (Exception e) {
- s_logger.debug("Unable to discover Ovm3 host: " + url.getHost(), e);
- return null;
- }
- }
-
- @Override
- public void postDiscovery(List hosts, long msId)
- throws CloudRuntimeException {
- // TODO Auto-generated method stub
- s_logger.debug("postDiscovery" + hosts);
- }
-
- @Override
- public boolean matchHypervisor(String hypervisor) {
- return HypervisorType.Ovm3.toString().equalsIgnoreCase(hypervisor);
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return HypervisorType.Ovm3;
- }
-
- @Override
- public HostVO createHostVOForConnectedAgent(HostVO host,
- StartupCommand[] cmd) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean processAnswers(long agentId, long seq, Answer[] answers) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean processCommands(long agentId, long seq, Command[] commands) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public AgentControlAnswer processControlCommand(long agentId,
- AgentControlCommand cmd) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* for reconnecting */
- @Override
- public void processConnect(Host host, StartupCommand cmd,
- boolean forRebalance) {
- }
-
- @Override
- public boolean processDisconnect(long agentId, Status state) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isRecurring() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public int getTimeout() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean processTimeout(long agentId, long seq) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public HostVO createHostVOForDirectConnectAgent(HostVO host,
- StartupCommand[] startup, ServerResource resource,
- Map details, List hostTags) {
- StartupCommand firstCmd = startup[0];
- if (!(firstCmd instanceof StartupRoutingCommand)) {
- return null;
- }
-
- StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
- if (ssCmd.getHypervisorType() != HypervisorType.Ovm3) {
- return null;
- }
-
- // TODO: Double check this
- return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Ovm3,
- details, hostTags);
- }
-
- // TODO: Make sure that we cleanup when the host is removed
- @Override
- public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
- boolean isForceDeleteStorage) throws UnableDeleteHostException {
- if (host.getType() != com.cloud.host.Host.Type.Routing
- || host.getHypervisorType() != HypervisorType.Ovm3) {
- return null;
- }
-
- _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
- return new DeleteHostAnswer(true);
- }
-
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Fencer.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Fencer.java
deleted file mode 100755
index 30db663c07b..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Fencer.java
+++ /dev/null
@@ -1,133 +0,0 @@
-// 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.
-package com.cloud.hypervisor.ovm3.hypervisor;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.FenceAnswer;
-import com.cloud.agent.api.FenceCommand;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.exception.OperationTimedoutException;
-import com.cloud.ha.FenceBuilder;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.ResourceManager;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.VirtualMachine;
-
-@Local(value = FenceBuilder.class)
-public class Ovm3Fencer extends AdapterBase implements FenceBuilder {
- Map _params;
- private static final Logger s_logger = Logger.getLogger(Ovm3Fencer.class);
- @Inject
- AgentManager _agentMgr;
- @Inject
- ResourceManager _resourceMgr;
-
-
- @Override
- public boolean configure(String name, Map params)
- throws ConfigurationException {
- _params = params;
- return true;
- }
-
- @Override
- public boolean start() {
- // TODO Auto-generated method stub
- return true;
- }
-
- @Override
- public boolean stop() {
- // TODO Auto-generated method stub
- return true;
- }
-
- public Ovm3Fencer() {
- super();
- }
-
- @Override
- public Boolean fenceOff(VirtualMachine vm, Host host) {
- if (host.getHypervisorType() != HypervisorType.Ovm3) {
- s_logger.debug("Don't know how to fence non Ovm3 hosts "
- + host.getHypervisorType());
- return null;
- } else {
- s_logger.debug("Fencing " + vm + " on host " + host
- + " with params: "+ _params );
- }
-
- List hosts = _resourceMgr.listAllHostsInCluster(host
- .getClusterId());
- FenceCommand fence = new FenceCommand(vm, host);
-
- for (HostVO h : hosts) {
- if (h.getHypervisorType() != HypervisorType.Ovm3) {
- continue;
- }
-
- if (h.getStatus() != Status.Up) {
- continue;
- }
-
- if (h.getId() == host.getId()) {
- continue;
- }
-
- FenceAnswer answer;
- try {
- answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
- } catch (AgentUnavailableException e) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Moving on to the next host because "
- + h.toString() + " is unavailable");
- }
- continue;
- } catch (OperationTimedoutException e) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Moving on to the next host because "
- + h.toString() + " is unavailable");
- }
- continue;
- }
-
- if (answer != null && answer.getResult()) {
- return true;
- }
- }
-
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Unable to fence off " + vm.toString() + " on "
- + host.toString());
- }
-
- return false;
- }
-
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Guru.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Guru.java
deleted file mode 100755
index 08aac30703f..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Guru.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// 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.
-
-/* shameless rip from original ovm guru */
-package com.cloud.hypervisor.ovm3.hypervisor;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.HypervisorGuru;
-import com.cloud.hypervisor.HypervisorGuruBase;
-import com.cloud.storage.GuestOSVO;
-import com.cloud.storage.dao.GuestOSDao;
-import com.cloud.vm.VirtualMachineProfile;
-
-@Local(value = HypervisorGuru.class)
-public class Ovm3Guru extends HypervisorGuruBase implements HypervisorGuru {
- // private static final Logger s_logger = Logger.getLogger(VMwareGuru.class);
-
- @Inject
- GuestOSDao _guestOsDao;
-
- protected Ovm3Guru() {
- super();
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return HypervisorType.Ovm3;
- }
-
- @Override
- public VirtualMachineTO implement(VirtualMachineProfile vm) {
- VirtualMachineTO to = toVirtualMachineTO(vm);
- to.setBootloader(vm.getBootLoaderType());
-
- // Determine the VM's OS description
- GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine()
- .getGuestOSId());
- to.setOs(guestOS.getDisplayName());
-
- return to;
- }
-
- @Override
- public boolean trackVmHostChange() {
- return true;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Helper.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Helper.java
deleted file mode 100755
index 8b0b1b5cff9..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3Helper.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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.
-package com.cloud.hypervisor.ovm3.hypervisor;
-
-import java.util.HashMap;
-
-public class Ovm3Helper {
- /* /usr/lib64/python2.4/site-packages/agent/lib/assembly */
- private static final HashMap s_ovmMap = new HashMap();
-
- public static final String HVM = "hvm";
- public static final String PV = "xen_pvm";
- public static final String DOMSOL = "ldoms_pvm";
- public static final String DEFAULT = "default";
-
- static {
- s_ovmMap.put("Oracle Enterprise Linux 6.0 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 6.0 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.0 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.0 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.1 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.1 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.2 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.2 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.3 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.3 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.4 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.4 (64-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.5 (32-bit)", PV);
- s_ovmMap.put("Oracle Enterprise Linux 5.5 (64-bit)", PV);
- s_ovmMap.put("Other Linux (32-bit)", PV);
- s_ovmMap.put("Other Linux (64-bit)", PV);
- s_ovmMap.put("Other PV (32-bit)", PV);
- s_ovmMap.put("Other PV (64-bit)", PV);
- s_ovmMap.put("Debian GNU/Linux 7(32-bit)", PV);
- s_ovmMap.put("Debian GNU/Linux 7(64-bit)", PV);
- s_ovmMap.put("Linux HVM (32-bit)", HVM);
- s_ovmMap.put("Linux HVM (64-bit)", HVM);
- s_ovmMap.put("Dos", HVM);
- s_ovmMap.put("Windows 7 (32-bit)", HVM);
- s_ovmMap.put("Windows 7 (64-bit)", HVM);
- s_ovmMap.put("Windows 8 (64-bit)", HVM);
- s_ovmMap.put("Windows Server 2003 (32-bit)", HVM);
- s_ovmMap.put("Windows Server 2003 (64-bit)", HVM);
- s_ovmMap.put("Windows Server 2008 (32-bit)", HVM);
- s_ovmMap.put("Windows Server 2008 (64-bit)", HVM);
- s_ovmMap.put("Windows Server 2008 R2 (64-bit)", HVM);
- s_ovmMap.put("Windows Server 2012 (64-bit)", HVM);
- s_ovmMap.put("Windows 2000 SP4 (32-bit)", HVM);
- s_ovmMap.put("Windows Vista (32-bit)", HVM);
- s_ovmMap.put("Windows XP SP2 (32-bit)", HVM);
- s_ovmMap.put("Windows XP SP3 (32-bit)", HVM);
- s_ovmMap.put("Sun Solaris 10(32-bit)", HVM);
- s_ovmMap.put("Sun Solaris 10(64-bit)", HVM);
- s_ovmMap.put("Sun Solaris 9(Experimental)", HVM);
- s_ovmMap.put("Sun Solaris 8(Experimental)", HVM);
- s_ovmMap.put("Sun Solaris 11 (32-bit)", HVM);
- s_ovmMap.put("Sun Solaris 11 (64-bit)", HVM);
- s_ovmMap.put("Sun Solaris PV (32-bit)", PV);
- s_ovmMap.put("Sun Solaris PV (64-bit)", PV);
- s_ovmMap.put("Sun Solaris Sparc (32-bit)", DOMSOL);
- s_ovmMap.put("Sun Solaris Sparc (64-bit)", DOMSOL);
- }
-
- public static String getOvm3GuestType(String stdType) {
- return s_ovmMap.get(stdType);
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3ResourceBase.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3ResourceBase.java
deleted file mode 100755
index 6b563d542a1..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/hypervisor/Ovm3ResourceBase.java
+++ /dev/null
@@ -1,3211 +0,0 @@
-// 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.
-package com.cloud.hypervisor.ovm3.hypervisor;
-
-import java.io.File;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.net.URI;
-import java.util.ArrayList;
-// import java.net.URISyntaxException;
-/*
- * import java.util.ArrayList;
- */
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.net.URL;
-
-import org.apache.commons.lang.BooleanUtils;
-
-import com.google.gson.Gson;
-
-import org.apache.commons.codec.binary.Base64;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.apache.xmlrpc.XmlRpcException;
-import org.apache.cloudstack.storage.to.TemplateObjectTO;
-import org.apache.cloudstack.storage.to.VolumeObjectTO;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-
-
-
-
-// import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-// import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import com.cloud.agent.IAgentControl;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.AttachIsoCommand;
-import com.cloud.agent.api.AttachVolumeAnswer;
-import com.cloud.agent.api.AttachVolumeCommand;
-import com.cloud.agent.api.CheckNetworkAnswer;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.agent.api.CheckVirtualMachineAnswer;
-import com.cloud.agent.api.CheckVirtualMachineCommand;
-// import com.cloud.agent.api.CleanupNetworkRulesCmd;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
-import com.cloud.agent.api.CreateStoragePoolCommand;
-import com.cloud.agent.api.DeleteStoragePoolCommand;
-import com.cloud.agent.api.FenceAnswer;
-import com.cloud.agent.api.FenceCommand;
-import com.cloud.agent.api.GetHostStatsAnswer;
-import com.cloud.agent.api.GetHostStatsCommand;
-import com.cloud.agent.api.GetStorageStatsAnswer;
-import com.cloud.agent.api.GetStorageStatsCommand;
-import com.cloud.agent.api.GetVmStatsAnswer;
-import com.cloud.agent.api.GetVmStatsCommand;
-import com.cloud.agent.api.GetVncPortAnswer;
-import com.cloud.agent.api.GetVncPortCommand;
-import com.cloud.agent.api.GetDomRVersionAnswer;
-import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.NetworkRulesSystemVmCommand;
-import com.cloud.agent.api.routing.DhcpEntryCommand;
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.api.routing.VmDataCommand;
-// import com.cloud.agent.api.routing.DhcpEntryAnswer;
-import com.cloud.agent.api.HostStatsEntry;
-import com.cloud.agent.api.HostVmStateReportEntry;
-import com.cloud.agent.api.MaintainAnswer;
-import com.cloud.agent.api.MaintainCommand;
-import com.cloud.agent.api.MigrateAnswer;
-import com.cloud.agent.api.MigrateCommand;
-import com.cloud.agent.api.ModifyStoragePoolAnswer;
-import com.cloud.agent.api.ModifyStoragePoolCommand;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.PingRoutingCommand;
-import com.cloud.agent.api.PingTestCommand;
-import com.cloud.agent.api.PrepareForMigrationAnswer;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-// import com.cloud.agent.api.PrepareOCFS2NodesCommand;
-import com.cloud.agent.api.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-import com.cloud.agent.api.RebootAnswer;
-import com.cloud.agent.api.RebootCommand;
-/*
- * import com.cloud.agent.api.SecurityGroupRuleAnswer;
- * import com.cloud.agent.api.SecurityGroupRulesCmd;
- */
-import com.cloud.agent.api.StartAnswer;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.agent.api.StartupStorageCommand;
-import com.cloud.agent.api.StopAnswer;
-import com.cloud.agent.api.StopCommand;
-import com.cloud.agent.api.VmStatsEntry;
-import com.cloud.agent.api.storage.CopyVolumeAnswer;
-import com.cloud.agent.api.storage.CopyVolumeCommand;
-import com.cloud.agent.api.storage.CreateAnswer;
-import com.cloud.agent.api.storage.CreateCommand;
-import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
-import com.cloud.agent.api.storage.DestroyCommand;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.agent.api.to.DiskTO;
-import com.cloud.agent.api.to.NfsTO;
-import com.cloud.agent.api.to.NicTO;
-import com.cloud.agent.api.to.StorageFilerTO;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.agent.api.to.VolumeTO;
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetworkSetupInfo;
-// import com.cloud.network.NetworkModel;
-import com.cloud.resource.ServerResource;
-import com.cloud.resource.hypervisor.HypervisorResource;
-// import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.Volume;
-import com.cloud.storage.template.TemplateProp;
-import com.cloud.template.VirtualMachineTemplate.BootloaderType;
-// import com.cloud.utils.Pair;
-// import com.cloud.utils.Ternary;
-import com.cloud.utils.exception.CloudRuntimeException;
-// import com.cloud.utils.script.Script;
-import com.cloud.utils.ssh.SshHelper;
-import com.trilead.ssh2.SCPClient;
-import com.cloud.utils.ssh.SSHCmdHelper;
-import com.cloud.agent.api.check.CheckSshAnswer;
-import com.cloud.agent.api.check.CheckSshCommand;
-import com.cloud.vm.DiskProfile;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineName;
-import com.cloud.vm.VirtualMachine.PowerState;
-import com.cloud.vm.VirtualMachine.State;
-import com.cloud.hypervisor.ovm3.object.Common;
-import com.cloud.hypervisor.ovm3.object.Connection;
-import com.cloud.hypervisor.ovm3.object.Linux;
-import com.cloud.hypervisor.ovm3.object.Network;
-import com.cloud.hypervisor.ovm3.object.OvmObject;
-import com.cloud.hypervisor.ovm3.object.Pool;
-import com.cloud.hypervisor.ovm3.object.PoolOCFS2;
-import com.cloud.hypervisor.ovm3.object.Repository;
-import com.cloud.hypervisor.ovm3.object.StoragePlugin;
-import com.cloud.hypervisor.ovm3.object.Xen;
-import com.cloud.hypervisor.ovm3.object.CloudStackPlugin;
-
-import org.apache.cloudstack.storage.command.CopyCommand;
-import org.apache.cloudstack.storage.command.DeleteCommand;
-import org.apache.cloudstack.storage.command.CopyCmdAnswer;
-import org.apache.cloudstack.storage.command.CreateObjectAnswer;
-import org.apache.cloudstack.storage.command.CreateObjectCommand;
-
-import com.cloud.storage.resource.StorageProcessor;
-
-import org.apache.cloudstack.storage.command.ForgetObjectCmd;
-import org.apache.cloudstack.storage.command.IntroduceObjectCmd;
-import org.apache.cloudstack.storage.command.DettachCommand;
-// import org.apache.cloudstack.storage.command.DettachAnswer;
-import org.apache.cloudstack.storage.command.AttachCommand;
-
-
-
-// import org.apache.cloudstack.storage.command.AttachAnswer;
-import com.cloud.storage.Storage.ImageFormat;
-/* do we need this ? */
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.resource.ResourceManager;
-import com.cloud.utils.script.Script;
-
-import org.apache.commons.io.FileUtils;
-
-import javax.inject.Inject;
-
-/* TODO: Seperate these out */
-public class Ovm3ResourceBase implements ServerResource, HypervisorResource,
- StorageProcessor {
- private static final Logger s_logger = Logger
- .getLogger(Ovm3ResourceBase.class);
- private Connection c;
- private Connection m;
- private String _name;
- private String _ip;
- Long _zoneId;
- Long _podId;
- Long _poolId;
- Long _clusterId;
- String _host;
- String _guid;
- String _username = "root";
- String _password;
- String _agentUserName = "oracle";
- String _agentPassword;
- Integer _agentPort = 8899;
- Boolean _agentSsl = false;
- String _ovmSshKey = "id_rsa.cloud";
- String _masterUuid = "d1a749d4295041fb99854f52ea4dea97";
- Boolean _isMaster = false;
- Boolean _hasMaster = false;
- Boolean _ovm3pool = false;
- Boolean _ovm3cluster = false;
- String _ovm3vip = "";
- protected boolean _checkHvm = false;
- /* _clusterDetailsDao.findDetail(clusterId, getVagKey(storagePoolId)); */
- String _privateNetworkName;
- String _publicNetworkName;
- String _guestNetworkName;
- String _storageNetworkName;
- String _controlNetworkName = "control0";
- String _controlNetworkIp = "169.254.0.1";
- // String _controlNetworkMask = "255.255.0.0";
- boolean _canBridgeFirewall = false;
- String _ovmRepo = "/OVS/Repositories";
- String _ovmSec = "/nfsmnt";
- OvmObject _ovmObject = new OvmObject();
- static boolean s_isHeartBeat = false;
- protected final int DefaultDomRSshPort = 3922;
- String DefaultDomRPath = "/opt/cloud/bin/";
- private Map _interfaces = null;
- /* switch to concurrenthasmaps all over the place ? */
- private final ConcurrentHashMap> _vmStats =
- new ConcurrentHashMap>();
-
- // TODO vmsync {
- /* This is replaced by the vmList in getall VMs, and operate on that */
- // protected HashMap _vms = new HashMap(250);
- protected Map _vms = new HashMap();
- protected Map _vmstates = new HashMap();
-
- static HashMap s_stateMaps;
- static {
- s_stateMaps = new HashMap();
- s_stateMaps.put("Stopping", State.Stopping);
- s_stateMaps.put("Running", State.Running);
- s_stateMaps.put("Stopped", State.Stopped);
- s_stateMaps.put("Error", State.Error);
- s_stateMaps.put("Suspended", State.Running);
- s_stateMaps.put("Paused", State.Running);
- s_stateMaps.put("Migrating", State.Migrating);
- }
-
- static HashMap s_powerStateMaps;
- static {
- s_powerStateMaps = new HashMap();
- s_powerStateMaps.put("Stopping", PowerState.PowerOn);
- s_powerStateMaps.put("Running", PowerState.PowerOn);
- s_powerStateMaps.put("Stopped", PowerState.PowerOff);
- s_powerStateMaps.put("Error", PowerState.PowerUnknown);
- s_powerStateMaps.put("Suspended", PowerState.PowerOn);
- s_powerStateMaps.put("Paused", PowerState.PowerOn);
- /* unknown ? */
- s_powerStateMaps.put("Migrating", PowerState.PowerOn);
- }
-
- @Inject
- PrimaryDataStoreDao _storagePoolDao;
- @Inject
- HostDao _hostDao;
- @Inject
- ResourceManager _resourceMgr;
-
- GlobalLock _exclusiveOpLock = GlobalLock.getInternLock("ovm3.exclusive.op");
-
- /* return params we want to add, damnit */
- @Override
- public boolean configure(String name, Map params)
- throws ConfigurationException {
- _name = name;
- s_logger.debug("configure " + name + " with params: " + params);
- /* do we have enough ? */
- try {
- _zoneId = Long.parseLong((String) params.get("zone"));
- _podId = Long.parseLong((String) params.get("pod"));
- _clusterId = Long.parseLong((String) params.get("cluster"));
- _ovm3vip = String.valueOf(params.get("ovm3vip"));
- _ovm3pool = BooleanUtils.toBoolean((String) params.get("ovm3pool"));
- _ovm3cluster = BooleanUtils.toBoolean((String) params
- .get("ovm3cluster"));
- _host = (String) params.get("host");
- _ip = (String) params.get("ip");
- _username = (String) params.get("username");
- _password = (String) params.get("password");
- _guid = (String) params.get("guid");
- _agentUserName = (String) params.get("agentusername");
- _agentPassword = (String) params.get("agentpassword");
- _privateNetworkName = (String) params.get("private.network.device");
- _publicNetworkName = (String) params.get("public.network.device");
- _guestNetworkName = (String) params.get("guest.network.device");
- _storageNetworkName = (String) params.get("storage.network.device");
-
- if (params.get("agentport") != null)
- _agentPort = Integer.parseInt((String) params.get("agentport"));
-
- // Add later
- // _agentSsl = (Boolean)params.get("agentssl");
- } catch (Exception e) {
- s_logger.debug("Configure " + _host + " failed", e);
- throw new ConfigurationException("Configure " + _host + " failed, "
- + e.toString());
- }
-
- if (_podId == null) {
- String msg = "Unable to get the pod";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_host == null) {
- String msg = "Unable to get the host";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_username == null) {
- String msg = "Unable to get the username";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_password == null) {
- String msg = "Unable to get the password";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_guid == null) {
- String msg = "Unable to get the guid";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_agentUserName == null) {
- String msg = "Unable to get the agent username";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_agentPassword == null) {
- String msg = "Unable to get the agent password";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- if (_agentPort == null) {
- String msg = "Unable to get the agent port";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
-
- /* TODO: Needs to be relocated */
- if (_ovm3vip.equals("")) {
- s_logger.debug("No VIP, Setting ovm3pool and ovm3cluster to false");
- this._ovm3pool = false;
- this._ovm3cluster = false;
- this._ovm3vip = "";
- }
- /* if we're a cluster we have to be a pool ? */
- if (_ovm3cluster) {
- this._ovm3pool = true;
- }
-
- /* check if we're master or not and if we can connect */
- try {
- try {
- c = new Connection(_host, _agentPort, _agentUserName,
- _agentPassword);
- } catch (XmlRpcException ex) {
- String msg = "Unable to connect to " + _host;
- s_logger.warn(msg + ": " + ex.getMessage());
- throw new Exception(msg, ex);
- }
- this._isMaster = masterCheck();
- } catch (Exception e) {
- String msg = "Base checks failed for " + _host;
- s_logger.debug(msg, e);
- throw new ConfigurationException(msg);
- }
- /* setup ovm3 plugin */
- try {
- installOvsPlugin();
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- cSp.ovsUploadSshKey(this._ovmSshKey,
- FileUtils.readFileToString(getSystemVMKeyFile()));
- } catch (Exception e) {
- String msg = "Failed to setup server: " + _host;
- s_logger.error(msg + ": " + e.getMessage());
- throw new ConfigurationException(msg + ", " + e);
- }
-
- try {
- try {
- /*
- * TODO: setup meta tags for the management interface (probably
- * required with multiple interfaces)?
- */
- Network net = new Network(c);
- _interfaces = net.getInterfaceList();
- s_logger.debug("all interfaces: " + _interfaces);
- if (_controlNetworkName != null
- && !_interfaces.containsKey(_controlNetworkName)) {
- /*
- * TODO: find a more elegant way to do this
- * for now we need the route del and ifconfig
- * as loopback bridges have arp disabled by default,
- * and zeroconf configures a route on the main bridge...
- */
- try {
- net.startOvsLocalConfig(_controlNetworkName);
- } catch (Exception e) {
- s_logger.debug("Unable to configure"
- + _controlNetworkName + ":" + e.getMessage());
- }
- /* ovs replies too "fast" so the bridge can be "busy" */
- while (!_interfaces.containsKey(_controlNetworkName)) {
- s_logger.debug("waiting for " + _controlNetworkName);
- _interfaces = net.getInterfaceList();
- Thread.sleep(1 * 1000);
- }
- }
- /* The bridge is remembered upon reboot, but not the IP */
- net.ovsIpConfig(_controlNetworkName,
- "static",
- _controlNetworkIp,
- "255.255.0.0");
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- cSp.ovsControlInterface(_controlNetworkName,
- _controlNetworkIp + "/16");
-
- // Missing netM = new Missing(c);
- /* build ovs_if_meta in Net based on the following */
- if (_privateNetworkName != null
- && net.getBridgeByName(_privateNetworkName).getName() == null) {
- throw new ConfigurationException(
- "Cannot find private bridge "
- + _privateNetworkName
- + " on host "
- + _host
- + " - "
- + net.getBridgeByName(_privateNetworkName)
- .getName());
- }
- if (_publicNetworkName != null
- && net.getBridgeByName(_publicNetworkName).getName() == null) {
- throw new ConfigurationException(
- "Cannot find private bridge "
- + _publicNetworkName
- + " on host "
- + _host
- + " - "
- + net.getBridgeByName(_publicNetworkName)
- .getName());
- }
- if (_guestNetworkName != null
- && net.getBridgeByName(_guestNetworkName).getName() == null) {
- throw new ConfigurationException(
- "Cannot find private bridge "
- + _guestNetworkName
- + " on host "
- + _host
- + " - "
- + net.getBridgeByName(_guestNetworkName)
- .getName());
- }
- if (_storageNetworkName != null
- && net.getBridgeByName(_storageNetworkName).getName() == null) {
- throw new ConfigurationException(
- "Cannot find private bridge "
- + _storageNetworkName
- + " on host "
- + _host
- + " - "
- + net.getBridgeByName(_storageNetworkName)
- .getName());
- }
- } catch (Exception e) {
- s_logger.debug("Get bridges failed on host " + _host + ", ", e);
- throw new ConfigurationException("Cannot get bridges on host "
- + _host + ", " + e);
- }
- try {
- prepareForPool();
- } catch (Exception e) {
- throw new ConfigurationException("Failed to prepare for pool "
- + _host + ", " + e);
- }
-
- /*
- * set to false so each time ModifyStoragePoolCommand will re-setup
- * heartbeat
- */
- /*
- * only required if we do cluster and then o2cb will take care of it
- * s_isHeartBeat = false;
- */
-
- /*
- * - uses iptables in XenServer, but not agent accessible for agent
- * *should make module*
- */
- try {
- _canBridgeFirewall = canBridgeFirewall();
- } catch (XmlRpcException e) {
- s_logger.error("Failed to detect whether the host supports security groups.",
- e);
- _canBridgeFirewall = false;
- }
-
- s_logger.debug(_canBridgeFirewall ? "OVM3 host supports security groups."
- : "OVM3 host doesn't support security groups.");
- /*
- * } catch (XmlRpcException e) {
- * String msg = "XML RPC Exception, unable to setup host: " + _host
- * + " " + e;
- * s_logger.debug(msg);
- * throw new ConfigurationException(msg);
- */
- } catch (Exception e) {
- String msg = "Generic Exception, failed to setup host: " + _host;
- s_logger.debug(msg + ": " + e.getMessage());
- throw new ConfigurationException(msg + ":" + e.getMessage());
- } /*
- * catch (IOException e) { s_logger.debug("Failed to setup host " +
- * _host, e); throw new
- * ConfigurationException("Unable to setup host"); }
- */
- return true;
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- return true;
- }
-
- @Override
- public String getName() {
- return _name;
- }
-
- @Override
- public Type getType() {
- return Type.Routing;
- }
-
- protected void fillHostInfo(StartupRoutingCommand cmd) {
- try {
- /* get data we need from parts */
- Linux host = new Linux(c);
- if (!host.getOvmVersion().startsWith("3.2.")) {
- throw new CloudRuntimeException(
- "OVM 3.2.X is only supported, not "
- + host.getOvmVersion());
- }
- Xen vms = new Xen(c);
- vms.listVms();
- Xen.Vm dom0 = vms.getRunningVmConfig("Domain-0");
-
- cmd.setName(host.getHostName());
- cmd.setSpeed(host.getCpuKhz());
- cmd.setCpus(host.getTotalThreads());
- cmd.setCpuSockets(host.getCpuSockets());
- cmd.setMemory(host.getMemory().longValue());
- /*
- * TODO: Convert Bigint to long in Linux
- */
- BigInteger totalmem = BigInteger.valueOf(host.getMemory()
- .longValue());
- BigInteger freemem = BigInteger.valueOf(host.getFreeMemory()
- .longValue());
- cmd.setDom0MinMemory(totalmem.subtract(freemem).longValue());
- // setPoolSync and setCaps.
- cmd.setGuid(_guid);
- cmd.setDataCenter(_zoneId.toString());
- cmd.setPod(_podId.toString());
- // also set uuid for ownership, or else pooling/clustering will not
- // work
- // cmd.setOwner(host.getManagerUuid());
- cmd.setCluster(_clusterId.toString());
- cmd.setHypervisorVersion(host.getOvmVersion());
- cmd.setVersion(host.getAgentVersion());
- cmd.setHypervisorType(HypervisorType.Ovm3);
- /* is this true ? */
- cmd.setCaps(host.getCapabilities());
- // TODO: Control ip, for now cheat ?
- cmd.setPrivateIpAddress(_ip);
- cmd.setStorageIpAddress(_ip);
- cmd.setHostVmStateReport(HostVmStateReport());
-
- Network net = new Network(c);
- /* more detail -- fix -- and shouldn't matter */
- /* should this be the bond before the bridge ?*/
- String defaultBridge = net.getBridgeByIp(_ip).getName();
- if (defaultBridge == null) {
- throw new CloudRuntimeException(
- "Unable to obtain valid bridge with " + _ip);
- }
-
- /* TODO: cleanup network section, this is not right */
- if (_publicNetworkName == null) {
- _publicNetworkName = defaultBridge;
- }
- if (_privateNetworkName == null) {
- _privateNetworkName = _publicNetworkName;
- }
- if (_guestNetworkName == null) {
- _guestNetworkName = _publicNetworkName;
- }
- /*
- * if (_storageNetworkName == null) {
- * _storageNetworkName = _privateNetworkName;
- * }
- */
- Map d = cmd.getHostDetails();
- d.put("public.network.device", _publicNetworkName);
- if (_privateNetworkName != null)
- d.put("private.network.device", _privateNetworkName);
- if (_guestNetworkName != null)
- d.put("guest.network.device", _guestNetworkName);
- if (_storageNetworkName != null)
- d.put("storage.network.device", _storageNetworkName);
- d.put("ismaster", this._isMaster.toString());
- cmd.setHostDetails(d);
- s_logger.debug("Add an Ovm3 host " + _name + ":"
- + cmd.getHostDetails());
- } catch (XmlRpcException e) {
- s_logger.debug("XML RPC Exception" + e.getMessage(), e);
- throw new CloudRuntimeException("XML RPC Exception"
- + e.getMessage(), e);
- } catch (Exception e) {
- s_logger.debug("Exception " + e.getMessage(), e);
- throw new CloudRuntimeException("Exception" + e.getMessage(), e);
- }
- }
-
- /*
- * plugs the ovm module into the ovs-agent
- */
- protected void installOvsPlugin() throws IOException {
- /* ssh-copy-id anyone ? */
- try {
- com.trilead.ssh2.Connection sshConnection =
- SSHCmdHelper.acquireAuthorizedConnection(_ip,
- _username,
- _password);
- if (sshConnection == null) {
- throw new ConfigurationException(String.format("Unable to "
- + "connect to server(IP=%1$s, username=%2$s, "
- + "password=%3$s", _ip, _username, _password));
- }
- SCPClient scp = new SCPClient(sshConnection);
- String userDataScript = "scripts/vm/hypervisor/ovm3/cloudstack.py";
- String userDataScriptPath = Script.findScript("", userDataScript);
- if (userDataScriptPath == null) {
- throw new ConfigurationException("Can not find "
- + userDataScript);
- }
- scp.put(userDataScriptPath, "", "0755");
- String prepareCmd = String.format("./cloudstack.py "
- + "--ssl=" + this._agentSsl + " "
- + "--port=" + this._agentPort);
- if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
- throw new ConfigurationException("Module insertion at "
- + _host + " failed");
- }
- } catch (Exception es) {
- s_logger.error("Unexpected exception ", es);
- String msg = "Unable to install module in agent";
- s_logger.error(msg);
- throw new CloudRuntimeException(msg);
- }
- }
-
- /* startup */
- @Override
- public StartupCommand[] initialize() {
- s_logger.debug("Ovm3 resource intializing");
- try {
- StartupRoutingCommand srCmd = new StartupRoutingCommand();
-
- StartupStorageCommand ssCmd = new StartupStorageCommand();
- fillHostInfo(srCmd);
- String pool = srCmd.getPool();
- s_logger.debug("Ovm3 pool " + ssCmd + " " + srCmd);
-
- Map changes = null;
- synchronized (_vmstates) {
- _vmstates.clear();
- changes = sync();
- }
- srCmd.setStateChanges(changes);
- /* should not force HVM */
- // cmd.setCaps("hvm");
- return new StartupCommand[] { srCmd, ssCmd };
- } catch (Exception e) {
- s_logger.debug("Ovm3 resource initializes failed", e);
- return null;
- }
- }
-
- /* See if the agent is still up on the host */
- @Override
- public PingCommand getCurrentStatus(long id) {
- try {
- /* feels useless somehow */
- Common test = new Common(c);
- String ping = "put";
- String pong = test.echo(ping);
- if (pong.contains(ping)) {
- HashMap newStates = sync();
- return new PingRoutingCommand(getType(), id, newStates,
- HostVmStateReport());
- }
- } catch (XmlRpcException e) {
- s_logger.debug("Check agent status failed", e);
- return null;
- } catch (Exception e) {
- s_logger.debug("Check agent status failed", e);
- return null;
- }
- return null;
- }
-
- /* Check if the host is in ready state for CS */
- protected ReadyAnswer execute(ReadyCommand cmd) {
- try {
- Linux host = new Linux(c);
- Pool pool = new Pool(c);
-
- /* only interesting when doing cluster */
- if (!host.getIsMaster() && _ovm3cluster) {
- if (pool.getPoolMasterVip().equalsIgnoreCase(_ip)) {
- /* check pool state here */
- return new ReadyAnswer(cmd);
- } else {
- s_logger.debug("Master IP changes to "
- + pool.getPoolMasterVip() + ", it should be " + _ip);
- return new ReadyAnswer(cmd, "I am not the master server");
- }
- } else if (host.getIsMaster()) {
- s_logger.debug("Master, not clustered " + _host);
- return new ReadyAnswer(cmd);
- } else {
- s_logger.debug("No master, not clustered " + _host);
- return new ReadyAnswer(cmd);
- }
- } catch (XmlRpcException e) {
- s_logger.debug("XML RPC Exception" + e.getMessage(), e);
- throw new CloudRuntimeException("XML RPC Exception"
- + e.getMessage(), e);
- } catch (Exception e) {
- s_logger.debug("Exception" + e.getMessage(), e);
- throw new CloudRuntimeException("Exception" + e.getMessage(), e);
- }
-
- }
-
- /*
- * Primary storage, will throw an error if ownership does not match!
- * Pooling is a part of this, for now
- */
- protected boolean createRepo(StorageFilerTO cmd) throws XmlRpcException {
- String basePath = this._ovmRepo;
- Repository repo = new Repository(c);
- String primUuid = repo.deDash(cmd.getUuid());
- String ovsRepo = basePath + "/" + primUuid;
- /* should add port ? */
- String mountPoint = String.format("%1$s:%2$s",
- cmd.getHost(),
- cmd.getPath());
-
- String msg;
- if (cmd.getType() == StoragePoolType.NetworkFilesystem) {
- /* base repo first */
-
- repo.mountRepoFs(mountPoint, ovsRepo);
- s_logger.debug("NFS repository " + mountPoint + " on " + ovsRepo
- + " requested for " + _host);
- try {
- repo.addRepo(mountPoint, ovsRepo);
- } catch (Exception e) {
- s_logger.debug("NFS repository " + mountPoint + " on "
- + ovsRepo + " not found creating!");
- try {
- repo.createRepo(mountPoint,
- ovsRepo,
- primUuid,
- "OVS Reposutory");
- } catch (Exception es) {
- msg = "NFS repository " + mountPoint + " on "
- + ovsRepo + " create failed!";
- s_logger.debug(msg);
- throw new CloudRuntimeException(
- msg + " " + es.getMessage(), es);
- }
- }
- /* add base pooling first */
- if (this._ovm3pool) {
- try {
- msg = "Configuring host for pool";
- s_logger.debug(msg);
- setupPool(cmd);
- msg = "Configured host for pool";
- /* add clustering after pooling */
- if (this._ovm3cluster) {
- msg = "Configuring host for cluster";
- s_logger.debug(msg);
- /* setup cluster */
- /*
- * From cluster.java
- * configure_server_for_cluster(cluster conf, fs, mount,
- * fsuuid, poolfsbaseuuid)
- */
- /* create_cluster(poolfsuuid,) */
- msg = "Configuring host for cluster";
- }
- } catch (Exception e) {
- msg = "Unable to setup pool on " + ovsRepo;
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg + " " + e.getMessage(), e);
- }
- } else {
- msg = "no way dude I can't stand for this";
- s_logger.debug(msg);
- }
- /*
- * this is to create the .generic_fs_stamp else we're not allowed
- * to create any data\disks on this thing
- */
- try {
- URI uri = new URI(cmd.getType() + "://" + cmd.getHost() + ":"
- + +cmd.getPort() + cmd.getPath() + "/VirtualMachines");
- this.setupNfsStorage(uri, cmd.getUuid());
- } catch (Exception e) {
- msg = "NFS mount " + mountPoint + " on " + _ovmSec + "/"
- + cmd.getUuid() + " create failed!";
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg + " " + e.getMessage(), e);
- }
- } else {
- msg = "NFS repository " + mountPoint + " on " + ovsRepo
- + " create failed, was type " + cmd.getType();
- s_logger.debug(msg);
- return false;
- }
-
- try {
- /* systemvm iso is imported here */
- prepareSecondaryStorageStore(ovsRepo);
- } catch (Exception e) {
- msg = "systemvm.iso copy failed to " + ovsRepo;
- s_logger.debug(msg);
- return false;
- }
- return true;
- }
-
- /* */
- public void prepareSecondaryStorageStore(String storageUrl) {
- String mountPoint = storageUrl;
-
- GlobalLock lock = GlobalLock.getInternLock("prepare.systemvm");
- try {
- /* double check */
- if (this._hasMaster && this._ovm3pool) {
- s_logger.debug("Skip systemvm iso copy, leave it to the master");
- return;
- }
- if (lock.lock(3600)) {
- try {
- File srcIso = getSystemVMPatchIsoFile();
- String destPath = mountPoint + "/ISOs/";
- String repoPath[] = mountPoint.split(File.separator);
- String destIso = destPath + "/"
- + getSystemVMIsoFileNameOnDatastore();
- String result = "";
- try {
- StoragePlugin sp = new StoragePlugin(c);
- // sp.storagePluginGetFileInfo(repoPath[repoPath.length],
- // destIso);
- if (sp.getFileSize() > 0) {
- s_logger.info(" System VM patch ISO file already exists: "
- + srcIso.getAbsolutePath().toString()
- + ", destination: " + destIso);
- }
- } catch (Exception e) {
- /*
- * Cloudstack already does this at boot time:
- * s_logger.info(
- * "Inject SSH key pairs before copying systemvm.iso into secondary storage"
- * );
- */
- s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: "
- + srcIso.getAbsolutePath()
- + ", destination: "
- + destIso);
- try {
- /*
- * should actualy come from importIso in
- * Storageplugin, so craft a url that can be used
- * for that.
- */
- SshHelper.scpTo(this._host,
- 22,
- this._username,
- null,
- this._password,
- destPath,
- srcIso.getAbsolutePath().toString(),
- "0644");
- } catch (Exception es) {
- s_logger.error("Unexpected exception ", es);
- String msg = "Unable to copy systemvm ISO on secondary storage. src location: "
- + srcIso.toString()
- + ", dest location: "
- + destIso;
- s_logger.error(msg);
- throw new CloudRuntimeException(msg);
- }
- }
- } finally {
- lock.unlock();
- }
- }
- } finally {
- lock.releaseRef();
- }
- }
-
- /* stolen from vmware impl */
- public String getSystemVMIsoFileNameOnDatastore() {
- String version = this.getClass().getPackage()
- .getImplementationVersion();
- String fileName = "systemvm-" + version + ".iso";
- return fileName.replace(':', '-');
- }
-
- /* stolen from vmware impl */
- private File getSystemVMPatchIsoFile() {
- // locate systemvm.iso
- String svmName = getSystemVMIsoFileNameOnDatastore();
- URL url = this.getClass().getClassLoader()
- .getResource("vms/" + svmName);
- s_logger.debug(url);
- File isoFile = null;
- if (url != null) {
- isoFile = new File(url.getPath());
- }
- if (isoFile == null || !isoFile.exists()) {
- isoFile = new File("/usr/share/cloudstack-common/vms/" + svmName);
- }
-
- assert (isoFile != null);
- if (!isoFile.exists()) {
- s_logger.error("Unable to locate " + svmName + " in your setup at "
- + isoFile.toString());
- }
- return isoFile;
- }
-
- /* get the key */
- public File getSystemVMKeyFile() {
- URL url = this.getClass().getClassLoader()
- .getResource("scripts/vm/systemvm/" + this._ovmSshKey);
- File keyFile = null;
- if (url != null) {
- keyFile = new File(url.getPath());
- }
- if (keyFile == null || !keyFile.exists()) {
- keyFile = new File(
- "/usr/share/cloudstack-common/scripts/vm/systemvm/"
- + _ovmSshKey);
- }
- assert (keyFile != null);
- if (!keyFile.exists()) {
- s_logger.error("Unable to locate " + _ovmSshKey
- + " in your setup at " + keyFile.toString());
- }
- return keyFile;
- }
-
- /*
- * TODO: local OCFS2? or iSCSI OCFS2
- */
- protected Boolean createOCFS2Sr(StorageFilerTO pool) throws XmlRpcException {
- /*
- * Ovm3StoragePool.Details d = new Ovm3StoragePool.Details(); d.path =
- * pool.getPath(); d.type = Ovm3StoragePool.OCFS2; d.uuid =
- * pool.getUuid(); Ovm3StoragePool.create(_conn, d);
- * s_logger.debug(String.format("Created SR (mount point:%1$s)",
- * d.path));
- */
- s_logger.debug("OCFS2 Not implemented yet");
- return false;
- }
-
- /* TODO: heartbeats are done by the oracle cluster when clustering */
- private void setupHeartBeat(String poolUuid) {
- try {
- if (!s_isHeartBeat) {
- // Ovm3Host.setupHeartBeat(_conn, poolUuid, _ip);
- s_isHeartBeat = true;
- }
- } catch (Exception e) {
- s_logger.debug("setup heart beat for " + _host + " failed", e);
- s_isHeartBeat = false;
- }
- }
-
- /* Setup a storage pool and also get the size */
- protected Answer execute(ModifyStoragePoolCommand cmd) {
- StorageFilerTO pool = cmd.getPool();
- s_logger.debug("modifying pool " + pool);
- try {
- if (pool.getType() == StoragePoolType.NetworkFilesystem) {
- /* this should actually not be here */
- createRepo(pool);
- } else if (pool.getType() == StoragePoolType.OCFS2) {
- createOCFS2Sr(pool);
- } else {
- return new Answer(cmd, false, "The pool type: "
- + pool.getType().name() + " is not supported.");
- }
-
- if (this._ovm3cluster) {
- // setupHeartBeat(pool.getUuid());
- }
- /* TODO: needs to be in network fs above */
- StoragePlugin store = new StoragePlugin(c);
- String propUuid = store.deDash(pool.getUuid());
- String mntUuid = pool.getUuid();
- String nfsHost = pool.getHost();
- String nfsPath = pool.getPath();
- store.setUuid(propUuid);
- store.setSsUuid(propUuid);
- store.setMntUuid(mntUuid);
- store.setFsHost(nfsHost);
- store.setFsSourcePath(nfsHost + ":" + nfsPath);
- store.storagePluginGetFileSystemInfo();
-
- Map tInfo = new HashMap();
- ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd,
- Long.parseLong(store.getTotalSize()), Long.parseLong(store
- .getFreeSize()), tInfo);
- return answer;
- } catch (Exception e) {
- s_logger.debug("ModifyStoragePoolCommand failed", e);
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- /* TODO: add iSCSI */
- protected Answer execute(CreateStoragePoolCommand cmd) {
- StorageFilerTO pool = cmd.getPool();
- s_logger.debug("creating pool " + pool);
- try {
- if (pool.getType() == StoragePoolType.NetworkFilesystem) {
- createRepo(pool);
- } else if (pool.getType() == StoragePoolType.IscsiLUN) {
- return new Answer(cmd, false,
- "iSCSI is unsupported at the moment");
- // getIscsiSR(conn, pool.getUuid(), pool.getHost(),
- // pool.getPath(), null, null, false);
- } else if (pool.getType() == StoragePoolType.OCFS2) {
- return new Answer(cmd, false,
- "OCFS2 is unsupported at the moment");
- } else if (pool.getType() == StoragePoolType.PreSetup) {
- s_logger.warn("pre setup for pool " + pool);
- } else {
- return new Answer(cmd, false, "The pool type: "
- + pool.getType().name() + " is not supported.");
- }
- } catch (Exception e) {
- String msg = "Catch Exception " + e.getClass().getName()
- + ", create StoragePool failed due to " + e.toString()
- + " on host:" + _host + " pool: " + pool.getHost()
- + pool.getPath();
- s_logger.warn(msg, e);
- return new Answer(cmd, false, msg);
- }
- return new Answer(cmd, true, "success");
- }
-
- /*
- * Download some primary storage into the repository, we need the repoid to
- * do that, but also have a uuid for the disk...
- * TODO: check disk
- * TODO: looks like we don't need this for now! (dead code)
- */
- protected PrimaryStorageDownloadAnswer execute(
- final PrimaryStorageDownloadCommand cmd) {
- try {
- Repository repo = new Repository(c);
- String tmplturl = cmd.getUrl();
- String poolName = cmd.getPoolUuid();
- String image = repo.deDash(repo.newUuid()) + ".raw";
-
- /* url to download from, image name, and repo to copy it to */
- repo.importVirtualDisk(tmplturl, image, poolName);
-
- /* TODO: return uuid and size */
- return new PrimaryStorageDownloadAnswer(image);
- } catch (Exception e) {
- s_logger.debug("PrimaryStorageDownloadCommand failed", e);
- return new PrimaryStorageDownloadAnswer(e.getMessage());
- }
- }
-
- /*
- * TODO: Split out in Sec to prim and prim to prim and types ?
- * Storage mount also goes in here for secstorage
- */
- protected final Answer execute(final CopyCommand cmd) {
- DataTO srcData = cmd.getSrcTO();
- DataStoreTO srcStore = srcData.getDataStore();
- DataTO destData = cmd.getDestTO();
- DataStoreTO destStore = destData.getDataStore();
-
- try {
- /* target and source are NFS and TEMPLATE */
- if ((srcStore instanceof NfsTO)
- && (srcData.getObjectType() == DataObjectType.TEMPLATE)
- && (destData.getObjectType() == DataObjectType.TEMPLATE)) {
- NfsTO srcImageStore = (NfsTO) srcStore;
- TemplateObjectTO srcTemplate = (TemplateObjectTO) srcData;
- String storeUrl = srcImageStore.getUrl();
-
- URI uri = new URI(storeUrl);
- String secPoolUuid = setupSecondaryStorage(storeUrl);
- String primaryPoolUuid = destData.getDataStore().getUuid();
- String destPath = this._ovmRepo + "/"
- + _ovmObject.deDash(primaryPoolUuid) + "/"
- + "Templates";
- String sourcePath = this._ovmSec + "/" + secPoolUuid;
-
- Linux host = new Linux(c);
- String destUuid = srcTemplate.getUuid();
- /*
- * TODO: add dynamic formats (tolower), it also supports VHD and
- * QCOW2, although Ovm3.2 does not have tapdisk2 anymore so we
- * can forget about that.
- */
- /* TODO: add checksumming */
- String srcFile = sourcePath + "/" + srcData.getPath();
- if (srcData.getPath().endsWith("/")) {
- srcFile = sourcePath + "/" + srcData.getPath() + "/"
- + destUuid + ".raw";
- }
- String destFile = destPath + "/" + destUuid + ".raw";
- s_logger.debug("CopyFrom: " + srcData.getObjectType() + ","
- + srcFile + " to " + destData.getObjectType() + ","
- + destFile);
- host.copyFile(srcFile, destFile);
-
- TemplateObjectTO newVol = new TemplateObjectTO();
- newVol.setUuid(destUuid);
- newVol.setPath(destPath);
- newVol.setFormat(ImageFormat.RAW);
- return new CopyCmdAnswer(newVol);
- /* we assume the cache for templates is local */
- } else if ((srcData.getObjectType() == DataObjectType.TEMPLATE)
- && (destData.getObjectType() == DataObjectType.VOLUME)) {
- if (srcStore.getUrl().equals(destStore.getUrl())) {
- TemplateObjectTO srcTemplate = (TemplateObjectTO) srcData;
- VolumeObjectTO dstVolume = (VolumeObjectTO) destData;
-
- String srcFile = srcTemplate.getPath() + "/"
- + srcTemplate.getUuid() + ".raw";
- String vDisksPath = srcTemplate.getPath()
- .replace("Templates", "VirtualDisks");
- String destFile = vDisksPath + "/" + dstVolume.getUuid()
- + ".raw";
-
- Linux host = new Linux(c);
- s_logger.debug("CopyFrom: " + srcData.getObjectType() + ","
- + srcFile + " to " + destData.getObjectType() + ","
- + destFile);
- host.copyFile(srcFile, destFile);
- VolumeObjectTO newVol = new VolumeObjectTO();
- newVol.setUuid(dstVolume.getUuid());
- newVol.setPath(vDisksPath);
- newVol.setFormat(ImageFormat.RAW);
- return new CopyCmdAnswer(newVol);
- } else {
- s_logger.debug("Primary to Primary doesn't match");
- }
- } else {
- String msg = "Unable to do stuff for " + srcStore.getClass()
- + ":" + srcData.getObjectType() + " to "
- + destStore.getClass() + ":" + destData.getObjectType();
- s_logger.debug(msg);
- }
- } catch (Exception e) {
- String msg = "Catch Exception " + e.getClass().getName()
- + " for template due to " + e.toString();
- s_logger.warn(msg, e);
- return new CopyCmdAnswer(msg);
- }
- return new CopyCmdAnswer("not implemented yet");
- }
-
- protected Answer execute(DeleteCommand cmd) {
- DataTO data = cmd.getData();
- s_logger.debug("Deleting object: " + data.getObjectType());
- if (data.getObjectType() == DataObjectType.VOLUME) {
- return deleteVolume(cmd);
- } else if (data.getObjectType() == DataObjectType.SNAPSHOT) {
-
- } else if (data.getObjectType() == DataObjectType.TEMPLATE) {
-
- } else {
-
- }
- String msg = "Delete not implemented yet for this object";
- s_logger.debug(msg);
- return new Answer(cmd);
- }
-
- /* TODO: Create a Disk from a template needs cleaning */
- protected CreateAnswer execute(CreateCommand cmd) {
- StorageFilerTO primaryStorage = cmd.getPool();
- DiskProfile disk = cmd.getDiskCharacteristics();
-
- /* disk should have a uuid */
- String fileName = UUID.randomUUID().toString() + ".img";
- String dst = primaryStorage.getPath() + "/" + primaryStorage.getUuid()
- + "/" + fileName;
-
- try {
- StoragePlugin store = new StoragePlugin(c);
- store.setUuid(primaryStorage.getUuid());
- store.setName(primaryStorage.getUserInfo());
- store.setSsUuid(primaryStorage.getUserInfo());
- if (cmd.getTemplateUrl() != null) {
- s_logger.debug("CreateCommand " + cmd.getTemplateUrl() + " "
- + dst);
- Linux host = new Linux(c);
- host.copyFile(cmd.getTemplateUrl(), dst);
- } else {
- /* this is a dup with the createVolume ? */
- s_logger.debug("CreateCommand " + dst);
- store.storagePluginCreate(primaryStorage.getUuid(),
- primaryStorage.getHost(),
- dst,
- disk.getSize());
- }
-
- store.storagePluginGetFileInfo(dst);
- VolumeTO volume = new VolumeTO(cmd.getVolumeId(), disk.getType(),
- primaryStorage.getType(), primaryStorage.getUuid(),
- primaryStorage.getPath(), fileName, store.getFileName(),
- store.getFileSize(), null);
- return new CreateAnswer(cmd, volume);
- } catch (Exception e) {
- s_logger.debug("CreateCommand failed", e);
- return new CreateAnswer(cmd, e.getMessage());
- }
- }
-
- /*
- * Add rootdisk, datadisk and iso's
- */
- protected Boolean createVbds(Xen.Vm vm, VirtualMachineTO spec) {
- for (DiskTO volume : spec.getDisks()) {
- try {
- if (volume.getType() == Volume.Type.ROOT) {
- VolumeObjectTO vol = (VolumeObjectTO) volume.getData();
- DataStoreTO ds = (DataStoreTO) vol.getDataStore();
- String dsk = vol.getPath() + "/" + vol.getUuid() + ".raw";
- vm.addRootDisk(dsk);
- /* TODO: needs to be replaced by rootdiskuuid? */
- vm.setPrimaryPoolUuid(ds.getUuid());
- s_logger.debug("Adding root disk: " + dsk);
- } else if (volume.getType() == Volume.Type.ISO) {
- DataTO isoTO = volume.getData();
- if (isoTO.getPath() != null) {
- TemplateObjectTO template = (TemplateObjectTO) isoTO;
- DataStoreTO store = template.getDataStore();
- if (!(store instanceof NfsTO)) {
- throw new CloudRuntimeException(
- "unsupported protocol");
- }
- NfsTO nfsStore = (NfsTO) store;
- String secPoolUuid = setupSecondaryStorage(nfsStore
- .getUrl());
- String isoPath = this._ovmSec + File.separator
- + secPoolUuid + File.separator
- + template.getPath();
- // + template.getUuid() + ".iso";
- vm.addIso(isoPath);
- /* check if secondary storage is mounted */
- s_logger.debug("Adding ISO: " + isoPath);
- }
- } else if (volume.getType() == Volume.Type.DATADISK) {
- vm.addDataDisk(volume.getData().getPath());
- s_logger.debug("Adding data disk: "
- + volume.getData().getPath());
- } else {
- throw new CloudRuntimeException("Unknown volume type: "
- + volume.getType());
- }
- } catch (Exception e) {
- s_logger.debug("CreateVbds failed", e);
- throw new CloudRuntimeException("Exception" + e.getMessage(), e);
- }
- }
- return true;
- }
-
- /* TODO: iptables/etables logic in the supporting libs ? */
- protected Boolean createVifs(Xen.Vm vm, VirtualMachineTO spec) {
- NicTO[] nics = spec.getNics();
- for (NicTO nic : nics) {
- if (nic.isSecurityGroupEnabled()) {
- if (spec.getType().equals(VirtualMachine.Type.User)) {
- /*
- * defaultNetworkRulesForUserVm(vmName, vmSpec.getId(),
- * nic);
- */
- }
- }
- try {
- if (getNetwork(nic) != null)
- vm.addVif(nic.getDeviceId(), getNetwork(nic), nic.getMac());
- } catch (Exception e) {
- String msg = "Unable to add vif " + nic.getType() + " for "
- + spec.getName() + " " + e.getMessage();
- s_logger.debug(msg);
- throw new CloudRuntimeException(msg);
- }
- }
- vm.setupVifs();
- return true;
- }
-
- /*
- * TODO: ovs calls ? depending on the type of network
- * TODO: get the bridge on a per VM base so we can throw it away?
- */
- private String createVlanBridge(String networkName, Integer vlanId)
- throws XmlRpcException {
- if (vlanId < 2 || vlanId > 4094) {
- throw new CloudRuntimeException("Vlan " + vlanId
- + " needs to be between 1-4095");
- }
- Network net = new Network(c);
- /* figure out if our bridged vlan exists, if not then create */
- String brName = networkName + "." + vlanId.toString();
- try {
- String physInterface = net.getPhysicalByBridgeName(networkName);
- String physVlanInt = physInterface + "." + vlanId;
-
- if (net.getInterfaceByName(physVlanInt) == null)
- net.startOvsVlanConfig(physInterface, vlanId);
-
- if (net.getInterfaceByName(brName) == null)
- net.startOvsBrConfig(brName, physVlanInt);
- } catch (Exception e) {
- throw new CloudRuntimeException("Unable to create vlan "
- + vlanId.toString() + " bridge for " + networkName
- + e.getMessage());
- }
- return brName;
- }
-
- // TODO: complete all network support
- protected String getNetwork(NicTO nic) throws XmlRpcException {
- String vlanId = null;
- String bridgeName = null;
- if (nic.getBroadcastType() == BroadcastDomainType.Vlan) {
- vlanId = BroadcastDomainType.getValue(nic.getBroadcastUri());
- }
-
- if (nic.getType() == TrafficType.Guest) {
- if (nic.getBroadcastType() == BroadcastDomainType.Vlan
- && !vlanId.equalsIgnoreCase("untagged")) {
- bridgeName = createVlanBridge(_guestNetworkName,
- Integer.valueOf(vlanId));
- } else {
- bridgeName = _guestNetworkName;
- }
- } else if (nic.getType() == TrafficType.Control) {
- bridgeName = _controlNetworkName;
- } else if (nic.getType() == TrafficType.Public) {
- bridgeName = _publicNetworkName;
- } else if (nic.getType() == TrafficType.Management) {
- bridgeName = _privateNetworkName;
- } else if (nic.getType() == TrafficType.Storage) {
- /* TODO: Add storage network */
- bridgeName = _storageNetworkName;
- } else {
- throw new CloudRuntimeException("Unknown network traffic type:"
- + nic.getType());
- }
- return bridgeName;
- }
-
- /* This is not create for us, but really start */
- protected boolean startVm(String repoId, String vmId)
- throws XmlRpcException {
- Xen host = new Xen(c);
- try {
- if (host.getRunningVmConfig(vmId) == null) {
- s_logger.error("Create VM " + vmId + " first on " + c.getIp());
- return false;
- } else {
- s_logger.info("VM " + vmId + " exists on " + c.getIp());
- }
- host.startVm(repoId, vmId);
- } catch (Exception e) {
- s_logger.error("Failed to start VM " + vmId + " on " + c.getIp()
- + " " + e.getMessage());
- return false;
- }
- return true;
- }
-
- /*
- * TODO: OVM already cleans stuff up, just not the extra bridges which we
- * don't want right now, as we'd have to keep a state table of which vlans
- * need to stay on the host!?
- * A map with vlanid -> list-o-hosts
- */
- private void cleanupNetwork(List vifs) throws XmlRpcException {
- /* peel out vif info for vlan stuff */
- /*
- * for (String vif : vifs) { if (vif.bridge.startsWith("vlan")) {
- * Network net = new Network(c); net.ovsVlanBridgeStop(br, net, vlan);
- * // Ovm3Bridge.deleteVlanBridge(_conn, vif.bridge); } }
- */
- }
-
- protected void cleanup(Xen.Vm vm) {
- try {
- cleanupNetwork(vm.getVmVifs());
- } catch (XmlRpcException e) {
- s_logger.debug("Clean up network for " + vm.getVmName() + " failed",
- e);
- }
- String vmName = vm.getVmName();
- /* should become a single entity */
- this._vmStats.remove(vmName);
- }
-
- /*
- * TODO: The actual VM provisioning start to end, we can rip this from our
- * simple stuff
- */
- @Override
- public synchronized StartAnswer execute(StartCommand cmd) {
- VirtualMachineTO vmSpec = cmd.getVirtualMachine();
- String vmName = vmSpec.getName();
- State state = State.Stopped;
- Xen xen = new Xen(c);
-
- try {
- synchronized (this._vmstates) {
- this._vmstates.put(vmName, State.Starting);
- }
- Xen.Vm vm = xen.getVmConfig();
- /* max and min ? */
- vm.setVmCpus(vmSpec.getCpus());
- /* in mb not in bytes */
- vm.setVmMemory(vmSpec.getMinRam() / 1024 / 1024);
- vm.setVmUuid(UUID.nameUUIDFromBytes(vmSpec.getName().getBytes())
- .toString());
- vm.setVmName(vmName);
- String domType = Ovm3Helper.getOvm3GuestType(vmSpec.getOs());
- if (domType == null || domType.equals("")) {
- domType = "default";
- s_logger.debug("VM Virt type missing setting to: " + domType);
- } else {
- s_logger.debug("VM Virt type set to " + domType + " for "
- + vmSpec.getOs());
- }
- vm.setVmDomainType(domType);
- /* only for none user VMs? */
- vm.setVmExtra(vmSpec.getBootArgs().replace(" ", "%"));
-
- /* TODO: booting from CD... */
- if (vmSpec.getBootloader() == BootloaderType.CD) {
- // do something with this please...
- }
- /*
- * officially CD boot is only supported on HVM, although there is a
- * simple way around it..
- */
- /* TODO: pool uuid now comes from here should change! */
- createVbds(vm, vmSpec);
-
- if (vmSpec.getType() != VirtualMachine.Type.User) {
- String svmPath = _ovmRepo + "/"
- + _ovmObject.deDash(vm.getPrimaryPoolUuid()) + "/ISOs";
- String svmIso = svmPath + "/"
- + getSystemVMIsoFileNameOnDatastore();
- vm.addIso(svmIso);
- }
- /* TODO: OVS should go here! */
- createVifs(vm, vmSpec);
-
- /* vm migration requires a 0.0.0.0 bind */
- vm.setVncPassword(vmSpec.getVncPassword());
- vm.setVncAddress("0.0.0.0");
- vm.setVnc();
-
- /* this should be getVmRootDiskPoolId ? */
- xen.createVm(_ovmObject.deDash(vm.getPrimaryPoolUuid()),
- vm.getVmUuid());
- xen.startVm(_ovmObject.deDash(vm.getPrimaryPoolUuid()),
- vm.getVmUuid());
- state = State.Running;
-
- if (vmSpec.getType() != VirtualMachine.Type.User) {
- String controlIp = null;
- for (NicTO nic : vmSpec.getNics()) {
- if (nic.getType() == TrafficType.Control) {
- controlIp = nic.getIp();
- }
- }
-
- try {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- for (int count = 0; count < 60; count++) {
- Boolean res = cSp.domrCheckSsh(controlIp);
- s_logger.debug("connected to " + controlIp
- + " on attempt " + count + " result: " + res);
- Thread.sleep(5000);
- if (res) {
- break;
- }
- /*
- * Older xend issues in, took me a while to figure this
- * out:
- * ../xen/xend/XendConstants.py
- * """Minimum time between domain restarts in seconds."""
- * MINIMUM_RESTART_TIME = 60
- * this does NOT work!!!--^^ as we respawn within 30
- * seconds easily.
- * return state stopped.
- */
- if (_vmstates.get(vmName) == null) {
- String msg = "VM " + vmName + " went missing on "
- + _host + ", returning stopped";
- s_logger.debug(msg);
- state = State.Stopped;
- return new StartAnswer(cmd, msg);
- }
- }
- } catch (Exception x) {
- s_logger.debug("unable to connect to " + controlIp + " "
- + x.getMessage());
- }
- }
- /*
- * TODO: Can't remember if HA worked if we were only a pool ?
- */
- if (_ovm3pool && _ovm3cluster) {
- xen.configureVmHa(_ovmObject.deDash(vm.getPrimaryPoolUuid()),
- vm.getVmUuid(),
- true);
- }
- /* should be starting no ? */
- state = State.Running;
- return new StartAnswer(cmd);
- } catch (Exception e) {
- s_logger.debug("Start vm " + vmName + " failed", e);
- state = State.Stopped;
- // cleanup(vmDetails);
- return new StartAnswer(cmd, e.getMessage());
- } finally {
- synchronized (this._vmstates) {
- // FIXME: where to come to Stopped???
- this._vmstates.put(vmName, state);
- }
- }
- }
-
- /* split out domr stuff later */
- private GetDomRVersionAnswer execute(GetDomRVersionCmd cmd) {
- String args = this.DefaultDomRPath + "get_template_version.sh";
- String ip = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- try {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- CloudStackPlugin.ReturnCode result;
- result = cSp.domrExec(ip, args);
- if (!result.getRc() || result.getStdOut().isEmpty()) {
- return new GetDomRVersionAnswer(cmd, "getDomRVersionCmd failed");
- }
- String domResp = result.getStdOut();
- String[] lines = domResp.split("&");
- if (lines.length != 2) {
- return new GetDomRVersionAnswer(cmd, domResp);
- }
- return new GetDomRVersionAnswer(cmd, domResp, lines[0], lines[1]);
- } catch (Exception e) {
- return new GetDomRVersionAnswer(cmd, "getDomRVersionCmd "
- + e.getMessage());
- }
- }
-
- private Answer giveDomRAns(Command cmd, String ip, String args, String resp) {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- try {
- CloudStackPlugin.ReturnCode result = cSp.domrExec(ip, args);
- if (!result.getRc()) {
- return new Answer(cmd, false, result.getStdOut());
- }
- } catch (Exception e) {
- return new Answer(cmd, false, e.getMessage());
- }
- return new Answer(cmd);
- }
-
- protected synchronized Answer execute(final DhcpEntryCommand cmd) {
- String args = this.DefaultDomRPath + "edithosts.sh";
- String ip = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- if (cmd.getVmIpAddress() != null) {
- args += " -4 " + cmd.getVmIpAddress();
- }
- args += " -m " + cmd.getVmMac();
- args += " -n " + cmd.getVmName();
- if (cmd.getDefaultRouter() != null) {
- args += " -d " + cmd.getDefaultRouter();
- }
- if (cmd.getStaticRoutes() != null) {
- args += " -s " + cmd.getStaticRoutes();
- }
-
- if (cmd.getDefaultDns() != null) {
- args += " -N " + cmd.getDefaultDns();
- }
-
- if (cmd.getVmIp6Address() != null) {
- args += " -6 " + cmd.getVmIp6Address();
- args += " -u " + cmd.getDuid();
- }
-
- if (!cmd.isDefault()) {
- args += " -z";
- }
-
- return giveDomRAns(cmd, ip, args, "DhcpEntry failed");
- }
-
- protected Answer execute(final SavePasswordCommand cmd) {
- final String password = cmd.getPassword();
- final String ip = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- final String vmIpAddress = cmd.getVmIpAddress();
- String args = this.DefaultDomRPath + "savepassword.sh ";
- args += " -v " + vmIpAddress;
- args += " -p " + password;
- return giveDomRAns(cmd, ip, args, "SavePassword failed");
- }
-
- protected Answer execute(final VmDataCommand cmd) {
- String ip = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- Map> data = new HashMap>();
- data.put(cmd.getVmIpAddress(), cmd.getVmData());
- String json = new Gson().toJson(data);
- json = Base64.encodeBase64String(json.getBytes());
- String args = this.DefaultDomRPath + "vmdata.py -d " + json;
- return giveDomRAns(cmd, ip, args, "Set vm_data failed");
- }
-
- /*
- * we don't for now, gave an error on migration though....
- */
- private Answer execute(NetworkRulesSystemVmCommand cmd) {
- boolean success = true;
- if (_canBridgeFirewall) {
- // meh
- }
- return new Answer(cmd, success, "");
- }
-
- public CheckSshAnswer execute(CheckSshCommand cmd) {
- String vmName = cmd.getName();
- String privateIp = cmd.getIp();
- int cmdPort = cmd.getPort();
- int interval = cmd.getInterval();
- int retries = cmd.getRetries();
-
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Trying port " + privateIp + ":" + cmdPort);
- }
- try {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- if (!cSp.domrCheckPort(privateIp, cmdPort, retries, interval)) {
- s_logger.info(vmName + ":" + cmdPort + " nok");
- return new CheckSshAnswer(cmd, "unable to connect");
- }
- s_logger.info(vmName + ":" + cmdPort + " ok");
- } catch (Exception e) {
- s_logger.error("Can not reach port on System vm " + vmName
- + " due to exception", e);
- return new CheckSshAnswer(cmd, e);
- }
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Ping command port succeeded for vm " + vmName + " "
- + cmd);
- }
- if (VirtualMachineName.isValidRouterName(vmName)) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Execute network usage setup command on "
- + vmName);
- }
- // TODO: check this one out...
- }
- return new CheckSshAnswer(cmd);
- }
-
- protected Answer execute(GetHostStatsCommand cmd) {
- try {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- Map stats = cSp.ovsDom0Stats(this._publicNetworkName);
- Double cpuUtil = Double.parseDouble(stats.get("cpu"));
- Double rxBytes = Double.parseDouble(stats.get("rx"));
- Double txBytes = Double.parseDouble(stats.get("tx"));
- Double totalMemory = Double.parseDouble(stats.get("total"));
- Double freeMemory = Double.parseDouble(stats.get("free"));
- HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(),
- cpuUtil, rxBytes, txBytes, "host", totalMemory, freeMemory,
- 0, 0);
- return new GetHostStatsAnswer(cmd, hostStats);
- } catch (Exception e) {
- s_logger.debug("Get host stats of " + cmd.getHostName() + " failed",
- e);
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- /* TODO: Stop the VM, this means cleanup too, should this be destroy ? */
- @Override
- public StopAnswer execute(StopCommand cmd) {
- String vmName = cmd.getVmName();
- State state = State.Error;
- synchronized (this._vmstates) {
- state = _vmstates.get(vmName);
- this._vmstates.put(vmName, State.Stopping);
- }
-
- try {
- Xen vms = new Xen(c);
- Xen.Vm vm = null;
- vm = vms.getRunningVmConfig(vmName);
-
- if (vm == null) {
- state = State.Stopping;
- s_logger.debug("Unable to get details of vm: " + vmName
- + ", treating it as Stopping");
- return new StopAnswer(cmd, "success", true);
- }
- String repoId = _ovmObject.deDash(vm.getVmRootDiskPoolId());
- String vmId = vm.getVmUuid();
-
- /* can we do without the poolId ? */
- vms.stopVm(repoId, vmId);
- int tries = 30;
- while (vms.getRunningVmConfig(vmName) != null && tries > 0) {
- String msg = "Waiting for " + vmName + " to stop";
- s_logger.debug(msg);
- tries--;
- Thread.sleep(10 * 1000);
- }
- vms.deleteVm(repoId, vmId);
- /* TODO: Check cleanup */
- this.cleanup(vm);
-
- if (vms.getRunningVmConfig(vmName) != null) {
- String msg = "Stop " + vmName + " failed ";
- s_logger.debug(msg);
- return new StopAnswer(cmd, msg, false);
- }
- state = State.Stopped;
- return new StopAnswer(cmd, "success", true);
- } catch (Exception e) {
- /* TODO: check output of message, might be that it did get removed */
- s_logger.debug("Stop " + vmName + " failed ", e);
- return new StopAnswer(cmd, e.getMessage(), false);
- } finally {
- synchronized (this._vmstates) {
- if (state != null) {
- this._vmstates.put(vmName, state);
- } else {
- this._vmstates.remove(vmName);
- }
- }
- }
- }
-
- /* Reboot the VM and destroy should call the same method in here ? */
- @Override
- public RebootAnswer execute(RebootCommand cmd) {
- String vmName = cmd.getVmName();
-
- synchronized (this._vmstates) {
- this._vmstates.put(vmName, State.Starting);
- }
-
- try {
- Xen xen = new Xen(c);
- Xen.Vm vm = xen.getRunningVmConfig(vmName);
- /* TODO: stop, start or reboot, reboot for now ? */
- xen.rebootVm(_ovmObject.deDash(vm.getVmRootDiskPoolId()),
- vm.getVmUuid());
- vm = xen.getRunningVmConfig(vmName);
- /* erh but this don't work, should point at cloudstackplugin */
- Integer vncPort = vm.getVncPort();
- return new RebootAnswer(cmd, null, vncPort);
- } catch (Exception e) {
- s_logger.debug("Reboot " + vmName + " failed", e);
- return new RebootAnswer(cmd, e.getMessage(), false);
- } finally {
- synchronized (this._vmstates) {
- this._vmstates.put(cmd.getVmName(), State.Running);
- }
- }
- }
-
- protected State convertPowerToState(PowerState ps) {
- final State state = s_stateMaps.get(ps.toString());
- return state == null ? State.Unknown : state;
- }
-
- private static PowerState convertStateToPower(State s) {
- final PowerState state = s_powerStateMaps.get(s.toString());
- return state == null ? PowerState.PowerUnknown : state;
- }
-
- /* State to power in the states */
- protected Map HostVmStateReport()
- throws XmlRpcException {
- final HashMap vmStates = new HashMap();
- Map vms = sync();
- for (final Map.Entry vm : vms.entrySet()) {
- /* TODO: Figure out how to get xentools version in here */
- s_logger.debug("VM " + vm.getKey() + " state: " + vm.getValue()
- + ":" + convertStateToPower(vm.getValue()));
- vmStates.put(vm.getKey(), new HostVmStateReportEntry(
- convertStateToPower(vm.getValue()), c.getIp(), null));
- }
- return vmStates;
- }
-
- /* uses the running configuration, not the vm.cfg configuration */
- protected Map getAllVms() throws XmlRpcException {
- try {
- Xen vms = new Xen(c);
- return vms.getRunningVmConfigs();
- } catch (Exception e) {
- s_logger.debug("getting VM list from " + _host + " failed", e);
- throw new CloudRuntimeException("Exception on getting VMs from "
- + _host + ":" + e.getMessage(), e);
- }
- }
-
- /*
- * Get all the states and set them up according to xm(1)
- * TODO: check migrating ?
- */
- protected HashMap getAllVmStates() throws XmlRpcException {
- Map vms = getAllVms();
- final HashMap states = new HashMap();
- for (final Map.Entry entry : vms.entrySet()) {
- Xen.Vm vm = entry.getValue();
- if (vm.isControlDomain()) {
- continue;
- }
- State ns = State.Running;
- String as = vm.getVmState();
- /* missing VM is stopped */
- if (as == null) {
- ns = State.Stopped;
- continue;
- }
- /* The domain is currently running on a CPU */
- /* need a more exact match! */
- if (as.contains("r")) {
- ns = State.Running;
- /* The domain is blocked, and not running or runnable. */
- } else if (as.contains("b")) {
- ns = State.Running;
- /* The domain has been paused */
- } else if (as.contains("p")) {
- ns = State.Running;
- /* The guest has requested to be shutdown, still migrating... */
- } else if (as.contains("s")) {
- if (this._vmstates.get(vm.getVmName()) == State.Migrating)
- ns = State.Migrating;
- ns = State.Stopped;
- /* The domain has crashed */
- } else if (as.contains("c")) {
- ns = State.Error;
- /*
- * The domain is in process of dying (if we see this twice we
- * have a problem ?)
- */
- } else if (as.contains("d")) {
- ns = State.Stopping;
- } else {
- ns = State.Unknown;
- }
- s_logger.debug("state " + ns + " for " + vm.getVmName()
- + " based on " + as);
- states.put(vm.getVmName(), ns);
- }
- return states;
- }
-
- /* sync the state we know of with reality */
- protected HashMap sync() {
- HashMap newStates;
- HashMap oldStates = null;
-
- try {
- final HashMap changes = new HashMap();
- newStates = getAllVmStates();
- if (newStates == null) {
- s_logger.debug("Unable to get the vm states so no state sync at this point.");
- return null;
- }
-
- synchronized (_vmstates) {
- oldStates = new HashMap(_vmstates.size());
- oldStates.putAll(_vmstates);
-
- for (final Map.Entry entry : newStates
- .entrySet()) {
- final String vmName = entry.getKey();
- State newState = entry.getValue();
- final State oldState = oldStates.remove(vmName);
- s_logger.debug("state for " + vmName + ", old: " + oldState
- + ", new: " + newState);
-
- /* eurh ? */
- if (newState == State.Stopped && oldState != State.Stopping
- && oldState != null && oldState != State.Stopped) {
- s_logger.debug("Getting power state....");
- newState = State.Running;
- }
-
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("VM "
- + vmName
- + ": ovm has state "
- + newState
- + " and we have state "
- + (oldState != null ? oldState.toString()
- : "null"));
- }
-
- /* TODO: is this really true ? should be right ? */
- if (newState == State.Migrating) {
- s_logger.debug(vmName
- + " is migrating, skipping state check");
- continue;
- }
-
- if (oldState == null) {
- _vmstates.put(vmName, newState);
- s_logger.debug("New state without old state: " + vmName);
- changes.put(vmName, newState);
- } else if (oldState == State.Starting) {
- if (newState == State.Running) {
- _vmstates.put(vmName, newState);
- } else if (newState == State.Stopped) {
- s_logger.debug("Ignoring vm " + vmName
- + " because of a lag in starting the vm.");
- }
- } else if (oldState == State.Migrating) {
- if (newState == State.Running) {
- s_logger.debug("Detected that a migrating VM is now running: "
- + vmName);
- _vmstates.put(vmName, newState);
- }
- } else if (oldState == State.Stopping) {
- if (newState == State.Stopped) {
- _vmstates.put(vmName, newState);
- } else if (newState == State.Running) {
- s_logger.debug("Ignoring vm " + vmName
- + " because of a lag in stopping the vm. ");
- }
- } else if (oldState != newState) {
- _vmstates.put(vmName, newState);
- if (newState == State.Stopped) {
- // TODO: need to state.error here ?
- }
- changes.put(vmName, newState);
- }
- }
-
- for (final Map.Entry entry : oldStates
- .entrySet()) {
- final String vmName = entry.getKey();
- final State oldState = entry.getValue();
-
- if (oldState == State.Stopping) {
- s_logger.debug("Removing VM " + vmName
- + " in transition state stopping.");
- _vmstates.remove(vmName);
- } else if (oldState == State.Starting) {
- s_logger.debug("Removing VM " + vmName
- + " in transition state starting.");
- _vmstates.remove(vmName);
- } else if (oldState == State.Stopped) {
- s_logger.debug("Stopped VM " + vmName + " removing.");
- _vmstates.remove(vmName);
- } else if (oldState == State.Migrating) {
- /*
- * do something smarter here.. newstate should
- * say stopping already
- */
- s_logger.debug("Ignoring VM " + vmName
- + " in migrating state.");
- } else {
- /* if it's not there name it stopping */
- _vmstates.remove(vmName);
- State state = State.Stopping;
- s_logger.debug("VM "
- + vmName
- + " is now missing from ovm3 server so removing it");
- /* TODO: something about killed/halted VM's in here ? */
- changes.put(vmName, state);
- }
- }
- }
-
- return changes;
- } catch (Exception e) {
- s_logger.debug("Ovm3 full sync failed", e);
- return null;
- }
- }
-
- /* cleanup the storageplugin so we can use an object here */
- protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
- // cmd.getStorageId();
- s_logger.debug("Getting stats for: " + cmd.getStorageId());
- try {
- Linux host = new Linux(c);
- /* TODO: NFS only for now */
- Map fsList = host
- .getFileSystemList("nfs");
- Linux.FileSystem fs = fsList.get(cmd.getStorageId());
- StoragePlugin store = new StoragePlugin(c);
- /*
- * TODO: something odd here where do I get which Storage I need to
- * look at ?
- */
- String propUuid = store.deDash(cmd.getStorageId());
- String mntUuid = cmd.getStorageId();
- store.setUuid(propUuid);
- store.setSsUuid(propUuid);
- store.setMntUuid(mntUuid);
- store.setFsHost(fs.getHost());
- store.setFsSourcePath(fs.getDevice());
- store.storagePluginGetFileSystemInfo();
- long total = Long.parseLong(store.getTotalSize());
- long used = total - Long.parseLong(store.getFreeSize());
- return new GetStorageStatsAnswer(cmd, total, used);
- } catch (Exception e) {
- s_logger.debug("GetStorageStatsCommand on pool "
- + cmd.getStorageId() + " failed",
- e);
- return new GetStorageStatsAnswer(cmd, e.getMessage());
- }
- }
-
- private VmStatsEntry getVmStat(String vmName) throws XmlRpcException {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- Map stats = cSp.ovsDomUStats(vmName);
- Map o_stats = this._vmStats.get(vmName);
- VmStatsEntry e = new VmStatsEntry();
- if (o_stats == null) {
- e.setNumCPUs(1);
- e.setNetworkReadKBs(0);
- e.setNetworkWriteKBs(0);
- e.setDiskReadKBs(0);
- e.setDiskWriteKBs(0);
- e.setDiskReadIOs(0);
- e.setDiskWriteIOs(0);
- e.setCPUUtilization(0);
- e.setEntityType("vm");
- } else {
- /* beware of negatives ? */
- Integer cpus = Integer.parseInt(stats.get("vcpus"));
- e.setNumCPUs(Integer.parseInt(stats.get(cpus)));
- e.setNetworkReadKBs(Double.parseDouble(stats.get("rx_bytes"))
- - Double.parseDouble(o_stats.get("rx_bytes")));
- e.setNetworkWriteKBs(Double.parseDouble(stats.get("tx_bytes"))
- - Double.parseDouble(o_stats.get("tx_bytes")));;
- e.setDiskReadKBs(Double.parseDouble(stats.get("rd_bytes"))
- - Double.parseDouble(o_stats.get("rd_bytes")));;
- e.setDiskWriteKBs(Double.parseDouble(stats.get("rw_bytes"))
- - Double.parseDouble(o_stats.get("rw_bytes")));
- e.setDiskReadIOs(Double.parseDouble(stats.get("rd_ops"))
- - Double.parseDouble(o_stats.get("rd_ops")));
- e.setDiskWriteIOs(Double.parseDouble(stats.get("rw_ops"))
- - Double.parseDouble(o_stats.get("rw_ops")));
-
- Double d_cpu = Double.parseDouble(stats.get("cputime"))
- - Double.parseDouble(o_stats.get("cputime"));
- Double d_time = Double.parseDouble(stats.get("uptime"))
- - Double.parseDouble(o_stats.get("uptime"));
- Double cpupct = d_cpu/d_time * 100 * cpus;
- e.setCPUUtilization(cpupct);
- e.setEntityType("vm");
- }
- this._vmStats.replace(vmName, stats);
- return e;
- }
-
- /* TODO: The main caller for vm statstics */
- protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) {
- List vmNames = cmd.getVmNames();
- HashMap vmStatsNameMap = new HashMap();
- for (String vmName : vmNames) {
- try {
- VmStatsEntry e = getVmStat(vmName);
- vmStatsNameMap.put(vmName, e);
- } catch (XmlRpcException e) {
- s_logger.debug("Get vm stat for " + vmName + " failed", e);
- continue;
- }
- }
- return new GetVmStatsAnswer(cmd, vmStatsNameMap);
- }
-
- /* TODO: Hot plugging harddisks... */
- protected AttachVolumeAnswer execute(AttachVolumeCommand cmd) {
- return new AttachVolumeAnswer(cmd, "You must stop " + cmd.getVmName()
- + " first, OVM doesn't support hotplug datadisk");
- }
-
- /* Destroy a volume (image) */
- public Answer execute(DestroyCommand cmd) {
- VolumeTO vol = cmd.getVolume();
- String vmName = cmd.getVmName();
- try {
- StoragePlugin store = new StoragePlugin(c);
- // TODO: check if path is correct...
- store.storagePluginDestroy(vol.getPoolUuid(), vol.getPath());
- return new Answer(cmd, true, "Success");
- } catch (Exception e) {
- s_logger.debug("Destroy volume " + vol.getName() + " failed for "
- + vmName + " ", e);
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- /* Migration should make sure both HVs are the same ? */
- protected PrepareForMigrationAnswer execute(PrepareForMigrationCommand cmd) {
- VirtualMachineTO vm = cmd.getVirtualMachine();
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Preparing host for migrating " + vm.getName());
- }
- /* securitygroups */
- try {
- synchronized (_vmstates) {
- _vmstates.put(vm.getName(), State.Migrating);
- }
- return new PrepareForMigrationAnswer(cmd);
- } catch (Exception e) {
- s_logger.warn("Catch Exception " + e.getClass().getName()
- + " prepare for migration failed due to " + e.toString(), e);
- return new PrepareForMigrationAnswer(cmd, e);
- }
- }
-
- /* do migrations of VMs in a simple way just inside a cluster for now */
- protected MigrateAnswer execute(final MigrateCommand cmd) {
- final String vmName = cmd.getVmName();
- String destUuid = cmd.getHostGuid();
- String destIp = cmd.getDestinationIp();
- State state = State.Error;
- /*
- * TODO: figure out non pooled migration, works from CLI but not from
- * the agent... perhaps pause the VM and then migrate it ? for now
- * just stop the VM.
- */
- String msg = "Migrating " + vmName + " to " + destIp;
- s_logger.info(msg);
- if (!this._ovm3cluster && !this._ovm3pool) {
- try {
- Xen xen = new Xen(c);
- Xen.Vm vm = xen.getRunningVmConfig(vmName);
- HostVO destHost = _resourceMgr.findHostByGuid(destUuid);
- if (destHost == null) {
- msg = "Unable to find migration target host in DB "
- + destUuid + " with ip " + destIp;
- s_logger.info(msg);
- return new MigrateAnswer(cmd, false, msg, null);
- }
- xen.stopVm(_ovmObject.deDash(vm.getVmRootDiskPoolId()),
- vm.getVmUuid());
- msg = destHost.toString();
- state = State.Stopping;
- return new MigrateAnswer(cmd, false, msg, null);
- } catch (Exception e) {
- msg = "Unpooled VM Migrate of " + vmName + " to " + destUuid
- + " failed due to: " + e.getMessage();
- s_logger.debug(msg, e);
- return new MigrateAnswer(cmd, false, msg, null);
- } finally {
- /* shouldn't we just reinitialize completely as a last resort ? */
- synchronized (_vmstates) {
- _vmstates.put(vmName, state);
- }
- }
- } else {
- try {
- Xen xen = new Xen(c);
- Xen.Vm vm = xen.getRunningVmConfig(vmName);
- if (vm == null) {
- state = State.Stopped;
- msg = vmName + " is no running on " + _host;
- return new MigrateAnswer(cmd, false, msg, null);
- }
- /* not a storage migration!!! */
- xen.migrateVm(_ovmObject.deDash(vm.getVmRootDiskPoolId()),
- vm.getVmUuid(),
- destIp);
- state = State.Stopping;
- msg = "Migration of " + vmName + " successfull";
- return new MigrateAnswer(cmd, true, msg, null);
- } catch (Exception e) {
- msg = "Pooled VM Migrate" + ": Migration of " + vmName + " to "
- + destIp + " failed due to " + e.getMessage();
- s_logger.debug(msg, e);
- return new MigrateAnswer(cmd, false, msg, null);
- } finally {
- /* if (state != state.Stopped) { */
- synchronized (_vmstates) {
- _vmstates.put(vmName, state);
- }
- }
- }
- }
-
- /* hHeck "the" virtual machine */
- protected CheckVirtualMachineAnswer execute(
- final CheckVirtualMachineCommand cmd) {
- String vmName = cmd.getVmName();
- try {
- // if state migrating skip ?
- Xen vms = new Xen(c);
- Xen.Vm vm = vms.getRunningVmConfig(vmName);
- /* check if there is a VM */
-
- CloudStackPlugin plug = new CloudStackPlugin(c);
- Integer vncPort = Integer.valueOf(plug.getVncPort(vmName));
- if (vncPort == 0) {
- s_logger.warn("No VNC port for " + vmName);
- }
- /* we already have the state ftw */
- Map states = getAllVmStates();
- State vmState = states.get(vmName);
- if (vmState == null) {
- s_logger.warn("Check state of " + vmName
- + " return null in CheckVirtualMachineCommand");
- vmState = State.Stopped;
- }
- synchronized (_vmstates) {
- _vmstates.put(vmName, State.Running);
- }
- return new CheckVirtualMachineAnswer(cmd, vmState, vncPort);
- } catch (Exception e) {
- s_logger.debug("Check migration for " + vmName + " failed", e);
- return new CheckVirtualMachineAnswer(cmd, State.Stopped, null);
- }
- }
-
- /* TODO: fill this one, for maintenance */
- protected MaintainAnswer execute(MaintainCommand cmd) {
- /* leave cluster, leave pool, release ownership ? */
- try {
- Network net = new Network(c);
- Pool pool = new Pool(c);
- // pool.leaveServerPool();
- net.stopOvsLocalConfig(_controlNetworkName);
- } catch (Exception e) {
- s_logger.debug("unable to disable " + _controlNetworkName);
- }
- return new MaintainAnswer(cmd);
- }
-
- /*
- */
- protected GetVncPortAnswer execute(GetVncPortCommand cmd) {
- try {
- Xen host = new Xen(c);
- Xen.Vm vm = host.getRunningVmConfig(cmd.getName());
- Integer vncPort = vm.getVncPort();
- s_logger.debug("get vnc port for " + cmd.getName() + ": " + vncPort);
- return new GetVncPortAnswer(cmd, _ip, vncPort);
- } catch (Exception e) {
- s_logger.debug("get vnc port for " + cmd.getName() + " failed", e);
- return new GetVncPortAnswer(cmd, e.getMessage());
- }
- }
-
- protected Answer execute(PingTestCommand cmd) {
- try {
- if (cmd.getComputingHostIp() != null) {
- CloudStackPlugin cSp = new CloudStackPlugin(c);
- if (!cSp.ping(cmd.getComputingHostIp())) {
- return new Answer(cmd, false, "ping failed");
- }
- } else {
- return new Answer(cmd, false, "why asks me to ping router???");
- }
- return new Answer(cmd, true, "success");
- } catch (Exception e) {
- s_logger.debug("Ping " + cmd.getComputingHostIp() + " failed", e);
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- /*
- * TODO: no heartbeat if no cluster, should we add a heartbeat ?
- * cloudstack/plugins
- * /hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmHostModule.py contains
- * fence
- */
- protected FenceAnswer execute(FenceCommand cmd) {
- try {
- Boolean res = false;
- return new FenceAnswer(cmd, res, res.toString());
- } catch (Exception e) {
- s_logger.debug("fence " + cmd.getHostIp() + " failed", e);
- return new FenceAnswer(cmd, false, e.getMessage());
- }
- }
-
- /* TODO: nothing yet */
- protected boolean canBridgeFirewall() throws XmlRpcException {
- return false;
- }
-
- protected boolean prepareForPool() throws ConfigurationException {
- /* need single master uuid */
- try {
- Linux host = new Linux(c);
- Pool pool = new Pool(c);
-
- /* setup pool and role, needs utility to be able to do things */
- if (host.getServerRoles().contentEquals(pool.getValidRoles()
- .toString())) {
- s_logger.debug("Server role for host " + _host + " is ok");
- } else {
- try {
- pool.setServerRoles(pool.getValidRoles());
- } catch (Exception e) {
- s_logger.debug("Failed to set server role for host "
- + _host, e);
- throw new ConfigurationException(
- "Unable to set server role for host");
- }
- }
- if (host.getMembershipState().contentEquals("Unowned")) {
- try {
- s_logger.debug("Take ownership of host " + _host);
- pool.takeOwnership(_masterUuid, "");
- } catch (Exception e) {
- String msg = "Failed to take ownership of host " + _host;
- s_logger.debug(msg, e);
- throw new ConfigurationException(msg);
- }
- } else {
- /* TODO: check if it's part of our pool, give ok if it is */
- if (host.getManagerUuid().equals(_masterUuid)) {
- String msg = "Host " + _host + " owned by us";
- s_logger.debug(msg);
- return true;
- } else {
- String msg = "Host " + _host
- + " already part of a pool, and not owned by us";
- s_logger.debug(msg);
- throw new ConfigurationException(msg);
- }
- }
- } catch (Exception es) {
- String msg = "Failed to prepare " + _host + " for pool";
- s_logger.debug(msg, es);
- throw new ConfigurationException(msg + ": " + es.getMessage());
- }
- return true;
- }
-
- /*
- * TODO: redo this, it's a mess now.
- */
- protected Boolean setupPool(StorageFilerTO cmd)
- throws ConfigurationException, XmlRpcException, Exception {
- String primUuid = cmd.getUuid();
- String ssUuid = _ovmObject.deDash(primUuid);
- String ovsRepo = this._ovmRepo + "/" + _ovmObject.deDash(primUuid);
- String fsType = "nfs";
- /* TODO: 16, need to get this from the cluster id actually */
- String clusterUuid = _masterUuid.substring(0, 15);
- String managerId = _masterUuid;
- String poolAlias = cmd.getHost() + ":" + cmd.getPath();
- String mountPoint = String.format("%1$s:%2$s",
- cmd.getHost(),
- cmd.getPath()) +
- "/VirtualMachines";
- List members = new ArrayList();
- _isMaster = masterCheck();
- Integer poolSize = 0;
- String msg = "";
-
- try {
- Pool poolHost = new Pool(c);
- if (_isMaster && !poolHost.getPoolId().contentEquals(primUuid)
- && !_hasMaster) {
- PoolOCFS2 poolFs = new PoolOCFS2(c);
- try {
- try {
- msg = "Create poolfs on " + _host + " for repo "
- + primUuid;
- s_logger.debug(msg);
- poolFs.createPoolFs(fsType,
- mountPoint,
- clusterUuid,
- primUuid,
- ssUuid,
- managerId,
- primUuid);
- } catch (Exception e) {
- msg = "Poolfs already exists on " + _host
- + " for repo " + primUuid;
- s_logger.debug(msg);
- }
- try {
- poolHost.createServerPool(poolAlias,
- primUuid,
- _ovm3vip,
- poolSize + 1,
- _host,
- _ip);
- } catch (Exception e) {
- msg = "Server pool with id " + clusterUuid + " on "
- + _host;
- s_logger.debug(msg);
- }
- } catch (Exception e) {
- msg = "Failed to create pool on " + _host + " for repo "
- + primUuid;
- s_logger.debug(msg, e);
- throw new Exception(msg);
- }
- } else if (!_isMaster || _hasMaster) {
- Pool poolMaster = new Pool(m);
- poolSize = poolMaster.getPoolMemberIpList().size() + 1;
- members.addAll(poolMaster.getPoolMemberIpList());
-
- poolHost = new Pool(c);
- if (!poolHost.getPoolId().contentEquals(primUuid)) {
-
- /* get all the details from the master */
- try {
- /* why does it call bloody M here???!?!?!! */
- poolHost.joinServerPool(poolAlias,
- primUuid,
- _ovm3vip,
- poolSize,
- _host,
- _ip);
- } catch (Exception e) {
- msg = "Failed to join server pool "
- + poolMaster.getPoolAlias() + " on " + _host
- + " for pool " + primUuid;
- s_logger.debug(msg, e);
- throw new Exception(msg);
- }
- }
- } else {
- s_logger.debug("Pool " + primUuid + " already configured on "
- + _host);
- }
- if (!members.contains(_ip)) {
- members.add(_ip);
- }
- for (String member : members) {
- /* easy way out for now..., should get this from hostVO */
- String url = "http://" + this._agentUserName + ":"
- + this._agentPassword + "@" + member + ":" + _agentPort
- + "/api/3";
- /*
- * Common comCall = new Common(c);
- * comCall.dispatch(url,
- * "set_pool_member_ip_list",
- * StringUtils.join(members, ","));
- */
- Connection x = new Connection(member, _agentPort,
- _agentUserName, _agentPassword);
- Pool xpool = new Pool(x);
- xpool.setPoolIps(members);
- xpool.setPoolMemberIpList();
- msg = "Added " + member + " to pool " + primUuid;
- s_logger.debug(msg);
- }
- } catch (Exception e) {
- msg = "Failed to setup server pool on " + _host;
- s_logger.debug(msg, e);
- throw new Exception(msg);
- }
- return true;
- }
-
- /* the storage url combination of host and path is unique */
- protected String setupSecondaryStorage(String url) throws Exception {
- URI uri = URI.create(url);
- String uuid = _ovmObject.newUuid(uri.getHost() + ":" + uri.getPath());
- s_logger.info("Secondary storage with uuid: " + uuid);
- return setupNfsStorage(uri, uuid);
- }
-
- protected String setupNfsStorage(URI uri, String uuid) throws Exception {
- String fsUri = "nfs";
- String fsType = "FileSys";
- String msg = "";
- String mountPoint = this._ovmSec + "/" + uuid;
- Linux host = new Linux(c);
- try {
- Map fsList = host
- .getFileSystemList(fsUri);
- Linux.FileSystem fs = fsList.get(uuid);
- if (fs == null || !fs.getMountPoint().equals(mountPoint)) {
- try {
- StoragePlugin sp = new StoragePlugin(c);
- sp.storagePluginMount(uri.getHost(),
- uri.getPath(),
- uuid,
- mountPoint);
- msg = "Nfs storage " + uri + " mounted on " + mountPoint;
- return uuid;
- } catch (Exception ec) {
- msg = "Nfs storage " + uri + " mount on " + mountPoint
- + " FAILED " + ec.getMessage();
- throw new Exception(msg, ec);
- }
- } else {
- msg = "NFS storage " + uri + " already mounted on "
- + mountPoint;
- return uuid;
- }
- } finally {
- s_logger.debug(msg);
- }
- }
-
- /* TODO: move the connection elsewhere.... */
- protected boolean masterCheck() throws ConfigurationException, Exception {
- if (_ovm3vip.equals("")) {
- s_logger.debug("No cluster vip, not checking for master");
- return false;
- }
- try {
- /* should get the details of that host hmmz */
- m = new Connection(_ovm3vip, _agentPort, _agentUserName,
- _agentPassword);
- Linux master = new Linux(m);
- if (master.getHostName().equals(_host)) {
- s_logger.debug("Host " + _host + " is master");
- this._isMaster = true;
- } else {
- s_logger.debug("Host " + _host + " has master "
- + master.getHostName());
- _hasMaster = true;
- }
- } catch (Exception e) {
- this._isMaster = true;
- s_logger.debug("Unable to connect to master, we are master");
- } finally {
- if (!this._isMaster) {
- if (this._hasMaster) {
- s_logger.debug("Host " + _host + " will become a slave "
- + _ovm3vip);
- return this._isMaster;
- } else {
- this._isMaster = true;
- s_logger.debug("Host " + _host + " will become a master "
- + _ovm3vip);
- return this._isMaster;
- }
- }
- }
- return this._isMaster;
- }
-
- /* check if a VM is running should be added */
- protected CreatePrivateTemplateAnswer execute(
- final CreatePrivateTemplateFromVolumeCommand cmd) {
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- String volumePath = cmd.getVolumePath();
- Long accountId = cmd.getAccountId();
- Long templateId = cmd.getTemplateId();
- int wait = cmd.getWait();
- if (wait == 0) {
- /* Defaut timeout 2 hours */
- wait = 7200;
- }
-
- try {
- URI uri;
- uri = new URI(secondaryStorageUrl);
- String secondaryStorageMountPath = uri.getHost() + ":"
- + uri.getPath();
- /* missing uuid */
- String installPath = _ovmRepo + "/Templates/" + accountId + "/"
- + templateId;
- String templateLoc = installPath;
- Linux host = new Linux(c);
- /* check if VM is running or thrown an error, or pause it :P */
- host.copyFile(volumePath, installPath);
- /* TODO: look at the original */
- return new CreatePrivateTemplateAnswer(cmd, true, installPath);
- /*
- * res.get("installPath"), Long.valueOf(res.get("virtualSize")),
- * Long.valueOf(res.get("physicalSize")),
- * res.get("templateFileName"), ImageFormat.RAW);
- */
- } catch (Exception e) {
- s_logger.debug("Create template failed", e);
- return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage());
- }
- }
-
- /*
- * Might have some logic errors that's what debugging is for...
- */
- protected CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
- String volumePath = cmd.getVolumePath();
- /* is a repository */
- String secondaryStorageURL = cmd.getSecondaryStorageURL();
- int wait = cmd.getWait();
- if (wait == 0) {
- wait = 7200;
- }
-
- /* TODO: we need to figure out what sec and prim really is */
- try {
- Linux host = new Linux(c);
-
- /* to secondary storage */
- if (cmd.toSecondaryStorage()) {
- s_logger.debug("Copy to secondary storage " + volumePath
- + " to " + secondaryStorageURL);
- host.copyFile(volumePath, secondaryStorageURL);
- /* from secondary storage */
- } else {
- s_logger.debug("Copy from secondary storage "
- + secondaryStorageURL + " to " + volumePath);
- host.copyFile(secondaryStorageURL, volumePath);
- }
- /* check the truth of this */
- return new CopyVolumeAnswer(cmd, true, null, null, null);
- } catch (Exception e) {
- s_logger.debug("Copy volume failed", e);
- return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
- }
- }
-
- /*
- * TODO: this ties into if we're in a cluster or just a pool, leaving a pool
- * means just leaving the pool and getting rid of the pooled fs, different a
- * repo though
- */
- protected Answer execute(DeleteStoragePoolCommand cmd) {
- try {
- Pool pool = new Pool(c);
- pool.leaveServerPool(cmd.getPool().getUuid());
- /* also connect to the master and update the pool list ? */
- } catch (Exception e) {
- s_logger.debug("Delete storage pool on host "
- + _host
- + " failed, however, we leave to user for cleanup and tell managment server it succeeded",
- e);
- }
-
- return new Answer(cmd);
- }
-
- /* TODO: check getPhysicalNetworkInfoList */
- /*
- * need to refactor this bit, networksetupbyname makes no sense, and neither
- * does the physical bit
- */
- protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Checking if network name setup is done on " + _host);
- }
-
- List infoList = cmd
- .getPhysicalNetworkInfoList();
- boolean errorout = false;
- String msg = "";
- /* here we assume all networks are set */
- for (PhysicalNetworkSetupInfo info : infoList) {
- if (info.getGuestNetworkName() == null)
- info.setGuestNetworkName(this._guestNetworkName);
- if (info.getPublicNetworkName() == null)
- info.setPublicNetworkName(this._publicNetworkName);
- if (info.getPrivateNetworkName() == null)
- info.setPrivateNetworkName(this._privateNetworkName);
- if (info.getStorageNetworkName() == null)
- info.setStorageNetworkName(this._storageNetworkName);
-
- if (!isNetworkSetupByName(info.getGuestNetworkName())) {
- msg = "For Physical Network id:"
- + info.getPhysicalNetworkId()
- + ", Guest Network is not configured on the backend by name "
- + info.getGuestNetworkName();
- errorout = true;
- break;
- }
- if (!isNetworkSetupByName(info.getPrivateNetworkName())) {
- msg = "For Physical Network id:"
- + info.getPhysicalNetworkId()
- + ", Private Network is not configured on the backend by name "
- + info.getPrivateNetworkName();
- errorout = true;
- break;
- }
- if (!isNetworkSetupByName(info.getPublicNetworkName())) {
- msg = "For Physical Network id:"
- + info.getPhysicalNetworkId()
- + ", Public Network is not configured on the backend by name "
- + info.getPublicNetworkName();
- errorout = true;
- break;
- }
- /* Storage network is optional, will revert to private otherwise */
- }
-
- if (errorout) {
- s_logger.error(msg);
- return new CheckNetworkAnswer(cmd, false, msg);
- } else {
- return new CheckNetworkAnswer(cmd, true,
- "Network Setup check by names is done");
- }
- }
-
- private boolean isNetworkSetupByName(String nameTag) {
- s_logger.debug("known networks: " + this._guestNetworkName + " "
- + this._publicNetworkName + " " + this._privateNetworkName);
- if (nameTag != null) {
- s_logger.debug("Looking for network setup by name " + nameTag);
-
- try {
- Network net = new Network(c);
- net.setBridgeList(_interfaces);
- if (net.getBridgeByName(nameTag) != null) {
- s_logger.debug("Found bridge with name: " + nameTag);
- return true;
- }
- } catch (Exception e) {
- s_logger.debug("Unxpected error looking for name: " + nameTag);
- return false;
- }
- }
- s_logger.debug("No bridge with name: " + nameTag);
- return false;
- }
-
- @Override
- public Answer executeRequest(Command cmd) {
- Class extends Command> clazz = cmd.getClass();
- if (clazz == ReadyCommand.class) {
- return execute((ReadyCommand) cmd);
- } else if (clazz == CopyCommand.class) {
- return execute((CopyCommand) cmd);
- } else if (clazz == DeleteCommand.class) {
- return execute((DeleteCommand) cmd);
- } else if (clazz == CreateStoragePoolCommand.class) {
- return execute((CreateStoragePoolCommand) cmd);
- } else if (clazz == ModifyStoragePoolCommand.class) {
- return execute((ModifyStoragePoolCommand) cmd);
- } else if (clazz == PrimaryStorageDownloadCommand.class) {
- return execute((PrimaryStorageDownloadCommand) cmd);
- } else if (clazz == CreateCommand.class) {
- return execute((CreateCommand) cmd);
- } else if (clazz == GetHostStatsCommand.class) {
- return execute((GetHostStatsCommand) cmd);
- } else if (clazz == StopCommand.class) {
- return execute((StopCommand) cmd);
- } else if (clazz == RebootCommand.class) {
- return execute((RebootCommand) cmd);
- } else if (clazz == GetStorageStatsCommand.class) {
- return execute((GetStorageStatsCommand) cmd);
- } else if (clazz == GetVmStatsCommand.class) {
- return execute((GetVmStatsCommand) cmd);
- } else if (clazz == AttachVolumeCommand.class) {
- return execute((AttachVolumeCommand) cmd);
- } else if (clazz == DestroyCommand.class) {
- return execute((DestroyCommand) cmd);
- } else if (clazz == PrepareForMigrationCommand.class) {
- return execute((PrepareForMigrationCommand) cmd);
- } else if (clazz == MigrateCommand.class) {
- return execute((MigrateCommand) cmd);
- } else if (clazz == CheckVirtualMachineCommand.class) {
- return execute((CheckVirtualMachineCommand) cmd);
- } else if (clazz == MaintainCommand.class) {
- return execute((MaintainCommand) cmd);
- } else if (clazz == StartCommand.class) {
- return execute((StartCommand) cmd);
- } else if (clazz == GetVncPortCommand.class) {
- return execute((GetVncPortCommand) cmd);
- } else if (clazz == PingTestCommand.class) {
- return execute((PingTestCommand) cmd);
- } else if (clazz == FenceCommand.class) {
- return execute((FenceCommand) cmd);
- } else if (clazz == AttachIsoCommand.class) {
- return execute((AttachIsoCommand) cmd);
- } else if (clazz == DettachCommand.class) {
- return execute((DettachCommand) cmd);
- } else if (clazz == AttachCommand.class) {
- return execute((AttachCommand) cmd);
- } else if (clazz == NetworkRulesSystemVmCommand.class) {
- return execute((NetworkRulesSystemVmCommand) cmd);
- /*
- * } else if (clazz == SecurityGroupRulesCmd.class) { return
- * execute((SecurityGroupRulesCmd) cmd); } else if (clazz ==
- * CleanupNetworkRulesCmd.class) { return
- * execute((CleanupNetworkRulesCmd) cmd); } else if (clazz ==
- * PrepareOCFS2NodesCommand.class) { return
- * execute((PrepareOCFS2NodesCommand) cmd);
- */
- } else if (clazz == CreatePrivateTemplateFromVolumeCommand.class) {
- return execute((CreatePrivateTemplateFromVolumeCommand) cmd);
- } else if (clazz == CopyVolumeCommand.class) {
- return execute((CopyVolumeCommand) cmd);
- } else if (clazz == DeleteStoragePoolCommand.class) {
- return execute((DeleteStoragePoolCommand) cmd);
- } else if (clazz == CheckNetworkCommand.class) {
- return execute((CheckNetworkCommand) cmd);
- } else if (clazz == CheckSshCommand.class) {
- return execute((CheckSshCommand) cmd);
- } else if (clazz == GetDomRVersionCmd.class) {
- return execute((GetDomRVersionCmd) cmd);
- } else if (clazz == DhcpEntryCommand.class) {
- return execute((DhcpEntryCommand) cmd);
- } else if (clazz == SavePasswordCommand.class) {
- return execute((SavePasswordCommand) cmd);
- } else if (clazz == VmDataCommand.class) {
- return execute((VmDataCommand) cmd);
- } else if (clazz == CreateObjectCommand.class) {
- return execute((CreateObjectCommand) cmd);
- } else {
- return Answer.createUnsupportedCommandAnswer(cmd);
- }
- }
-
- @Override
- public void disconnected() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public IAgentControl getAgentControl() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setAgentControl(IAgentControl agentControl) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setName(String name) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setConfigParams(Map params) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Map getConfigParams() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int getRunLevel() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public void setRunLevel(int level) {
- // TODO Auto-generated method stub
-
- }
-
- /* TODO: move to the StoragPprocessor */
- @Override
- public Answer copyTemplateToPrimaryStorage(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer createTemplateFromVolume(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer createTemplateFromSnapshot(CopyCommand cmd) {
- return null; // To change body of implemented methods use File |
- // Settings | File Templates.
- }
-
- @Override
- public Answer backupSnapshot(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- /*
- * TODO: Add iso and update config of the VM is done from set_disk in
- * lib/xenxm.py (Example found in Xen.java)
- * Iso first needs to be copied over to the primary storage where the ISOs
- * reside, or just mount secondary storage, feh!
- */
- protected Answer execute(AttachIsoCommand cmd) {
- try {
- URI iso = new URI(cmd.getIsoPath());
- String isoPath = iso.getHost() + ":" + iso.getPath();
- /*
- * Ovm3Vm.detachOrAttachIso(_conn, cmd.getVmName(), isoPath,
- * cmd.isAttach());
- */
- // setupSecStorage()
- s_logger.debug(cmd.getStoreUrl() + " " + cmd.getIsoPath());
- return new Answer(cmd);
- } catch (Exception e) {
- s_logger.debug("Attach or detach ISO " + cmd.getIsoPath() + " for "
- + cmd.getVmName() + " attach:" + cmd.isAttach() + " failed",
- e);
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- @Override
- public Answer attachIso(AttachCommand cmd) {
- s_logger.debug("attachIso not implemented yet");
- return new Answer(cmd);
- }
-
- @Override
- public Answer dettachIso(DettachCommand cmd) {
- s_logger.debug("detachIso not implemented yet");
- return new Answer(cmd);
- }
-
- public String isoAttachDetach(String vmName, DiskTO disk, boolean isAttach) {
- Xen xen = new Xen(c);
- String doThis = (isAttach) ? "AttachIso" : "DettachIso";
- String msg = null;
- try {
- Xen.Vm vm = xen.getVmConfig(vmName);
- /* check running */
- if (vm == null) {
- msg = doThis + " can't find VM " + vmName;
- return msg;
- }
- TemplateObjectTO isoTO = (TemplateObjectTO) disk.getData();
- DataStoreTO store = isoTO.getDataStore();
- if (!(store instanceof NfsTO)) {
- msg = doThis + " unsupported protocol";
- return msg;
- }
- NfsTO nfsStore = (NfsTO) store;
- String secPoolUuid = setupSecondaryStorage(nfsStore.getUrl());
- String isoPath = _ovmSec + File.separator + secPoolUuid
- + File.separator + isoTO.getPath();
- s_logger.debug(doThis + " " + isoPath);
- if (isAttach) {
- /* check if iso is not already there ? */
- vm.addIso(isoPath);
- } else {
- if (!vm.removeDisk(isoPath)) {
- msg = doThis + " failed for "
- + vmName + " iso was not attached " + isoPath;
- return msg;
- }
- }
- xen.configureVm(_ovmObject.deDash(vm.getPrimaryPoolUuid()),
- vm.getVmUuid());
- return msg;
- } catch (Exception e) {
- msg = doThis + " failed for " + vmName + " " + e.getMessage();
- return msg;
- } finally {
- if (msg == null) {
- msg = "success";
- }
- s_logger.debug(msg);
- }
- }
-
- public Answer execute(AttachCommand cmd) {
- String vmName = cmd.getVmName();
- DiskTO disk = cmd.getDisk();
- Boolean success = false;
- String answer = "";
- if (cmd.getDisk().getType() == Volume.Type.ISO) {
- answer = isoAttachDetach(vmName, disk, true);
- }
-
- if (answer == null) {
- success = true;
- }
- return new Answer(cmd, success, answer);
- }
-
- public Answer execute(DettachCommand cmd) {
- String vmName = cmd.getVmName();
- DiskTO disk = cmd.getDisk();
- Boolean success = false;
- String answer = "";
- if (cmd.getDisk().getType() == Volume.Type.ISO) {
- answer = isoAttachDetach(vmName, disk, false);
- }
-
- if (answer == null) {
- success = true;
- }
- return new Answer(cmd, success, answer);
- /*
- * s_logger.debug("dettaching object: " + cmd.getDisk().getType());
- * if (this._vmstates.get(vmName) == State.Running) {
- * return new DettachAnswer("Dettach unsupported on running VM "
- * + vmName);
- */
- }
-
- /*
- * for now we assume that the datastore is there or else we
- * never came this far
- */
- public Answer execute(CreateObjectCommand cmd) {
- // public Answer execute(CreateObjectCommand cmd) {
- DataTO data = cmd.getData();
- s_logger.debug("creating new object: " + data.getObjectType());
- if (data.getObjectType() == DataObjectType.VOLUME) {
- return createVolume(cmd);
- } else if (data.getObjectType() == DataObjectType.SNAPSHOT) {
- /*
- * if stopped yes, if runniing ... no, unless we have ocfs2
- * when using raw partitions (file:) if using tap:aio we cloud...
- */
- /* if (_vmstates(get)) { */
- } else if (data.getObjectType() == DataObjectType.TEMPLATE) {
- /* aaalwaaays */
- } else {
-
- }
- return new CreateObjectAnswer("Create unsupported object type: "
- + data.getObjectType());
- }
-
- @Override
- public Answer createVolume(CreateObjectCommand cmd) {
- DataTO data = cmd.getData();
- VolumeObjectTO volume = (VolumeObjectTO) data;
- try {
- /*
- * public Boolean storagePluginCreate(String uuid, String ssuuid,
- * String
- * host, String file, Integer size)
- */
- String poolUuid = data.getDataStore().getUuid();
- String storeUrl = data.getDataStore().getUrl();
- URI uri = new URI(storeUrl);
- String host = uri.getHost();
- String file = this._ovmRepo + "/" + _ovmObject.deDash(poolUuid)
- + "/VirtualDisks/"
- + volume.getUuid() + ".raw";
- Long size = volume.getSize();
- StoragePlugin sp = new StoragePlugin(c);
- sp.storagePluginCreate(poolUuid, host, file, size);
- sp.storagePluginGetFileInfo(file);
- VolumeObjectTO newVol = new VolumeObjectTO();
- newVol.setName(volume.getName());
- newVol.setSize(sp.getFileSize());
- newVol.setPath(file);
- return new CreateObjectAnswer(newVol);
- } catch (Exception e) {
- s_logger.debug("create volume failed: " + e.toString());
- return new CreateObjectAnswer(e.toString());
- }
- }
-
- /* volumes are created on primary storage, ehm they should be ... */
- @Override
- public Answer attachVolume(AttachCommand cmd) {
- return new Answer(cmd);
- }
-
- /* stub */
- @Override
- public Answer dettachVolume(DettachCommand cmd) {
- return new Answer(cmd);
- }
-
- /* is it supported? */
- @Override
- public Answer createSnapshot(CreateObjectCommand cmd) {
- /* createsnap, but should be implemented */
- return new Answer(cmd);
- }
-
- @Override
- public Answer deleteVolume(DeleteCommand cmd) {
- /* storagePluginDestroy(String ssuuid, String file) */
- DataTO data = cmd.getData();
- VolumeObjectTO volume = (VolumeObjectTO) data;
- try {
- String poolUuid = data.getDataStore().getUuid();
- /* needs the file attached too please... */
- String file = volume.getPath();
- if (file.endsWith("/")) {
- file = volume.getPath() + "/" + volume.getUuid() + ".raw";
- }
- StoragePlugin sp = new StoragePlugin(c);
- sp.storagePluginDestroy(poolUuid, file);
- s_logger.debug("delete volume success: " + file);
- } catch (Exception e) {
- s_logger.debug("delete volume failed: " + e.toString());
- return new CreateObjectAnswer(e.toString());
- }
- return new Answer(cmd);
- }
-
- /* copies it from secondary to primary ? */
- @Override
- public Answer createVolumeFromSnapshot(CopyCommand cmd) {
- return new Answer(cmd);
- }
-
- @Override
- public Answer deleteSnapshot(DeleteCommand cmd) {
- /* storagePluginDestroy(String ssuuid, String file) */
- return new Answer(cmd);
- }
-
- @Override
- public Answer introduceObject(IntroduceObjectCmd cmd) {
- return new Answer(cmd, false, "not implememented yet");
- }
-
- @Override
- public Answer forgetObject(ForgetObjectCmd cmd) {
- return new Answer(cmd, false, "not implememented yet");
- }
-
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/CloudStackPlugin.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/CloudStackPlugin.java
deleted file mode 100644
index 94275f4e799..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/CloudStackPlugin.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-public class CloudStackPlugin extends OvmObject {
-
- public CloudStackPlugin(Connection c) {
- client = c;
- }
-
- public String getVncPort(String vmName) throws XmlRpcException {
- String x = (String) callWrapper("get_vncport", vmName);
- return x;
- }
-
- public boolean ovsUploadSshKey(String key, String content)
- throws XmlRpcException {
- Object x = callWrapper("ovs_upload_ssh_key", key, content);
- if (x==null) {
- return false;
- }
- return true;
- }
-
- public class ReturnCode {
- private Map _rc = new HashMap() {
- {
- put("rc", null);
- put("exit", null);
- put("err", null);
- put("out", null);
- }
- };
- public void setValues(Map m) {
- this._rc.putAll(m);
- }
- public Boolean getRc() {
- try {
- Long rc = (Long) _rc.get("rc");
- _rc.put("exit", rc);
- if (rc != 0)
- return false;
- return true;
- } catch (Exception e) {
-
- }
- return false;
- }
- public String getStdOut() {
- return (String) _rc.get("out");
- }
- public String getStdErr() {
- return (String) _rc.get("err");
- }
- public Integer getExit() {
- if (_rc.get("exit") == null)
- _rc.put("exit", _rc.get("rc"));
- return Integer.valueOf((String) _rc.get("exit"));
- }
- }
- public ReturnCode domrExec(String ip, String cmd) throws XmlRpcException {
- ReturnCode rc = new ReturnCode();
- rc.setValues((Map) callWrapper("exec_domr", ip, cmd));
- return rc;
- }
-
- public boolean domrCheckPort(String ip, Integer port, Integer retries, Integer interval)
- throws XmlRpcException, InterruptedException {
- Boolean x= false;
- /* should deduct the interval from the timeout and sleep on it */
- Integer sleep=interval;
- while(x == false && retries > 0) {
- x = (Boolean) callWrapper("check_domr_port", ip, port, interval);
- retries--;
- Thread.sleep(sleep * 1000);
- }
- return x;
- }
-
- public Map ovsDom0Stats(String bridge) throws XmlRpcException {
- Map stats = (Map)
- callWrapper("ovs_dom0_stats", bridge);
- return stats;
- }
-
-
- public Map ovsDomUStats(String domain) throws XmlRpcException {
- Map stats = (Map)
- callWrapper("ovs_domU_stats", domain);
- return stats;
- }
- public boolean domrCheckPort(String ip, Integer port) throws XmlRpcException {
- Object x = callWrapper("check_domr_port", ip, port);
- return (Boolean) x;
- }
-
- public boolean domrCheckSsh(String ip) throws XmlRpcException {
- Object x = callWrapper("check_domr_ssh", ip);
- return (Boolean) x;
- }
-
- public boolean ovsControlInterface(String dev, String ipmask) throws XmlRpcException {
- Object x = callWrapper("ovs_control_interface", dev, ipmask);
- return (Boolean) x;
- }
-
- public boolean ping(String host) throws XmlRpcException {
- Object x = callWrapper("ping", host);
- return (Boolean) x;
- }
-
- public boolean ovsCheckFile(String file) throws XmlRpcException {
- Object x = callWrapper("ovs_check_file", file);
- return (Boolean) x;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Cluster.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Cluster.java
deleted file mode 100644
index 703f8a2cf61..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Cluster.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-/*
- * should become an interface implementation
- */
-public class Cluster extends OvmObject {
-
- public Cluster(Connection c) {
- client = c;
- }
-
- /*
- * leave_cluster, argument:
- * self - default: None argument: poolfsUuid - default: None
- */
- public Boolean leaveCluster(String poolfsUuid) throws XmlRpcException {
- Object x = callWrapper("leave_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * configure_server_for_cluster, argument: self - default: None <( ?
- * argument: o2cb_conf - default: None <( ? argument: clusterConf -
- * default: None <( ? argument: poolfs_type - default: None argument:
- * poolfs_target - default: None argument: poolfsUuid - default: None
- * argument: poolfs_nfsbase_uuid - default: None
- */
- public Boolean configureServerForCluster(String poolfsUuid)
- throws XmlRpcException {
- Object x = callWrapper("configure_server_for_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * deconfigure_server_for_cluster, argument: self - default: None
- * argument: poolfsUuid - default: None
- */
- public Boolean deconfigureServerForCluster(String poolfsUuid)
- throws XmlRpcException {
- Object x = callWrapper("deconfigure_server_for_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * join_cluster, argument: self
- * - default: None argument: poolfsUuid - default: None
- */
- public Boolean joinCLuster(String poolfsUuid) throws XmlRpcException {
- Object x = callWrapper("join_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * discover_cluster, argument:
- * self - default: None
- */
- /*
- * <
- * 61
- * 2000
- * 2000
- * ba9aaf00ae5e2d73
- * 60000
- * true o2cb
- *
- * ba9aaf00ae5e2d73 1
- * global
- *
- * 0004FB0000050000E70FBDDEB802208F
- * ba9aaf00ae5e2d73
- * 0 7777
- * 192.168.1.64 ovm-1
- * ba9aaf00ae5e2d73
- *
- */
- /* returns xml - sigh */
- public Boolean discoverCluster() throws XmlRpcException {
- Object x = callWrapper("discover_cluster");
- // System.out.println(x);
-
- return false;
- }
-
- /*
- * update_clusterConfiguration, argument: self - default: None
- * argument: cluster_conf - default: None <( ? cluster_conf can be a "dict"
- * or a plain file: print master.update_clusterConfiguration(
- * "heartbeat:\n\tregion = 0004FB0000050000E70FBDDEB802208F\n\tcluster = ba9aaf00ae5e2d72\n\nnode:\n\tip_port = 7777\n\tip_address = 192.168.1.64\n\tnumber = 0\n\tname = ovm-1\n\tcluster = ba9aaf00ae5e2d72\n\nnode:\n\tip_port = 7777\n\tip_address = 192.168.1.65\n\tnumber = 1\n\tname = ovm-2\n\tcluster = ba9aaf00ae5e2d72\n\ncluster:\n\tnode_count = 2\n\theartbeat_mode = global\n\tname = ba9aaf00ae5e2d72\n"
- * )
- */
- public Boolean updateClusterConfiguration(String clusterConf)
- throws XmlRpcException {
- Object x = callWrapper("update_clusterConfiguration", clusterConf);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * destroy_cluster, argument:
- * self - default: None argument: poolfsUuid - default: None
- */
- public Boolean destroyCluster(String poolfsUuid) throws XmlRpcException {
- Object x = callWrapper("destroy_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * is_cluster_online, argument:
- * self - default: None
- */
- public Boolean isClusterOnline() throws XmlRpcException {
- Object x = callWrapper("is_cluster_online");
- return Boolean.valueOf(x.toString());
- }
-
- /*
- * create_cluster, argument:
- * self - default: None argument: poolfsUuid - default: None
- */
- public Boolean createCluster(String poolfsUuid) throws XmlRpcException {
- Object x = callWrapper("create_cluster", poolfsUuid);
- if (x == null)
- return true;
-
- return false;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Common.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Common.java
deleted file mode 100644
index ca247489f3a..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Common.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-/*
- * should become an interface implementation
- */
-public class Common extends OvmObject {
- public String apiVersion;
-
- public Common(Connection c) {
- client = c;
- }
-
- /*
- * get_api_version,
- */
- public String getApiVersion() throws XmlRpcException {
- return callString("get_api_version");
-
- }
-
- /*
- * sleep, argument: secs - default: None
- */
- public String sleep(int seconds) throws XmlRpcException {
- return callString("sleep", seconds);
- }
-
- /*
- * dispatch, argument: uri - default: None
- * argument: func - default: None
- */
- /*
- * normally used to push commands to other hosts in a cluster: *
- * dispatch function join_server_pool
- * to server https://oracle:******@192.168.1.67:8899/api/3/
- */
- public String dispatch(String url, String function, T... args)
- throws XmlRpcException {
- return callString("dispatch", url, function, args);
- }
-
- /*
- * echo, argument: msg - default: None
- */
- public String echo(String msg) throws XmlRpcException {
- return callString("echo", msg);
- }
-
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Connection.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Connection.java
deleted file mode 100644
index 53a8e10233b..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Connection.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-import java.net.URL;
-import java.util.TimeZone;
-import java.util.Vector;
-
-import org.apache.log4j.Logger;
-import org.apache.xmlrpc.XmlRpcException;
-import org.apache.xmlrpc.client.TimingOutCallback;
-import org.apache.xmlrpc.client.XmlRpcClient;
-import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-
-public class Connection extends XmlRpcClient {
- private static final Logger s_logger = Logger.getLogger(Connection.class);
- private final XmlRpcClientConfigImpl _config = new XmlRpcClientConfigImpl();
- private XmlRpcClient _client;
- private String _username;
- private String _password;
- private String _ip;
- private Integer _port = 8898;
- private Boolean _isSsl = false;
- private String cert = "";
- private String key = "";
- private Integer timeout = 1200; /* seconds */
- private Integer _timeout = timeout * 1000; /* native is ms */
-
- private XmlRpcClient getXmlClient() throws XmlRpcException {
- // check ssl boolean
- final XmlRpcClient client = new XmlRpcClient();
-
- URL url;
- try {
- // here too
- url = new URL("http://" + _ip + ":" + _port.toString());
- _config.setTimeZone(TimeZone.getTimeZone("UTC"));
- _config.setServerURL(url);
- _config.setReplyTimeout(0); // disable, we use asyncexecute to
- // control timeout
- _config.setConnectionTimeout(60000);
- _config.setReplyTimeout(60 * 15000);
- _config.setBasicUserName(_username);
- _config.setBasicPassword(_password);
- _config.setXmlRpcServer(null);
- // _config.setEnabledForExtensions(true);
- client.setConfig(_config);
- client.setTypeFactory(new RpcTypeFactory(client));
- } catch (Throwable e) {
- throw new XmlRpcException(e.getMessage());
- }
- return client;
- }
-
- public Connection(String ip, Integer port, String username, String password)
- throws XmlRpcException {
- _ip = ip;
- _port = port;
- _username = username;
- _password = password;
- _client = getXmlClient();
- }
-
- public Connection(String ip, String username, String password)
- throws XmlRpcException {
- _ip = ip;
- _username = username;
- _password = password;
- _client = getXmlClient();
- }
-
- public Object call(String method, Vector> params) throws XmlRpcException {
- /* default timeout is 10 mins */
- return callTimeoutInSec(method, params, this._timeout);
- }
-
- public Object call(String method, Vector> params, boolean debug)
- throws XmlRpcException {
- /* default timeout is 10 mins */
- return callTimeoutInSec(method, params, this._timeout, debug);
- }
-
- public Object callTimeoutInSec(String method, Vector> params,
- int timeout, boolean debug) throws XmlRpcException {
- TimingOutCallback callback = new TimingOutCallback(timeout * 1000);
- if (debug) {
- /*
- * some parameters including user password should not be printed in
- * log
- */
- s_logger.debug("Call Ovm3 agent: " + method + " with " + params);
- }
-
- long startTime = System.currentTimeMillis();
- _client.executeAsync(method, params, callback);
- try {
- return callback.waitForResponse();
- } catch (TimingOutCallback.TimeoutException to) {
- throw to;
- } catch (Throwable e) {
- throw new XmlRpcException(-2, e.getMessage());
- } finally {
- long endTime = System.currentTimeMillis();
- float during = (endTime - startTime) / 1000; // in secs
- s_logger.debug("Ovm3 call " + method + " finished in " + during
- + " secs, on " + _ip + ":" + _port);
- }
- }
-
- public Object callTimeoutInSec(String method, Vector> params, int timeout)
- throws XmlRpcException {
- return callTimeoutInSec(method, params, timeout, true);
- }
-
- public String getIp() {
- return _ip;
- }
-
- public Integer getPort() {
- return _port;
- }
-
- public String getUserName() {
- return _username;
- }
-
- public String getPassword() {
- return _password;
- }
-
- public Boolean getIsSsl() {
- return _isSsl;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Linux.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Linux.java
deleted file mode 100644
index 3be9feb6e57..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Linux.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xmlrpc.XmlRpcException;
-import org.w3c.dom.Document;
-
-/*
- * should become an interface implementation
- */
-public class Linux extends OvmObject {
- private Integer _init = 0;
-
- /*
- * use capabilities to match things later, perhaps also hardware discovery ?
- * wrap getters and setters.... for Mapps...
- */
- public Map Capabilities = new HashMap();
- /*
- * MAX_CONCURRENT_MIGRATION_IN=1, ALL_VM_CPU_OVERSUBSCRIBE=True,
- * HIGH_AVAILABILITY=True, LOCAL_STORAGE_ELEMENT=True, NFS=True,
- * MTU_CONFIGURATION=True, CONCURRENT_MIGRATION=False,
- * VM_MEMORY_ALIGNMENT=1048576, CLUSTERS=True, VM_SUSPEND=True,
- * BOND_MODE_LINK_AGGREGATION=True, YUM_PACKAGE_MANAGEMENT=True,
- * VM_VNC_CONSOLE=True, BOND_MODE_ACTIVE_BACKUP=True,
- * MAX_CONCURRENT_MIGRATION_OUT=1, MIGRATION_SETUP=False,
- * PER_VM_CPU_OVERSUBSCRIBE=True, POWER_ON_WOL=True, FIBRE_CHANNEL=True,
- * ISCSI=True, HVM_MAX_VNICS=8}
- */
- public Map VMM = new HashMap();
- public Map VMMc = new HashMap();
- public Map NTP = new HashMap();
- public Map DateTime = new HashMap();
- public Map Generic = new HashMap();
- /*
- * {OS_Major_Version=5, Statistic=20, Membership_State=Unowned,
- * OVM_Version=3.2.1-517, OS_Type=Linux, Hypervisor_Name=Xen,
- * CPU_Type=x86_64, Manager_Core_API_Version=3.2.1.516,
- * Is_Current_Master=false, OS_Name=Oracle VM Server,
- * Server_Roles=xen,utility, Pool_Unique_Id=none,
- * Host_Kernel_Release=2.6.39-300.22.2.el5uek, OS_Minor_Version=7,
- * Agent_Version=3.2.1-183, Boot_Time=1392366638, RPM_Version=3.2.1-183,
- * Exports=, Hypervisor_Type=xen, Host_Kernel_Version=#1 SMP Fri Jan 4
- * 12:40:29 PST 2013,
- * Unique_Id=1d:d5:e8:91:d9:d0:ed:bd:81:c2:a6:9a:b3:d1:b7:ea,
- * Manager_Unique_Id=none, Cluster_State=Offline, Hostname=ovm-1}
- */
- public Map hwVMM = new HashMap();
- public Map hwSystem = new HashMap();
- public int localTime;
- public int lastBootTime;
- public String timeZone;
- public String timeUTC;
- public List _mounts = null;
-
- // public Map Settings = new HashMap();
-
- public Linux(Connection c) {
- client = c;
- }
-
- /*
- * discover_server, argument: self -
- * default: None
- */
- public Boolean discoverServer() throws Exception {
- String cmd = "discover_server";
- Object result = callWrapper(cmd);
- if (result == null) {
- return false;
- }
-
- Document xmlDocument = prepParse((String) result);
- /* System.out.println(result); */
- /* could be more subtle */
- String path = "//Discover_Server_Result/Server";
- Capabilities = xmlToMap(path + "/Capabilities", xmlDocument);
- VMM = xmlToMap(path + "/VMM/Version", xmlDocument);
- VMMc = xmlToMap(path + "/VMM", xmlDocument);
- NTP = xmlToMap(path + "/NTP", xmlDocument);
- DateTime = xmlToMap(path + "/Date_Time", xmlDocument);
- Generic = xmlToMap(path, xmlDocument);
-
- // System.out.println(Get("Agent_Version"));
-
- // System.out.println(Generic.toString());
- return true;
- }
-
- public String getAgentVersion() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Agent_Version");
- }
- public String getHostKernelRelease() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Host_Kernel_Release");
- }
- public String getHostOs() throws ParserConfigurationException, IOException,
- Exception {
- return this.Get("OS_Name");
- }
- public String getHostOsVersion() throws ParserConfigurationException,
- IOException, Exception {
- String ver = this.Get("OS_Major_Version") + "."
- + this.Get("OS_Minor_Version");
- return ver;
- }
- public String getHypervisorName() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Hypervisor_Name");
- }
- public String getHypervisorVersion() throws ParserConfigurationException, IOException, Exception {
- String ver = this.getHypervisorMajor() + "."
- + this.getHypervisorMinor() + "." + this.getHypervisorExtra();
- return ver;
- }
- public String getCapabilities() throws ParserConfigurationException,
- IOException, Exception {
- return this.Get("Capabilities");
- }
- public String getHypervisorMajor() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Major");
- }
- public String getHypervisorMinor() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Minor");
- }
- public String getHypervisorExtra() throws ParserConfigurationException,
- IOException, Exception {
- return this.Get("Extra").replace(".", "");
- }
- public String getManagerUuid() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Manager_Unique_Id");
- }
-
- public String getMembershipState() throws ParserConfigurationException,
- IOException, Exception {
- return this.Get("Membership_State");
- }
-
- public String getServerRoles() throws ParserConfigurationException,
- IOException, Exception {
- return this.Get("Server_Roles");
- }
- public boolean getIsMaster() throws ParserConfigurationException,
- IOException, Exception {
- return Boolean.parseBoolean(this.Get("Is_Current_Master"));
- }
- public String getOvmVersion() throws ParserConfigurationException, IOException, Exception {
- return this.Get("OVM_Version");
- }
- public String getHostName() throws ParserConfigurationException, IOException, Exception {
- return this.Get("Hostname");
- }
- public Integer getCpuKhz() throws NumberFormatException, ParserConfigurationException, IOException, Exception {
- return Integer.valueOf(this.Get("CPUKHz"));
- }
- public Integer getCpuSockets() throws NumberFormatException, ParserConfigurationException, IOException, Exception {
- return Integer.valueOf(this.Get("SocketsPerNode"));
- }
- public Integer getCpuThreads() throws NumberFormatException, ParserConfigurationException, IOException, Exception {
- return Integer.valueOf(this.Get("ThreadsPerCore"));
- }
- public Integer getCpuCores() throws NumberFormatException, ParserConfigurationException, IOException, Exception {
- return Integer.valueOf(this.Get("CoresPerSocket"));
- }
- public Integer getTotalThreads() throws NumberFormatException, ParserConfigurationException, IOException, Exception {
- return this.getCpuSockets() * this.getCpuCores() * this.getCpuThreads();
- }
-
- public Double getMemory() throws NumberFormatException,
- ParserConfigurationException, IOException, Exception {
- return Double.valueOf(this.Get("TotalPages")) * 4096;
- }
-
- public Double getFreeMemory() throws NumberFormatException,
- ParserConfigurationException, IOException, Exception {
- return Double.valueOf(this.Get("FreePages")) * 4096;
- }
- public String getUuid() throws NumberFormatException,
- ParserConfigurationException, IOException, Exception {
- return this.Get("Unique_Id");
- }
-
- public String Get(String element) throws ParserConfigurationException, IOException, Exception {
- if (this._init == 0) {
- this.discoverHardware();
- this.discoverServer();
- this._init = 1;
- }
- if (Generic.containsKey(element))
- return Generic.get(element);
- if (VMMc.containsKey(element))
- return VMMc.get(element);
- if (VMM.containsKey(element))
- return VMM.get(element);
- if (hwVMM.containsKey(element))
- return hwVMM.get(element);
- if (hwSystem.containsKey(element))
- return hwSystem.get(element);
- if (Capabilities.containsKey(element))
- return Capabilities.get(element);
- return "";
- }
-
- /*
- * unexport_fs, argument: self -
- * default: None argument: export_uuid - default: None
- */
-
- /*
- * get_last_boot_time, argument: self -
- * default: None
- */
- public Integer getLastBootTime() throws XmlRpcException {
- HashMap result = callMap("get_last_boot_time");
- if (result == null)
- return null;
- this.lastBootTime = result.get("last_boot_time").intValue();
- this.localTime = result.get("local_time").intValue();
- return lastBootTime;
- }
-
- /*
- * delete_yum_repo, argument: self -
- * default: None argument: repo_id - default: None
- */
-
- /*
- * notify_manager, argument: self -
- * default: None argument: notification - default: None argument: data -
- * default: None
- */
-
- /*
- * update_core_api_bindings, argument:
- * self - default: None argument: url - default: None argument: option -
- * default: None
- */
-
- /*
- * set_datetime, argument: self -
- * default: None argument: year - default: None argument: month - default:
- * None argument: day - default: None argument: hour - default: None
- * argument: min - default: None argument: sec - default: None
- */
- public Boolean setDateTime(int year, int month, int day, int hour, int min,
- int sec) throws XmlRpcException {
- Object x = callWrapper("set_datetime", year, month, day, hour, min, sec);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * list_package, argument: self -
- * default: None argument: name - default: None
- */
-
- /*
- * discover_physical_luns, argument:
- * self - default: None argument: args - default: None
- */
- public String discoverPhysicalLuns() throws XmlRpcException {
- String x = (String) callWrapper("discover_physical_luns", "");
- return x;
- }
-
- /*
- * ovs_download_file, argument: self -
- * default: None argument: url - default: None argument: filename - default:
- * None argument: option - default: None argument: obj - default: None
- * argument: obj_current - default: None argument: obj_total - default: None
- * argument: update_period - default: None
- */
-
- /*
- * install_package, argument: self -
- * default: None argument: pkg_data - default: None argument: option -
- * default: None
- */
-
- /*
- * get_support_files, argument: self -
- * default: None
- */
-
- /*
- * export_fs, argument: self - default:
- * None argument: export_uuid - default: None argument: export_type -
- * default: None argument: client - default: None argument: path - default:
- * None argument: options - default: None
- */
-
- /*
- * ovs_async_proc_status, argument:
- * self - default: None argument: pid - default: None
- */
-
- /*
- * set_timezone, argument: self -
- * default: None argument: timezone - default: None argument: utc - default:
- * None
- */
- public Boolean setTimeZone(String tz, Boolean utc) throws XmlRpcException {
- Object x = callWrapper("set_timezone", tz, utc);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * copy_file, argument: self - default:
- * None argument: src - default: None argument: dst - default: None
- * argument: sparse - default: None argument: update_period - default: None
- */
- public Boolean copyFile(String src, String dst) throws XmlRpcException {
- Object x = callWrapper("copy_file", src, dst, false);
- if (x == null)
- return true;
-
- return false;
- }
-
- public Boolean copyFile(String src, String dst, Boolean sparse)
- throws XmlRpcException {
- Object x = callWrapper("copy_file", src, dst, sparse);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * discover_mounted_file_systems,
- * argument: self - default: None argument: args - default: None
- */
- /*
- *
- * cs-mgmt:/volumes/cs-data/secondary/
- * rw,relatime
- * ,vers=3,rsize=524288,wsize=524288,namlen=255,hard
- * ,proto=tcp,port=65535,timeo
- * =600,retrans=2,sec=sys,local_lock=none,addr=192.168.1.61
- * ...
- */
-
- public Boolean discoverMountedFs() throws XmlRpcException {
- Object x = callWrapper("discover_mounted_file_systems");
- // System.out.println(x);
- if (x == null)
- return true;
-
- return false;
- }
-
- /* Filesystem bits and bobs */
- private Map fsList = null;
-
- public Map getFileSystemList(String type)
- throws ParserConfigurationException, IOException, Exception {
- if (fsList == null)
- this.discoverMountedFs(type);
-
- return fsList;
- }
-
- public void setFileSystemList(Map list) {
- fsList = list;
- }
- public class FileSystem {
- public Map _fs = new HashMap() {
- {
- put("Mount_Options", null);
- put("Name", null);
- put("Device", null);
- put("Host", null);
- put("Dir", null);
- put("Mount_Point", null);
- put("Uuid", null);
- }
- };
-
- public String getUuid() {
- return (String) _fs.get("Uuid");
- }
-
- public String setUuid(String uuid) {
- return (String) _fs.put("Uuid", uuid);
- }
- public String getName() {
- return (String) _fs.get("Name");
- }
-
- public String setName(String name) {
- return (String) _fs.put("Name", name);
- }
-
- public String getDevice() {
- return (String) _fs.get("Device");
- }
-
- public String setDevice(String dev) {
- return (String) _fs.put("Device", dev);
- }
-
- public String getHost() {
- if (getDevice() != null && getDevice().contains(":")) {
- String spl[] = getDevice().split(":");
- setHost(spl[0]);
- setMountPoint(spl[1]);
- } else {
- return null;
- }
- return (String) _fs.get("Host");
- }
-
- public String setHost(String host) {
- return (String) _fs.put("Host", host);
- }
-
- public String getDir() {
- return (String) _fs.get("Dir");
- }
-
- public String setDir(String dir) {
- return (String) _fs.put("Dir", dir);
- }
-
- public String getMountPoint() {
- if (getHost() != null) {
- return (String) _fs.get("Mount_Point");
- }
- return null;
- }
- public String setMountPoint(String pnt) {
- return (String) _fs.put("Mount_Point", pnt);
- }
- };
-
- /* should actually be called "getMountedsFsDevice" or something */
- public Map discoverMountedFs(String type)
- throws ParserConfigurationException, IOException, Exception {
- // if (postDiscovery == null) {
- // postDiscovery = callWrapper("discover_network");
- this.fsList = new HashMap();
- //}
- Object x = callWrapper("discover_mounted_file_systems", type);
- Document xmlDocument = prepParse((String) x);
- // List list = new ArrayList();
- String bpath = "//Discover_Mounted_File_Systems_Result/Filesystem";
- String mpath = bpath + "/Mount/@Dir";
- _mounts = xmlToList(mpath, xmlDocument);
- for (String mnt : _mounts) {
- String dpath = bpath + "/Mount[@Dir='" + mnt + "']";
- Map fs = xmlToMap(dpath, xmlDocument);
- FileSystem f = new FileSystem();
- f._fs = fs;
- String[] spl = mnt.split("/");
- String uuid = spl[spl.length - 1];
- // System.out.println(uuid + " " + mnt);
- f.setUuid(uuid);
- f.setDir(mnt);
- fsList.put(uuid, f);
- }
- setFileSystemList(fsList);
- if (x == null) {
- return this.fsList;
- }
-
- return this.fsList;
- }
-
- /*
- * ovs_async_proc, argument: self -
- * default: None argument: func - default: None
- */
-
- /*
- * get_log, argument: self - default:
- * None argument: loglist - default: None
- */
-
- /*
- * update_agent_password, argument:
- * self - default: None argument: username - default: None argument:
- * password - default: None
- */
- public Boolean updateAgentPassword(String user, String pass)
- throws XmlRpcException {
- Object x = callWrapper("update_agent_password", user, pass);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * yum_update, argument: self -
- * default: None argument: option - default: None
- */
-
- /*
- * discover_hardware, argument: self -
- * default: None
- */
- public Boolean discoverHardware()
- throws ParserConfigurationException, IOException, Exception {
- Object result = callWrapper("discover_hardware");
-
- Document xmlDocument = prepParse((String) result);
- /* could be more subtle */
- String path = "//Discover_Hardware_Result/NodeInformation";
- hwVMM = xmlToMap(path + "/VMM/PhysicalInfo", xmlDocument);
- hwSystem = xmlToMap(path + "/DMTF/System", xmlDocument);
-
- if (result == null)
- return true;
-
- return false;
- }
-
- /*
- * uninstall_package, argument: self -
- * default: None argument: pkg_list - default: None argument: option -
- * default: None
- */
-
- /*
- * get_datetime, argument: self -
- * default: None
- */
- public Integer getDateTime() throws XmlRpcException {
- this.getLastBootTime();
- return this.localTime;
- }
-
- /*
- * configure_yum, argument: self -
- * default: None argument: section - default: None argument: params -
- * default: None
- */
-
- /*
- * get_yum_config, argument: self -
- * default: None
- */
- public Boolean getYumConfig() throws XmlRpcException {
- Object x = callWrapper("get_yum_config");
- // System.out.println(x);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_async_proc_stop, argument: self
- * - default: None argument: pid - default: None
- */
-
- /*
- * set_statistic_interval, argument:
- * interval - default: None
- */
- public Boolean setStatisticsInterval(int val) throws XmlRpcException {
- Object x = callWrapper("set_statistics_interval", val);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * yum_list_package, argument: self -
- * default: None argument: pkgnarrow - default: None argument: patterns -
- * default: None argument: showdups - default: None argument: ignore_case -
- * default: None
- */
-
- /*
- * get_timezone, argument: self -
- * default: None
- */
- public Boolean getTimeZone() throws XmlRpcException {
- Object[] result = (Object[]) callWrapper("get_timezone");
- if (result != null) {
- this.timeZone = result[0].toString();
- this.timeUTC = result[1].toString();
- return true;
- }
- return false;
- }
-
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Network.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Network.java
deleted file mode 100644
index 0ae9d847faf..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Network.java
+++ /dev/null
@@ -1,628 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-// import java.util.Map;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xmlrpc.XmlRpcException;
-import org.w3c.dom.Document;
-// import java.util.HashMap;
-
-/*
- * should become an interface implementation
- */
-public class Network extends OvmObject {
-
- public Network(Connection c) {
- client = c;
- }
-
- private Map interfaceList = null;
-
- public Map getInterfaceList()
- throws ParserConfigurationException, IOException, Exception {
- try {
- this.discoverNetwork();
- } catch (Exception e) {
- throw new Exception(e.getMessage());
- }
- return interfaceList;
- }
-
- public void setBridgeList(Map list) {
- interfaceList = list;
- }
-
- public class Interface {
- private Map _interface = new HashMap() {
- {
- put("Type", null);
- put("Physical", null);
- put("Name", null);
- put("Address", null);
- put("Broadcast", null);
- put("MAC", null);
- put("Vlan", null);
- }
- };
-
- public void setIfType(String t) {
- this._interface.put("Type", t);
- }
- public String getIfType() {
- return this._interface.get("Type");
- }
- public void setInterface(Map itf) {
- this._interface.putAll(itf);
- }
-
- public String getName() {
- return _interface.get("Name");
- }
-
- public String getPhysical() {
- return _interface.get("Physical");
- }
-
- public String getAddress() {
- return _interface.get("Address");
- }
-
- public String getBroadcast() {
- return _interface.get("Broadcast");
- }
-
- public String getMac() {
- return _interface.get("MAC");
- }
-
- public String setName(String name) {
- return _interface.put("Name", name);
- }
-
- public String setPhysical(String ph) {
- return _interface.put("Physical", ph);
- }
- public String setAddress(String addr) {
- return _interface.put("Address", addr);
- }
-
- public String setBroadcast(String bcast) {
- return _interface.put("Broadcast", bcast);
- }
-
- public String setMac(String mac) {
- return _interface.put("MAC", mac);
- }
- }
-
- private Network.Interface _getInterface(String key, String val)
- throws ParserConfigurationException, IOException, Exception {
- HashMap ifaces = new HashMap();
- ifaces = (HashMap) this.getInterfaceList();
- for (final Entry iface : ifaces.entrySet()) {
- String match = "default";
- if (key.equals("Address"))
- match = iface.getValue().getAddress();
- if (key.equals("Name"))
- match = iface.getKey();
- // .getName();
- if (match != null && match.equals(val))
- return iface.getValue();
- }
- return null;
- }
-
- public Network.Interface getInterfaceByIp(String ip)
- throws ParserConfigurationException, IOException, Exception {
- return _getInterface("Address", ip);
- }
-
- public Network.Interface getInterfaceByName(String name)
- throws ParserConfigurationException, IOException, Exception {
- return _getInterface("Name", name);
- }
- /* check if it is a BRIDGE */
- public String getPhysicalByBridgeName(String name)
- throws ParserConfigurationException, IOException, Exception {
- return getInterfaceByName(name).getPhysical();
- }
-
- public Network.Interface getBridgeByName(String name)
- throws ParserConfigurationException, IOException, Exception {
- if (_getInterface("Name", name).getIfType().contentEquals("Bridge")) {
- return _getInterface("Name", name);
- }
- return null;
- }
- public Network.Interface getBridgeByIp(String ip)
- throws ParserConfigurationException, IOException, Exception {
- if (_getInterface("Address", ip).getIfType().contentEquals("Bridge")) {
- return _getInterface("Address", ip);
- }
- return null;
- }
- private Object postDiscovery = null;
-
- private List netInterfaces = new ArrayList();
-
- /*
- * ovs_bond_mode,
- Change Bond mode.
-
- @param bond One of the logical channel bonds (bond0, bond1 ...etc)
- @mode Current supported bonding modes (1 = active-backup, 4 = 802.3ad
- 6 = balance-alb).
- @return If successful, returns bond's names and its new mode
- Raises an exception on failure
- Restriction:
- -bond must be one of the logical channel bonds (bond0, bond1 ...etc)
-
- */
- public Boolean ovsBondMode(String bond, String mode) throws XmlRpcException {
- Object x = callWrapper("ovs_bond_mode", bond, mode);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_change_mtu,
- Changes MTU on a physical,vlan,bond,and bridge interface.
- Changing a bond MTU will also change the MTU of its slaves.
- Changing the MTU of an interface that is part of a bridge,
- will cause the bridge MTU and all of the interfaces change.
- When a Guest VIF attach to a bridge,the VIF MTU will be set
- to the bridge MTU
-
-
- @param interface Physical,bond,vlan, and a bridge
- @param MTU Values are 1500 to 64000
-
- @return If successful, returns the interface, and the new MTU
- Raises an exception on failure
-
- Restriction:
- -Can not change the MTU of a bridge without interfaces.
- -VLAN MTU must less or equal to the MTU of the underlying
- physical interface.
- */
- public Boolean ovsChangeMtu(String net, int mtu) throws XmlRpcException {
- Object x = callWrapper("ovs_change_mtu", net, mtu);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_async_bridge,
- * argument: self - default: None argument: action - default: None argument:
- * br_name - default: None argument: net_dev - default: None
- */
- public Boolean ovsAsyncBridge(String action, String bridge, String netdev)
- throws XmlRpcException {
- Object x = callWrapper("ovs_async_bridge", action, bridge, netdev);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_bond_op,
- * argument: self - default: None argument: action - default: None argument:
- * bond - default: None argument: backup - default: None
- */
- public Boolean ovsBondOp(String action, String bond, String backup)
- throws XmlRpcException {
- Object x = callWrapper("ovs_bond_op", action, bond, backup);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * configure_virtual_ip, argument: self - default:
- * None argument: virtual_ip - default: None argument: base_ip - default:
- * None
- */
- public Boolean configureVip(String vip, String baseip)
- throws XmlRpcException {
- Object x = callWrapper("configure_virtual_ip", vip, baseip);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_ip_config,
- Assigns/flushes IP, netmask address to a physical,VLAN, and bond interfaces.
-
- @param interface The interface on which to assign
- @param optype (static|dynamic|flush)
- static: Assigns the given IP, and netmask to the interface, and
- saves the config file to /etc/sysconfig/network-scripts.
- dynamic: Flushes current address, and creats and save the config
- file to /etc/sysconfig/network-scripts, (BOOTPROTO=dhcp)
- flush: flushes the interface address,routes, removes the current
- config file from /etc/sysconfig/network-scripts.
- Creats a new one with BOOTPROTO=static
-
- @args Required for the static option, otherwise it is ignored
- IP address: IPv4 address in decimal notation (101.230.112)
- netmask: Standard netmask in a decimal notation,NOT CIDR.
- example(255.255.255.0)
-
- @return If successful, returns the interface, and addresses added/flushed
- Raises an exception on failure
-
- Restriction:
- -Interface must be physical, VLAN, or a Bond
- -Interface must not be a bridge port, or slave to a bond
- -Addresses must be valid in a decimal notation
-
- */
- public Boolean ovsIpConfig(String net, String optype, String ip,
- String netmask)
- throws XmlRpcException {
- Object x = callWrapper("ovs_ip_config", net, optype, ip, netmask);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_if_meta,
- This function creates meta data file meta-interface, and write the string
- (METADATA=data) to it. This string is used by the manager to identify
- networks that interfaces belong to. Dom0 does not make used of this string,
- it just saves it and returns it during running, saved network discovery.
-
- - If an interface already has a meta data string, then it gets
- replace by the new one
- - An empty meta data string, indicates to remove the existing string
- (remove the meta-interface) file
-
- @param interface physical,VLAN, bond ...etc interfaces
- @param data meta data to save
-
- @return If successful, returns the interface, and meta data
- Raises an exception on failure
-
- Restriction:
- - data string that starts with leading spaces will be rejected
- * ovs_if_meta('bond0',
- * 'ethernet:c0a80100{192.168.1.0}:MANAGEMENT,CLUSTER_HEARTBEAT,LIVE_MIGRATE,VIRTUAL_MACHINE,STORAGE')
- */
- public Boolean ovsIfMeta(String net, String data) throws XmlRpcException {
- Object x = callWrapper("ovs_if_meta", net, data);
- if (x == null)
- return true;
-
- return false;
- }
-
-
- /*
- * ovs_bond_config,
- * argument: self - default: None argument: action - default: None argument:
- * bond - default: None
- */
- public Boolean ovsBondConfig(String action, String bond)
- throws XmlRpcException {
- Object x = callWrapper("ovs_bond_config", action, bond);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * discover_network,
- Discover information about the current network configuration.
- This includes the state of physical NICs, bonds, and bridges. Also return
- information stored for this server that is needed to configure
- the network when the OVM Manager is not available.
-
- Discovery of the current network configuration is handled by invoking
- a python extension that calls legacy C code from the VI agent.
-
- @param None
-
- @return Returns the discovery data as an XML document.
- Raises an exception on failure.
- *
- *
- * 52:54:00:24:47:70 (0x1843) IFF_UP IFF_BROADCAST
- * IFF_RUNNING IFF_SLAVE IFF_MULTICAST
- * Complete 1000baseT-FD
- * ok 10baseT-HD 10baseT-FD 100baseT-HD
- * 100baseT-FD 1000baseT-FD 10baseT-HD
- * 10baseT-FD 100baseT-HD 100baseT-FD 1000baseT-FD
- * disabled
- * INTERFACE=eth0 IFINDEX=2
- * 0 6
- * 0x0 2 2
- * 0x40014ba9 1 0
- * 1 1000 full
- * 0 up 1500
- * 0x1903 1000
- * 0 0x8086
- * 0x100e 0x1af4
- * 0x1100 0x020000
- * none ....
- *
- * active-backup eth0
- * (primary_reselect always)
- * eth0
- * up
- * 250 500
- * 500
- * up 1000 Mbps
- * full 0
- * 52:54:00:24:47:70
- * 52:54:00:24:47:70
- * 1500 none
- * ethernet:c0a80100
- * {192.168.1.0}:MANAGEMENT,CLUSTER_HEARTBEAT,LIVE_MIGRATE
- * ,VIRTUAL_MACHINE,STORAGE
- *
- * 52:54:00:24:47:70 192.168.1.64
- * 255.255.255.0 192.168.1.255
- * bond0
- * static
- *
- */
- /* put more in when required, for now ok */
- public Boolean discoverNetwork() throws ParserConfigurationException,
- IOException, Exception {
- // if (postDiscovery == null) {
- postDiscovery = callWrapper("discover_network");
- this.interfaceList = new HashMap();
- // }
- // System.out.println(postDiscovery);
- Document xmlDocument = prepParse((String) postDiscovery);
- String path = "//Discover_Network_Result/Network/Active";
- String bpath = path + "/Bridges/Device";
-
- netInterfaces = new ArrayList();
- netInterfaces.addAll(xmlToList(bpath + "/@Name",
- xmlDocument));
- for (String b : netInterfaces) {
- Map br = xmlToMap(bpath + "[@Name='" + b
- + "']/Family", xmlDocument);
- /* vifs are here too */
- String phyInt = (String) this.xmlToMap(bpath + "[@Name='" + b
- + "']/Interfaces", xmlDocument).get("PhyInterface");
- Interface iface = new Interface();
- iface.setInterface(br);
- iface.setName(b);
- iface.setIfType("Bridge");
- if (phyInt == null) {
- iface.setIfType("Local");
- }
- iface.setPhysical(phyInt);
- interfaceList.put(b, iface);
- }
- /* add "physical" interfaces */
- bpath = path + "/Network/Device";
- netInterfaces = new ArrayList();
- netInterfaces.addAll(xmlToList(bpath + "/@Name", xmlDocument));
- for (String p : netInterfaces) {
- Map nf = xmlToMap("//Device[@Name='" + p
- + "']", xmlDocument);
- Interface iface = new Interface();
- iface.setPhysical(nf.get("Basename"));
- iface.setName(p);
- iface.setMac(nf.get("MAC"));
- iface.setIfType("Physical");
- interfaceList.put(p, iface);
- }
- /* add virtual interfaces ? */
- if (postDiscovery == null)
- return false;
-
- return true;
- }
-
- /*
- * ovs_local_config,
- Configure a Local Bridge ((NIC-less bridge)
-
- @param action (start | stop)
- start: Creates local bridge without a physical interface, and saves bridge config
- file in /etc/sysconfig/network-scripts
- stop: Deletes local bridge, removes bridge config file from
- /etc/sysconfig/network-scripts
-
- @param br_name The bridge name to add
-
- @return If successful, returns the name of the bridge
- Raises an exception on failure
-
- */
- public Boolean startOvsLocalConfig(String br)
- throws XmlRpcException {
- return ovsLocalConfig("start", br);
- }
-
- public Boolean stopOvsLocalConfig(String br)
- throws XmlRpcException {
- return ovsLocalConfig("stop", br);
- }
-
- public Boolean ovsLocalConfig(String action, String br)
- throws XmlRpcException {
- Object x = callWrapper("ovs_local_config", action, br);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_vlan_config,
- Creates a VLAN interface on a physical, or a bond interface.
-
- @param action (add|remove)
- add: Creates a VLAN on an interface,saves the VLAN config file in
- /etc/sysconfig/network-scripts
- remove: Removes a VLAN from an interfacei,removes its config file from
- /etc/sysconfig/network-scripts
-
- @param interface The interface on which to create a VLAN
- @param vlanid VLAN ID (2-4095)
-
- @return If successful, returns the interface, and VLAN created
- Raises an exception on failure
-
- Restriction:
- -Interface must be physical, or bond
- -Interface must not be member of a bridge, or slave to a bond
- -VLAN ID must not exist on the same interface
-
- */
- public Boolean startOvsVlanConfig(String dev, int vlan)
- throws XmlRpcException {
- return ovsVlanConfig("add", dev, vlan);
- }
-
- public Boolean stopOvsVlanConfig(String dev, int vlan)
- throws XmlRpcException {
- return ovsVlanConfig("del", dev, vlan);
- }
- public Boolean ovsVlanConfig(String action, String net, int vlan)
- throws XmlRpcException {
- Object x = callWrapper("ovs_vlan_config", action, net, vlan);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_br_config,
- Configure a Standard Bridge.
-
- @param action (start | stop)
- start: Creates the bridge, Copies the IP and MAC addresses from netdev to bridge,
- enslaves net_dev to bridge, and saves bridge config files in
- /etc/sysconfig/network-scripts
- stop: Removes net_dev from the bridge,transfers addresses, routes from bridge to
- net_dev, deletes the bridge, and revomes bridge config files from
- /etc/sysconfig/network-scripts
-
- @param br_name The bridge name to add
- @param net_dev The physical interface to add to the bridge
-
- @return If successful, returns the names of the bridge and it's physical interface.
- Raises an exception on failure
- Restriction:
- -net_dev must be physical, or bond
- -net_dev must not be member of a bridge, or slave to a bond
- */
- public Boolean startOvsBrConfig(String br, String dev)
- throws XmlRpcException {
- return ovsBrConfig("start", br, dev);
- }
-
- public Boolean stopOvsBrConfig(String br, String dev)
- throws XmlRpcException {
- return ovsBrConfig("stop", br, dev);
- }
-
- public Boolean ovsBrConfig(String action, String br, String net)
- throws XmlRpcException {
- Object x = callWrapper("ovs_br_config", action, br, net);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_vlan_bridge,
- @param action (start | stop)
- start: Creates the bridge, creats VLAN on net_dev,enslaves
- the VLAN to the bridge, and saves VLAN bridge config
- files in /etc/sysconfig/network-scripts
- stop: Removes the VLAN from the bridge, removes the VLAN,
- deletes the bridge, and removes VLAN bridge config files
- from /etc/sysconfig/network-scripts
-
- @param br_name The bridge name to add
- @param net_dev The physical interface on which to create a VLAN.
- @param vlan_id VLAN ID (1-4095). VLAN ID of 1 is the untagged VLAN.
-
- @return If successful, returns the names of the bridge and it's VLAN interface
- Raises an exception on failure
- */
- public Boolean stopOvsVlanBridge(String br, String net, int vlan) throws XmlRpcException {
- return ovsVlanBridge("stop", br, net, vlan);
- }
-
- public Boolean startOvsVlanBridge(String br, String net, int vlan) throws XmlRpcException {
- return ovsVlanBridge("start", br, net, vlan);
- }
-
- public Boolean ovsVlanBridge(String action, String br, String net, int vlan)
- throws XmlRpcException {
- Object x = callWrapper("ovs_vlan_bridge", action, br, net, vlan);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * deconfigure_virtual_ip, argument: self - default:
- * None argument: virtual_ip - default: None
- */
- public Boolean deconfigureVip(String vip) throws XmlRpcException {
- Object x = callWrapper("deconfigure_virtual_ip", vip);
- if (x == null)
- return true;
-
- return false;
- }
-
- /*
- * ovs_async_bond,
- * argument: self - default: None argument: action - default: None argument:
- * bond - default: None
- */
- public Boolean ovsAsyncBond(String action, String bond)
- throws XmlRpcException {
- Object x = callWrapper("ovs_async_bond", action, bond);
- if (x == null)
- return true;
-
- return false;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Ntp.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Ntp.java
deleted file mode 100644
index 96b1b4e2ecb..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Ntp.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-/*
- * should become an interface implementation
- */
-public class Ntp extends OvmObject {
- private List Servers = new ArrayList();
- private Boolean isServer = null;
- private Boolean isRunning = null;
-
- public Ntp(Connection c) {
- client = c;
- }
-
- public List addServer(String server) {
- if (Servers.contains(server) == false)
- Servers.add(server);
-
- return Servers;
- }
-
- public List removeServer(String server) {
- if (Servers.contains(server))
- Servers.remove(server);
-
- return Servers;
- }
-
- public List servers() {
- return Servers;
- }
-
- public Boolean isRunning() {
- return isRunning;
- }
-
- public Boolean isServer() {
- return isServer;
- }
-
- public Boolean getDetails() throws XmlRpcException {
- return this.getNtp();
- }
-
- /*
- * get_ntp, argument: self - default:
- * None
- */
- public Boolean getNtp() throws XmlRpcException {
- Object[] v = (Object[]) callWrapper("get_ntp");
- int c = 0;
- for (Object o : v) {
- // System.out.println(o.getClass());
- if (o instanceof java.lang.Boolean) {
- if (c == 0)
- this.isServer = (Boolean) o;
-
- if (c == 1)
- this.isRunning = (Boolean) o;
-
- // should not get here
- if (c > 1)
- return false;
-
- c += 1;
- } else if (o instanceof java.lang.Object) {
- Object[] S = (Object[]) o;
- for (Object m : S) {
- this.addServer((String) m);
- }
- }
- }
- return true;
- }
-
- /*
- * set_ntp, argument: self - default:
- * None argument: servers - default: None argument: local_time_source -
- * default: None argument: allow_query - default: None // right, can't be
- * set eh
- */
- public Boolean setNtp(List servers, Boolean running)
- throws XmlRpcException {
- if (callWrapper("set_ntp", servers, running) == null) {
- return this.getNtp();
- } else {
- return false;
- }
- }
-
- /* also cleans the vector */
- public Boolean setNtp(String server, Boolean running)
- throws XmlRpcException {
- this.Servers = new ArrayList();
- this.Servers.add(server);
- return setNtp(this.Servers, running);
- }
-
- public Boolean setNtp(Boolean running) throws XmlRpcException {
- return setNtp(this.Servers, running);
- }
-
- /*
- * disable_ntp, argument: self -
- * default: None
- */
- public Boolean disableNtp() throws XmlRpcException {
- if (callWrapper("disable_ntp") == null)
- return true;
- return false;
- }
-
- /*
- * enable_ntp, argument: self -
- * default: None
- */
- public Boolean enableNtp() throws XmlRpcException {
- if (callWrapper("enable_ntp") == null)
- return true;
- return false;
- }
-}
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/OvmObject.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/OvmObject.java
deleted file mode 100644
index 4dba83c3625..00000000000
--- a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/OvmObject.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Licensed 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.
- ******************************************************************************/
-package com.cloud.hypervisor.ovm3.object;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.xmlrpc.XmlRpcException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-public class OvmObject {
- public static Connection client = null;
- public static Vector> emptyParams = new Vector