Skip to content

Commit

Permalink
fixing logic in blob mount
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Storey committed Jun 9, 2020
1 parent d3c6272 commit 27a4030
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions databricks/mounts.go
Expand Up @@ -210,21 +210,25 @@ func NewAzureADLSGen1Mount(storageResource string, directory string, mountName s
// Create creates a azure datalake gen 1 storage mount given a cluster id
func (m AzureADLSGen1Mount) Create(client *service.DBApiClient, clusterID string) error {
iamMountCommand := fmt.Sprintf(`
for mount in dbutils.fs.mounts():
if mount.mountPoint == "/mnt/%[8]s" and mount.source=="adl://%[6]s.azuredatalakestore.net%[7]s":
print ("Mount already exists")
dbutils.notebook.exit("success")
try:
configs = {"%s.oauth2.access.token.provider.type": "ClientCredential",
"%s.oauth2.client.id": "%s",
"%s.oauth2.credential": dbutils.secrets.get(scope = "%s", key = "%s"),
"%s.oauth2.refresh.url": "https://login.microsoftonline.com/%s/oauth2/token"}
configs = {"%[1]s.oauth2.access.token.provider.type": "ClientCredential",
"%[1]s.oauth2.client.id": "%[2]s",
"%[1]s.oauth2.credential": dbutils.secrets.get(scope = "%[3]s", key = "%[4]s"),
"%[1]s.oauth2.refresh.url": "https://login.microsoftonline.com/%[5]s/oauth2/token"}
dbutils.fs.mount(
source = "adl://%s.azuredatalakestore.net%s",
mount_point = "/mnt/%s",
source = "adl://%[6]s.azuredatalakestore.net%[7]s",
mount_point = "/mnt/%[8]s",
extra_configs = configs)
except Exception as e:
dbutils.fs.unmount("/mnt/%s")
dbutils.fs.unmount("/mnt/%[8]s")
raise e
dbutils.notebook.exit("success")
`, m.PrefixType, m.PrefixType, m.ClientID, m.PrefixType, m.SecretScope, m.SecretKey, m.PrefixType, m.TenantID,
m.StorageResource, m.Directory, m.MountName, m.MountName)
`, m.PrefixType, m.ClientID, m.SecretScope, m.SecretKey, m.TenantID, m.StorageResource, m.Directory, m.MountName, m.MountName)
resp, err := client.Commands().Execute(clusterID, "python", iamMountCommand)
if err != nil {
return err
Expand Down

0 comments on commit 27a4030

Please sign in to comment.