Merge branch 'master' into ui-plugins

This commit is contained in:
Brian Federle 2012-12-21 12:53:10 -08:00
commit 0e3184cdcc
12 changed files with 2106 additions and 2061 deletions

3824
LICENSE

File diff suppressed because it is too large Load Diff

146
NOTICE
View File

@ -6,9 +6,84 @@
This distribution contains third party resources requiring the following notices:
Source code distribution if this software contains third party resources requiring
the following notices:
For
jquery.md5.js
jQuery MD5 Plugin 1.2.1
https://github.com/blueimp/jQuery-MD5
Copyright 2010, Sebastian Tschan
https://blueimp.net
Licensed under the MIT license:
http://creativecommons.org/licenses/MIT/
Based on
A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
Digest Algorithm, as defined in RFC 1321.
Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
Distributed under the BSD License
See http://pajhome.org.uk/crypt/md5 for more info.
For
jquery.js
jQuery JavaScript Library v1.3.2
http://jquery.com/
Copyright (c) 2009 John Resig
Dual licensed under the MIT and GPL licenses.
http://docs.jquery.com/License
Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
Revision: 6246
For
jquery.js
jQuery JavaScript Library v1.6.1
http://jquery.com/
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
http://sizzlejs.com/
Copyright 2011, The Dojo Foundation
Released under the MIT, BSD, and GPL Licenses.
Date: Thu May 12 15:04:36 2011 -0400
For
jquery.colorhelpers.js
Plugin for jQuery for working with colors.
Version 1.1.
Inspiration from jQuery color animation plugin by John Resig.
Released under the MIT license by Ole Laursen, October 2009.
********************************************************************************
Binary or packaged versions of this software (including versions built from source)
contains third party resources requiring the following notices:
For
cloud-ejb-api-3.0.jar
cloud-email.jar
@ -337,28 +412,6 @@
without prior written authorization of the copyright holder.
For
jquery.md5.js
jQuery MD5 Plugin 1.2.1
https://github.com/blueimp/jQuery-MD5
Copyright 2010, Sebastian Tschan
https://blueimp.net
Licensed under the MIT license:
http://creativecommons.org/licenses/MIT/
Based on
A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
Digest Algorithm, as defined in RFC 1321.
Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
Distributed under the BSD License
See http://pajhome.org.uk/crypt/md5 for more info.
For
XmlSchema-1.4.3.jar
@ -430,21 +483,6 @@
THE SOFTWARE.
For
jquery.js
jQuery JavaScript Library v1.3.2
http://jquery.com/
Copyright (c) 2009 John Resig
Dual licensed under the MIT and GPL licenses.
http://docs.jquery.com/License
Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
Revision: 6246
For
axis2-1.5.1.jar
axis2-adb-1.5.1.jar
@ -532,25 +570,6 @@
--------------------------------------------------------------------------------
For
jquery.js
jQuery JavaScript Library v1.6.1
http://jquery.com/
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
http://sizzlejs.com/
Copyright 2011, The Dojo Foundation
Released under the MIT, BSD, and GPL Licenses.
Date: Thu May 12 15:04:36 2011 -0400
For
rampart-lib
@ -588,19 +607,6 @@
software copyright (c) 1999.
For
jquery.colorhelpers.js
Plugin for jQuery for working with colors.
Version 1.1.
Inspiration from jQuery color animation plugin by John Resig.
Released under the MIT license by Ole Laursen, October 2009.
For
woden-api-1.0M8.jar
woden-impl-dom-1.0M8.jar

View File

@ -105,6 +105,8 @@ public enum Config {
SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding", "true", "If true, the user VM would be added to the default security group by default", null),
GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkManager.class, String.class, "network.dhcp.nondefaultnetwork.setgateway.guestos", "Windows", "The guest OS's name start with this fields would result in DHCP server response gateway information even when the network it's on is not default network. Names are separated by comma.", null),
//VPN
RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length", "24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),
RemoteAccessVpnClientIpRange("Network", AgentManager.class, String.class, "remote.access.vpn.client.iprange", "10.1.2.1-10.1.2.8", "The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server", null),
@ -293,6 +295,7 @@ public enum Config {
VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"),
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously. 0 means to never retry.", "Seconds"),

View File

@ -341,6 +341,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
int _routerCheckInterval = 30;
protected ServiceOfferingVO _offering;
private String _dnsBasicZoneUpdates = "all";
private Set<String> _guestOSNeedGatewayOnNonDefaultNetwork = new HashSet<String>();
private boolean _disable_rp_filter = false;
int _routerExtraPublicNics = 2;
@ -501,6 +502,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
if(virtualRouter == null){
throw new CloudRuntimeException("Failed to stop router with id " + routerId);
}
// Clear stop pending flag after stopped successfully
if (router.isStopPending()) {
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after stop router successfully");
router.setStopPending(false);
router = _routerDao.persist(router);
virtualRouter.setStopPending(false);
}
return virtualRouter;
}
@ -584,6 +593,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
String guestOSString = configs.get("network.dhcp.nondefaultnetwork.setgateway.guestos");
if (guestOSString != null) {
String[] guestOSList = guestOSString.split(",");
for (String os : guestOSList) {
_guestOSNeedGatewayOnNonDefaultNetwork.add(os);
}
}
String value = configs.get("start.retry");
_retry = NumbersUtil.parseInt(value, 2);
@ -2413,6 +2430,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Starting router " + router);
if (_itMgr.start(router, params, user, caller, planToDeploy) != null) {
if (router.isStopPending()) {
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
router.setStopPending(false);
router = _routerDao.persist(router);
}
// We don't want the failure of VPN Connection affect the status of router, so we try to make connection
// only after router start successfully
Long vpcId = router.getVpcId();
@ -2918,14 +2940,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
String gatewayIp = findGatewayIp(vm.getId());
boolean needGateway = true;
if (!gatewayIp.equals(nic.getGateway())) {
needGateway = false;
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
// Don't set dhcp:router option for non-default nic on CentOS/RHEL, because they would set routing on wrong interface
// This is tricky, we may need to update this when we have more information on various OS's behavior
if (guestOS.getDisplayName().startsWith("CentOS") || guestOS.getDisplayName().startsWith("Red Hat Enterprise")) {
gatewayIp = "0.0.0.0";
// Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset.
// Because some OS(e.g. CentOS) would set routing on wrong interface
for (String name : _guestOSNeedGatewayOnNonDefaultNetwork) {
if (guestOS.getDisplayName().startsWith(name)) {
needGateway = true;
break;
}
}
}
if (!needGateway) {
gatewayIp = "0.0.0.0";
}
dhcpCommand.setDefaultRouter(gatewayIp);
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
@ -3308,6 +3338,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
for (DomainRouterVO router : routers) {
if (router.isStopPending()) {
s_logger.info("Stopping router " + router.getInstanceName() + " due to stop pending flag found!");
State state = router.getState();
if (state != State.Stopped && state != State.Destroyed) {
try {

View File

@ -18,6 +18,7 @@
package com.cloud.upgrade.dao;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import java.io.File;
import java.sql.Connection;
@ -29,7 +30,7 @@ import java.sql.SQLException;
* @author htrippaers
*
*/
public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade {
public class Upgrade40to41 implements DbUpgrade {
/**
*
@ -67,7 +68,12 @@ public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade {
*/
@Override
public File[] getPrepareScripts() {
return new File[0];
String script = Script.findScript("", "db/schema-40to410.sql");
if (script == null) {
throw new CloudRuntimeException("Unable to find db/schema-40to410.sql");
}
return new File[] { new File(script) };
}
/* (non-Javadoc)

View File

@ -166,7 +166,7 @@ CREATE TABLE `cloud`.`version` (
INDEX `i_version__version`(`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `version` (`version`, `updated`, `step`) VALUES('4.0.0.2012-09-12T14:47:37Z', now(), 'Complete');
INSERT INTO `version` (`version`, `updated`, `step`) VALUES('4.1.0', now(), 'Complete');
CREATE TABLE `cloud`.`op_it_work` (
`id` char(40) COMMENT 'reservation id',

View File

@ -1,23 +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.
--;
-- Schema upgrade from 4.0 to 4.1.0;
--;
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;

View File

@ -56,3 +56,7 @@ ALTER TABLE `cloud`.`snapshots` ADD COLUMN `s3_id` bigint unsigned COMMENT 'S3 t
ALTER TABLE `cloud`.`snapshots` ADD CONSTRAINT `fk_snapshots__s3_id` FOREIGN KEY `fk_snapshots__s3_id` (`s3_id`) REFERENCES `s3` (`id`);
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network','DEFAULT','NetworkManager','network.dhcp.nondefaultnetwork.setgateway.guestos','Windows','The guest OS\'s name start with this fields would result in DHCP server response gateway information even when the network it\'s on is not default network. Names are separated by comma.');

View File

@ -37,6 +37,7 @@ try:
from urllib2 import HTTPError, URLError
from httplib import BadStatusLine
from prettytable import PrettyTable
from common import __version__, config_file, config_fields
from common import grammar, precached_verbs
from marvin.cloudstackConnection import cloudConnection
@ -65,7 +66,7 @@ logger = logging.getLogger(__name__)
completions = cloudstackAPI.__all__
class CloudStackShell(cmd.Cmd, object):
class CloudMonkeyShell(cmd.Cmd, object):
intro = ("☁ Apache CloudStack 🐵 cloudmonkey " + __version__ +
". Type help or ? to list commands.\n")
ruler = "="
@ -137,7 +138,7 @@ class CloudStackShell(cmd.Cmd, object):
print self.intro
while True:
try:
super(CloudStackShell, self).cmdloop(intro = "")
super(CloudMonkeyShell, self).cmdloop(intro="")
self.postloop()
except KeyboardInterrupt:
print("^C")
@ -173,29 +174,58 @@ class CloudStackShell(cmd.Cmd, object):
except Exception, e:
print colored.red("Error: "), e
def print_result(self, result):
def print_result(self, result, result_filter=None):
if result is None or len(result) == 0:
return
def print_result_as_dict(result):
def printer_helper(printer, toprow):
if printer:
print printer
return PrettyTable(toprow)
def print_result_tabular(result, result_filter=None):
toprow = None
printer = None
for node in result:
if toprow != node.keys():
if result_filter is not None and len(result_filter) != 0:
commonkeys = filter(lambda x: x in node.keys(),
result_filter)
if commonkeys != toprow:
toprow = commonkeys
printer = printer_helper(printer, toprow)
else:
toprow = node.keys()
printer = printer_helper(printer, toprow)
row = map(lambda x: node[x], toprow)
if printer and row:
printer.add_row(row)
if printer:
print printer
def print_result_as_dict(result, result_filter=None):
for key in result.keys():
if not (isinstance(result[key], list) or
isinstance(result[key], dict)):
self.print_shell("%s = %s" % (key, result[key]))
else:
self.print_shell(key + ":\n" + len(key) * "=")
self.print_result(result[key])
self.print_shell(key + ":\n" + len(key) * self.ruler)
self.print_result(result[key], result_filter)
def print_result_as_list(result):
def print_result_as_list(result, result_filter=None):
for node in result:
# Tabular print if it's a list of dict and tabularize is true
if isinstance(node, dict) and self.tabularize == 'true':
print_result_tabular(result, result_filter)
break
self.print_result(node)
if len(result) > 1:
self.print_shell(self.ruler * 80)
if isinstance(result, dict):
print_result_as_dict(result)
print_result_as_dict(result, result_filter)
elif isinstance(result, list):
print_result_as_list(result)
print_result_as_list(result, result_filter)
elif isinstance(result, str):
print result
elif not (str(result) is None):
@ -281,6 +311,11 @@ class CloudStackShell(cmd.Cmd, object):
args_dict = dict(map(lambda x: [x.partition("=")[0],
x.partition("=")[2]],
args[1:])[x] for x in range(len(args) - 1))
field_filter = None
if 'filter' in args_dict:
field_filter = filter(lambda x: x is not '',
map(lambda x: x.strip(),
args_dict.pop('filter').split(',')))
api_cmd_str = "%sCmd" % api_name
api_mod = self.get_api_module(api_name, [api_cmd_str])
@ -313,7 +348,8 @@ class CloudStackShell(cmd.Cmd, object):
return
try:
# Response is in the key "apiname+response" (lowercase)
self.print_result(result[api_name.lower()+'response'])
self.print_result(result[api_name.lower() + 'response'],
field_filter)
print
except Exception as e:
self.print_shell("🙈 Error on parsing and printing", e)
@ -367,6 +403,7 @@ class CloudStackShell(cmd.Cmd, object):
self.cache_verbs[verb][subject][1])
search_string = text
autocompletions.append("filter=")
return [s for s in autocompletions if s.startswith(search_string)]
def do_api(self, args):
@ -388,7 +425,7 @@ class CloudStackShell(cmd.Cmd, object):
def do_set(self, args):
"""
Set config for CloudStack CLI. Available options are:
Set config for cloudmonkey. For example, options can be:
host, port, apikey, secretkey, log_file, history_file
You may also edit your ~/.cloudmonkey_config instead of using set.
@ -460,13 +497,13 @@ class CloudStackShell(cmd.Cmd, object):
def do_exit(self, args):
"""
Quit Apache CloudStack CLI
Quit CloudMonkey CLI
"""
return self.do_quit(args)
def do_quit(self, args):
"""
Quit Apache CloudStack CLI
Quit CloudMonkey CLI
"""
self.print_shell("Bye!")
return self.do_EOF(args)
@ -480,7 +517,7 @@ class CloudStackShell(cmd.Cmd, object):
def main():
# Create handlers on the fly using closures
self = CloudStackShell
self = CloudMonkeyShell
global grammar
for rule in grammar:
def add_grammar(rule):
@ -496,7 +533,6 @@ def main():
try:
args_partition = args.partition(" ")
res = self.cache_verbs[rule][args_partition[0]]
except KeyError, e:
self.print_shell("Error: invalid %s api arg" % rule, e)
return
@ -511,7 +547,7 @@ def main():
grammar_handler.__name__ = 'do_' + rule
setattr(self, grammar_handler.__name__, grammar_handler)
shell = CloudStackShell()
shell = CloudMonkeyShell()
if len(sys.argv) > 1:
shell.onecmd(' '.join(sys.argv[1:]))
else:

View File

@ -33,6 +33,7 @@ config_fields = {'host': 'localhost', 'port': '8080',
'apikey': '', 'secretkey': '',
'timeout': '3600', 'asyncblock': 'true',
'prompt': '🐵 cloudmonkey>', 'color': 'true',
'tabularize': 'false',
'log_file':
os.path.expanduser('~/.cloudmonkey_log'),
'history_file':

View File

@ -26,7 +26,9 @@ from cloudmonkey import __version__
name = 'cloudmonkey'
version = __version__
requires = ['clint>=0.3.0',]
requires = ['clint>=0.3.0',
'prettytable>=0.6',
]
try:
import readline

View File

@ -2634,6 +2634,29 @@ Copyright (c) 2004 Clinton Begin
</by-organisation>
</with-license>
</within>
<within dir='scripts/storage/secondary'>
<with-license id='ApacheLicenseVersion2'>
<copyright-notice>
Copyright (c) 2010-2011 OpenStack, LLC.
</copyright-notice>
<by-organisation id='openstack.org'>
<resource name='swift' />
</by-organisation>
</with-license>
</within>
<within dir='scripts/vm/hypervisor/xenserver'>
<with-license id='ApacheLicenseVersion2'>
<copyright-notice>
Copyright (c) 2010-2011 OpenStack, LLC.
</copyright-notice>
<by-organisation id='openstack.org'>
<resource name='swift' />
</by-organisation>
</with-license>
</within>
<!-- Resources below this line are binary dependencies that are only pulled in during the build process. -->
<within dir='target/jar'>
<with-license id='MIT'>
<copyright-notice>
@ -2789,26 +2812,6 @@ All rights reserved.
</by-organisation>
</public-domain>
</within>
<within dir='scripts/storage/secondary'>
<with-license id='ApacheLicenseVersion2'>
<copyright-notice>
Copyright (c) 2010-2011 OpenStack, LLC.
</copyright-notice>
<by-organisation id='openstack.org'>
<resource name='swift' />
</by-organisation>
</with-license>
</within>
<within dir='scripts/vm/hypervisor/xenserver'>
<with-license id='ApacheLicenseVersion2'>
<copyright-notice>
Copyright (c) 2010-2011 OpenStack, LLC.
</copyright-notice>
<by-organisation id='openstack.org'>
<resource name='swift' />
</by-organisation>
</with-license>
</within>
<within dir='deps/awsapi-lib'>
<with-license id='ApacheLicenseVersion2'>
<copyright-notice>