Skip to content

Commit 68cf2ba

Browse files
author
Frank.Zhang
committed
BUG-ID: CS-19152
[upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, destroy baremetal instance fail BUG-ID: CS-19150 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to start baremetal instance BUG-ID: CS-19149 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, baremetal host remain in Disconnected state. But instance associated with baremetal host is running. BUG-ID: CS-19151 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to reboot baremetal instance BUG-ID: CS-19156 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to stop baremetal instance reviewed-by: edison (cherry picked from commit 3787579) Signed-off-by: Animesh Chaturvedi <animesh@apache.org> Conflicts: plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
1 parent 1b8df42 commit 68cf2ba

21 files changed

Lines changed: 925 additions & 192 deletions

File tree

‎plugins/hypervisors/baremetal/pom.xml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
<artifactId>cloud-plugin-hypervisor-baremetal</artifactId>
2828
<name>Apache CloudStack Plugin - Hypervisor Baremetal</name>
2929
<dependencies>
30-
<dependency>
31-
<groupId>commons-lang</groupId>
32-
<artifactId>commons-lang</artifactId>
33-
<version>2.6</version>
34-
</dependency>
30+
<dependency>
31+
<groupId>commons-lang</groupId>
32+
<artifactId>commons-lang</artifactId>
33+
<version>2.6</version>
34+
</dependency>
3535
</dependencies>
3636

3737
</project>

‎plugins/hypervisors/baremetal/resources/META-INF/cloudstack/baremetal-compute/spring-baremetal-compute-context.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
<property name="name" value="BaremetalGuru" />
3232
</bean>
3333

34-
34+
3535
</beans>

‎plugins/hypervisors/baremetal/resources/META-INF/cloudstack/baremetal-discoverer/spring-baremetal-discoverer-context.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
<bean id="BareMetalDiscoverer" class="com.cloud.baremetal.manager.BareMetalDiscoverer">
3131
<property name="name" value="Bare Metal Agent" />
3232
</bean>
33-
33+
3434
</beans>

‎plugins/hypervisors/baremetal/resources/META-INF/cloudstack/baremetal-network/spring-baremetal-network-context.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242

4343
<bean id="BaremetalDhcpManager"
4444
class="com.cloud.baremetal.networkservice.BaremetalDhcpManagerImpl" />
45-
45+
4646
</beans>

‎plugins/hypervisors/baremetal/resources/META-INF/cloudstack/baremetal-planner/spring-baremetal-planner-context.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
<bean id="BareMetalPlanner" class="com.cloud.baremetal.manager.BareMetalPlanner">
3131
<property name="name" value="BareMetalPlanner" />
3232
</bean>
33-
33+
3434
</beans>

‎plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838

3939
<bean id="baremetalDhcpDaoImpl" class="com.cloud.baremetal.database.BaremetalDhcpDaoImpl" />
4040
<bean id="baremetalPxeDaoImpl" class="com.cloud.baremetal.database.BaremetalPxeDaoImpl" />
41-
41+
4242
</beans>

‎plugins/hypervisors/baremetal/resources/security_group_agent/cs-sgagent‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
# to you under the Apache License, Version 2.0 (the
1919
# "License"); you may not use this file except in compliance
2020
# with the License. You may obtain a copy of the License at
21-
#
21+
#
2222
# http://www.apache.org/licenses/LICENSE-2.0
23-
#
23+
#
2424
# Unless required by applicable law or agreed to in writing,
2525
# software distributed under the License is distributed on an
2626
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -29,31 +29,31 @@
2929
# under the License.
3030

3131
check_status() {
32-
pidfile='/var/run/cssgagent.pid'
33-
if [ ! -f $pidfile ]; then
34-
echo "cloudstack baremetal security group agent is stopped"
35-
exit 1
36-
else
37-
pid=`cat $pidfile`
38-
ps -p $pid > /dev/null
39-
if [ $? -eq 0 ]; then
40-
echo "cloudstack baremetal security group agent is running, pid is $pid"
41-
exit 0
42-
else
43-
echo "cloudstack baremetal security group agent is stopped, but pidfile at $pidfile is not cleaned. It may be caused by the agent crashed at last time, manually cleaning it would be ok"
44-
exit 1
45-
fi
46-
fi
32+
pidfile='/var/run/cssgagent.pid'
33+
if [ ! -f $pidfile ]; then
34+
echo "cloudstack baremetal security group agent is stopped"
35+
exit 1
36+
else
37+
pid=`cat $pidfile`
38+
ps -p $pid > /dev/null
39+
if [ $? -eq 0 ]; then
40+
echo "cloudstack baremetal security group agent is running, pid is $pid"
41+
exit 0
42+
else
43+
echo "cloudstack baremetal security group agent is stopped, but pidfile at $pidfile is not cleaned. It may be caused by the agent crashed at last time, manually cleaning it would be ok"
44+
exit 1
45+
fi
46+
fi
4747
}
4848

4949
if [ $# -eq 0 ]; then
50-
echo "usage: $0
50+
echo "usage: $0
5151
[start|stop|restart|status]"
52-
exit 1
52+
exit 1
5353
fi
5454

5555
if [ "$@" = "status" ]; then
56-
check_status
56+
check_status
5757
else
5858
python -c "from security_group_agent import cs_sg_agent; cs_sg_agent.main()" $@
5959
fi

‎plugins/hypervisors/baremetal/resources/security_group_agent/security_group_agent/__init__.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
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
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
#
17+
#
1818
# Automatically generated by addcopyright.py at 01/29/2013

‎plugins/hypervisors/baremetal/resources/security_group_agent/security_group_agent/cs_sg_agent.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
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
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
#
17+
#
1818
# Automatically generated by addcopyright.py at 01/29/2013
1919
'''
2020
Created on Jan 2, 2013
@@ -234,4 +234,3 @@ def main():
234234
agentdaemon.restart()
235235

236236
sys.exit(0)
237-

‎plugins/hypervisors/baremetal/resources/security_group_agent/security_group_agent/sglib.py‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
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
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
#
18+
#
1919
# Automatically generated by addcopyright.py at 01/29/2013
2020

2121
import sys, os, time, atexit
@@ -31,7 +31,7 @@ def __init__(self):
3131
self.body = None
3232
self.method = None
3333
self.query_string = None
34-
34+
3535
@staticmethod
3636
def from_cherrypy_request(creq):
3737
req = Request()
@@ -40,10 +40,10 @@ def from_cherrypy_request(creq):
4040
req.method = copy.copy(creq.method)
4141
req.query_string = copy.copy(creq.query_string) if creq.query_string else None
4242
return req
43-
43+
4444
class ShellError(Exception):
4545
'''shell error'''
46-
46+
4747
class ShellCmd(object):
4848
'''
4949
classdocs
@@ -57,11 +57,11 @@ def __init__(self, cmd, workdir=None, pipe=True):
5757
self.process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/sh', cwd=workdir)
5858
else:
5959
self.process = subprocess.Popen(cmd, shell=True, executable='/bin/sh', cwd=workdir)
60-
60+
6161
self.stdout = None
6262
self.stderr = None
6363
self.return_code = None
64-
64+
6565
def __call__(self, is_exception=True):
6666
(self.stdout, self.stderr) = self.process.communicate()
6767
if is_exception and self.process.returncode != 0:
@@ -71,18 +71,18 @@ def __call__(self, is_exception=True):
7171
err.append('stdout: %s' % self.stdout)
7272
err.append('stderr: %s' % self.stderr)
7373
raise ShellError('\n'.join(err))
74-
74+
7575
self.return_code = self.process.returncode
7676
return self.stdout
7777

7878
class Daemon(object):
7979
"""
8080
A generic daemon class.
81-
81+
8282
Usage: subclass the Daemon class and override the run() method
8383
"""
8484
atexit_hooks = []
85-
85+
8686
def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
8787
self.stdin = stdin
8888
self.stdout = stdout
@@ -102,37 +102,37 @@ def _atexit():
102102
content = traceback.format_exc()
103103
err = 'Exception when calling atexit hook[%s]\n%s' % (hook.__name__, content)
104104
#logger.error(err)
105-
105+
106106
def daemonize(self):
107107
"""
108-
do the UNIX double-fork magic, see Stevens' "Advanced
108+
do the UNIX double-fork magic, see Stevens' "Advanced
109109
Programming in the UNIX Environment" for details (ISBN 0201563177)
110110
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
111111
"""
112-
try:
113-
pid = os.fork()
112+
try:
113+
pid = os.fork()
114114
if pid > 0:
115115
# exit first parent
116-
sys.exit(0)
117-
except OSError, e:
116+
sys.exit(0)
117+
except OSError, e:
118118
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
119119
sys.exit(1)
120-
120+
121121
# decouple from parent environment
122-
os.chdir("/")
123-
os.setsid()
124-
os.umask(0)
125-
122+
os.chdir("/")
123+
os.setsid()
124+
os.umask(0)
125+
126126
# do second fork
127-
try:
128-
pid = os.fork()
127+
try:
128+
pid = os.fork()
129129
if pid > 0:
130130
# exit from second parent
131-
sys.exit(0)
132-
except OSError, e:
131+
sys.exit(0)
132+
except OSError, e:
133133
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
134-
sys.exit(1)
135-
134+
sys.exit(1)
135+
136136
# redirect standard file descriptors
137137
sys.stdout.flush()
138138
sys.stderr.flush()
@@ -142,13 +142,13 @@ def daemonize(self):
142142
os.dup2(si.fileno(), sys.stdin.fileno())
143143
os.dup2(so.fileno(), sys.stdout.fileno())
144144
os.dup2(se.fileno(), sys.stderr.fileno())
145-
145+
146146
# write pidfile
147147
Daemon.register_atexit_hook(self.delpid)
148148
atexit.register(Daemon._atexit)
149149
pid = str(os.getpid())
150150
file(self.pidfile,'w').write("%s\n" % pid)
151-
151+
152152
def delpid(self):
153153
os.remove(self.pidfile)
154154

@@ -163,15 +163,15 @@ def start(self):
163163
pf.close()
164164
except IOError:
165165
pid = None
166-
166+
167167
if pid:
168168
pscmd = ShellCmd('ps -p %s > /dev/null' % pid)
169169
pscmd(is_exception=False)
170170
if pscmd.return_code == 0:
171171
message = "Daemon already running, pid is %s\n"
172172
sys.stderr.write(message % pid)
173173
sys.exit(0)
174-
174+
175175
# Start the daemon
176176
self.daemonize()
177177
try:
@@ -192,13 +192,13 @@ def stop(self):
192192
pf.close()
193193
except IOError:
194194
pid = None
195-
195+
196196
if not pid:
197197
message = "pidfile %s does not exist. Daemon not running?\n"
198198
sys.stderr.write(message % self.pidfile)
199199
return # not an error in a restart
200200

201-
# Try killing the daemon process
201+
# Try killing the daemon process
202202
try:
203203
while 1:
204204
os.kill(pid, SIGTERM)

0 commit comments

Comments
 (0)