Skip to content

Commit e9de865

Browse files
committed
Merge pull request apache#1162 from greenqloud/pr-no-start
Add support for not (re)starting server after cloud-setup-management.This adds an option to the cloud-setup-management script to not start the management server after a successful configuration of it. The primary motivation for this is to avoid circular dependency issues on systems that use systemd. When calling cloud-setup-management from a unit with a Before= directive on a service depending on cloudstack-management, the process will deadlock because /usr/bin/service will delegate to systemd, which is waiting for the Before service to start. Executing the cloud-setup-management script with this new `--no-start` option will simply leave the management server stopped after a successful configuration. systemd can then be bypassed with `export _SYSTEMCTL_SKIP_REDIRECT=1` and using the init.d script. * pr/1162: Add support for not (re)starting server after cloud-setup-management. Signed-off-by: Remi Bergsma <github@remi.nl>
2 parents 9ce1334 + e0e65f5 commit e9de865

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

client/bindir/cloud-setup-management.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# to you under the Apache License, Version 2.0 (the
77
# "License"); you may not use this file except in compliance
88
# with the License. You may obtain a copy of the License at
9-
#
9+
#
1010
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
11+
#
1212
# Unless required by applicable law or agreed to in writing,
1313
# software distributed under the License is distributed on an
1414
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -26,18 +26,21 @@ from optparse import OptionParser
2626
if __name__ == '__main__':
2727
initLoging("@MSLOGDIR@/setupManagement.log")
2828
glbEnv = globalEnv()
29-
29+
3030
parser = OptionParser()
3131
parser.add_option("--https", action="store_true", dest="https", help="Enable HTTPs connection of management server")
3232
parser.add_option("--tomcat7", action="store_true", dest="tomcat7", help="Use Tomcat7 configuration files in Management Server")
33+
parser.add_option("--no-start", action="store_true", dest="nostart", help="Do not start management server after successful configuration")
3334
(options, args) = parser.parse_args()
3435
if options.https:
3536
glbEnv.svrMode = "HttpsServer"
3637
if options.tomcat7:
3738
glbEnv.svrConf = "Tomcat7"
39+
if options.nostart:
40+
glbEnv.noStart = True
3841

3942
glbEnv.mode = "Server"
40-
43+
4144
print "Starting to configure CloudStack Management Server:"
4245
try:
4346
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)

python/lib/cloudutils/globalEnv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,6 +20,8 @@ def __init__(self):
2020
self.mode = None
2121
#server mode: normal/mycloud
2222
self.svrMode = None
23+
#noStart: do not start mgmt server after configuration?
24+
self.noStart = False
2325
#myCloud/Agent/Console
2426
self.agentMode = None
2527
#Tomcat6/Tomcat7

python/lib/cloudutils/serviceConfigServer.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,7 +25,7 @@ class cloudManagementConfig(serviceCfgBase):
2525
def __init__(self, syscfg):
2626
super(cloudManagementConfig, self).__init__(syscfg)
2727
self.serviceName = "CloudStack Management Server"
28-
28+
2929
def config(self):
3030
def checkHostName():
3131
ret = bash("hostname --fqdn")
@@ -46,7 +46,7 @@ def checkHostName():
4646
dbPass = None
4747
dbName = cfo.getEntry("db.cloud.name")
4848
db = Database(dbUser, dbPass, dbHost, dbPort, dbName)
49-
49+
5050
try:
5151
db.testConnection()
5252
except CloudRuntimeException, e:
@@ -56,27 +56,27 @@ def checkHostName():
5656

5757
try:
5858
statement = """ UPDATE configuration SET value='%s' WHERE name='%s'"""
59-
59+
6060
db.execute(statement%('true','use.local.storage'))
6161
db.execute(statement%('20','max.template.iso.size'))
62-
62+
6363
statement = """ UPDATE vm_template SET url='%s',checksum='%s' WHERE id='%s' """
6464
db.execute(statement%('https://rightscale-cloudstack.s3.amazonaws.com/kvm/RightImage_CentOS_5.4_x64_v5.6.28.qcow2.bz2', '90fcd2fa4d3177e31ff296cecb9933b7', '4'))
65-
65+
6666
statement="""UPDATE disk_offering set use_local_storage=1"""
6767
db.execute(statement)
6868
except:
6969
raise e
70-
70+
7171
#add DNAT 443 to 8250
7272
if not bash("iptables-save |grep PREROUTING | grep 8250").isSuccess():
7373
bash("iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-port 8250 ")
74-
74+
7575
#generate keystore
7676
keyPath = "/var/cloudstack/management/web.keystore"
7777
if not os.path.exists(keyPath):
7878
cmd = bash("keytool -genkey -keystore %s -storepass \"cloud.com\" -keypass \"cloud.com\" -validity 3650 -dname cn=\"Cloudstack User\",ou=\"mycloud.cloud.com\",o=\"mycloud.cloud.com\",c=\"Unknown\""%keyPath)
79-
79+
8080
if not cmd.isSuccess():
8181
raise CloudInternalException(cmd.getErrMsg())
8282
if not self.syscfg.env.svrConf == "Tomcat7":
@@ -129,17 +129,22 @@ def checkHostName():
129129
cfo.add_lines("cloud soft nproc -1\n")
130130
cfo.add_lines("cloud hard nproc -1\n")
131131
cfo.save()
132-
132+
133133
try:
134134
if self.syscfg.env.svrConf == "Tomcat7":
135135
self.syscfg.svo.disableService("tomcat")
136136
else:
137137
self.syscfg.svo.disableService("tomcat6")
138138
except:
139139
pass
140-
140+
141141
self.syscfg.svo.stopService("cloudstack-management")
142-
if self.syscfg.svo.enableService("cloudstack-management"):
143-
return True
142+
143+
if self.syscfg.env.noStart == False:
144+
if self.syscfg.svo.enableService("cloudstack-management"):
145+
return True
146+
else:
147+
raise CloudRuntimeException("Failed to configure %s, please see the /var/log/cloudstack/management/setupManagement.log for detail"%self.serviceName)
144148
else:
145-
raise CloudRuntimeException("Failed to configure %s, please see the /var/log/cloudstack/management/setupManagement.log for detail"%self.serviceName)
149+
print "Configured successfully, but not starting management server."
150+
return True

0 commit comments

Comments
 (0)