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
5 changes: 3 additions & 2 deletions client/bindir/cloud-setup-management.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ if __name__ == '__main__':
try:
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
except UnknownSystemException:
print(("Error: CloudStack failed to detect your "
"operating system. Exiting."), file=sys.stderr)
print("Error: CloudStack failed to detect your "
"operating system. Exiting.", file=sys.stderr)
sys.exit(1)
try:
syscfg.registerService(cloudManagementConfig)
syscfg.config()
print("CloudStack Management Server setup is Done!")
print("Please ensure the following ports are open for the management server to function properly : 8080 8250 8443 9090")
except (CloudRuntimeException, CloudInternalException) as e:
print(e)
print("Try to restore your system:")
Expand Down
33 changes: 2 additions & 31 deletions python/lib/cloudutils/serviceConfig.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 Down Expand Up @@ -772,32 +772,3 @@ def config(self):

def restore(self):
return True

class firewallConfigServer(firewallConfigBase):
def __init__(self, syscfg):
super(firewallConfigServer, self).__init__(syscfg)
#9090 is used for cluster management server
if self.syscfg.env.svrMode == "myCloud":
self.ports = "443 8080 8250 8443 9090".split()
else:
self.ports = "8080 8250 9090".split()

class ubuntuFirewallConfigServer(firewallConfigServer):
def allowPort(self, port):
status = False
try:
status = bash("iptables-save|grep INPUT|grep -w %s"%port).isSuccess()
except:
pass

if not status:
bash("ufw allow %s/tcp"%port)

def config(self):
try:
for port in self.ports:
self.allowPort(port)

return True
except:
raise
38 changes: 19 additions & 19 deletions python/lib/cloudutils/syscfg.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 @@ -29,7 +29,7 @@ def getSysConfigFactory(glbEnv):
return sysConfigDbFactory.getDb(glbEnv)
else:
raise CloudInternalException("Need to specify which mode are u running: Agent/Server/Db")

class sysConfigAgentFactory:
@staticmethod
def getAgent(glbEnv):
Expand Down Expand Up @@ -61,7 +61,7 @@ def getServer(glbEnv):
else:
print("Can't find the distribution version")
return sysConfig()

class sysConfigDbFactory:
@staticmethod
def getDb(glbEnv):
Expand All @@ -71,39 +71,39 @@ class sysConfig(object):
def __init__(self, env):
self.env = env
self.services = []

def registerService(self, service):
self.services.append(service(self))

def config(self):
if not self.check():
return False

for service in self.services:
if not service.configration():
raise CloudInternalException("Configuration failed for service %s" % service.serviceName)

def restore(self):
for service in self.services:
service.backup()

def check(self):
return True

class sysConfigAgent(sysConfig):
def __init__(self, env):
super(sysConfigAgent, self).__init__(env)

def check(self):
if self.env.debug:
return True

if self.env.agentMode == "myCloud":
if self.env.distribution.getVersion() != "Ubuntu":
raise CloudInternalException("Need to run myCloud agent on an Ubuntu machine\n")
elif self.env.distribution.getArch() != "x86_64":
raise CloudInternalException("Need to run myCloud agent on an 64bit machine\n")
#check free disk space on the local disk
#check free disk space on the local disk
if os.path.exists("/var/lib/libvirt/images"):
size = -1
try:
Expand All @@ -127,18 +127,18 @@ def check(self):

if os.geteuid() != 0:
raise CloudInternalException("Need to execute with root permission\n")

hostname = bash("hostname -f")
if not hostname.isSuccess():
raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n")

kvmEnabled = self.svo.isKVMEnabled()
if not kvmEnabled:
raise CloudInternalException("Checking KVM...[Failed]\nPlease enable KVM on this machine\n")

return True


class sysConfigAgentRedhatBase(sysConfigAgent):
def __init__(self, env):
self.svo = serviceOpsRedhat()
Expand Down Expand Up @@ -188,7 +188,7 @@ def __init__(self, glbEnv):
libvirtConfigRedhat(self),
firewallConfigAgent(self),
cloudAgentConfig(self)]

#it covers RHEL7
class sysConfigRedhat7(sysConfigAgentRedhat7Base):
def __init__(self, glbEnv):
Expand Down Expand Up @@ -219,15 +219,15 @@ def check(self):
if not hostname.isSuccess():
raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n")
return True

class sysConfigServerRedhat(sysConfigServer):
def __init__(self, glbEnv):
super(sysConfigServerRedhat, self).__init__(glbEnv)
self.svo = serviceOpsRedhat()
self.services = [firewallConfigServer(self)]
Copy link
Member

Choose a reason for hiding this comment

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

@davidjumani I think we should revert the previous behaviour and simply print the statement. Otherwise, env will not deploy. Previously the cloudstack-setup-management would open firewall, now that you've changed it - either (a) document this and fix trillian to open the ports both CentOS/Ubuntu envs, or (b) just print the line for information sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rhtyd I was able to deploy a kvm env for basic testing, and everything seems to work. Will look into why it failed this time

Copy link
Member

Choose a reason for hiding this comment

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

okay @davidjumani when you confirm we'll be able to merge this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's good to go. Env came up and smoke tests ran successfully!

self.services = []

class sysConfigServerUbuntu(sysConfigServer):
def __init__(self, glbEnv):
super(sysConfigServerUbuntu, self).__init__(glbEnv)
self.svo = serviceOpsUbuntu()
self.services = [ubuntuFirewallConfigServer(self)]
self.services = []