Skip to content

Commit

Permalink
Fixed options parsing for filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
feist committed Sep 6, 2012
1 parent 1b764b7 commit dbfbdf4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 91 deletions.
5 changes: 4 additions & 1 deletion pcs/pcs.py
Expand Up @@ -19,15 +19,18 @@ def main(argv):
real_argv = []
try:
# pull out negative number arguments and add them back after getopt
prev_arg = ""
for arg in argv:
if arg[0] == "-":
if arg[1:].isdigit():
real_argv.append(arg)
else:
modified_argv.append(arg)
else:
real_argv.append(arg)
if prev_arg != "-f":
real_argv.append(arg)
modified_argv.append(arg)
prev_arg = arg

pcs_options, argv = getopt.gnu_getopt(modified_argv, "hf:p", ["local","start","all"])
except getopt.GetoptError, err:
Expand Down
30 changes: 15 additions & 15 deletions pcs/test/test.sh
Expand Up @@ -7,39 +7,39 @@ echo "Testing Resources..."
../pcs.py -f test.xml resource create ClusterIP3 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource create ClusterIP3 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource create ClusterIP4 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource delete ClusterIP3
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource create ClusterIP32 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource list ClusterIP2
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource show ClusterIP2
../pcs.py -f test.xml resource update ClusterIP2 ip=192.168.0.100
../pcs.py -f test.xml resource add_operation ClusterIP2 monitor interval="31s"
../pcs.py -f test.xml resource add_operation ClusterIP2 monitor interval="32s"
../pcs.py -f test.xml resource remove_operation ClusterIP2 monitor interval="32s"
../pcs.py -f test.xml resource list ClusterIP2
../pcs.py -f test.xml resource show ClusterIP2
../pcs.py -f test.xml resource group add MyGroup ClusterIP2 ClusterIP32 ClusterIP4
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource group remove_resource MyGroup ClusterIP4
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource group add MyGroup2 ClusterIP4
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource group remove_resource MyGroup2 ClusterIP4
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource clone create ClusterIP4 globally-unique=false
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource list ClusterIP4-clone
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource show ClusterIP4-clone
../pcs.py -f test.xml resource clone update ClusterIP4 globally-unique=true
../pcs.py -f test.xml resource list ClusterIP4-clone
../pcs.py -f test.xml resource show ClusterIP4-clone
../pcs.py -f test.xml resource create ClusterIP5 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource create ClusterIP6 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s
../pcs.py -f test.xml resource master create MyMaster ClusterIP5 master-max=1
../pcs.py -f test.xml resource master update MyMaster master-max=2
../pcs.py -f test.xml resource master create MyMaster2 ClusterIP6
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource list MyMaster
../pcs.py -f test.xml resource show
../pcs.py -f test.xml resource show MyMaster
../pcs.py -f test.xml resource master remove MyMaster2
../pcs.py -f test.xml resource list
../pcs.py -f test.xml resource show
diff test.xml final.xml


77 changes: 2 additions & 75 deletions pcs/test/test.xml
@@ -1,85 +1,12 @@
<cib admin_epoch="0" cib-last-written="Thu Aug 23 17:12:51 2012" crm_feature_set="3.0.6" dc-uuid="2" epoch="580" have-quorum="0" num_updates="1" update-client="crmd" update-origin="rh7-3" validate-with="pacemaker-1.2">
<cib epoch="557" num_updates="122" admin_epoch="0" validate-with="pacemaker-1.2" crm_feature_set="3.0.6" update-origin="rh7-3" update-client="crmd" cib-last-written="Thu Aug 23 16:49:17 2012" have-quorum="0" dc-uuid="2">
<configuration>
<crm_config/>
<nodes>
<node id="1" type="normal" uname="rh7-1"/>
<node id="2" type="normal" uname="rh7-2"/>
<node id="3" type="normal" uname="rh7-3"/>
</nodes>
<resources>
<primitive class="ocf" id="ClusterIP" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP-instance_attributes">
<nvpair id="ClusterIP-instance_attributes-ip" name="ip" value="192.168.0.99"/>
<nvpair id="ClusterIP-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP-interval-30s" interval="30s" name="monitor"/>
</operations>
</primitive>
<primitive class="ocf" id="DummyRes" provider="heartbeat" type="Dummy">
<instance_attributes id="DummyRes-instance_attributes">
<nvpair id="DummyRes-instance_attributes-fake" name="fake" value="my fake"/>
</instance_attributes>
</primitive>
<group id="MyGroup">
<primitive class="ocf" id="ClusterIP2" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP2-instance_attributes">
<nvpair id="ClusterIP2-instance_attributes-ip" name="ip" value="192.168.0.100"/>
<nvpair id="ClusterIP2-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP2-interval-30s" interval="30s" name="monitor"/>
<op id="ClusterIP2-name-monitor-interval-31s" interval="31s" name="monitor"/>
</operations>
</primitive>
<primitive class="ocf" id="ClusterIP32" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP32-instance_attributes">
<nvpair id="ClusterIP32-instance_attributes-ip" name="ip" value="192.168.0.99"/>
<nvpair id="ClusterIP32-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP32-interval-30s" interval="30s" name="monitor"/>
</operations>
</primitive>
</group>
<clone id="ClusterIP4-clone">
<primitive class="ocf" id="ClusterIP4" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP4-instance_attributes">
<nvpair id="ClusterIP4-instance_attributes-ip" name="ip" value="192.168.0.99"/>
<nvpair id="ClusterIP4-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP4-interval-30s" interval="30s" name="monitor"/>
</operations>
</primitive>
<meta_attributes id="ClusterIP4-clone-meta">
<nvpair id="ClusterIP4-globally-unique" name="globally-unique" value="true"/>
</meta_attributes>
</clone>
<master id="MyMaster">
<primitive class="ocf" id="ClusterIP5" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP5-instance_attributes">
<nvpair id="ClusterIP5-instance_attributes-ip" name="ip" value="192.168.0.99"/>
<nvpair id="ClusterIP5-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP5-interval-30s" interval="30s" name="monitor"/>
</operations>
</primitive>
<meta_attributes id="MyMaster-meta_attributes">
<nvpair id="MyMaster-meta_attributes-master-max" name="master-max" value="2"/>
</meta_attributes>
</master>
<primitive class="ocf" id="ClusterIP6" provider="heartbeat" type="IPaddr2">
<instance_attributes id="ClusterIP6-instance_attributes">
<nvpair id="ClusterIP6-instance_attributes-ip" name="ip" value="192.168.0.99"/>
<nvpair id="ClusterIP6-instance_attributes-cidr_netmask" name="cidr_netmask" value="32"/>
</instance_attributes>
<operations>
<op id="ClusterIP6-interval-30s" interval="30s" name="monitor"/>
</operations>
</primitive>
</resources>
<resources/>
<constraints/>
</configuration>
<status/>
Expand Down

0 comments on commit dbfbdf4

Please sign in to comment.