-
Notifications
You must be signed in to change notification settings - Fork 2
/
Credential.py
50 lines (38 loc) · 1.44 KB
/
Credential.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import json
class Credentials(object):
'''
Azure credentials needed to run Azure.
'''
def __init__(self):
configFilename = os.environ["HOME"] + "/.azure/config.json"
tmpName = os.path.join(os.getcwd(), configFilename)
if not os.path.exists(tmpName):
errMsg = "Cannot run Azure when the expected config file containing Azure credentials, '%s', does not exist!" % (tmpName)
raise EnvironmentError(errMsg)
with open(tmpName, "r") as f:
self.ns = json.load(f)
self.config_path = os.path.dirname(tmpName)
def getManagementCertFile(self):
try:
return self.ns[u'managementcertfile']
except:
return self.config_path + "/managementCertificate.pem"
def getSubscriptionId(self):
return self.ns[u'subscriptionid']
def getSubscription(self):
return self.ns[u'subscription']
def getServiceBusKey(self):
return self.ns[u'servicebuskey']
def getServiceBusNamespace(self):
return self.ns[u'servicebusns']
def getStorageServicesKey(self):
return self.ns[u'storageserviceskey']
def getStorageServicesName(self):
return self.ns[u'storageservicesname']
def getLinuxOSVHD(self):
return self.ns[u'linuxosvhd']
def getProxyHost(self):
return self.ns[u'proxyhost']
def getProxyPort(self):
return self.ns[u'proxyport']