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: mixed-line-ending
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
rev: 7.0.0
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-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-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-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-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-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
@ -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-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-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-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-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-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
@ -657,11 +657,11 @@ Version 4.1.0
-------------
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:
* The project now uses Maven 3 exclusively to build.
* The project now uses Maven 3 exclusively to build.
New Features:
* CLOUDSTACK-101: OVS support in KVM
@ -976,14 +976,14 @@ Issues fixed in this release:
* 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-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.
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:

View File

@ -3,7 +3,7 @@ Contributing to Apache CloudStack (ACS)
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.
_Lets get started!!!_
@ -11,17 +11,17 @@ _Lets get started!!!_
Bug fixes
---------
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.
This can be either the "current release" or the "previous release", depending on which ones are maintained.
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.
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)
Developing new features
-----------------------
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).
PR will only be merged when main is open, will be held otherwise until main is open again.
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).
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!
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.
Fork the code
Fork the code
-------------
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
------------------
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
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
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.
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
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

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

View File

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

View File

@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -46,7 +46,7 @@ cfg = "@MSCONF@/db.properties"
#---------------------- 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."""
@ -88,7 +88,7 @@ def parseuserpwfromhosts(hosts):
return creds
class XenServerConfigurator(Thread):
def __init__(self,host,user,password,keyfiledata):
Thread.__init__(self)
self.host = host
@ -99,7 +99,7 @@ class XenServerConfigurator(Thread):
self.stdout = ""
self.stderr = ""
self.state = 'initialized'
def run(self):
try:
self.state = 'running'
@ -120,18 +120,18 @@ class XenServerConfigurator(Thread):
c.close()
if self.retval != 0: self.state = 'failed'
else: self.state = 'finished'
except Exception as e:
self.state = 'failed'
self.retval = e
#raise
def __str__(self):
if self.state == 'failed':
return "<%s XenServerConfigurator on %s@%s: %s>"%(self.state,self.user,self.host,str(self.retval))
else:
return "<%s XenServerConfigurator on %s@%s>"%(self.state,self.user,self.host)
#------------- actual code --------------------
(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:
print(c.host + "...", end=' ')
c.join()

View File

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

View File

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

View File

@ -47,5 +47,5 @@ echo "new mysql server is started on port "$PORT
echo $db
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"

View File

@ -294,7 +294,7 @@ This is independent of StorPool as snapshots exist on secondary.
### 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.
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.
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
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -129,11 +129,11 @@ config_dnsmasq domain=cloudnine.internal
config_dnsmasq "
# Send options to hosts which ask for a DHCP lease.
# 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.
# Note that all the common settings, such as netmask and
# 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
# are some options which are recommended, they are detailed at the
# end of this section.

View File

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

View File

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

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# 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 $
# create_private_template.sh -- create a private template from a snapshot
@ -31,7 +31,7 @@ create_template() {
local fspath=$1
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
if $qemu_img info "$tmpltimg" | grep -q backing; then
qemu-img convert -O qcow2 /$fspath $destpath

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,16 +6,16 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# $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
@ -41,7 +41,7 @@ fi
untar() {
local ft=$(file $1| awk -F" " '{print $2}')
case $ft in
USTAR)
USTAR)
printf "tar archives not supported\n" >&2
return 1
;;
@ -87,12 +87,12 @@ uncompress() {
;;
esac
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Failed to uncompress file (filetype=$ft), exiting "
return 1
return 1
fi
rm -f $1
printf $tmpfile
@ -167,7 +167,7 @@ do
done
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
#Currently only cifs is supported in hyperv zone.
mount | grep "type cifs" > /dev/null
@ -182,7 +182,7 @@ fi
mkdir -p $tmpltfs
if [ ! -f $tmpltimg ]
if [ ! -f $tmpltimg ]
then
printf "root disk file $tmpltimg doesn't exist\n"
exit 3

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# 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 $
# createvolume.sh -- install a volume
@ -53,7 +53,7 @@ verify_cksum() {
esac
echo "$1 $2" | $digestalgo -c --status
#printf "$1\t$2" | $digestalgo -c --status
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Checksum failed, not proceeding with install\n"
exit 3
@ -63,7 +63,7 @@ verify_cksum() {
untar() {
local ft=$(file $1| awk -F" " '{print $2}')
case $ft in
USTAR)
USTAR)
printf "tar archives not supported\n" >&2
return 1
;;
@ -109,12 +109,12 @@ uncompress() {
;;
esac
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Failed to uncompress file (filetype=$ft), exiting "
return 1
return 1
fi
rm -f $1
printf $tmpfile
@ -205,7 +205,7 @@ fi
mkdir -p $tmpltfs
if [ ! -f $tmpltimg ]
if [ ! -f $tmpltimg ]
then
printf "root disk file $tmpltimg doesn't exist\n"
exit 3
@ -227,7 +227,7 @@ then
if [ isCifs -ne 0 ] ;
then
if which vhd-util &>/dev/null
then
then
vhd-util check -n ${tmpltimg2} > /dev/null
rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
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
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,7 +29,7 @@ usage() {
verify_cksum() {
echo "$1 $2" | md5sum -c --status
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Checksum failed, not proceeding with install\n"
exit 3
@ -44,7 +44,7 @@ install_file() {
mv $isofile /$isofs/$tmpltname
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Move operation failed, iso $isofile not installed\n"
exit 4
@ -55,7 +55,7 @@ install_file() {
isofs=$isofs/$file
mp=${isofs%/iso/*}
mp=/$mp/iso
path=${isofs:${#mp}}
path=${isofs:${#mp}}
pushd $mp
ln -s $path $file
popd
@ -108,10 +108,10 @@ then
isofs=${isofs:1}
fi
if [ ! -d /$isofs ]
if [ ! -d /$isofs ]
then
mkdir -p /$isofs
if [ $? -gt 0 ]
if [ $? -gt 0 ]
then
printf "Failed to create iso fs $isofs\n" >&2
exit 1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,7 +17,7 @@
# under the License.
#set -x
usage() {
printf "Usage: %s \n" $(basename $0) >&2
@ -33,7 +33,7 @@ moveConfigToBond() {
if [ -n "$bondSlaveIp" ]; then
mode=$(xe pif-param-get param-name=IP-configuration-mode 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)
management=$(xe pif-param-get param-name=management uuid=$bondSlave)
slavedevice=$(xe pif-param-get param-name=device uuid=$bondSlave)
@ -47,7 +47,7 @@ moveConfigToBond() {
echo " --Succeeded"
if [ "$management" = "true" ]; then
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
echo " --Failed to move management interface from $bondSlave to $bondMaster, please run xe host-management-reconfigure pif-uuid=$bondMaster manually"
exit 1
@ -62,7 +62,7 @@ moveConfigToBond() {
xe pif-plug uuid=$bondMaster
done
fi
}
}
poolUuid=$(xe pool-list | grep ^uuid | awk '{print $NF}')
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
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,14 +17,14 @@
# under the License.
#set -x
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()
{
if [ ! -z $localmp ]; then
if [ ! -z $localmp ]; then
umount -fl $localmp
if [ $? -eq 0 ]; then
rmdir $localmp
@ -158,7 +158,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
exit 0
fi
copyvhd $desvhd $vhdfile $lvsize $type
else
else
echo "15#doesn't support sr type $type"
cleanup
exit 0

View File

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

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,20 +17,20 @@
# under the License.
#set -x
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'
cleanup()
{
if [ ! -z $snapshotdir ]; then
if [ ! -z $snapshotdir ]; then
umount $snapshotdir
if [ $? -eq 0 ]; then
rmdir $snapshotdir
fi
fi
if [ ! -z $templatedir ]; then
if [ ! -z $templatedir ]; then
umount $templatedir
if [ $? -eq 0 ]; then
rmdir $templatedir
@ -110,7 +110,7 @@ copyvhd()
exit 0
fi
if [[ "${parent}" =~ " no parent" ]]; then
dd if=$srcvhd of=$desvhd bs=2M
dd if=$srcvhd of=$desvhd bs=2M
if [ $? -ne 0 ]; then
echo "31#failed to dd $srcvhd to $desvhd"
cleanup

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,20 +17,20 @@
# under the License.
#set -x
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()
{
if [ ! -z $snapshotdir ]; then
if [ ! -z $snapshotdir ]; then
umount $snapshotdir
if [ $? -eq 0 ]; then
rmdir $snapshotdir
fi
fi
if [ ! -z $templatedir ]; then
if [ ! -z $templatedir ]; then
umount $templatedir
if [ $? -eq 0 ]; then
rmdir $templatedir
@ -99,7 +99,7 @@ upgradeSnapshot()
exit 0
fi
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
echo "31#failed to dd $templatevhd to $snapshotdir/$templatefilenamed"
cleanup

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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