Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions client/bindir/cloud-setup-management.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# to you 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
Expand All @@ -26,18 +26,21 @@ from optparse import OptionParser
if __name__ == '__main__':
initLoging("@MSLOGDIR@/setupManagement.log")
glbEnv = globalEnv()

parser = OptionParser()
parser.add_option("--https", action="store_true", dest="https", help="Enable HTTPs connection of management server")
parser.add_option("--tomcat7", action="store_true", dest="tomcat7", help="Use Tomcat7 configuration files in Management Server")
parser.add_option("--no-start", action="store_true", dest="nostart", help="Do not start management server after successful configuration")
(options, args) = parser.parse_args()
if options.https:
glbEnv.svrMode = "HttpsServer"
if options.tomcat7:
glbEnv.svrConf = "Tomcat7"
if options.nostart:
glbEnv.noStart = True

glbEnv.mode = "Server"

print "Starting to configure CloudStack Management Server:"
try:
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
Expand Down
6 changes: 4 additions & 2 deletions python/lib/cloudutils/globalEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to you 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
Expand All @@ -20,6 +20,8 @@ def __init__(self):
self.mode = None
#server mode: normal/mycloud
self.svrMode = None
#noStart: do not start mgmt server after configuration?
self.noStart = False
#myCloud/Agent/Console
self.agentMode = None
#Tomcat6/Tomcat7
Expand Down
35 changes: 20 additions & 15 deletions python/lib/cloudutils/serviceConfigServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to you 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
Expand All @@ -25,7 +25,7 @@ class cloudManagementConfig(serviceCfgBase):
def __init__(self, syscfg):
super(cloudManagementConfig, self).__init__(syscfg)
self.serviceName = "CloudStack Management Server"

def config(self):
def checkHostName():
ret = bash("hostname --fqdn")
Expand All @@ -46,7 +46,7 @@ def checkHostName():
dbPass = None
dbName = cfo.getEntry("db.cloud.name")
db = Database(dbUser, dbPass, dbHost, dbPort, dbName)

try:
db.testConnection()
except CloudRuntimeException, e:
Expand All @@ -56,27 +56,27 @@ def checkHostName():

try:
statement = """ UPDATE configuration SET value='%s' WHERE name='%s'"""

db.execute(statement%('true','use.local.storage'))
db.execute(statement%('20','max.template.iso.size'))

statement = """ UPDATE vm_template SET url='%s',checksum='%s' WHERE id='%s' """
db.execute(statement%('https://rightscale-cloudstack.s3.amazonaws.com/kvm/RightImage_CentOS_5.4_x64_v5.6.28.qcow2.bz2', '90fcd2fa4d3177e31ff296cecb9933b7', '4'))

statement="""UPDATE disk_offering set use_local_storage=1"""
db.execute(statement)
except:
raise e

#add DNAT 443 to 8250
if not bash("iptables-save |grep PREROUTING | grep 8250").isSuccess():
bash("iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-port 8250 ")

#generate keystore
keyPath = "/var/cloudstack/management/web.keystore"
if not os.path.exists(keyPath):
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)

if not cmd.isSuccess():
raise CloudInternalException(cmd.getErrMsg())
if not self.syscfg.env.svrConf == "Tomcat7":
Expand Down Expand Up @@ -127,17 +127,22 @@ def checkHostName():
cfo.add_lines("cloud soft nproc -1\n")
cfo.add_lines("cloud hard nproc -1\n")
cfo.save()

try:
if self.syscfg.env.svrConf == "Tomcat7":
self.syscfg.svo.disableService("tomcat")
else:
self.syscfg.svo.disableService("tomcat6")
except:
pass

self.syscfg.svo.stopService("cloudstack-management")
if self.syscfg.svo.enableService("cloudstack-management"):
return True

if self.syscfg.env.noStart == False:
if self.syscfg.svo.enableService("cloudstack-management"):
return True
else:
raise CloudRuntimeException("Failed to configure %s, please see the /var/log/cloudstack/management/setupManagement.log for detail"%self.serviceName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be a nag @ProjectMoon but can you change the path in the log message as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it, but it should be known that this was actually the original message. :) Does need to be fixed though.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, one possible issue with this: will the serviceConfigServer.py script be processed by the *.in ant tasks, or will a new antrun task need to be added to process the files found at python/lib/cloudutils?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you are right, and am I glad I forgot to add a 👎 ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We crossed each other here, what do you mean?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original message had the log message in the wrong place (I think it was pointing at /var/log/cloudstack-management/setupManagement.log). I changed it to the right path on Linux systems (for Ubuntu and friends). But probably the log path can be fixed as part of this commit or in another one. But in order for the replace.properties stuff to work, there is an antrun task I believe. Not sure it would currently process files in the directory that serviceConfigServer.py is in.

else:
raise CloudRuntimeException("Failed to configure %s, please see the /var/log/cloudstack/management/setupManagement.log for detail"%self.serviceName)
print "Configured successfully, but not starting management server."
return True