Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
* master:
  add updated docs namespace and description
  add rstudio-server tag for rserver hdI
  fix error message display
  fix and tests for rserver hdi
  clusterVersion fix and add r-server and edge node options
  camel case fix and add alias for AzureListRG
  fix `AzureListRG` -> `azureListRG`; camel case change in function name
  #40 ENCODE the client secret to avoid occasional 401
  Added Scale Sets functions Deploy Template handle FAIL condition
  Added 3 functions for ScaleSets Fixed Deploy template to manager FAILED status
  • Loading branch information
andrie committed Feb 6, 2017
2 parents e4097bf + 5d00fc6 commit 6db4bc0
Show file tree
Hide file tree
Showing 64 changed files with 426 additions and 73 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Suggests:
testthat
VignetteBuilder: knitr
LazyData: TRUE
RoxygenNote: 5.0.1
RoxygenNote: 6.0.0
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method(print,azureActiveContext)
S3method(str,azureActiveContext)
export(AzureListRG)
export(as.azureActiveContext)
export(azureAuthenticate)
export(azureBlobCD)
Expand Down Expand Up @@ -30,6 +31,9 @@ export(azureListAllResources)
export(azureListHDI)
export(azureListRG)
export(azureListSA)
export(azureListScaleSetNetwork)
export(azureListScaleSetVM)
export(azureListScaleSets)
export(azureListStorageBlobs)
export(azureListStorageContainers)
export(azureListSubscriptions)
Expand Down
4 changes: 3 additions & 1 deletion R/AzureAuthenticate.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ azureAuthenticate <- function(azureActiveContext, tenantID, clientID, authKey, v

URLGT <- paste0("https://login.microsoftonline.com/", AtenantID, "/oauth2/token?api-version=1.0")

AauthKeyE <- URLencode(AauthKey, reserved = TRUE)

bodyGT <- paste0("grant_type=client_credentials&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=",
AclientID, "&client_secret=", AauthKey)
AclientID, "&client_secret=", AauthKeyE)

r <- httr::POST(URLGT,
add_headers(
Expand Down
37 changes: 31 additions & 6 deletions R/AzureHDI.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ azureDeleteHDI <- function(azureActiveContext, clustername, azToken, subscriptio
#'
#'
#' @param version HDinsight version
#' @param kind HDinsight kind: "hadoop","spark" or "rserver"
#' @param adminUser Admin user name
#' @param adminPassword Admin user password
#' @param workers Define the number of worker nodes
Expand All @@ -383,6 +384,7 @@ azureDeleteHDI <- function(azureActiveContext, clustername, azToken, subscriptio
#' @param hiveUser Hive user name
#' @param hivePassword Hive user password
#' @param componentVersion Spark componentVersion. Default : 1.6.2
#' @param vmSize Size of nodes: "Large", "Small", "Standard_D14_V2", etc.
#' @param mode Provisioning mode, "Sync" or "Async". Use "Async" to immediately return to R session after submission of request
#'
#' @return Success message
Expand All @@ -393,6 +395,7 @@ azureDeleteHDI <- function(azureActiveContext, clustername, azToken, subscriptio
azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "spark", storageAccount,
storageKey, version = "3.4", componentVersion="1.6.2", workers = 2, adminUser, adminPassword, sshUser,
sshPassword, hiveServer, hiveDB, hiveUser, hivePassword, resourceGroup,
vmSize = "Large",
azToken, subscriptionID, mode = "Sync", verbose = FALSE) {
azureCheckToken(azureActiveContext)

Expand Down Expand Up @@ -470,7 +473,7 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
"location": "LLLLLLLLLLL",
"tags": { "tag1": "value1", "tag2": "value2" },
"properties": {
"clusterversion": "VVVV",
"clusterVersion": "VVVV",
"osType": "Linux",
"tier": "standard",
"clusterDefinition": {
Expand All @@ -485,7 +488,8 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
"core-site": {
"fs.defaultFS": "wasb://CCCCCC@TTTTTTTTTTT.blob.core.windows.net",
"fs.azure.account.key.TTTTTTTTTTT.blob.core.windows.net": "KKKKKKKKKKKKKKKK"
}
},
YYYYYYYYYYYYYY,
HHHHHHHHHHHHHH
}},
"computeProfile": {
Expand All @@ -494,7 +498,19 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmsize": "Large"
"vmsize": "ZZZZZZ"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "UUUUUUUUU",
"password": "PPPPPPPPP"
}}},
{
"name": "edgenode",
"minInstanceCount": 1,
"targetInstanceCount": 1,
"hardwareProfile": {
"vmSize": "ZZZZZZ"
},
"osProfile": {
"linuxOperatingSystemProfile": {
Expand All @@ -505,7 +521,7 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
"name": "workernode",
"targetInstanceCount": WWWWWW,
"hardwareProfile": {
"vmsize": "Large"
"vmsize": "ZZZZZZ"
},
"osProfile": {
"linuxOperatingSystemProfile": {
Expand Down Expand Up @@ -543,7 +559,15 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
"hive_existing_mssql_server_host": "SSSSSSSSSS",
"hive_hostname": "SSSSSSSSSS"
}'


rserver <- (kind == "rserver")

if (rserver) {
bodyI <- gsub("YYYYYYYYYYYYYY", "\"rserver\": {\"rstudio\": true}\n", bodyI)
} else {
bodyI <- gsub("YYYYYYYYYYYYYY", "", bodyI)
}

bodyI <- gsub("CCCCCC", clustername, bodyI)
bodyI <- gsub("UUUUUUUUU", sshUser, bodyI)
bodyI <- gsub("PPPPPPPPP", sshPassword, bodyI)
Expand All @@ -555,7 +579,8 @@ azureCreateHDI <- function(azureActiveContext, clustername, location, kind = "sp
bodyI <- gsub("TTTTTTTTTTT", storageAccount, bodyI)
bodyI <- gsub("KKKKKKKKKKKKKKKK", storageKey, bodyI)
bodyI <- gsub("DDDDDDDDD", kind, bodyI)
bodyI <- gsub("VVVV", version, bodyI)
bodyI <- gsub("VVVV", componentVersion, bodyI)
bodyI <- gsub("ZZZZZZ", vmSize, bodyI)
if (HIVE) {
HIVEJSON <- gsub("SSSSSSSSSS", hiveServer, HIVEJSON)
HIVEJSON <- gsub("DDDDDDDDDD", hiveDB, HIVEJSON)
Expand Down
5 changes: 5 additions & 0 deletions R/AzureResources.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ azureListRG <- function(azureActiveContext, subscriptionID, azToken, verbose = F
}


#' @rdname azureListRG
#' @export
AzureListRG <- azureListRG


#' Get all Resource in default Subscription.
#'
#' @inheritParams setAzureContext
Expand Down
10 changes: 7 additions & 3 deletions R/AzureTemplate.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ azureDeployTemplate <- function(azureActiveContext, deplname, templateURL,
r <- PUT(URL, add_headers(.headers = c(Host = "management.azure.com",
Authorization = AT, `Content-type` = "application/json")), body = bodyI,
verbosity)

rl <- content(r, "text", encoding = "UTF-8")
if (verbose == TRUE && status_code(r) != 200 && status_code(r) != 201 && status_code(r) !=
202) print (rl)

# print(paste(deplname,'Submitted'))
if (status_code(r) != 200 && status_code(r) != 201 && status_code(r) !=
202) {
stopWithAzureError(r)
}
rl <- content(r, "text", encoding = "UTF-8")
# print (rl)
df <- fromJSON(rl)
if (toupper(mode) == "SYNC") {
Expand All @@ -103,7 +107,7 @@ azureDeployTemplate <- function(azureActiveContext, deplname, templateURL,
writeLines(paste("Finished Deploying Sucessfully: ", Sys.time()))
(break)()
}
if (grepl("Error", rc)) {
if (grepl("Error", rc) || grepl("Failed", rc)) {
writeLines("")
writeLines(paste("Error Deploying: ", Sys.time()))
(break)()
Expand All @@ -130,7 +134,7 @@ azureDeployTemplate <- function(azureActiveContext, deplname, templateURL,
}
}
writeLines(paste("Deployment", deplname, "Submitted: ", Sys.time()))
return("OK")
return(TRUE)
}


Expand Down
Loading

0 comments on commit 6db4bc0

Please sign in to comment.