user's can't set/unset site in Login Details without the proper authorization
[plstackapi.git] / opencloud.spec
1 Summary: OpenCloud core services
2 Name: opencloud
3 Version: 1.0.29
4 Release: 3
5 License: GPL+
6 Group: Development/Tools
7 Source0: %{_tmppath}/%{name}-%{version}.tar.gz
8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
9 requires: postgresql
10 requires: postgresql-server
11 requires: python-psycopg2
12 requires: graphviz
13 requires: graphviz-devel
14 requires: graphviz-python
15 requires: libxslt-devel
16 requires: python-pip
17 requires: tar
18 requires: gcc
19 requires: python-httplib2
20 requires: GeoIP
21 requires: wget
22
23 %description
24 %{summary}
25
26 %prep
27 %setup -q
28
29 %build
30 # Empty section.
31
32 %pre
33 pip-python install django==1.7
34 pip-python install djangorestframework==2.4.4
35 pip-python install markdown  # Markdown support for the browseable API.
36 pip-python install pyyaml    # YAML content-type support.
37 pip-python install django-filter  # Filtering support
38 pip-python install lxml  # XML manipulation library
39 pip-python install netaddr # IP Addr library
40 pip-python install pytz
41 pip-python install django-timezones
42 pip-python install requests
43 pip-python install django-crispy-forms
44 pip-python install django-geoposition
45 pip-python install django-extensions
46 pip-python install django-suit
47 pip-python install django-evolution
48 pip-python install django-bitfield
49 pip-python install django-ipware
50 pip-python install django-encrypted-fields
51 pip-python install python-keyczar
52 pip-python install python-keystoneclient
53 pip-python install python-novaclient
54 pip-python install python-neutronclient 
55 pip-python install python-glanceclient
56 pip-python install python-ceilometerclient
57
58
59 easy_install django_evolution
60 easy_install python_gflags
61 easy_install google_api_python_client
62
63 if [ ! -f /usr/lib/python2.7/site-packages/suit/static/suit/js/jquery-1.9.1.min.js ]; then
64     wget -P /usr/lib/python2.7/site-packages/suit/static/suit/js http://code.jquery.com/jquery-1.9.1.min.js
65 fi
66
67 if [ ! -f /usr/share/GeoIP/GeoLiteCity.dat ]; then
68    rm -f /usr/share/GeoIP/GeoLiteCity.*
69    wget -P /usr/share/GeoIP http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
70    gzip -d /usr/share/GeoIP/GeoLiteCity*.gz
71 fi
72
73 if [ "$1" == 2 ] ; then
74     if [[ -e /opt/planetstack/scripts/opencloud ]]; then
75         echo "UPGRADE - saving current state"
76         /opt/planetstack/scripts/opencloud dumpdata
77     fi
78 fi
79
80 %install
81 rm -rf %{buildroot}
82 mkdir -p  %{buildroot}
83 install -d %{buildroot}/opt/planetstack
84 install -d %{buildroot}/etc/init.d
85
86 # in builddir
87
88
89 # don't copy symbolic links (they are handled in %post)
90 rsync -rptgoD ./planetstack %{buildroot}/opt/.  
91 cp observer-initscript %{buildroot}/etc/init.d/plstackobserver
92
93 find %{buildroot}/opt/planetstack -type f -print | sed "s@^$RPM_BUILD_ROOT@@g" > %{_tmppath}/tmp-filelist
94 echo /etc/init.d/plstackobserver >> %{_tmppath}/tmp-filelist
95
96 # remove config files from the file list (see %config below)
97 cat > %{_tmppath}/config-files << "EOF"
98 /opt/planetstack/plstackapi_config
99 /opt/planetstack/deployment_auth.py
100 EOF
101
102 sort %{_tmppath}/tmp-filelist > %{_tmppath}/tmp-filelist.sorted
103 sort %{_tmppath}/config-files > %{_tmppath}/config-files.sorted
104 comm -13 %{_tmppath}/config-files.sorted %{_tmppath}/tmp-filelist.sorted > %{_tmppath}/tmp-filelist
105
106 cp %{_tmppath}/tmp-filelist /tmp/tmp-filelist
107
108
109 %clean
110 rm -rf %{buildroot}
111
112 %files -f %{_tmppath}/tmp-filelist
113 %defattr(-,root,root,-)
114 %config /opt/planetstack/plstackapi_config
115 %config /opt/planetstack/deployment_auth.py
116 %config /opt/planetstack/model-deps
117
118 %post
119 ln -s ec2_observer /opt/planetstack/observer
120 ln -s config-opencloud.py /opt/planetstack/syndicate_observer/syndicatelib_config/config.py
121
122 if [ ! -e /opt/planetstack/public_keys ]; then
123     cd /opt/planetstack
124     scripts/opencloud genkeys
125 fi
126
127 if [ "$1" == 1 ] ; then
128     echo "NEW INSTALL - initializing database"
129     /opt/planetstack/scripts/opencloud initdb
130 else
131     # scripts/opencloud will choose evolve or migrate depending on django version
132     echo "UPGRADE - doing evolution/migration"
133     /opt/planetstack/scripts/opencloud evolvedb
134 fi
135
136 # Clone ansible with latest openstack modules
137 git clone --recursive git://github.com/ansible/ansible.git /opt/ansible
138 mkdir -p /etc/ansible
139 echo > /etc/ansible/hosts << "EOF"
140 [localhost]
141 127.0.0.1
142 EOF
143
144
145 # start the server
146 /opt/planetstack/scripts/opencloud runserver
147
148 %preun
149 if [ "$1" = 0 ] ; then
150     echo "UNINSTALL - destroying planetstack"
151     rm -rf /opt/planetstack
152 fi
153
154 %changelog
155 * Sat Feb 22 2014  Siobhan Tully  1.0.0
156 - First Build
157