pre-commit: add hook to trim trailing whitespace (#8205)

This commit is contained in:
John Bampton 2024-05-28 17:01:30 +10:00 committed by GitHub
parent 40c5d35377
commit 28e8e2d009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
157 changed files with 753 additions and 754 deletions

View File

@ -58,7 +58,9 @@ repos:
- id: forbid-submodules - id: forbid-submodules
- id: mixed-line-ending - id: mixed-line-ending
exclude: \.(cs|xml)$ exclude: \.(cs|xml)$
# - id: trailing-whitespace - id: trailing-whitespace
files: \.(in|java|md|py|rb|sh|vue|yaml|yml)$
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 7.0.0 rev: 7.0.0
hooks: hooks:

View File

@ -430,11 +430,11 @@ Bug ID | Description
[CLOUDSTACK-6099](https://issues.apache.org/jira/browse/CLOUDSTACK-6099) | live migration is failing for vm deployed using dynamic compute offerings with NPE [CLOUDSTACK-6099](https://issues.apache.org/jira/browse/CLOUDSTACK-6099) | live migration is failing for vm deployed using dynamic compute offerings with NPE
[CLOUDSTACK-7528](https://issues.apache.org/jira/browse/CLOUDSTACK-7528) | More verbose logging when sending alert fails [CLOUDSTACK-7528](https://issues.apache.org/jira/browse/CLOUDSTACK-7528) | More verbose logging when sending alert fails
[CLOUDSTACK-6624](https://issues.apache.org/jira/browse/CLOUDSTACK-6624) | set specifyIpRanges to true if specifyVlan is set to true [CLOUDSTACK-6624](https://issues.apache.org/jira/browse/CLOUDSTACK-6624) | set specifyIpRanges to true if specifyVlan is set to true
[CLOUDSTACK-7404](https://issues.apache.org/jira/browse/CLOUDSTACK-7404) | Failed to start an instance when originating template has been deleted [CLOUDSTACK-7404](https://issues.apache.org/jira/browse/CLOUDSTACK-7404) | Failed to start an instance when originating template has been deleted
[CLOUDSTACK-6531](https://issues.apache.org/jira/browse/CLOUDSTACK-6531) | Stopping the router in case of command failures [CLOUDSTACK-6531](https://issues.apache.org/jira/browse/CLOUDSTACK-6531) | Stopping the router in case of command failures
[CLOUDSTACK-6115](https://issues.apache.org/jira/browse/CLOUDSTACK-6115) | TravisCI configuration [CLOUDSTACK-6115](https://issues.apache.org/jira/browse/CLOUDSTACK-6115) | TravisCI configuration
[CLOUDSTACK-7405](https://issues.apache.org/jira/browse/CLOUDSTACK-7405) | allowing VR meta-data to be accessed without trailing slash [CLOUDSTACK-7405](https://issues.apache.org/jira/browse/CLOUDSTACK-7405) | allowing VR meta-data to be accessed without trailing slash
[CLOUDSTACK-7260](https://issues.apache.org/jira/browse/CLOUDSTACK-7260) | Management server not responding after some time for Vmware due to Oom [CLOUDSTACK-7260](https://issues.apache.org/jira/browse/CLOUDSTACK-7260) | Management server not responding after some time for Vmware due to Oom
[CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server pkg for debian [CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server pkg for debian
[CLOUDSTACK-6892](https://issues.apache.org/jira/browse/CLOUDSTACK-6892) | Create separate package for the mysql HA component [CLOUDSTACK-6892](https://issues.apache.org/jira/browse/CLOUDSTACK-6892) | Create separate package for the mysql HA component
[CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server/rpms [CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server/rpms
@ -449,12 +449,12 @@ Bug ID | Description
[CLOUDSTACK-7006](https://issues.apache.org/jira/browse/CLOUDSTACK-7006) | Restore template ID in ROOT volume usages [CLOUDSTACK-7006](https://issues.apache.org/jira/browse/CLOUDSTACK-7006) | Restore template ID in ROOT volume usages
[CLOUDSTACK-6747](https://issues.apache.org/jira/browse/CLOUDSTACK-6747) | test to allow all cidrs on other end of vpc [CLOUDSTACK-6747](https://issues.apache.org/jira/browse/CLOUDSTACK-6747) | test to allow all cidrs on other end of vpc
[CLOUDSTACK-6272](https://issues.apache.org/jira/browse/CLOUDSTACK-6272) | Fix recover/restore VM actions [CLOUDSTACK-6272](https://issues.apache.org/jira/browse/CLOUDSTACK-6272) | Fix recover/restore VM actions
[CLOUDSTACK-6927](https://issues.apache.org/jira/browse/CLOUDSTACK-6927) | store virsh list in list instead of querying libvirt [CLOUDSTACK-6927](https://issues.apache.org/jira/browse/CLOUDSTACK-6927) | store virsh list in list instead of querying libvirt
[CLOUDSTACK-6317](https://issues.apache.org/jira/browse/CLOUDSTACK-6317) | [VMware] Tagged VLAN support broken for Management/Control/Storage traffic [CLOUDSTACK-6317](https://issues.apache.org/jira/browse/CLOUDSTACK-6317) | [VMware] Tagged VLAN support broken for Management/Control/Storage traffic
[CLOUDSTACK-5891](https://issues.apache.org/jira/browse/CLOUDSTACK-5891) | [VMware] If a template has been registered and "cpu.corespersocket=X" , [CLOUDSTACK-5891](https://issues.apache.org/jira/browse/CLOUDSTACK-5891) | [VMware] If a template has been registered and "cpu.corespersocket=X" ,
[CLOUDSTACK-6478](https://issues.apache.org/jira/browse/CLOUDSTACK-6478) | Failed to download Template when having 3 SSVM's in one [CLOUDSTACK-6478](https://issues.apache.org/jira/browse/CLOUDSTACK-6478) | Failed to download Template when having 3 SSVM's in one
[CLOUDSTACK-6464](https://issues.apache.org/jira/browse/CLOUDSTACK-6464) | if guest network type is vlan://untagged, and traffic label is used [CLOUDSTACK-6464](https://issues.apache.org/jira/browse/CLOUDSTACK-6464) | if guest network type is vlan://untagged, and traffic label is used
[CLOUDSTACK-6816](https://issues.apache.org/jira/browse/CLOUDSTACK-6816) | bugfix: cloudstack-setup-management make /root directory's permission 0777 [CLOUDSTACK-6816](https://issues.apache.org/jira/browse/CLOUDSTACK-6816) | bugfix: cloudstack-setup-management make /root directory's permission 0777
[CLOUDSTACK-6204](https://issues.apache.org/jira/browse/CLOUDSTACK-6204) | applying missed patch [CLOUDSTACK-6204](https://issues.apache.org/jira/browse/CLOUDSTACK-6204) | applying missed patch
[CLOUDSTACK-6472](https://issues.apache.org/jira/browse/CLOUDSTACK-6472) | (4.3 specific) listUsageRecords: Pull information from removed items as well [CLOUDSTACK-6472](https://issues.apache.org/jira/browse/CLOUDSTACK-6472) | (4.3 specific) listUsageRecords: Pull information from removed items as well
[CLOUDSTACK-5976](https://issues.apache.org/jira/browse/CLOUDSTACK-5976) | Typo in "ssh_keypairs" table's foreign key constraints on the Upgraded Setup [CLOUDSTACK-5976](https://issues.apache.org/jira/browse/CLOUDSTACK-5976) | Typo in "ssh_keypairs" table's foreign key constraints on the Upgraded Setup
@ -657,11 +657,11 @@ Version 4.1.0
------------- -------------
This is the second major release of CloudStack from within the Apache Software Foundation, and the This is the second major release of CloudStack from within the Apache Software Foundation, and the
first major release as a Top-Level Project (TLP). first major release as a Top-Level Project (TLP).
Build Tool Changes: Build Tool Changes:
* The project now uses Maven 3 exclusively to build. * The project now uses Maven 3 exclusively to build.
New Features: New Features:
* CLOUDSTACK-101: OVS support in KVM * CLOUDSTACK-101: OVS support in KVM
@ -976,14 +976,14 @@ Issues fixed in this release:
* CLOUDSTACK-1845: KVM - storage migration often fails * CLOUDSTACK-1845: KVM - storage migration often fails
* CLOUDSTACK-1846: KVM - storage pools can silently fail to be unregistered, leading to failure to register later * CLOUDSTACK-1846: KVM - storage pools can silently fail to be unregistered, leading to failure to register later
* CLOUDSTACK-2003: Deleting domain while deleted account is cleaning up leaves VMs expunging forever due to 'Failed to update resource count' * CLOUDSTACK-2003: Deleting domain while deleted account is cleaning up leaves VMs expunging forever due to 'Failed to update resource count'
* CLOUDSTACK-2090: Upgrade from version 4.0.1 to version 4.0.2 triggers the 4.0.0 to 4.0.1. * CLOUDSTACK-2090: Upgrade from version 4.0.1 to version 4.0.2 triggers the 4.0.0 to 4.0.1.
* CLOUDSTACK-2091: Error in API documentation for 4.0.x. * CLOUDSTACK-2091: Error in API documentation for 4.0.x.
Version 4.0.1-incubating Version 4.0.1-incubating
------------------------ ------------------------
This is a bugfix release for Apache CloudStack 4.0.0-incubating, with no new features. This is a bugfix release for Apache CloudStack 4.0.0-incubating, with no new features.
Security Fixes: Security Fixes:

View File

@ -3,7 +3,7 @@ Contributing to Apache CloudStack (ACS)
Summary Summary
------- -------
This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions. This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions.
These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project and you will submit a Pull Request for your changes to be added. These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project and you will submit a Pull Request for your changes to be added.
_Lets get started!!!_ _Lets get started!!!_
@ -11,17 +11,17 @@ _Lets get started!!!_
Bug fixes Bug fixes
--------- ---------
It's very important that we can easily track bug fix commits, so their hashes should remain the same in all branches. It's very important that we can easily track bug fix commits, so their hashes should remain the same in all branches.
Therefore, a pull request (PR) that fixes a bug, should be sent against a release branch. Therefore, a pull request (PR) that fixes a bug, should be sent against a release branch.
This can be either the "current release" or the "previous release", depending on which ones are maintained. This can be either the "current release" or the "previous release", depending on which ones are maintained.
Since the goal is a stable main, bug fixes should be "merged forward" to the next branch in order: "previous release" -> "current release" -> main (in other words: old to new) Since the goal is a stable main, bug fixes should be "merged forward" to the next branch in order: "previous release" -> "current release" -> main (in other words: old to new)
Developing new features Developing new features
----------------------- -----------------------
Development should be done in a feature branch, branched off of main. Development should be done in a feature branch, branched off of main.
Send a PR(steps below) to get it into main (2x LGTM applies). Send a PR(steps below) to get it into main (2x LGTM applies).
PR will only be merged when main is open, will be held otherwise until main is open again. PR will only be merged when main is open, will be held otherwise until main is open again.
No back porting / cherry-picking features to existing branches! No back porting / cherry-picking features to existing branches!
PendingReleaseNotes file PendingReleaseNotes file
@ -33,7 +33,7 @@ When adding information to the PendingReleaseNotes file make sure that you write
Updating the PendingReleaseNotes file is preferably a part of the original Pull Request, but that is up to the developers' discretion. Updating the PendingReleaseNotes file is preferably a part of the original Pull Request, but that is up to the developers' discretion.
Fork the code Fork the code
------------- -------------
In your browser, navigate to: [https://github.com/apache/cloudstack](https://github.com/apache/cloudstack) In your browser, navigate to: [https://github.com/apache/cloudstack](https://github.com/apache/cloudstack)
@ -136,4 +136,4 @@ $ git push origin :feature_x
Release Principles Release Principles
------------------ ------------------
Detailed information about ACS release principles is available at https://cwiki.apache.org/confluence/display/CLOUDSTACK/Release+principles+for+Apache+CloudStack+4.6+and+up Detailed information about ACS release principles is available at https://cwiki.apache.org/confluence/display/CLOUDSTACK/Release+principles+for+Apache+CloudStack+4.6+and+up

View File

@ -142,7 +142,7 @@ This distribution includes cryptographic software. The country in which you curr
reside may have restrictions on the import, possession, use, and/or re-export to another reside may have restrictions on the import, possession, use, and/or re-export to another
country, of encryption software. BEFORE using any encryption software, please check your country, of encryption software. BEFORE using any encryption software, please check your
country's laws, regulations and policies concerning the import, possession, or use, and country's laws, regulations and policies concerning the import, possession, or use, and
re-export of encryption software, to see if this is permitted. See [The Wassenaar Arrangement](http://www.wassenaar.org/) re-export of encryption software, to see if this is permitted. See [The Wassenaar Arrangement](http://www.wassenaar.org/)
for more information. for more information.
The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -46,7 +46,7 @@ cfg = "@MSCONF@/db.properties"
#---------------------- option parsing and command line checks ------------------------ #---------------------- option parsing and command line checks ------------------------
usage = """%prog <license file> <-a | host names / IP addresses...> usage = """%prog <license file> <-a | host names / IP addresses...>
This command deploys the license file specified in the command line into a specific XenServer host or all XenServer hosts known to the management server.""" This command deploys the license file specified in the command line into a specific XenServer host or all XenServer hosts known to the management server."""
@ -88,7 +88,7 @@ def parseuserpwfromhosts(hosts):
return creds return creds
class XenServerConfigurator(Thread): class XenServerConfigurator(Thread):
def __init__(self,host,user,password,keyfiledata): def __init__(self,host,user,password,keyfiledata):
Thread.__init__(self) Thread.__init__(self)
self.host = host self.host = host
@ -99,7 +99,7 @@ class XenServerConfigurator(Thread):
self.stdout = "" self.stdout = ""
self.stderr = "" self.stderr = ""
self.state = 'initialized' self.state = 'initialized'
def run(self): def run(self):
try: try:
self.state = 'running' self.state = 'running'
@ -120,18 +120,18 @@ class XenServerConfigurator(Thread):
c.close() c.close()
if self.retval != 0: self.state = 'failed' if self.retval != 0: self.state = 'failed'
else: self.state = 'finished' else: self.state = 'finished'
except Exception as e: except Exception as e:
self.state = 'failed' self.state = 'failed'
self.retval = e self.retval = e
#raise #raise
def __str__(self): def __str__(self):
if self.state == 'failed': if self.state == 'failed':
return "<%s XenServerConfigurator on %s@%s: %s>"%(self.state,self.user,self.host,str(self.retval)) return "<%s XenServerConfigurator on %s@%s: %s>"%(self.state,self.user,self.host,str(self.retval))
else: else:
return "<%s XenServerConfigurator on %s@%s>"%(self.state,self.user,self.host) return "<%s XenServerConfigurator on %s@%s>"%(self.state,self.user,self.host)
#------------- actual code -------------------- #------------- actual code --------------------
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -162,7 +162,7 @@ for host,(user,password) in list(creds.items()):
for c in configurators: c.start() for c in configurators: c.start()
for c in configurators: for c in configurators:
print(c.host + "...", end=' ') print(c.host + "...", end=' ')
c.join() c.join()

View File

@ -8,7 +8,7 @@
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -47,5 +47,5 @@ echo "new mysql server is started on port "$PORT
echo $db echo $db
echo "commands ...." echo "commands ...."
echo "to connect(from local host): mysql -h 127.0.0.1 -P "$PORT echo "to connect(from local host): mysql -h 127.0.0.1 -P "$PORT
echo "to stop: mysqladmin -S /tmp/mysql"$PORT"/mysqld.sock shutdown -u root" echo "to stop: mysqladmin -S /tmp/mysql"$PORT"/mysqld.sock shutdown -u root"

View File

@ -294,7 +294,7 @@ This is independent of StorPool as snapshots exist on secondary.
### Creating ROOT volume from templates ### Creating ROOT volume from templates
When creating the first volume based on the given template, if snapshot of the template does not exists on StorPool it will be first downloaded (cached) to PRIMARY storage. When creating the first volume based on the given template, if snapshot of the template does not exists on StorPool it will be first downloaded (cached) to PRIMARY storage.
This is mapped to a StorPool snapshot so, creating succecutive volumes from the same template does not incur additional This is mapped to a StorPool snapshot so, creating succecutive volumes from the same template does not incur additional
copying of data to PRIMARY storage. copying of data to PRIMARY storage.
This cached snapshot is garbage collected when the original template is deleted from CloudStack. This cleanup is done This cached snapshot is garbage collected when the original template is deleted from CloudStack. This cleanup is done

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -52,7 +52,7 @@ start() {
log_end_msg 1 log_end_msg 1
exit 1 exit 1
fi fi
if start-stop-daemon --start --quiet \ if start-stop-daemon --start --quiet \
--pidfile "$PIDFILE" \ --pidfile "$PIDFILE" \
--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS --exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -51,7 +51,7 @@ verify_cksum() {
esac esac
echo "$1 $2" | $digestalgo -c --status echo "$1 $2" | $digestalgo -c --status
#printf "$1\t$2" | $digestalgo -c --status #printf "$1\t$2" | $digestalgo -c --status
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Checksum failed, not proceeding with install\n" printf "Checksum failed, not proceeding with install\n"
exit 3 exit 3
@ -92,12 +92,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file, exiting " printf "Failed to uncompress file, exiting "
exit 1 exit 1
fi fi
mv $tmpfile $imgfile mv $tmpfile $imgfile
printf "$imgfile" printf "$imgfile"
@ -184,10 +184,10 @@ then
tmpltfs=${tmpltfs:1} tmpltfs=${tmpltfs:1}
fi fi
if [ ! -d /$tmpltfs ] if [ ! -d /$tmpltfs ]
then then
zfs create -p $tmpltfs zfs create -p $tmpltfs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create user fs $tmpltfs\n" >&2 printf "Failed to create user fs $tmpltfs\n" >&2
exit 1 exit 1
@ -203,7 +203,7 @@ fi
tmpltimg2=$(uncompress $tmpltimg) tmpltimg2=$(uncompress $tmpltimg)
tmpltimg2=$(untar $tmpltimg2 /$tmpltfs vmi-root) tmpltimg2=$(untar $tmpltimg2 /$tmpltfs vmi-root)
if [ ! -f $tmpltimg2 ] if [ ! -f $tmpltimg2 ]
then then
rollback_if_needed $tmpltfs 2 "root disk file $tmpltimg doesn't exist\n" rollback_if_needed $tmpltfs 2 "root disk file $tmpltimg doesn't exist\n"
exit 3 exit 3
@ -217,15 +217,15 @@ fi
#determine source file size -- it needs to be less than or equal to volsize #determine source file size -- it needs to be less than or equal to volsize
imgsize=$(ls -lh $tmpltimg2| awk -F" " '{print $5}') imgsize=$(ls -lh $tmpltimg2| awk -F" " '{print $5}')
if [ ${imgsize:(-1)} == G ] if [ ${imgsize:(-1)} == G ]
then then
imgsize=${imgsize%G} #strip out the G imgsize=${imgsize%G} #strip out the G
imgsize=${imgsize%.*} #...and any decimal part imgsize=${imgsize%.*} #...and any decimal part
let imgsize=imgsize+1 # add 1 to compensate for decimal part let imgsize=imgsize+1 # add 1 to compensate for decimal part
volsizetmp=${volsize%G} volsizetmp=${volsize%G}
if [ $volsizetmp -lt $imgsize ] if [ $volsizetmp -lt $imgsize ]
then then
volsize=${imgsize}G volsize=${imgsize}G
fi fi
fi fi
@ -234,11 +234,11 @@ tgtfile=${tmpltfs}/vmi-root-${tmpltname}
create_from_file $tmpltfs $tmpltimg2 $tgtfile $volsize $cleanup create_from_file $tmpltfs $tmpltimg2 $tgtfile $volsize $cleanup
tmpltswap=$(ls -lh /$tmpltfs | grep swap) tmpltswap=$(ls -lh /$tmpltfs | grep swap)
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
swapsize=$(echo $tmpltswap | awk '{print $5}') swapsize=$(echo $tmpltswap | awk '{print $5}')
tmpltswap=$(echo $tmpltswap | awk '{print $NF}') tmpltswap=$(echo $tmpltswap | awk '{print $NF}')
tmpltswap=/${tmpltfs}/${tmpltswap} tmpltswap=/${tmpltfs}/${tmpltswap}
tgtfile=${tmpltfs}/vmi-swap-${tmpltname} tgtfile=${tmpltfs}/vmi-swap-${tmpltname}
create_from_file $tmpltfs $tmpltswap $tgtfile $swapsize $cleanup create_from_file $tmpltfs $tmpltswap $tgtfile $swapsize $cleanup
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -93,12 +93,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file, exiting " printf "Failed to uncompress file, exiting "
exit 1 exit 1
fi fi
mv $tmpfile $imgfile mv $tmpfile $imgfile
printf "$imgfile" printf "$imgfile"
@ -185,10 +185,10 @@ then
volfs=${volfs:1} volfs=${volfs:1}
fi fi
if [ ! -d /$volfs ] if [ ! -d /$volfs ]
then then
zfs create -p $volfs zfs create -p $volfs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create user fs $volfs\n" >&2 printf "Failed to create user fs $volfs\n" >&2
exit 1 exit 1
@ -204,7 +204,7 @@ fi
volimg2=$(uncompress $volimg) volimg2=$(uncompress $volimg)
volimg2=$(untar $volimg2 /$volfs vmi-root) volimg2=$(untar $volimg2 /$volfs vmi-root)
if [ ! -f $volimg2 ] if [ ! -f $volimg2 ]
then then
rollback_if_needed $volfs 2 "root disk file $volimg doesn't exist\n" rollback_if_needed $volfs 2 "root disk file $volimg doesn't exist\n"
exit 3 exit 3
@ -218,15 +218,15 @@ fi
#determine source file size -- it needs to be less than or equal to volsize #determine source file size -- it needs to be less than or equal to volsize
imgsize=$(ls -lh $volimg2| awk -F" " '{print $5}') imgsize=$(ls -lh $volimg2| awk -F" " '{print $5}')
if [ ${imgsize:(-1)} == G ] if [ ${imgsize:(-1)} == G ]
then then
imgsize=${imgsize%G} #strip out the G imgsize=${imgsize%G} #strip out the G
imgsize=${imgsize%.*} #...and any decimal part imgsize=${imgsize%.*} #...and any decimal part
let imgsize=imgsize+1 # add 1 to compensate for decimal part let imgsize=imgsize+1 # add 1 to compensate for decimal part
volsizetmp=${volsize%G} volsizetmp=${volsize%G}
if [ $volsizetmp -lt $imgsize ] if [ $volsizetmp -lt $imgsize ]
then then
volsize=${imgsize}G volsize=${imgsize}G
fi fi
fi fi
@ -235,11 +235,11 @@ tgtfile=${volfs}/vmi-root-${volname}
create_from_file $volfs $volimg2 $tgtfile $volsize $cleanup create_from_file $volfs $volimg2 $tgtfile $volsize $cleanup
volswap=$(ls -lh /$volfs | grep swap) volswap=$(ls -lh /$volfs | grep swap)
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
swapsize=$(echo $volswap | awk '{print $5}') swapsize=$(echo $volswap | awk '{print $5}')
volswap=$(echo $volswap | awk '{print $NF}') volswap=$(echo $volswap | awk '{print $NF}')
volswap=/${volfs}/${volswap} volswap=/${volfs}/${volswap}
tgtfile=${volfs}/vmi-swap-${volname} tgtfile=${volfs}/vmi-swap-${volname}
create_from_file $volfs $volswap $tgtfile $swapsize $cleanup create_from_file $volfs $volswap $tgtfile $swapsize $cleanup
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -38,7 +38,7 @@ do
;; ;;
c) cflag=1 c) cflag=1
create_tmplt_path="$OPTARG" create_tmplt_path="$OPTARG"
;; ;;
?) usage ?) usage
exit 2 exit 2
;; ;;
@ -47,14 +47,14 @@ done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ "$tflag" != "1" ] || [ "$cflag" != "1" ] if [ "$tflag" != "1" ] || [ "$cflag" != "1" ]
then then
usage usage
exit 2 exit 2
fi fi
tmpltfs=$template_location/public/os/centos53-x86_64 tmpltfs=$template_location/public/os/centos53-x86_64
if [ "$fflag" == "1" ] if [ "$fflag" == "1" ]
then then
zfs destroy -Rr $tmpltfs 2> /dev/null zfs destroy -Rr $tmpltfs 2> /dev/null
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -47,7 +47,7 @@ then
fi fi
tmpltfs=$1/private/u000000/os/consoleproxy tmpltfs=$1/private/u000000/os/consoleproxy
if [ "$fflag" == "1" ] if [ "$fflag" == "1" ]
then then
zfs destroy -r $tmpltfs 2> /dev/null zfs destroy -r $tmpltfs 2> /dev/null
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -32,7 +32,7 @@ then
fi fi
if [ "$VMOPS_HOME" == "" ] if [ "$VMOPS_HOME" == "" ]
then then
VMOPS_HOME="/usr/local/vmops" VMOPS_HOME="/usr/local/vmops"
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# used as a proxy to call script inside virtual router # used as a proxy to call script inside virtual router
#set -x #set -x

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -41,9 +41,9 @@ no_dhcp_release=$?
[ ! -f /etc/dhcphosts.txt ] && touch /etc/dhcphosts.txt [ ! -f /etc/dhcphosts.txt ] && touch /etc/dhcphosts.txt
[ ! -f /var/lib/misc/dnsmasq.leases ] && touch /var/lib/misc/dnsmasq.leases [ ! -f /var/lib/misc/dnsmasq.leases ] && touch /var/lib/misc/dnsmasq.leases
sed -i /$1/d /etc/dhcphosts.txt sed -i /$1/d /etc/dhcphosts.txt
sed -i /$2,/d /etc/dhcphosts.txt sed -i /$2,/d /etc/dhcphosts.txt
sed -i /$3,/d /etc/dhcphosts.txt sed -i /$3,/d /etc/dhcphosts.txt
echo "$1,$2,$3,infinite" >>/etc/dhcphosts.txt echo "$1,$2,$3,infinite" >>/etc/dhcphosts.txt
@ -54,9 +54,9 @@ then
fi fi
#delete leases to supplied mac and ip addresses #delete leases to supplied mac and ip addresses
sed -i /$1/d /var/lib/misc/dnsmasq.leases sed -i /$1/d /var/lib/misc/dnsmasq.leases
sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases
sed -i /"$3 "/d /var/lib/misc/dnsmasq.leases sed -i /"$3 "/d /var/lib/misc/dnsmasq.leases
#put in the new entry #put in the new entry
echo "0 $1 $2 $3 *" >> /var/lib/misc/dnsmasq.leases echo "0 $1 $2 $3 *" >> /var/lib/misc/dnsmasq.leases

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -129,11 +129,11 @@ config_dnsmasq domain=cloudnine.internal
config_dnsmasq " config_dnsmasq "
# Send options to hosts which ask for a DHCP lease. # Send options to hosts which ask for a DHCP lease.
# See RFC 2132 for details of available options. # See RFC 2132 for details of available options.
# Common options can be given to dnsmasq by name: # Common options can be given to dnsmasq by name:
# run \"dnsmasq --help dhcp\" to get a list. # run \"dnsmasq --help dhcp\" to get a list.
# Note that all the common settings, such as netmask and # Note that all the common settings, such as netmask and
# broadcast address, DNS server and default route, are given # broadcast address, DNS server and default route, are given
# sane defaults by dnsmasq. You very likely will not need # sane defaults by dnsmasq. You very likely will not need
# any dhcp-options. If you use Windows clients and Samba, there # any dhcp-options. If you use Windows clients and Samba, there
# are some options which are recommended, they are detailed at the # are some options which are recommended, they are detailed at the
# end of this section. # end of this section.

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,7 +29,7 @@ usage() {
verify_cksum() { verify_cksum() {
echo "$1 $2" | md5sum -c --status echo "$1 $2" | md5sum -c --status
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Checksum failed, not proceeding with install\n" printf "Checksum failed, not proceeding with install\n"
exit 3 exit 3
@ -44,7 +44,7 @@ install_file() {
mv $isofile /$isofs/$tmpltname mv $isofile /$isofs/$tmpltname
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Move operation failed, iso $isofile not installed\n" printf "Move operation failed, iso $isofile not installed\n"
exit 4 exit 4
@ -55,7 +55,7 @@ install_file() {
isofs=$isofs/$file isofs=$isofs/$file
mp=${isofs%/iso/*} mp=${isofs%/iso/*}
mp=/$mp/iso mp=/$mp/iso
path=${isofs:${#mp}} path=${isofs:${#mp}}
pushd $mp pushd $mp
ln -s $path $file ln -s $path $file
popd popd
@ -108,10 +108,10 @@ then
isofs=${isofs:1} isofs=${isofs:1}
fi fi
if [ ! -d /$isofs ] if [ ! -d /$isofs ]
then then
mkdir -p /$isofs mkdir -p /$isofs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create iso fs $isofs\n" >&2 printf "Failed to create iso fs $isofs\n" >&2
exit 1 exit 1

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: create_private_template.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/create_private_template.sh $ # $Id: create_private_template.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/create_private_template.sh $
# create_private_template.sh -- create a private template from a snapshot # create_private_template.sh -- create a private template from a snapshot
@ -31,7 +31,7 @@ create_template() {
local fspath=$1 local fspath=$1
local destpath=$2 local destpath=$2
# if backing image exists, we need to combine them, otherwise # if backing image exists, we need to combine them, otherwise
# copy the image to preserve snapshots/compression # copy the image to preserve snapshots/compression
if $qemu_img info "$tmpltimg" | grep -q backing; then if $qemu_img info "$tmpltimg" | grep -q backing; then
qemu-img convert -O qcow2 /$fspath $destpath qemu-img convert -O qcow2 /$fspath $destpath

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -70,12 +70,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file, exiting " printf "Failed to uncompress file, exiting "
exit 1 exit 1
fi fi
mv $tmpfile $imgfile mv $tmpfile $imgfile
printf "$imgfile" printf "$imgfile"
@ -89,7 +89,7 @@ create_from_file() {
if [ -b $tmpltimg ]; then if [ -b $tmpltimg ]; then
$qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname $qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
else else
# if backing image exists, we need to combine them, otherwise # if backing image exists, we need to combine them, otherwise
# copy the image to preserve snapshots/compression # copy the image to preserve snapshots/compression
if $qemu_img info "$tmpltimg" | grep -q backing; then if $qemu_img info "$tmpltimg" | grep -q backing; then
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null $qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
@ -97,7 +97,7 @@ create_from_file() {
cp -f $tmpltimg /$tmpltfs/$tmpltname cp -f $tmpltimg /$tmpltfs/$tmpltname
fi fi
fi fi
if [ "$cleanup" == "true" ] if [ "$cleanup" == "true" ]
then then
rm -f "$tmpltimg" rm -f "$tmpltimg"
@ -161,17 +161,17 @@ do
done done
if [ ! -d /$tmpltfs ] if [ ! -d /$tmpltfs ]
then then
mkdir -p /$tmpltfs mkdir -p /$tmpltfs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create user fs $tmpltfs\n" >&2 printf "Failed to create user fs $tmpltfs\n" >&2
exit 1 exit 1
fi fi
fi fi
if [ ! -f $tmpltimg -a ! -b $tmpltimg ] if [ ! -f $tmpltimg -a ! -b $tmpltimg ]
then then
printf "root disk file $tmpltimg doesn't exist\n" printf "root disk file $tmpltimg doesn't exist\n"
exit 3 exit 3

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,11 +18,11 @@
# $Id: createvm.sh 10292 2010-07-07 00:24:04Z edison $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/createvm.sh $ # $Id: createvm.sh 10292 2010-07-07 00:24:04Z edison $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/createvm.sh $
# createvm.sh -- create a vm image # createvm.sh -- create a vm image
usage() { usage() {
echo "Usage (clone VM from template): createvm.sh -t <template dir> -i <rootdisk dir> -f <datadisk folder> -n <datadisk name> -s <datadisk size in GB>\n\ echo "Usage (clone VM from template): createvm.sh -t <template dir> -i <rootdisk dir> -f <datadisk folder> -n <datadisk name> -s <datadisk size in GB>\n\
Usage (create blank rootdisk): createvm.sh -i <rootdisk dir> -S <rootdisk size in GB> \n" Usage (create blank rootdisk): createvm.sh -i <rootdisk dir> -S <rootdisk size in GB> \n"
} }
check_params() { check_params() {
@ -43,7 +43,7 @@ check_params() {
return 1 return 1
fi fi
fi fi
return 0 return 0
} }
@ -53,7 +53,7 @@ cleanup_and_exit_if_error() {
local rootdiskfolder=$3 local rootdiskfolder=$3
local datadiskfolder=$4 local datadiskfolder=$4
local datadiskname=$5 local datadiskname=$5
if [ $return_code -gt 0 ] if [ $return_code -gt 0 ]
then then
cleanup_disks $rootdiskfolder $datadiskfolder $datadiskname cleanup_disks $rootdiskfolder $datadiskfolder $datadiskname
@ -71,24 +71,24 @@ cleanup_disks() {
then then
datadiskpath="${datadiskfolder}/${datadiskname}" datadiskpath="${datadiskfolder}/${datadiskname}"
fi fi
if [ "$rootdiskfolder" != "" ] && [ -d $rootdiskfolder ] if [ "$rootdiskfolder" != "" ] && [ -d $rootdiskfolder ]
then then
rm -rf $rootdiskfolder rm -rf $rootdiskfolder
fi fi
if [ "$datadiskpath" != "" ] && [ -f $datadiskpath ] if [ "$datadiskpath" != "" ] && [ -f $datadiskpath ]
then then
rm $datadiskpath rm $datadiskpath
fi fi
return 0 return 0
} }
exit_if_error() { exit_if_error() {
local return_code=$1 local return_code=$1
local msg=$2 local msg=$2
if [ $return_code -gt 0 ] if [ $return_code -gt 0 ]
then then
printf "${msg}\n" printf "${msg}\n"
@ -98,7 +98,7 @@ exit_if_error() {
make_folder() { make_folder() {
local folder=$1 local folder=$1
if [ ! -d ${folder} ] if [ ! -d ${folder} ]
then then
mkdir -p ${folder} mkdir -p ${folder}
@ -121,9 +121,9 @@ check_rootdisk() {
check_datadisk() { check_datadisk() {
local datadiskfolder=$1 local datadiskfolder=$1
local datadiskname=$2 local datadiskname=$2
make_folder $datadiskfolder make_folder $datadiskfolder
if [ -f ${datadiskfolder}/${datadiskname} ] if [ -f ${datadiskfolder}/${datadiskname} ]
then then
return 1 return 1
@ -134,12 +134,12 @@ check_datadisk() {
strip_leading_slash() { strip_leading_slash() {
local folder=$1 local folder=$1
if [ ${folder:0:1} != / ] if [ ${folder:0:1} != / ]
then then
folder=/$folder folder=/$folder
fi fi
echo $folder echo $folder
} }
@ -149,7 +149,7 @@ clone_template_to_rootdisk() {
curDir=$(pwd) curDir=$(pwd)
cd $rootdiskfolder cd $rootdiskfolder
qemu-img create -f qcow2 -b $templatepath ${rootdiskfolder}/rootdisk qemu-img create -f qcow2 -b $templatepath ${rootdiskfolder}/rootdisk
cd $curDir cd $curDir
return $? return $?
@ -158,9 +158,9 @@ clone_template_to_rootdisk() {
create_blank_rootdisk() { create_blank_rootdisk() {
local rootdiskfolder=$1 local rootdiskfolder=$1
local rootdisksize=$2 local rootdisksize=$2
rootdisksize=$(convert_size_to_gb $rootdisksize) rootdisksize=$(convert_size_to_gb $rootdisksize)
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
return 1 return 1
@ -176,27 +176,27 @@ create_datadisk() {
local datadiskname=$2 local datadiskname=$2
local datadisksize=$3 local datadisksize=$3
local diskfmt=$4 local diskfmt=$4
datadisksize=$(convert_size_to_gb $datadisksize) datadisksize=$(convert_size_to_gb $datadisksize)
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
return 1 return 1
fi fi
qemu-img create -f $diskfmt ${datadiskfolder}/${datadiskname} $datadisksize qemu-img create -f $diskfmt ${datadiskfolder}/${datadiskname} $datadisksize
return $? return $?
} }
convert_size_to_gb() { convert_size_to_gb() {
local size=$1 local size=$1
suffix=${size:(-1)} suffix=${size:(-1)}
case $suffix in case $suffix in
M) M)
;; ;;
G) G)
;; ;;
[0-9]) size=${size}G [0-9]) size=${size}G
;; ;;
@ -204,7 +204,7 @@ convert_size_to_gb() {
return 1 return 1
;; ;;
esac esac
echo $size echo $size
return 0 return 0
} }
@ -262,7 +262,7 @@ then
exit_if_error $? "Failed to clone template $templatepath to $rootdiskfolder/rootdisk." exit_if_error $? "Failed to clone template $templatepath to $rootdiskfolder/rootdisk."
else else
# A template path was not passed in, so create a blank rootdisk at the rootdisk folder # A template path was not passed in, so create a blank rootdisk at the rootdisk folder
create_blank_rootdisk $rootdiskfolder $rootdisksize create_blank_rootdisk $rootdiskfolder $rootdisksize
exit_if_error $? "Failed to create a blank rootdisk at $rootdiskfolder/rootdisk." exit_if_error $? "Failed to create a blank rootdisk at $rootdiskfolder/rootdisk."
fi fi
fi fi
@ -270,8 +270,8 @@ fi
if [ -n "$datadisksize" ] if [ -n "$datadisksize" ]
then then
# Create the datadisk folder if necessary, and make sure there is no existing datadisk there # Create the datadisk folder if necessary, and make sure there is no existing datadisk there
check_datadisk $datadiskfolder $datadiskname check_datadisk $datadiskfolder $datadiskname
cleanup_and_exit_if_error $? "Failed to create datadisk in $datadiskfolder; datadisk with $datadiskname already exists." $rootdiskfolder cleanup_and_exit_if_error $? "Failed to create datadisk in $datadiskfolder; datadisk with $datadiskname already exists." $rootdiskfolder
# Create the datadisk # Create the datadisk
create_datadisk $datadiskfolder $datadiskname $datadisksize qcow2 create_datadisk $datadiskfolder $datadiskname $datadisksize qcow2
@ -285,7 +285,7 @@ else
retry=10 retry=10
while [ $retry -gt 0 ] while [ $retry -gt 0 ]
do do
success=$(losetup -a |grep $loopdev) success=$(losetup -a |grep $loopdev)
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
break break
@ -300,7 +300,7 @@ else
losetup -d $loopdev losetup -d $loopdev
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
break break
fi fi
retry=$(($retry-1)) retry=$(($retry-1))
sleep 1 sleep 1

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: createvol.sh 11601 2010-08-11 17:26:15Z kris $ $HeadURL: svn://svn.lab.vmops.com/repos/branches/2.1.refactor/java/scripts/storage/qcow2/createvol.sh $ # $Id: createvol.sh 11601 2010-08-11 17:26:15Z kris $ $HeadURL: svn://svn.lab.vmops.com/repos/branches/2.1.refactor/java/scripts/storage/qcow2/createvol.sh $
# createvol.sh -- install a volume # createvol.sh -- install a volume
@ -71,12 +71,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file, exiting " printf "Failed to uncompress file, exiting "
exit 1 exit 1
fi fi
mv $tmpfile $imgfile mv $tmpfile $imgfile
printf "$imgfile" printf "$imgfile"
@ -98,7 +98,7 @@ create_from_file() {
cp -f $volimg /$volfs/$volname cp -f $volimg /$volfs/$volname
fi fi
fi fi
if [ "$cleanup" == "true" ] if [ "$cleanup" == "true" ]
then then
rm -f "$volimg" rm -f "$volimg"
@ -162,17 +162,17 @@ do
done done
if [ ! -d /$volfs ] if [ ! -d /$volfs ]
then then
mkdir -p /$volfs mkdir -p /$volfs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create user fs $volfs\n" >&2 printf "Failed to create user fs $volfs\n" >&2
exit 1 exit 1
fi fi
fi fi
if [ ! -f $volimg -a ! -b $volimg ] if [ ! -f $volimg -a ! -b $volimg ]
then then
printf "root disk file $volimg doesn't exist\n" printf "root disk file $volimg doesn't exist\n"
exit 3 exit 3

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -54,20 +54,20 @@ then
fi fi
if [ "$iflag" == 1 ] if [ "$iflag" == 1 ]
then then
rm -rf $instancefs rm -rf $instancefs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to destroy instance fs\n" >&2 printf "Failed to destroy instance fs\n" >&2
exit 5 exit 5
fi fi
fi fi
if [ "$uflag" == 1 ] if [ "$uflag" == 1 ]
then then
rm -rf $userfs rm -rf $userfs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to destroy user fs\n" >&2 printf "Failed to destroy user fs\n" >&2
exit 5 exit 5

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,18 +29,18 @@ mount_local() {
local nbd_loaded=$? local nbd_loaded=$?
if [ $nbd_loaded -ne 0 ] if [ $nbd_loaded -ne 0 ]
then then
modprobe nbd max_part=8 &> /dev/null modprobe nbd max_part=8 &> /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
printf "No nbd module installed, failed to mount qcow2 image\n" printf "No nbd module installed, failed to mount qcow2 image\n"
return 1 return 1
fi fi
fi fi
qemu-nbd -c /dev/nbd0 $disk &> /dev/null qemu-nbd -c /dev/nbd0 $disk &> /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
printf "failed to create /dev/nbd0\n" printf "failed to create /dev/nbd0\n"
return 2 return 2
fi fi
@ -56,7 +56,7 @@ mount_local() {
fi fi
retry=$(($retry-1)) retry=$(($retry-1))
done done
if [ $retry -eq 0 ] if [ $retry -eq 0 ]
then then

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -49,7 +49,7 @@ setTmplMetaFile() {
local fileName=$5 local fileName=$5
virtualsize=$(qemu-img info $tmplfile|grep virtual |awk '{print $4}'|cut -d \( -f 2) virtualsize=$(qemu-img info $tmplfile|grep virtual |awk '{print $4}'|cut -d \( -f 2)
disksize=$(ls -l $tmplfile|awk '{print $5}') disksize=$(ls -l $tmplfile|awk '{print $5}')
echo "qcow2=true" >> $metaFile echo "qcow2=true" >> $metaFile
echo "id=$id" >> $metaFile echo "id=$id" >> $metaFile
echo "public=true" >> $metaFile echo "public=true" >> $metaFile
@ -91,31 +91,31 @@ then
exit 2 exit 2
fi fi
if [[ "$uflag" != "1" && "$rflag" == "1" && ! -f $rttmplt ]] if [[ "$uflag" != "1" && "$rflag" == "1" && ! -f $rttmplt ]]
then then
echo "template image file $rttmplt doesn't exist" echo "template image file $rttmplt doesn't exist"
exit 3 exit 3
fi fi
if [[ "$uflag" != "1" && "$vflag" == "1" && ! -f $vmtmplt ]] if [[ "$uflag" != "1" && "$vflag" == "1" && ! -f $vmtmplt ]]
then then
echo "template image file $vmtmplt doesn't exist" echo "template image file $vmtmplt doesn't exist"
exit 3 exit 3
fi fi
if [[ "$uflag" == "1" && "$rflag" != "1" ]] if [[ "$uflag" == "1" && "$rflag" != "1" ]]
then then
rttmplt=http://download.cloudstack.org/templates/builtin/a88232bf-6a18-38e7-aeee-c1702725079f.qcow2.bz2 rttmplt=http://download.cloudstack.org/templates/builtin/a88232bf-6a18-38e7-aeee-c1702725079f.qcow2.bz2
echo "download routing template from $rttmplt" echo "download routing template from $rttmplt"
fi fi
if [[ "$uflag" == "1" && "$vflag" != "1" ]] if [[ "$uflag" == "1" && "$vflag" != "1" ]]
then then
vmtmplt=http://download.cloudstack.org/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2 vmtmplt=http://download.cloudstack.org/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2
echo "download cnetos template from $vmtmplt" echo "download cnetos template from $vmtmplt"
fi fi
if [ ! -d $mntpoint ] if [ ! -d $mntpoint ]
then then
echo "mount point $mntpoint doesn't exist\n" echo "mount point $mntpoint doesn't exist\n"
exit 4 exit 4
@ -182,7 +182,7 @@ fi
tmpfilert=$(dirname $0)/$localfilert tmpfilert=$(dirname $0)/$localfilert
tmpfilevm=$(dirname $0)/$localfilevm tmpfilevm=$(dirname $0)/$localfilevm
if [ "$uflag" == "1" ] if [ "$uflag" == "1" ]
then then
downloadImage $tmpfilert $rttmplt downloadImage $tmpfilert $rttmplt
downloadImage $tmpfilevm $vmtmplt downloadImage $tmpfilevm $vmtmplt
fi fi
@ -195,7 +195,7 @@ then
printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n" printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"
exit 6 exit 6
fi fi
cp $vmtmplt $tmpfilevm cp $vmtmplt $tmpfilevm
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n" printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -58,25 +58,25 @@ fi
if [ "$rflag" == 1 ] if [ "$rflag" == 1 ]
then then
find $instancefs -name rootdisk find $instancefs -name rootdisk
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
exit 5 exit 5
fi fi
exit 0 exit 0
fi fi
if [ "$dflag" == 1 ] if [ "$dflag" == 1 ]
then then
if [[ $disknum -eq 0 ]] if [[ $disknum -eq 0 ]]
then then
find $instancefs -name datadisk find $instancefs -name datadisk
else else
find $instancefs -name datadisk${disknum} find $instancefs -name datadisk${disknum}
fi fi
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
exit 6 exit 6
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: listvmdisksize.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmdisksize.sh $ # $Id: listvmdisksize.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmdisksize.sh $
# listvmdisksize.sh -- list disk sizes of a VM # listvmdisksize.sh -- list disk sizes of a VM
@ -56,7 +56,7 @@ do
;; ;;
t) tflag=1 t) tflag=1
;; ;;
a) aflag=1 a) aflag=1
;; ;;
?) usage ?) usage
exit 2 exit 2
@ -71,11 +71,11 @@ then
fi fi
if [ "$tflag" == 1 ] if [ "$tflag" == 1 ]
then then
# Find the virtual size of the disk image # Find the virtual size of the disk image
size_in_bytes=$(qemu-img info /$diskfs | grep "virtual size" | awk '{print $4}') size_in_bytes=$(qemu-img info /$diskfs | grep "virtual size" | awk '{print $4}')
# Strip off the leading '(' # Strip off the leading '('
size_in_bytes=${size_in_bytes:1} size_in_bytes=${size_in_bytes:1}
else else

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $ # $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $
# listtmplt.sh -- list templates under a directory # listtmplt.sh -- list templates under a directory
@ -51,7 +51,7 @@ fi
for i in $(find /$rootdir -name template.properties ); for i in $(find /$rootdir -name template.properties );
do do
d=$(dirname $i) d=$(dirname $i)
filename=$(grep "filename" $i | awk -F"=" '{print $NF}') filename=$(grep "filename" $i | awk -F"=" '{print $NF}')
size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
@ -59,7 +59,7 @@ do
then then
d=$d/$filename/$size d=$d/$filename/$size
fi fi
echo ${d#/} #remove leading slash echo ${d#/} #remove leading slash
done done
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $ # $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $
# listtmplt.sh -- list volumes under a directory # listtmplt.sh -- list volumes under a directory
@ -51,7 +51,7 @@ fi
for i in $(find /$rootdir -name volume.properties ); for i in $(find /$rootdir -name volume.properties );
do do
d=$(dirname $i) d=$(dirname $i)
filename=$(grep "filename" $i | awk -F"=" '{print $NF}') filename=$(grep "filename" $i | awk -F"=" '{print $NF}')
size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
@ -59,7 +59,7 @@ do
then then
d=$d/$filename/$size d=$d/$filename/$size
fi fi
echo ${d#/} #remove leading slash echo ${d#/} #remove leading slash
done done
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,10 +16,10 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: managevolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/managevolume.sh $ # $Id: managevolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/managevolume.sh $
# modifyvolume.sh -- add or delete a disk volume # modifyvolume.sh -- add or delete a disk volume
usage() { usage() {
echo "Usage: modifydisk.sh -f <folder of volume> -p <path of volume> -s <size of volume> [-d <delete>] \n" echo "Usage: modifydisk.sh -f <folder of volume> -p <path of volume> -s <size of volume> [-d <delete>] \n"
@ -38,7 +38,7 @@ cleanup_and_exit_if_error() {
local return_code=$1 local return_code=$1
local msg=$2 local msg=$2
local path=$3 local path=$3
if [ $return_code -gt 0 ] if [ $return_code -gt 0 ]
then then
delete_disk $path delete_disk $path
@ -49,7 +49,7 @@ cleanup_and_exit_if_error() {
exit_if_error() { exit_if_error() {
local return_code=$1 local return_code=$1
local msg=$2 local msg=$2
if [ $return_code -gt 0 ] if [ $return_code -gt 0 ]
then then
printf "${msg}\n" printf "${msg}\n"
@ -59,7 +59,7 @@ exit_if_error() {
make_folder() { make_folder() {
local folder=$1 local folder=$1
if [ ! -d ${folder} ] if [ ! -d ${folder} ]
then then
mkdir -p ${folder} mkdir -p ${folder}
@ -69,9 +69,9 @@ make_folder() {
check_disk() { check_disk() {
local folder=$1 local folder=$1
local path=$2 local path=$2
make_folder $folder make_folder $folder
if [ -f $path ] if [ -f $path ]
then then
return 1 return 1
@ -82,37 +82,37 @@ check_disk() {
delete_disk() { delete_disk() {
local path=$1 local path=$1
if [ -f $path ] if [ -f $path ]
then then
rm $path rm $path
fi fi
return 0 return 0
} }
create_disk() { create_disk() {
local path=$1 local path=$1
local size=$2 local size=$2
size=$(convert_size_to_gb $size) size=$(convert_size_to_gb $size)
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
return 1 return 1
fi fi
qemu-img create -f qcow2 $path $size qemu-img create -f qcow2 $path $size
return $? return $?
} }
convert_size_to_gb() { convert_size_to_gb() {
local size=$1 local size=$1
suffix=${size:(-1)} suffix=${size:(-1)}
case $suffix in case $suffix in
G) G)
;; ;;
[0-9]) size=${size}G [0-9]) size=${size}G
;; ;;
@ -120,7 +120,7 @@ convert_size_to_gb() {
return 1 return 1
;; ;;
esac esac
echo $size echo $size
return 0 return 0
} }
@ -159,20 +159,20 @@ exit_if_error $? "$(usage)"
if [ "$dflag" == "0" ] if [ "$dflag" == "0" ]
then then
# Add the volume # Add the volume
# Create the folder if necessary, and make sure there is no existing disk there # Create the folder if necessary, and make sure there is no existing disk there
check_disk $folder $path check_disk $folder $path
cleanup_and_exit_if_error $? "Failed to create disk at $path; path already exists." $path cleanup_and_exit_if_error $? "Failed to create disk at $path; path already exists." $path
# Create the disk # Create the disk
create_disk $path $size create_disk $path $size
cleanup_and_exit_if_error $? "Failed to create disk at $path of size $datadisksize." $path cleanup_and_exit_if_error $? "Failed to create disk at $path of size $datadisksize." $path
else else
# Delete the volume # Delete the volume
delete_disk $path delete_disk $path
fi fi
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,9 +17,9 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s -t [template path] -n [template name] -s [snapshot name] -p [snapshot path] \n" $(basename $0) printf "Usage: %s -t [template path] -n [template name] -s [snapshot name] -p [snapshot path] \n" $(basename $0)
} }
snapshotPath= snapshotPath=
@ -68,7 +68,7 @@ copyvhd()
exit 2 exit 2
fi fi
if [[ "${parent}" =~ " no parent" ]]; then if [[ "${parent}" =~ " no parent" ]]; then
dd if=$srcvhd of=$desvhd bs=2M dd if=$srcvhd of=$desvhd bs=2M
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "31#failed to dd $srcvhd to $desvhd" echo "31#failed to dd $srcvhd to $desvhd"
rm -rf $desvhd > /dev/null rm -rf $desvhd > /dev/null

View File

@ -6,16 +6,16 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: createtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createtmplt.sh $ # $Id: createtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createtmplt.sh $
# createtmplt.sh -- install a template # createtmplt.sh -- install a template
@ -41,7 +41,7 @@ fi
untar() { untar() {
local ft=$(file $1| awk -F" " '{print $2}') local ft=$(file $1| awk -F" " '{print $2}')
case $ft in case $ft in
USTAR) USTAR)
printf "tar archives not supported\n" >&2 printf "tar archives not supported\n" >&2
return 1 return 1
;; ;;
@ -87,12 +87,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file (filetype=$ft), exiting " printf "Failed to uncompress file (filetype=$ft), exiting "
return 1 return 1
fi fi
rm -f $1 rm -f $1
printf $tmpfile printf $tmpfile
@ -167,7 +167,7 @@ do
done done
isCifs() { isCifs() {
#TO:DO incase of multiple zone where cifs and nfs exists, #TO:DO incase of multiple zone where cifs and nfs exists,
#then check if the template file is from cifs using df -P filename #then check if the template file is from cifs using df -P filename
#Currently only cifs is supported in hyperv zone. #Currently only cifs is supported in hyperv zone.
mount | grep "type cifs" > /dev/null mount | grep "type cifs" > /dev/null
@ -182,7 +182,7 @@ fi
mkdir -p $tmpltfs mkdir -p $tmpltfs
if [ ! -f $tmpltimg ] if [ ! -f $tmpltimg ]
then then
printf "root disk file $tmpltimg doesn't exist\n" printf "root disk file $tmpltimg doesn't exist\n"
exit 3 exit 3

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# $Id: createvolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createvolume.sh $ # $Id: createvolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createvolume.sh $
# createvolume.sh -- install a volume # createvolume.sh -- install a volume
@ -53,7 +53,7 @@ verify_cksum() {
esac esac
echo "$1 $2" | $digestalgo -c --status echo "$1 $2" | $digestalgo -c --status
#printf "$1\t$2" | $digestalgo -c --status #printf "$1\t$2" | $digestalgo -c --status
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Checksum failed, not proceeding with install\n" printf "Checksum failed, not proceeding with install\n"
exit 3 exit 3
@ -63,7 +63,7 @@ verify_cksum() {
untar() { untar() {
local ft=$(file $1| awk -F" " '{print $2}') local ft=$(file $1| awk -F" " '{print $2}')
case $ft in case $ft in
USTAR) USTAR)
printf "tar archives not supported\n" >&2 printf "tar archives not supported\n" >&2
return 1 return 1
;; ;;
@ -109,12 +109,12 @@ uncompress() {
;; ;;
esac esac
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to uncompress file (filetype=$ft), exiting " printf "Failed to uncompress file (filetype=$ft), exiting "
return 1 return 1
fi fi
rm -f $1 rm -f $1
printf $tmpfile printf $tmpfile
@ -205,7 +205,7 @@ fi
mkdir -p $tmpltfs mkdir -p $tmpltfs
if [ ! -f $tmpltimg ] if [ ! -f $tmpltimg ]
then then
printf "root disk file $tmpltimg doesn't exist\n" printf "root disk file $tmpltimg doesn't exist\n"
exit 3 exit 3
@ -227,7 +227,7 @@ then
if [ isCifs -ne 0 ] ; if [ isCifs -ne 0 ] ;
then then
if which vhd-util &>/dev/null if which vhd-util &>/dev/null
then then
vhd-util check -n ${tmpltimg2} > /dev/null vhd-util check -n ${tmpltimg2} > /dev/null
rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n" rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,7 +29,7 @@ usage() {
verify_cksum() { verify_cksum() {
echo "$1 $2" | md5sum -c --status echo "$1 $2" | md5sum -c --status
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Checksum failed, not proceeding with install\n" printf "Checksum failed, not proceeding with install\n"
exit 3 exit 3
@ -44,7 +44,7 @@ install_file() {
mv $isofile /$isofs/$tmpltname mv $isofile /$isofs/$tmpltname
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Move operation failed, iso $isofile not installed\n" printf "Move operation failed, iso $isofile not installed\n"
exit 4 exit 4
@ -55,7 +55,7 @@ install_file() {
isofs=$isofs/$file isofs=$isofs/$file
mp=${isofs%/iso/*} mp=${isofs%/iso/*}
mp=/$mp/iso mp=/$mp/iso
path=${isofs:${#mp}} path=${isofs:${#mp}}
pushd $mp pushd $mp
ln -s $path $file ln -s $path $file
popd popd
@ -108,10 +108,10 @@ then
isofs=${isofs:1} isofs=${isofs:1}
fi fi
if [ ! -d /$isofs ] if [ ! -d /$isofs ]
then then
mkdir -p /$isofs mkdir -p /$isofs
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to create iso fs $isofs\n" >&2 printf "Failed to create iso fs $isofs\n" >&2
exit 1 exit 1

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -50,7 +50,7 @@ fi
for i in $(find /$rootdir -name template.properties ); for i in $(find /$rootdir -name template.properties );
do do
d=$(dirname $i) d=$(dirname $i)
filename=$(grep "^filename" $i | awk -F"=" '{print $NF}') filename=$(grep "^filename" $i | awk -F"=" '{print $NF}')
# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') # size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
@ -58,7 +58,7 @@ do
# then # then
# d=$d/$filename/$size # d=$d/$filename/$size
# fi # fi
echo ${d#/}/$filename #remove leading slash echo ${d#/}/$filename #remove leading slash
done done
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -50,7 +50,7 @@ fi
for i in $(find /$rootdir -name volume.properties ); for i in $(find /$rootdir -name volume.properties );
do do
d=$(dirname $i) d=$(dirname $i)
filename=$(grep "^filename" $i | awk -F"=" '{print $NF}') filename=$(grep "^filename" $i | awk -F"=" '{print $NF}')
# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}') # size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
@ -58,7 +58,7 @@ do
# then # then
# d=$d/$filename/$size # d=$d/$filename/$size
# fi # fi
echo ${d#/}/$filename #remove leading slash echo ${d#/}/$filename #remove leading slash
done done
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,12 +17,12 @@
# under the License. # under the License.
help() { help() {
printf "Usage: $0 printf "Usage: $0
-i nfs server ip -i nfs server ip
-p nfs server path -p nfs server path
-m mount point -m mount point
-h host -h host
-r write/read hb log -r write/read hb log
-c cleanup -c cleanup
-t interval between read hb log\n" -t interval between read hb log\n"
exit 1 exit 1
@ -52,7 +52,7 @@ do
HostIP="$OPTARG" HostIP="$OPTARG"
;; ;;
r) r)
rflag=1 rflag=1
;; ;;
t) t)
interval="$OPTARG" interval="$OPTARG"
@ -75,7 +75,7 @@ fi
#delete VMs on this mountpoint #delete VMs on this mountpoint
deleteVMs() { deleteVMs() {
local mountPoint=$1 local mountPoint=$1
vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null) vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null)
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
return return
@ -100,7 +100,7 @@ then
mount $NfsSvrIP:$NfsSvrPath $MountPoint -o sync,soft,proto=tcp,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,noac &> /dev/null mount $NfsSvrIP:$NfsSvrPath $MountPoint -o sync,soft,proto=tcp,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,noac &> /dev/null
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint" printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint"
exit 1 exit 1
fi fi
if [ "$rflag" == "0" ] if [ "$rflag" == "0" ]
@ -162,6 +162,6 @@ then
echo b > /proc/sysrq-trigger echo b > /proc/sysrq-trigger
exit $? exit $?
else else
write_hbLog write_hbLog
exit $? exit $?
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
# Did cloudstack-agent installed # Did cloudstack-agent installed
#set -x #set -x
@ -26,7 +26,7 @@ install_cloud_agent() {
local retry=10 local retry=10
which cloudstack-setup-agent which cloudstack-setup-agent
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
# download the repo # download the repo
which wget which wget
if [ $? -gt 0 ] if [ $? -gt 0 ]
@ -36,7 +36,7 @@ install_cloud_agent() {
then then
printf "failed to install wget" printf "failed to install wget"
exit 1 exit 1
fi fi
fi fi
wget -N -P /etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo wget -N -P /etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo
if [ $? -gt 0 ] if [ $? -gt 0 ]
@ -46,7 +46,7 @@ install_cloud_agent() {
fi fi
if [ "$dev" == "1" ] if [ "$dev" == "1" ]
then then
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
fi fi
while [ "$retry" -gt "0" ] while [ "$retry" -gt "0" ]
do do
@ -74,7 +74,7 @@ install_cloud_agent() {
done done
fi fi
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to install agent" printf "Failed to install agent"
@ -87,7 +87,7 @@ install_cloud_consoleP() {
local retry=10 local retry=10
which cloud-setup-console-proxy which cloud-setup-console-proxy
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
# download the repo # download the repo
which wget which wget
if [ $? -gt 0 ] if [ $? -gt 0 ]
@ -97,7 +97,7 @@ install_cloud_consoleP() {
then then
printf "failed to install wget" printf "failed to install wget"
exit 1 exit 1
fi fi
fi fi
wget -N -P=/etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo wget -N -P=/etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo
if [ $? -gt 0 ] if [ $? -gt 0 ]
@ -107,7 +107,7 @@ install_cloud_consoleP() {
fi fi
if [ "$dev" == "1" ] if [ "$dev" == "1" ]
then then
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
fi fi
while [ "$retry" -gt "0" ] while [ "$retry" -gt "0" ]
do do
@ -135,7 +135,7 @@ install_cloud_consoleP() {
done done
fi fi
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to install console" printf "Failed to install console"
@ -176,28 +176,28 @@ prvNic=
while getopts 'h:z:p:u:c:P:N:d' OPTION while getopts 'h:z:p:u:c:P:N:d' OPTION
do do
case $OPTION in case $OPTION in
h) h)
host="$OPTARG" host="$OPTARG"
;; ;;
z) z)
zone="$OPTARG" zone="$OPTARG"
;; ;;
p) p)
pod="$OPTARG" pod="$OPTARG"
;; ;;
c) c)
cluster="$OPTARG" cluster="$OPTARG"
;; ;;
u) u)
guid="$OPTARG" guid="$OPTARG"
;; ;;
d) d)
dflag=1 dflag=1
;; ;;
P) P)
pubNic="$OPTARG" pubNic="$OPTARG"
;; ;;
N) N)
prvNic="$OPTARG" prvNic="$OPTARG"
;; ;;
*) ;; *) ;;

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) >&2 printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) >&2
@ -53,7 +53,7 @@ do
diff=`expr $date - $ping` diff=`expr $date - $ping`
if [ $diff -lt $2 ]; then if [ $diff -lt $2 ]; then
echo "=====> ALIVE <=====" echo "=====> ALIVE <====="
exit 0; exit 0;
fi fi
done done
@ -67,7 +67,7 @@ do
diff=`expr $date - $ping` diff=`expr $date - $ping`
if [ $diff -lt $2 ]; then if [ $diff -lt $2 ]; then
echo "=====> ALIVE <=====" echo "=====> ALIVE <====="
exit 0; exit 0;
fi fi
done done

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -88,7 +88,7 @@ fake_pv_driver() {
vms=$(xe vm-list is-control-domain=false| grep ^uuid | awk '{print $NF}') vms=$(xe vm-list is-control-domain=false| grep ^uuid | awk '{print $NF}')
for vm in $vms for vm in $vms
do do
state=$(xe vm-param-get uuid=$vm param-name=power-state) state=$(xe vm-param-get uuid=$vm param-name=power-state)
if [ $state = "running" ]; then if [ $state = "running" ]; then
fake_pv_driver $vm fake_pv_driver $vm

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s \n" $(basename $0) >&2 printf "Usage: %s \n" $(basename $0) >&2
@ -33,7 +33,7 @@ moveConfigToBond() {
if [ -n "$bondSlaveIp" ]; then if [ -n "$bondSlaveIp" ]; then
mode=$(xe pif-param-get param-name=IP-configuration-mode uuid=$bondSlave) mode=$(xe pif-param-get param-name=IP-configuration-mode uuid=$bondSlave)
netmask=$(xe pif-param-get param-name=netmask uuid=$bondSlave) netmask=$(xe pif-param-get param-name=netmask uuid=$bondSlave)
gateway=$(xe pif-param-get param-name=gateway uuid=$bondSlave) gateway=$(xe pif-param-get param-name=gateway uuid=$bondSlave)
DNS=$(xe pif-param-get param-name=DNS uuid=$bondSlave) DNS=$(xe pif-param-get param-name=DNS uuid=$bondSlave)
management=$(xe pif-param-get param-name=management uuid=$bondSlave) management=$(xe pif-param-get param-name=management uuid=$bondSlave)
slavedevice=$(xe pif-param-get param-name=device uuid=$bondSlave) slavedevice=$(xe pif-param-get param-name=device uuid=$bondSlave)
@ -47,7 +47,7 @@ moveConfigToBond() {
echo " --Succeeded" echo " --Succeeded"
if [ "$management" = "true" ]; then if [ "$management" = "true" ]; then
echo " --move management interface from $slavedevice($bondSlave) to $masterdevice($bondMaster)" echo " --move management interface from $slavedevice($bondSlave) to $masterdevice($bondMaster)"
xe host-management-reconfigure pif-uuid=$bondMaster xe host-management-reconfigure pif-uuid=$bondMaster
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo " --Failed to move management interface from $bondSlave to $bondMaster, please run xe host-management-reconfigure pif-uuid=$bondMaster manually" echo " --Failed to move management interface from $bondSlave to $bondMaster, please run xe host-management-reconfigure pif-uuid=$bondMaster manually"
exit 1 exit 1
@ -62,7 +62,7 @@ moveConfigToBond() {
xe pif-plug uuid=$bondMaster xe pif-plug uuid=$bondMaster
done done
fi fi
} }
poolUuid=$(xe pool-list | grep ^uuid | awk '{print $NF}') poolUuid=$(xe pool-list | grep ^uuid | awk '{print $NF}')
hostMaster=$(xe pool-param-get uuid=$poolUuid param-name=master) hostMaster=$(xe pool-param-get uuid=$poolUuid param-name=master)

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,14 +17,14 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [vhd file in secondary storage] [uuid of the source sr] [name label] \n" $(basename $0) printf "Usage: %s [vhd file in secondary storage] [uuid of the source sr] [name label] \n" $(basename $0)
} }
cleanup() cleanup()
{ {
if [ ! -z $localmp ]; then if [ ! -z $localmp ]; then
umount -fl $localmp umount -fl $localmp
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $localmp rmdir $localmp
@ -158,7 +158,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
exit 0 exit 0
fi fi
copyvhd $desvhd $vhdfile $lvsize $type copyvhd $desvhd $vhdfile $lvsize $type
else else
echo "15#doesn't support sr type $type" echo "15#doesn't support sr type $type"
cleanup cleanup
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,14 +17,14 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [mountpoint in secondary storage] [uuid of the source vdi] [uuid of the source sr]\n" $(basename $0) printf "Usage: %s [mountpoint in secondary storage] [uuid of the source vdi] [uuid of the source sr]\n" $(basename $0)
} }
cleanup() cleanup()
{ {
if [ ! -z $localmp ]; then if [ ! -z $localmp ]; then
umount $localmp umount $localmp
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $localmp rmdir $localmp
@ -120,7 +120,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
cleanup cleanup
exit 0 exit 0
fi fi
else else
echo "15#doesn't support sr type $type" echo "15#doesn't support sr type $type"
cleanup cleanup
exit 0 exit 0

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,20 +17,20 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] [template local dir] \n" $(basename $0) printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] [template local dir] \n" $(basename $0)
} }
options='tcp,soft,timeo=133,retrans=1' options='tcp,soft,timeo=133,retrans=1'
cleanup() cleanup()
{ {
if [ ! -z $snapshotdir ]; then if [ ! -z $snapshotdir ]; then
umount $snapshotdir umount $snapshotdir
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $snapshotdir rmdir $snapshotdir
fi fi
fi fi
if [ ! -z $templatedir ]; then if [ ! -z $templatedir ]; then
umount $templatedir umount $templatedir
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $templatedir rmdir $templatedir
@ -110,7 +110,7 @@ copyvhd()
exit 0 exit 0
fi fi
if [[ "${parent}" =~ " no parent" ]]; then if [[ "${parent}" =~ " no parent" ]]; then
dd if=$srcvhd of=$desvhd bs=2M dd if=$srcvhd of=$desvhd bs=2M
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "31#failed to dd $srcvhd to $desvhd" echo "31#failed to dd $srcvhd to $desvhd"
cleanup cleanup

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,9 +17,9 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [name label] \n" $(basename $0) printf "Usage: %s [name label] \n" $(basename $0)
} }
if [ -z $1 ]; then if [ -z $1 ]; then
@ -34,7 +34,7 @@ pid=`ps -ef | grep "dd" | grep $namelabel | grep -v "grep" | awk '{print $2}'`
if [ -z $pid ]; then if [ -z $pid ]; then
echo "true" echo "true"
exit 0 exit 0
fi fi
kill -9 $pid kill -9 $pid
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0)

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -23,7 +23,7 @@ usage() {
echo " -- fakes the presence of PV tools in <VM uuid>" echo " -- fakes the presence of PV tools in <VM uuid>"
echo " -- NB the VM must be either paused or running on localhost" echo " -- NB the VM must be either paused or running on localhost"
} }
fake(){ fake(){
local uuid=$1 local uuid=$1
domid=$(xe vm-list uuid=${uuid} params=dom-id --minimal) domid=$(xe vm-list uuid=${uuid} params=dom-id --minimal)

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -48,7 +48,7 @@ if [ `xe host-list | grep $1 | wc -l` -ne 1 ]; then
exit 0 exit 0
fi fi
if [ `xe sr-list uuid=$2 | wc -l` -eq 0 ]; then if [ `xe sr-list uuid=$2 | wc -l` -eq 0 ]; then
echo "#4# Unable to find SR with uuid: $2" echo "#4# Unable to find SR with uuid: $2"
exit 0 exit 0
fi fi
@ -64,7 +64,7 @@ if [ "$3" = "true" ]; then
srtype=`xe sr-param-get param-name=type uuid=$2` srtype=`xe sr-param-get param-name=type uuid=$2`
if [ "$srtype" = "nfs" ];then if [ "$srtype" = "nfs" ];then
dir=/var/run/sr-mount/$2 dir=/var/run/sr-mount/$2
filename=$dir/hb-$1 filename=$dir/hb-$1
@ -72,7 +72,7 @@ if [ "$3" = "true" ]; then
echo "#6# heartbeat file $filename doesn't exist" echo "#6# heartbeat file $filename doesn't exist"
exit 0 exit 0
fi fi
else else
dir=/dev/VG_XenStorage-$2 dir=/dev/VG_XenStorage-$2
link=$dir/hb-$1 link=$dir/hb-$1
lvchange -ay $link lvchange -ay $link
@ -93,9 +93,9 @@ if [ "$3" = "true" ]; then
echo $dir >> $hbfile echo $dir >> $hbfile
fi fi
else else
if [ -f $hbfile ]; then if [ -f $hbfile ]; then
sed -i /$2/d $hbfile sed -i /$2/d $hbfile
fi fi
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
# $Id: setup_iscsi.sh 9879 2010-06-24 02:41:46Z anthony $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/setup_iscsi.sh $ # $Id: setup_iscsi.sh 9879 2010-06-24 02:41:46Z anthony $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/setup_iscsi.sh $
#set -x #set -x
usage() { usage() {
printf "Usage: %s [uuid of host script is running on]\n" $(basename $0) >&2 printf "Usage: %s [uuid of host script is running on]\n" $(basename $0) >&2
} }

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: \n" $(basename $0) printf "Usage: \n" $(basename $0)

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,20 +17,20 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] \n" $(basename $0) printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] \n" $(basename $0)
} }
cleanup() cleanup()
{ {
if [ ! -z $snapshotdir ]; then if [ ! -z $snapshotdir ]; then
umount $snapshotdir umount $snapshotdir
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $snapshotdir rmdir $snapshotdir
fi fi
fi fi
if [ ! -z $templatedir ]; then if [ ! -z $templatedir ]; then
umount $templatedir umount $templatedir
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmdir $templatedir rmdir $templatedir
@ -99,7 +99,7 @@ upgradeSnapshot()
exit 0 exit 0
fi fi
if [ "${parent##*vhd has}" = " no parent" ]; then if [ "${parent##*vhd has}" = " no parent" ]; then
dd if=$templatevhd of=$snapshotdir/$templatefilename bs=2M dd if=$templatevhd of=$snapshotdir/$templatefilename bs=2M
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "31#failed to dd $templatevhd to $snapshotdir/$templatefilenamed" echo "31#failed to dd $templatevhd to $snapshotdir/$templatefilenamed"
cleanup cleanup

View File

@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License. # under the License.
#set -x #set -x
usage() { usage() {
printf "Usage: %s \n" $(basename $0) >&2 printf "Usage: %s \n" $(basename $0) >&2
@ -57,7 +57,7 @@ fi
for be in $bes for be in $bes
do do
device=`xenstore-read /local/domain/0/backend/tap/0/$be/dev` device=`xenstore-read /local/domain/0/backend/tap/0/$be/dev`
ls $device >/dev/null 2>&1 ls $device >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
remove_device $be remove_device $be
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -36,10 +36,10 @@ addVlan() {
ip link add link $pif name $vlanDev type vlan id $vlanId > /dev/null ip link add link $pif name $vlanDev type vlan id $vlanId > /dev/null
echo 1 > /proc/sys/net/ipv6/conf/$vlanDev/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/$vlanDev/disable_ipv6
ip link set $vlanDev up ip link set $vlanDev up
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
# race condition that someone already creates the vlan # race condition that someone already creates the vlan
if [ ! -d /sys/class/net/$vlanDev ] if [ ! -d /sys/class/net/$vlanDev ]
then then
printf "Failed to create vlan $vlanId on pif: $pif." printf "Failed to create vlan $vlanId on pif: $pif."
@ -47,18 +47,18 @@ addVlan() {
fi fi
fi fi
fi fi
# disable IPv6 # disable IPv6
echo 1 > /proc/sys/net/ipv6/conf/$vlanDev/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/$vlanDev/disable_ipv6
# is up? # is up?
ip link set $vlanDev up > /dev/null 2>/dev/null ip link set $vlanDev up > /dev/null 2>/dev/null
if [ ! -d /sys/class/net/$vlanBr ] if [ ! -d /sys/class/net/$vlanBr ]
then then
ip link add name $vlanBr type bridge ip link add name $vlanBr type bridge
echo 1 > /proc/sys/net/ipv6/conf/$vlanBr/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/$vlanBr/disable_ipv6
ip link set $vlanBr up ip link set $vlanBr up
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
if [ ! -d /sys/class/net/$vlanBr ] if [ ! -d /sys/class/net/$vlanBr ]
@ -68,15 +68,15 @@ addVlan() {
fi fi
fi fi
fi fi
#pif is eslaved into vlanBr? #pif is eslaved into vlanBr?
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
ip link set $vlanDev master $vlanBr ip link set $vlanDev master $vlanBr
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to add vlan: $vlanDev to $vlanBr" printf "Failed to add vlan: $vlanDev to $vlanBr"
@ -102,7 +102,7 @@ deleteVlan() {
if [ $deleteBr == "true" ] if [ $deleteBr == "true" ]
then then
ip link delete $vlanDev type vlan > /dev/null ip link delete $vlanDev type vlan > /dev/null
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
printf "Failed to del vlan: $vlanId" printf "Failed to del vlan: $vlanId"
@ -124,7 +124,7 @@ deleteVlan() {
fi fi
fi fi
return 0 return 0
} }
op= op=
@ -179,18 +179,18 @@ if [ "$op" == "add" ]
then then
# Add the vlan # Add the vlan
addVlan $vlanId $pif $brName addVlan $vlanId $pif $brName
# If the add fails then return failure # If the add fails then return failure
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
exit 1 exit 1
fi fi
else else
if [ "$op" == "delete" ] if [ "$op" == "delete" ]
then then
# Delete the vlan # Delete the vlan
deleteVlan $vlanId $pif $brName $deleteBr deleteVlan $vlanId $pif $brName $deleteBr
# Always exit with success # Always exit with success
exit 0 exit 0
fi fi

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
# $Id: pingtest.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/pingtest.sh $ # $Id: pingtest.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/pingtest.sh $
# pingtest.sh -- ping # pingtest.sh -- ping
usage() { usage() {
printf "Usage:\n %s -i <domR eth1 ip> -p <private-ip-address> \n" $(basename $0) >&2 printf "Usage:\n %s -i <domR eth1 ip> -p <private-ip-address> \n" $(basename $0) >&2
printf " %s -h <computing-agent-host-ip> \n" $(basename $0) >&2 printf " %s -h <computing-agent-host-ip> \n" $(basename $0) >&2

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -12,9 +12,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -69,15 +69,15 @@ class bash:
except: except:
raise CloudRuntimeException(formatExceptionInfo()) raise CloudRuntimeException(formatExceptionInfo())
# if not self.success: # if not self.success:
# raise CloudRuntimeException(self.getStderr()) # raise CloudRuntimeException(self.getStderr())
def isSuccess(self): def isSuccess(self):
return self.success return self.success
def getStdout(self): def getStdout(self):
return self.stdout.strip("\n") return self.stdout.strip("\n")
def getLines(self): def getLines(self):
return self.stdout.split("\n") return self.stdout.split("\n")
@ -88,13 +88,13 @@ class bash:
def initLoging(logFile=None): def initLoging(logFile=None):
try: try:
if logFile is None: if logFile is None:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
else: else:
logging.basicConfig(filename=logFile, level=logging.DEBUG) logging.basicConfig(filename=logFile, level=logging.DEBUG)
except: except:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
def writeProgressBar(msg, result=None): def writeProgressBar(msg, result=None):
if msg is not None: if msg is not None:
output = "%-80s"%msg output = "%-80s"%msg
elif result is True: elif result is True:
@ -103,7 +103,7 @@ def writeProgressBar(msg, result=None):
output = "[ \033[91m%-6s\033[0m ]\n"%"FAILED" output = "[ \033[91m%-6s\033[0m ]\n"%"FAILED"
sys.stdout.write(output) sys.stdout.write(output)
sys.stdout.flush() sys.stdout.flush()
def printError(msg): def printError(msg):
sys.stderr.write(msg) sys.stderr.write(msg)
sys.stderr.write("\n") sys.stderr.write("\n")
@ -123,7 +123,7 @@ def checkRpm(pkgName):
else: else:
writeProgressBar(None, True) writeProgressBar(None, True)
return True return True
def checkEnv(): def checkEnv():
writeProgressBar("Checking is root") writeProgressBar("Checking is root")
ret = bash("whoami") ret = bash("whoami")
@ -133,7 +133,7 @@ def checkEnv():
return False return False
else: else:
writeProgressBar(None, True) writeProgressBar(None, True)
pkgList = ['tftp-server', 'syslinux', 'xinetd', 'chkconfig', 'dhcp'] pkgList = ['tftp-server', 'syslinux', 'xinetd', 'chkconfig', 'dhcp']
for pkg in pkgList: for pkg in pkgList:
if not checkRpm(pkg): if not checkRpm(pkg):
@ -141,8 +141,8 @@ def checkEnv():
return True return True
def exitIfFail(ret): def exitIfFail(ret):
if not ret: sys.exit(1) if not ret: sys.exit(1)
def bashWithResult(cmd): def bashWithResult(cmd):
writeProgressBar("Executing '%s'"%cmd) writeProgressBar("Executing '%s'"%cmd)
ret = bash(cmd) ret = bash(cmd)
@ -153,23 +153,23 @@ def bashWithResult(cmd):
else: else:
writeProgressBar(None, True) writeProgressBar(None, True)
return True return True
def configurePxeStuff(): def configurePxeStuff():
stuff = ['tftp', 'xinetd', 'dhcpd'] stuff = ['tftp', 'xinetd', 'dhcpd']
cmds = ['chkconfig --level 345 %s on' % i for i in stuff] cmds = ['chkconfig --level 345 %s on' % i for i in stuff]
cmds.append('/etc/init.d/xinetd restart') cmds.append('/etc/init.d/xinetd restart')
for cmd in cmds: for cmd in cmds:
if not bashWithResult(cmd): return False if not bashWithResult(cmd): return False
chkIptable = bash('chkconfig --list iptables') chkIptable = bash('chkconfig --list iptables')
if 'on' in chkIptable.getStdout(): if 'on' in chkIptable.getStdout():
printMsg("Detected iptables is running, need to open tftp port 69") printMsg("Detected iptables is running, need to open tftp port 69")
if not bashWithResult('iptables -I INPUT 1 -p udp --dport 69 -j ACCEPT'): return False if not bashWithResult('iptables -I INPUT 1 -p udp --dport 69 -j ACCEPT'): return False
if not bashWithResult('/etc/init.d/iptables save'): return False if not bashWithResult('/etc/init.d/iptables save'): return False
return True return True
def getTftpRootDir(tftpRootDirList): def getTftpRootDir(tftpRootDirList):
tftpRoot = bash("cat /etc/xinetd.d/tftp | grep server_args") tftpRoot = bash("cat /etc/xinetd.d/tftp | grep server_args")
if not tftpRoot.isSuccess(): if not tftpRoot.isSuccess():
@ -187,16 +187,16 @@ def getTftpRootDir(tftpRootDirList):
def preparePING(tftpRootDir): def preparePING(tftpRootDir):
pingFiles = ['boot.msg', 'initrd.gz', 'kernel', 'pxelinux.0'] pingFiles = ['boot.msg', 'initrd.gz', 'kernel', 'pxelinux.0']
pingDir = "/usr/share/PING" pingDir = "/usr/share/PING"
for f in pingFiles: for f in pingFiles:
path = join(pingDir, f) path = join(pingDir, f)
if not exists(path): if not exists(path):
printError("Cannot find %s, please make sure PING-3.01 is installed"%path) printError("Cannot find %s, please make sure PING-3.01 is installed"%path)
return False return False
if not bashWithResult("cp -f %s %s"%(path, tftpRootDir)): return False if not bashWithResult("cp -f %s %s"%(path, tftpRootDir)): return False
if not bashWithResult("mkdir -p %s/pxelinux.cfg"%tftpRootDir): return False if not bashWithResult("mkdir -p %s/pxelinux.cfg"%tftpRootDir): return False
return True return True
def prepareSyslinux(tftpRootDir): def prepareSyslinux(tftpRootDir):
@ -211,16 +211,16 @@ def prepareSyslinux(tftpRootDir):
return True return True
if __name__ == "__main__": if __name__ == "__main__":
initLoging("/tmp/cloud-setup-baremetal.log") initLoging("/tmp/cloud-setup-baremetal.log")
tftpRootDirList = [] tftpRootDirList = []
exitIfFail(checkEnv()) exitIfFail(checkEnv())
exitIfFail(configurePxeStuff()) exitIfFail(configurePxeStuff())
exitIfFail(getTftpRootDir(tftpRootDirList)) exitIfFail(getTftpRootDir(tftpRootDirList))
tftpRootDir = tftpRootDirList[0].strip() tftpRootDir = tftpRootDirList[0].strip()
#exitIfFail(preparePING(tftpRootDir)) #exitIfFail(preparePING(tftpRootDir))
exitIfFail(prepareSyslinux(tftpRootDir)) exitIfFail(prepareSyslinux(tftpRootDir))
@ -228,4 +228,3 @@ if __name__ == "__main__":
printMsg("Setup BareMetal PXE server successfully") printMsg("Setup BareMetal PXE server successfully")
printMsg("TFTP root directory is: %s\n"%tftpRootDir) printMsg("TFTP root directory is: %s\n"%tftpRootDir)
sys.exit(0) sys.exit(0)

View File

@ -8,9 +8,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -71,12 +71,12 @@ class DBDeployer(object):
def backUpDbDotProperties(): def backUpDbDotProperties():
dbpPath = os.path.join(self.dbConfPath, 'db.properties') dbpPath = os.path.join(self.dbConfPath, 'db.properties')
copyPath = os.path.join(self.dbConfPath, 'db.properties.origin') copyPath = os.path.join(self.dbConfPath, 'db.properties.origin')
if os.path.isfile(dbpPath): if os.path.isfile(dbpPath):
shutil.copy2(dbpPath, copyPath) shutil.copy2(dbpPath, copyPath)
backUpDbDotProperties() backUpDbDotProperties()
def postRun(self): def postRun(self):
def cleanOrRecoverDbDotProperties(): def cleanOrRecoverDbDotProperties():
dbpPath = os.path.join(self.dbConfPath, 'db.properties') dbpPath = os.path.join(self.dbConfPath, 'db.properties')
@ -85,22 +85,22 @@ class DBDeployer(object):
if not self.success: if not self.success:
shutil.copy2(copyPath, dbpPath) shutil.copy2(copyPath, dbpPath)
os.remove(copyPath) os.remove(copyPath)
cleanOrRecoverDbDotProperties() cleanOrRecoverDbDotProperties()
def info(self, msg, result=None): def info(self, msg, result=None):
output = "" output = ""
if msg is not None: if msg is not None:
output = "%-80s"%msg output = "%-80s"%msg
if result is True: if result is True:
output += "[ \033[92m%-2s\033[0m ]\n"%"OK" output += "[ \033[92m%-2s\033[0m ]\n"%"OK"
elif result is False: elif result is False:
output += "[ \033[91m%-6s\033[0m ]\n"%"FAILED" output += "[ \033[91m%-6s\033[0m ]\n"%"FAILED"
sys.stdout.write(output) sys.stdout.write(output)
sys.stdout.flush() sys.stdout.flush()
def debug(self, msg): def debug(self, msg):
msg = "DEBUG:%s"%msg msg = "DEBUG:%s"%msg
sys.stdout.write(msg) sys.stdout.write(msg)
@ -113,19 +113,19 @@ class DBDeployer(object):
else: else:
self.dbDotProperties[key] = (value, self.dbDotPropertiesIndex) self.dbDotProperties[key] = (value, self.dbDotPropertiesIndex)
self.dbDotPropertiesIndex += 1 self.dbDotPropertiesIndex += 1
def getDbProperty(self, key): def getDbProperty(self, key):
if key not in self.dbDotProperties: if key not in self.dbDotProperties:
return None return None
(value, index) = self.dbDotProperties[key] (value, index) = self.dbDotProperties[key]
return value return value
def errorAndExit(self, msg): def errorAndExit(self, msg):
self.postRun() self.postRun()
err = '''\n\nWe apologize for below error: err = '''\n\nWe apologize for below error:
*************************************************************** ***************************************************************
%s %s
*************************************************************** ***************************************************************
Please run: Please run:
cloud-setup-encryption -h cloud-setup-encryption -h
@ -147,7 +147,7 @@ for full help
line = line.strip() line = line.strip()
if line.startswith("#"): key = line; value = ''; passed = True if line.startswith("#"): key = line; value = ''; passed = True
if line == '' or line == '\n': key = self.magicString + str(emptyLine); value = ''; emptyLine += 1; passed = True if line == '' or line == '\n': key = self.magicString + str(emptyLine); value = ''; emptyLine += 1; passed = True
try: try:
if not passed: if not passed:
(key, value) = line.split('=', 1) (key, value) = line.split('=', 1)
@ -161,9 +161,9 @@ for example:
self.errorAndExit(err) self.errorAndExit(err)
self.putDbProperty(key, value) self.putDbProperty(key, value)
self.info("Preparing %s"%dbpPath, True) self.info("Preparing %s"%dbpPath, True)
prepareDBDotProperties() prepareDBDotProperties()
def finalize(self): def finalize(self):
def finalizeDbProperties(): def finalizeDbProperties():
entries = [] entries = []
@ -176,62 +176,62 @@ for example:
else: else:
entries.insert(index, "%s=%s"%(key, value)) entries.insert(index, "%s=%s"%(key, value))
file(os.path.join(self.dbConfPath, 'db.properties'), 'w').write('\n'.join(entries)) file(os.path.join(self.dbConfPath, 'db.properties'), 'w').write('\n'.join(entries))
self.info("Finalizing setup ...", None) self.info("Finalizing setup ...", None)
finalizeDbProperties() finalizeDbProperties()
self.info(None, True) self.info(None, True)
self.success = True # At here, we have done successfully and nothing more after this flag is set self.success = True # At here, we have done successfully and nothing more after this flag is set
def processEncryptionStuff(self): def processEncryptionStuff(self):
def encrypt(value): def encrypt(value):
cmd = ['java','-classpath','"' + self.encryptionJarPath + '"','com.cloud.utils.crypt.EncryptionCLI','-i','"' + value + '"', '-p', '"' + self.mgmtsecretkey + '"'] cmd = ['java','-classpath','"' + self.encryptionJarPath + '"','com.cloud.utils.crypt.EncryptionCLI','-i','"' + value + '"', '-p', '"' + self.mgmtsecretkey + '"']
return runCmd(cmd).strip('\n') return runCmd(cmd).strip('\n')
def saveMgmtServerSecretKey(): def saveMgmtServerSecretKey():
if self.encryptiontype == 'file': if self.encryptiontype == 'file':
file(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey) file(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey)
def formatEncryptResult(value): def formatEncryptResult(value):
return 'ENC(%s)'%value return 'ENC(%s)'%value
def encryptDBSecretKey(): def encryptDBSecretKey():
self.putDbProperty('db.cloud.encrypt.secret', formatEncryptResult(encrypt(self.dbsecretkey))) self.putDbProperty('db.cloud.encrypt.secret', formatEncryptResult(encrypt(self.dbsecretkey)))
def encryptDBPassword(): def encryptDBPassword():
dbPassword = self.getDbProperty('db.cloud.password') dbPassword = self.getDbProperty('db.cloud.password')
if dbPassword == '': return # Don't encrypt empty password if dbPassword == '': return # Don't encrypt empty password
if dbPassword == None: self.errorAndExit('Cannot find db.cloud.password in %s'%os.path.join(self.dbConfPath, 'db.properties')) if dbPassword == None: self.errorAndExit('Cannot find db.cloud.password in %s'%os.path.join(self.dbConfPath, 'db.properties'))
self.putDbProperty('db.cloud.password', formatEncryptResult(encrypt(dbPassword))) self.putDbProperty('db.cloud.password', formatEncryptResult(encrypt(dbPassword)))
usagePassword = self.getDbProperty('db.usage.password') usagePassword = self.getDbProperty('db.usage.password')
if usagePassword == '': return # Don't encrypt empty password if usagePassword == '': return # Don't encrypt empty password
if usagePassword == None: self.errorAndExit('Cannot find db.usage.password in %s'%os.path.join(self.dbConfPath, 'db.properties')) if usagePassword == None: self.errorAndExit('Cannot find db.usage.password in %s'%os.path.join(self.dbConfPath, 'db.properties'))
self.putDbProperty('db.usage.password', formatEncryptResult(encrypt(usagePassword))) self.putDbProperty('db.usage.password', formatEncryptResult(encrypt(usagePassword)))
self.info("Processing encryption ...", None) self.info("Processing encryption ...", None)
self.putDbProperty("db.cloud.encryption.type", self.encryptiontype) self.putDbProperty("db.cloud.encryption.type", self.encryptiontype)
saveMgmtServerSecretKey() saveMgmtServerSecretKey()
encryptDBSecretKey() encryptDBSecretKey()
encryptDBPassword() encryptDBPassword()
self.info(None, True) self.info(None, True)
def parseOptions(self): def parseOptions(self):
def parseOtherOptions(): def parseOtherOptions():
self.encryptiontype = self.options.encryptiontype self.encryptiontype = self.options.encryptiontype
self.mgmtsecretkey = self.options.mgmtsecretkey self.mgmtsecretkey = self.options.mgmtsecretkey
self.dbsecretkey = self.options.dbsecretkey self.dbsecretkey = self.options.dbsecretkey
self.isDebug = self.options.debug self.isDebug = self.options.debug
def validateParameters(): def validateParameters():
if self.encryptiontype != 'file' and self.encryptiontype != 'web': if self.encryptiontype != 'file' and self.encryptiontype != 'web':
self.errorAndExit('Wrong encryption type %s, --encrypt-type can only be "file" or "web'%self.encryptiontype) self.errorAndExit('Wrong encryption type %s, --encrypt-type can only be "file" or "web'%self.encryptiontype)
#---------------------- option parsing and command line checks ------------------------ #---------------------- option parsing and command line checks ------------------------
usage = """%prog [-e ENCRYPTIONTYPE] [-m MGMTSECRETKEY] [-k DBSECRETKEY] [--debug] usage = """%prog [-e ENCRYPTIONTYPE] [-m MGMTSECRETKEY] [-k DBSECRETKEY] [--debug]
This command sets up the CloudStack Encryption. This command sets up the CloudStack Encryption.
""" """
self.parser = OptionParser(usage=usage) self.parser = OptionParser(usage=usage)
self.parser.add_option("-v", "--debug", action="store_true", dest="debug", default=False, self.parser.add_option("-v", "--debug", action="store_true", dest="debug", default=False,
@ -246,17 +246,17 @@ for example:
(self.options, self.args) = self.parser.parse_args() (self.options, self.args) = self.parser.parse_args()
parseOtherOptions() parseOtherOptions()
validateParameters() validateParameters()
def run(self): def run(self):
try: try:
self.preRun() self.preRun()
self.parseOptions() self.parseOptions()
self.prepareDBFiles() self.prepareDBFiles()
self.processEncryptionStuff() self.processEncryptionStuff()
self.finalize() self.finalize()
finally: finally:
self.postRun() self.postRun()
print('') print('')
print("CloudStack has successfully setup Encryption") print("CloudStack has successfully setup Encryption")
print('') print('')
@ -264,4 +264,3 @@ for example:
if __name__ == "__main__": if __name__ == "__main__":
o = DBDeployer() o = DBDeployer()
o.run() o.run()

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
# mysql phase 1 # mysql phase 1
@ -32,7 +32,7 @@ fi
echo Running upgrade for database: cloud from 2.2.1 to 2.2.2 echo Running upgrade for database: cloud from 2.2.1 to 2.2.2
mysql -u root -C cloud < 221to222.sql mysql -u root -C cloud < 221to222.sql
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
exit 1 exit 1
fi fi
echo Finished upgrade for database: cloud from 2.2.1 to 2.2.2 echo Finished upgrade for database: cloud from 2.2.1 to 2.2.2
@ -42,7 +42,7 @@ echo Finished upgrade for database: cloud from 2.2.1 to 2.2.2
echo Running upgrade for database: cloud_usage from 2.2.1 to 2.2.2 echo Running upgrade for database: cloud_usage from 2.2.1 to 2.2.2
mysql -u root -C cloud_usage < 221to222_usage.sql mysql -u root -C cloud_usage < 221to222_usage.sql
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
exit 1 exit 1
fi fi
echo Finished upgrade for database: cloud_usage from 2.2.1 to 2.2.2 echo Finished upgrade for database: cloud_usage from 2.2.1 to 2.2.2

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
# deploy-db.sh -- deploys the database configuration. # deploy-db.sh -- deploys the database configuration.
# set -x # set -x
@ -64,7 +64,7 @@ fi
handle_error() { handle_error() {
mysqlout=$? mysqlout=$?
if [ $mysqlout -eq 1 ]; then if [ $mysqlout -eq 1 ]; then
printf "Please enter root password for MySQL.\n" printf "Please enter root password for MySQL.\n"
mysql --user=root --password < $1 mysql --user=root --password < $1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Error: Cannot execute $1\n" printf "Error: Cannot execute $1\n"
@ -133,7 +133,7 @@ if [ "$2" != "" ]; then
exit 12 exit 12
fi fi
fi fi
echo "Creating Indice and Foreign Keys" echo "Creating Indice and Foreign Keys"
mysql --user=cloud --password=cloud cloud < create-index-fk.sql mysql --user=cloud --password=cloud cloud < create-index-fk.sql

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
# deploy-db.sh -- deploys the database configuration. # deploy-db.sh -- deploys the database configuration.
# set -x # set -x
@ -65,7 +65,7 @@ fi
handle_error() { handle_error() {
mysqlout=$? mysqlout=$?
if [ $mysqlout -eq 1 ]; then if [ $mysqlout -eq 1 ]; then
printf "Please enter root password for MySQL.\n" printf "Please enter root password for MySQL.\n"
mysql --user=root --password < $1 mysql --user=root --password < $1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Error: Cannot execute $1\n" printf "Error: Cannot execute $1\n"
@ -139,7 +139,7 @@ if [ "$2" != "" ]; then
exit 12 exit 12
fi fi
fi fi
echo "Creating Indice and Foreign Keys" echo "Creating Indice and Foreign Keys"
mysql --user=cloud --password=cloud cloud < create-index-fk.sql mysql --user=cloud --password=cloud cloud < create-index-fk.sql

View File

@ -74,7 +74,7 @@ cat $cfg | while read line; do
fi fi
done done
# archive the configuration file # archive the configuration file
mv $cfg /var/cache/cloud/processed/ mv $cfg /var/cache/cloud/processed/

View File

@ -84,7 +84,7 @@ restart_services() {
break break
fi fi
fi fi
done done
if [ $patchfailed == 1 ]; then if [ $patchfailed == 1 ]; then
return return
fi fi

View File

@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
set -e set -e

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
PATHSEP=':' PATHSEP=':'
if [[ $OSTYPE == "cygwin" ]] ; then if [[ $OSTYPE == "cygwin" ]] ; then

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
set -e set -e
DST='src/' DST='src/'

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
set -e set -e
DST='src/' DST='src/'

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
#set -x #set -x

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
while true while true

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
set -e set -e

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the # to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,7 +18,7 @@
PATHSEP=':' PATHSEP=':'
if [[ $OSTYPE == "cygwin" ]] ; then if [[ $OSTYPE == "cygwin" ]] ; then

Some files were not shown because too many files have changed in this diff Show More