Skip to content

Commit

Permalink
Updated manual with virtual storage commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfitBricks committed Mar 2, 2012
1 parent 83c7fb8 commit f37c0ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/pbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def getStorage(self, id):
ProfitBricks.APIError(err, {"RESOURCE_DELETED": "The Virtual Storage has been deleted by the user", "RESOURCE_NOT_FOUND": "Specified Virtual Storage does not exist", "UNAUTHORIZED": "User is not authorized to access the Virtual Storage"})

def connectStorageToServer(self, stoId, srvId, busType, deviceNumber = None):
args = { "storageId": stoId, "serverId": srvId, "busType": busType }
args = { "storageId": stoId, "serverId": srvId, "busType": busType.upper() }
if deviceNumber != None:
args["deviceNumber"] = deviceNumber
try:
Expand Down Expand Up @@ -440,11 +440,11 @@ def printDataCenter(self, dataCenter):
baseArgs["auth"] = sys.argv[i + 1]
try:
authFile = open(sys.argv[i + 1], "r")
baseArgs["u"] = authFile.readline().strip("\n")
baseArgs["p"] = authFile.readline().strip("\n")
authFile.close()
except:
ProfitBricks.ArgsError("Authfile does not exist or cannot be read")
baseArgs["u"] = authFile.readline().strip("\n")
baseArgs["p"] = authFile.readline().strip("\n")
authFile.close()
i += 1
elif arg.lower() == "-s":
baseArgs["s"] = True
Expand All @@ -457,6 +457,17 @@ def printDataCenter(self, dataCenter):
baseArgs["op"] = sys.argv[i];
i += 1

## Load auth from default.auth if exists

if "u" not in baseArgs or "p" not in baseArgs:
try:
authFile = open("default.auth", "r")
baseArgs["u"] = authFile.readline().strip("\n")
baseArgs["p"] = authFile.readline().strip("\n")
authFile.close()
except:
pass

## Verify that all required arguments are present

if "u" not in baseArgs:
Expand Down Expand Up @@ -527,7 +538,7 @@ def printDataCenter(self, dataCenter):
},
"connectStorageToServer": {
"args": ["stoid", "srvid", "bus"],
"lambda": lambda: formatter.printConnectStorageToServer(api.connectStorageToServer(opArgs["stoid"], opArgs["srvid"], opArgs["bus"], opArgs["deviceNumber"] if "deviceNumber" in opArgs else None))
"lambda": lambda: formatter.printConnectStorageToServer(api.connectStorageToServer(opArgs["stoid"], opArgs["srvid"], opArgs["bus"], opArgs["devnum"] if "devnum" in opArgs else None))
},
"disconnectStorageFromServer": {
"args": ["stoid", "srvid"],
Expand Down
7 changes: 5 additions & 2 deletions src/pbcli.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash

echo ""

if [ -e default.auth ]; then
default_args="-auth default.auth"
echo "Using -auth default.auth as default arguments"
else
#default_args="-auth ../../costi.auth"
read -e -p "Default arguments (usually -u user -p pass): " default_args
fi

echo "Type 'exit' to leave"
echo "Type 'exit' to leave or 'help' for help."
echo ""
while [ true ]; do
read -e -p "ProfitBricks> " command

Expand Down

0 comments on commit f37c0ea

Please sign in to comment.