Skip to content

Commit

Permalink
feature: make baremetal options managed by service config
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Apr 26, 2020
1 parent c7d5c76 commit ee9289c
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/apis/baremetal/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package baremetal

const (
SERVICE_TYPE = "baremetal"
SERVICE_VERSION = ""
)
15 changes: 15 additions & 0 deletions pkg/apis/baremetal/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package baremetal // import "yunion.io/x/onecloud/pkg/apis/baremetal"
41 changes: 41 additions & 0 deletions pkg/apis/identity/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ var (

ServiceBlacklistOptionMap = map[string][]string{
"default": []string{
// ############################
// common blacklist options
// ############################
"help",
"version",
"config",
Expand All @@ -120,7 +123,9 @@ var (
"session_endpoint_type",
"admin_password",
"admin_project",
"admin_project_domain",
"admin_user",
"admin_domain",
"auth_url",
"enable_ssl",
"ssl_certfile",
Expand All @@ -130,6 +135,9 @@ var (
"is_slave_node",
"config_sync_period_seconds",

// ############################
// db blacklist options
// ############################
"sql_connection",
"auto_sync_table",
"exit_after_db_init",
Expand All @@ -147,9 +155,42 @@ var (
"etcd_cert",
"etcd_key",

// ############################
// keystone blacklist options
// ############################
"bootstrap_admin_user_password",
"reset_admin_user_password",
"fernet_key_repository",

// ############################
// baremetal blacklist options
// ############################
"listen_interface",
"access_address",
"listen_address",
"tftp_root",
// "AutoRegisterBaremetal",
"baremetals_path",
// "LinuxDefaultRootUser",
"ipmi_lan_port_shared",
"zone",
"dhcp_lease_time",
"dhcp_renewal_time",
"enable_general_guest_dhcp",
"force_dhcp_probe_ipmi",
"tftp_block_size_in_bytes",
"tftp_max_timeout_retries",
"lengthy_worker_count",
"short_worker_count",
// "default_ipmi_password",
// "default_strong_ipmi_password",
// "windows_default_admin_user",
"cache_path",
"enable_pxe_boot",
"boot_iso_path",
// "status_probe_interval_seconds",
// "log_fetch_interval_seconds",
// "send_metrics_interval_seconds",
},
}
)
13 changes: 13 additions & 0 deletions pkg/baremetal/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ type BaremetalOptions struct {
var (
Options BaremetalOptions
)

func OnOptionsChange(oldO, newO interface{}) bool {
oldOpts := oldO.(*BaremetalOptions)
newOpts := newO.(*BaremetalOptions)

changed := false

if common_options.OnCommonOptionsChange(&oldOpts.CommonOptions, &newOpts.CommonOptions) {
changed = true
}

return changed
}
3 changes: 3 additions & 0 deletions pkg/baremetal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"yunion.io/x/log"

api "yunion.io/x/onecloud/pkg/apis/baremetal"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/baremetal"
"yunion.io/x/onecloud/pkg/baremetal/handler"
Expand Down Expand Up @@ -66,6 +67,8 @@ func (s *BaremetalService) StartService() {
app := app_common.InitApp(&o.Options.BaseOptions, false)
handler.InitHandlers(app)

common_options.StartOptionManager(&o.Options, o.Options.ConfigSyncPeriodSeconds, api.SERVICE_TYPE, api.SERVICE_VERSION, o.OnOptionsChange)

s.startAgent(app)

cron := cronman.InitCronJobManager(false, o.Options.CronJobWorkerCount)
Expand Down

0 comments on commit ee9289c

Please sign in to comment.