Skip to content

Commit

Permalink
Merge pull request #20 from xingzhang-suse/main
Browse files Browse the repository at this point in the history
NVSHAS-4733: federate clusters through proxy (Final)
  • Loading branch information
BinX-Suse authored Jan 12, 2022
2 parents 453c8a9 + e759430 commit a0d29b5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion admin/src/main/scala/com/neu/api/ClusterService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ClusterService()(implicit executionContext: ExecutionContext)
fedMembershipData.fed_role,
fedMembershipData.local_rest_info,
Some(clusters),
Some(fedMembershipData.use_proxy.fold("") {user_proxy => user_proxy})
Some(fedMembershipData.use_proxy.fold("") {use_proxy => use_proxy})
)

}
Expand Down
8 changes: 4 additions & 4 deletions admin/src/main/scala/com/neu/model/ClusterServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case class FedMemberData(
fed_role: String,
local_rest_info: Option[ClusterServerInfo] = None,
clusters: Option[Seq[ClusterServer]] = None,
user_proxy: Option[String] = None
use_proxy: Option[String] = None
)

case class ClusterServerInfo(
Expand Down Expand Up @@ -59,18 +59,18 @@ case class FedMembershipData(
case class FedPromptRequest(
name: String,
master_rest_info: Option[ClusterServerInfo],
user_proxy: Option[String]
use_proxy: Option[String]
)

case class FedConfigData(poll_interval: Int, name: Option[String], user_proxy: Option[String],rest_info: Option[ClusterServerInfo])
case class FedConfigData(poll_interval: Int, name: Option[String], use_proxy: Option[String],rest_info: Option[ClusterServerInfo])

case class FedJoinRequest(
name: String,
server: String,
port: Int,
join_token: String,
joint_rest_info: Option[ClusterServerInfo],
user_proxy: Option[String]
use_proxy: Option[String]
)

case class FedLeaveRequest(force: Boolean = true)
Expand Down
18 changes: 9 additions & 9 deletions admin/webapp/root/app/views/multiCluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h2 class="text-dark">{{'multiCluster.promotion.title' | translate}}</h2>
id="https"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="https"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -130,7 +130,7 @@ <h2 class="text-dark">{{'multiCluster.promotion.title' | translate}}</h2>
id="http"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="http"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -143,7 +143,7 @@ <h2 class="text-dark">{{'multiCluster.promotion.title' | translate}}</h2>
id="none"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value=""
/>
<span class="fa fa-check text-discover"/>
Expand Down Expand Up @@ -289,7 +289,7 @@ <h2 class="text-dark">{{'multiCluster.joining.title' | translate}}</h2>
id="https"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="https"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -302,7 +302,7 @@ <h2 class="text-dark">{{'multiCluster.joining.title' | translate}}</h2>
id="http"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="http"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -315,7 +315,7 @@ <h2 class="text-dark">{{'multiCluster.joining.title' | translate}}</h2>
id="none"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value=""
/>
<span class="fa fa-check text-discover"/>
Expand Down Expand Up @@ -448,7 +448,7 @@ <h2 class="text-dark">{{'multiCluster.edit.title' | translate}}</h2>
id="https"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="https"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -461,7 +461,7 @@ <h2 class="text-dark">{{'multiCluster.edit.title' | translate}}</h2>
id="http"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value="http"
/>
<span class="fa fa-check text-discover"/>
Expand All @@ -474,7 +474,7 @@ <h2 class="text-dark">{{'multiCluster.edit.title' | translate}}</h2>
id="none"
type="radio"
name="proxy"
ng-model="userProxy"
ng-model="useProxy"
value=""
/>
<span class="fa fa-check text-discover"/>
Expand Down
35 changes: 18 additions & 17 deletions admin/webapp/root/app_src/js/nv/setting/multiClusterController.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
$scope.isFederal = !$scope.isOrdinary;
$scope.clusters = fedData.clusters || [];
$scope.local = fedData.local_rest_info;
$scope.userProxy = fedData.user_proxy || "";
$scope.useProxy = fedData.use_proxy || "";
if (!($scope.gridOptions && $scope.gridOptions.api)) {
setGrid($scope.isMaster, $scope.isMember);
}
Expand Down Expand Up @@ -692,13 +692,14 @@
};

$scope.refreshGrid = function(seletedRow = null) {
taskCursor = -1;
multiClusterService
.getClusters()
.then(function(payload) {
$scope.clusters = payload.data.clusters || [];
$scope.isMaster = payload.data.fed_role === FED_ROLES.MASTER;
$scope.isMember = payload.data.fed_role === FED_ROLES.MEMBER;
$scope.userProxy = fedData.user_proxy || "";
$scope.useProxy = payload.data.use_proxy || "";
$rootScope.$broadcast("reloadClusters",$scope.clusters);
if ($scope.gridOptions && $scope.gridOptions.api) {
$scope.gridOptions.api.setRowData($scope.clusters);
Expand Down Expand Up @@ -902,7 +903,7 @@
controllerAs: "promoteCtl",
templateUrl: "dialog.promote.html",
locals: {
userProxy: $scope.userProxy
useProxy: $scope.useProxy
}
});
};
Expand All @@ -915,7 +916,7 @@
templateUrl: "dialog.join.html",
targetEvent: event,
locals: {
userProxy: $scope.userProxy
useProxy: $scope.useProxy
}
})
.finally(function() {
Expand All @@ -942,7 +943,7 @@
targetEvent: event,
locals: {
isEditable: isEditable,
userProxy: $scope.userProxy
useProxy: $scope.useProxy
}
})
.then(function() {
Expand Down Expand Up @@ -991,7 +992,7 @@
"$state",
"$rootScope",
"$http",
"userProxy"
"useProxy"
];

function PromoteDialogController(
Expand All @@ -1004,7 +1005,7 @@
$state,
$rootScope,
$http,
userProxy
useProxy
) {
$scope.hide = function() {
$mdDialog.hide();
Expand All @@ -1019,7 +1020,7 @@
port: FED_PORT.MASTER
};

$scope.userProxy = userProxy;
$scope.useProxy = useProxy;

$scope.getName = function() {
$http
Expand All @@ -1036,7 +1037,7 @@
$scope.promotionProcessing = true;

multiClusterService
.promote(cluster, $scope.userProxy)
.promote(cluster, $scope.useProxy)
.then(function() {
popupMsg("multiCluster.messages.promotion_ok");
setTimeout(function() {
Expand Down Expand Up @@ -1084,15 +1085,15 @@
"$mdDialog",
"$translate",
"multiClusterService",
"userProxy"
"useProxy"
];

function JoinDialogController(
$scope,
$mdDialog,
$translate,
multiClusterService,
userProxy
useProxy
) {
$scope.hide = function() {
$mdDialog.hide();
Expand All @@ -1112,7 +1113,7 @@
master_port: ""
};

$scope.userProxy = userProxy;
$scope.useProxy = useProxy;

$scope.getName = function() {
$http
Expand Down Expand Up @@ -1150,7 +1151,7 @@
$scope.join = function(cluster) {
$scope.joiningProcessing = true;
multiClusterService
.join(cluster)
.join(cluster, $scope.useProxy)
.then(function() {
popupMsg("multiCluster.messages.joining_ok");
$mdDialog.cancel();
Expand Down Expand Up @@ -1216,7 +1217,7 @@
"$translate",
"multiClusterService",
"isEditable",
"userProxy"
"useProxy"
];

function EditClusterDialogController(
Expand All @@ -1225,7 +1226,7 @@
$translate,
multiClusterService,
isEditable,
userProxy
useProxy
) {
$scope.hide = function() {
$mdDialog.hide();
Expand All @@ -1237,11 +1238,11 @@
$scope.isEditable = isEditable;

$scope.cluster = multiClusterService.cluster4Edit;
$scope.userProxy = userProxy;
$scope.useProxy = useProxy;

$scope.update = function(data, isEditable) {
multiClusterService
.updateCluster(data, isEditable, $scope.userProxy)
.updateCluster(data, isEditable, $scope.useProxy)
.then(function() {
popupMsg("multiCluster.messages.update_ok");
$mdDialog.hide();
Expand Down
14 changes: 7 additions & 7 deletions admin/webapp/root/app_src/js/nv/setting/multiClusterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
return $http.get(FED_MEMBER_URL);
}

function updateCluster(data, isEditable, userProxy) {
function updateCluster(data, isEditable, useProxy) {
let payload = isEditable ? {
poll_interval: 2,
name: data.name,
rest_info: {
server: data.api_server,
port: parseInt(data.api_port)
},
user_proxy: userProxy
use_proxy: useProxy
} : {
poll_interval: 2,
user_proxy: userProxy
use_proxy: useProxy
};
return $http.patch(FED_CFG_URL, payload);
}
Expand All @@ -35,14 +35,14 @@
return $http.get(DASHBOARD_SUMMARY_URL)
}

function promote(data, userProxy) {
function promote(data, useProxy) {
let payload = {
name: data.name,
master_rest_info: {
server: data.server,
port: parseInt(data.port)
},
user_proxy: userProxy
use_proxy: useProxy
};
return $http.post(FED_PROMOTE_URL, payload);
}
Expand All @@ -51,7 +51,7 @@
return $http.post(FED_DEMOTE_URL, "");
}

function join(data) {
function join(data, useProxy) {
let payload = {
name: data.name,
server: data.master_server,
Expand All @@ -61,7 +61,7 @@
server: data.server,
port: parseInt(data.port)
},
user_proxy: userProxy
use_proxy: useProxy
};
return $http.post(FED_JOIN_URL, payload);
}
Expand Down

0 comments on commit a0d29b5

Please sign in to comment.