Add pollStatus function for script actions #62

This commit is contained in:
Andrie de Vries 2017-05-30 20:43:32 +01:00
Родитель 1c13ecf0f3
Коммит 9c7fce1f13
3 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -2,6 +2,7 @@
S3method(print,azureActiveContext)
S3method(str,azureActiveContext)
S3method(summary,azureScriptActionHistory)
export(AzureListRG)
export(as.azureActiveContext)
export(azureAuthenticate)

Просмотреть файл

@ -356,9 +356,9 @@ azureResizeHDI <- function(azureActiveContext, clustername,
#' @inheritParams azureAuthenticate
#' @inheritParams azureListHDI
#'
#' @return Returns Dataframe of HDInsight Clusters information
#' @return Data frame with HDInsight clusters information
#' @family HDInsight functions
#' @reference https://docs.microsoft.com/en-us/rest/api/hdinsight/hdinsight-cluster#delete
#' @references https://docs.microsoft.com/en-us/rest/api/hdinsight/hdinsight-cluster#delete
#' @export
azureDeleteHDI <- function(azureActiveContext, clustername, subscriptionID,
resourceGroup, verbose = FALSE) {
@ -509,13 +509,15 @@ azureScriptActionHistory <- function(azureActiveContext, resourceGroup,
}
#' @export
#' @param object azureScriptActionHistory object, created by [azureScriptActionHistory()]
#' @param ... not used
#' @rdname azureScriptActionHistory
summary.azureScriptActionHistory <- function(x) {
do.call(rbind, lapply(x, function(x) {
summary.azureScriptActionHistory <- function(object, ...) {
do.call(rbind, lapply(object, function(x) {
data.frame(
x[c("name", "scriptExecutionId", "startTime")],
if (is.null(x$endTime)) list(endTime = NA) else x["endTime"],
x[c("status", "uri", "parameters")]
x[c("name", "scriptExecutionId", "startTime")],
if (is.null(x$endTime)) list(endTime = NA) else x["endTime"],
x[c("status", "uri", "parameters")]
)
}))
}

Просмотреть файл

@ -135,7 +135,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) {
while (iteration < 500 && waiting) {
status <- azureScriptActionHistory(azureActiveContext)
idx <- which(sapply(z, "[[", "name") == scriptname)[1]
idx <- which(sapply(status, "[[", "name") == scriptname)[1]
summary <- status[[idx]]$status
rc <- switch(tolower(summary),
accepted = "A",
@ -144,7 +144,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) {
failed = "F",
inprogress = ".",
"?"
)
)
message(rc, appendLF = FALSE)
if (rc %in% c("S", "E", "F")) {
@ -160,7 +160,7 @@ pollStatusScriptAction <- function(azureActiveContext, scriptname) {
iteration <- iteration + 1
if (!rc %in% c("S", "E", "F")) Sys.sleep(5)
}
}
message("")
message("Script action completed: ", Sys.time())
return(TRUE)