Skip to content

Commit 04cfb46

Browse files
committed
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
2 parents 8d498f4 + c2a477e commit 04cfb46

9 files changed

Lines changed: 407 additions & 105 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Usage
3+
# save_password -v <user VM IP> -p <password>
4+
#
5+
6+
while getopts 'v:p:' OPTION
7+
do
8+
case $OPTION in
9+
v) VM_IP="$OPTARG"
10+
;;
11+
p)
12+
ENCODEDPASSWORD="$OPTARG"
13+
PASSWORD=$(echo $ENCODEDPASSWORD | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]')
14+
;;
15+
?) echo "Incorrect usage"
16+
exit 1
17+
;;
18+
esac
19+
done
20+
21+
if [ ! -f /root/passwords ];
22+
then
23+
touch /root/passwords;
24+
fi
25+
26+
sed -i /$VM_IP/d /root/passwords
27+
echo "$VM_IP=$PASSWORD" >> /root/passwords
28+
29+
if [ $? -ne 0 ]
30+
then
31+
exit 1
32+
fi
33+
34+
exit 0
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/python
2+
3+
import sys
4+
import base64
5+
6+
def vm_data(args):
7+
8+
router_ip = args.pop('routerIP')
9+
vm_ip = args.pop('vmIP')
10+
11+
util.SMlog(" adding vmdata for VM with IP: " + vm_ip + " to router with IP: " + router_ip)
12+
13+
for pair in args:
14+
pairList = pair.split(',')
15+
vmDataFolder = pairList[0]
16+
vmDataFile = pairList[1]
17+
vmDataValue = args[pair]
18+
cmd = ["/bin/bash", "/root/userdata.sh", "-v", vm_ip, "-F", vmDataFolder, "-f", vmDataFile]
19+
20+
fd = None
21+
tmp_path = None
22+
if (vmDataValue != "none"):
23+
try:
24+
fd,tmp_path = tempfile.mkstemp()
25+
tmpfile = open(tmp_path, 'w')
26+
27+
if (vmDataFolder == "userdata"):
28+
vmDataValue = base64.urlsafe_b64decode(vmDataValue)
29+
30+
tmpfile.write(vmDataValue)
31+
tmpfile.close()
32+
cmd.append("-d")
33+
cmd.append(tmp_path)
34+
except:
35+
util.SMlog(" vmdata failed to write tempfile " )
36+
os.close(fd)
37+
os.remove(tmp_path)
38+
return ''
39+
40+
try:
41+
txt = util.pread2(cmd)
42+
txt = 'success'
43+
except:
44+
util.SMlog(" vmdata failed with folder: " + vmDataFolder + " and file: " + vmDataFile)
45+
txt = ''
46+
47+
if (fd != None):
48+
os.close(fd)
49+
os.remove(tmp_path)
50+
51+
return txt
52+
53+
def parseFileData(fileName):
54+
args = []
55+
fd = open(fileName)
56+
57+
line = fd.readline()
58+
while (line != ""):
59+
args.append(line)
60+
line = fd.readline()
61+
62+
return args
63+
64+
vmdata(parseFileData("/tmp/" + sys.argv[1]))
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
3+
usage() {
4+
printf "Usage: %s: -v <vm ip> -F <vm data folder> -f <vm data file> -d <data to put in file> \n" $(basename $0) >&2
5+
exit 2
6+
}
7+
8+
set -x
9+
10+
PORT=3922
11+
12+
create_htaccess() {
13+
local vmIp=$1
14+
local folder=$2
15+
local file=$3
16+
17+
local result=0
18+
19+
entry="RewriteRule ^$file$ ../$folder/%{REMOTE_ADDR}/$file [L,NC,QSA]"
20+
htaccessFolder="/var/www/html/latest"
21+
htaccessFile=$htaccessFolder/.htaccess
22+
mkdir -p $htaccessFolder
23+
touch $htaccessFile
24+
grep -F \"$entry\" $htaccessFile
25+
if [ \$? -gt 0 ]; then
26+
echo -e \"$entry\" >> $htaccessFile;
27+
fi
28+
result=$?
29+
30+
if [ $result -eq 0 ]; then
31+
entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
32+
htaccessFolder="/var/www/html/$folder/$vmIp"
33+
htaccessFile=$htaccessFolder/.htaccess
34+
35+
mkdir -p $htaccessFolder
36+
echo -e \"$entry\" > $htaccessFile
37+
result=$?
38+
fi
39+
40+
return $result
41+
}
42+
43+
copy_vm_data_file() {
44+
local vmIp=$1
45+
local folder=$2
46+
local file=$3
47+
local dataFile=$4
48+
49+
chmod +r $dataFile
50+
cp $dataFile /var/www/html/$folder/$vmIp/$file >/dev/null
51+
return $?
52+
}
53+
54+
delete_vm_data_file() {
55+
local domrIp=$1
56+
local vmIp=$2
57+
local folder=$3
58+
local file=$4
59+
60+
vmDataFilePath="/var/www/html/$folder/$vmIp/$file"
61+
if [ -f $vmDataFilePath ]; then
62+
rm -rf $vmDataFilePath
63+
fi
64+
return $?
65+
}
66+
67+
vmIp=
68+
folder=
69+
file=
70+
dataFile=
71+
72+
while getopts 'v:F:f:d:' OPTION
73+
do
74+
case $OPTION in
75+
v) vmIp="$OPTARG"
76+
;;
77+
F) folder="$OPTARG"
78+
;;
79+
f) file="$OPTARG"
80+
;;
81+
d) dataFile="$OPTARG"
82+
;;
83+
?) usage
84+
exit 1
85+
;;
86+
esac
87+
done
88+
89+
[ "$vmIp" == "" ] || [ "$folder" == "" ] || [ "$file" == "" ] && usage
90+
[ "$folder" != "userdata" ] && [ "$folder" != "metadata" ] && usage
91+
92+
if [ "$dataFile" != "" ]
93+
then
94+
create_htaccess $vmIp $folder $file
95+
96+
if [ $? -gt 0 ]
97+
then
98+
exit 1
99+
fi
100+
101+
copy_vm_data_file $vmIp $folder $file $dataFile
102+
else
103+
delete_vm_data_file $vmIp $folder $file
104+
fi
105+
106+
exit $?

‎server/src/com/cloud/network/router/DomainRouterManagerImpl.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import com.cloud.host.Host;
101101
import com.cloud.host.HostVO;
102102
import com.cloud.host.dao.HostDao;
103+
import com.cloud.hypervisor.Hypervisor;
103104
import com.cloud.hypervisor.Hypervisor.HypervisorType;
104105
import com.cloud.network.FirewallRuleVO;
105106
import com.cloud.network.IPAddressVO;
@@ -900,7 +901,7 @@ public DomainRouterVO start(long routerId, long startEventId) throws StorageUnav
900901
String privateIpAddress = null;
901902
String privateNetMask = null;
902903

903-
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase("VmWare")) {
904+
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase(Hypervisor.HypervisorType.VmWare.toString())) {
904905
privateIpAddress = _dcDao.allocateLinkLocalPrivateIpAddress(router.getDataCenterId(), routingHost.getPodId(), router.getId());
905906
privateNetMask = NetUtils.getLinkLocalNetMask();
906907
} else {
@@ -994,7 +995,7 @@ public DomainRouterVO start(long routerId, long startEventId) throws StorageUnav
994995

995996
router.setPrivateIpAddress(null);
996997

997-
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase("VmWare"))
998+
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase(Hypervisor.HypervisorType.VmWare.toString()))
998999
_dcDao.releaseLinkLocalPrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
9991000
else
10001001
_dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
@@ -1407,7 +1408,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
14071408
String value = configs.get("start.retry");
14081409
_retry = NumbersUtil.parseInt(value, 2);
14091410

1410-
_defaultHypervisorType = (String)params.get(Config.HypervisorDefaultType.key());
1411+
_defaultHypervisorType = _configDao.getValue(Config.HypervisorDefaultType.key());
14111412

14121413
value = configs.get("router.stats.interval");
14131414
_routerStatsInterval = NumbersUtil.parseInt(value, 300);
@@ -1515,7 +1516,7 @@ public void completeStopCommand(final DomainRouterVO router, final Event ev) {
15151516
String privateIpAddress = router.getPrivateIpAddress();
15161517

15171518
if (privateIpAddress != null) {
1518-
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase("VmWare"))
1519+
if(_defaultHypervisorType == null || !_defaultHypervisorType.equalsIgnoreCase(Hypervisor.HypervisorType.VmWare.toString()))
15191520
_dcDao.releaseLinkLocalPrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
15201521
else
15211522
_dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());

‎ui/new/css/main.css‎

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,6 @@ a:hover.search_button {
17951795
margin:0;
17961796
padding:0;
17971797
background:url(../images/actionpanel_border.gif) no-repeat top left;
1798-
17991798
}
18001799

18011800
.actionpanel_button{
@@ -1857,7 +1856,83 @@ a:hover.search_button {
18571856
margin:0;
18581857
padding:0;
18591858
z-index:1005;
1859+
}
1860+
1861+
.help_dropdown_box {
1862+
width:209px;
1863+
height:200px;
1864+
float:left;
1865+
position:absolute;
1866+
background:#FFF repeat top left;
1867+
border:1px solid #999;
1868+
top:20px;
1869+
right:7px;
1870+
margin:0;
1871+
padding:0;
1872+
z-index:1005;
1873+
}
1874+
1875+
.help_dropdown_box_titlebox {
1876+
width:190px;
1877+
height:auto;
1878+
float:left;
1879+
margin:8px 0 0 10px;
1880+
padding:0;
1881+
}
1882+
1883+
.help_dropdown_box_titlebox h2 {
1884+
width:auto;
1885+
height:auto;
1886+
float:left;
1887+
color:#999;
1888+
text-align:left;
1889+
font-size:14px;
1890+
margin:0;
1891+
padding:0;
1892+
}
1893+
1894+
.help_dropdown_box_titlebox a {
1895+
float:right;
1896+
color:#2c8bbc;
1897+
font-size:10px;
1898+
font-weight:normal;
1899+
text-align:left;
1900+
margin:0;
1901+
padding:0;
1902+
text-decoration:none;
1903+
}
1904+
1905+
.help_dropdown_box_titlebox a:link, .help_dropdown_box_titlebox a:visited {
1906+
text-decoration:none;
1907+
1908+
}
1909+
1910+
.help_dropdown_box_titlebox a:hover {
1911+
text-decoration:underline;
1912+
}
18601913

1914+
.help_dropdown_box_textbox {
1915+
width:190px;
1916+
height:140px;
1917+
float:left;
1918+
margin:0 0 0 10px;
1919+
padding:0;
1920+
overflow-y:auto;
1921+
overflow-y:scroll;
1922+
overflow-x:hidden;
1923+
1924+
}
1925+
1926+
.help_dropdown_box_textbox p{
1927+
width:190px;
1928+
height:auto;
1929+
float:left;
1930+
color:#333;
1931+
font-size:11px;
1932+
font-weight:normal;
1933+
text-align:left;
1934+
margin:12px 0 0 0;
1935+
padding:0;
18611936
}
18621937

18631938
.actionsdropdown_boxlist {

‎ui/new/index.jsp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,24 @@ long milliseconds = new Date().getTime();
258258
</div>
259259
</div>
260260
<div class="actionpanel_button_wrapper" id="help_link" style="display: block; float: right;
261-
background: none;">
261+
background: none; position: relative;">
262262
<div class="actionpanel_button">
263263
<div class="actionpanel_button_icons">
264264
<img src="images/help_actionicon.png" alt="Help" /></div>
265265
<div class="actionpanel_button_links">
266266
<%=t.t("help")%></div>
267267
</div>
268+
269+
<div class="help_dropdown_box" style="display:none;">
270+
<div class="help_dropdown_box_titlebox">
271+
<h2> Instance Help</h2>
272+
<a href="#"> Close</a>
273+
</div>
274+
275+
<div class="help_dropdown_box_textbox">
276+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. </p><p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
277+
</div>
278+
</div>
268279
</div>
269280
</div>
270281
<!-- Action Panel ends here-->

0 commit comments

Comments
 (0)