]> git.proxmox.com Git - pve-common.git/blame - README.dev
buildsys: use dpkg-dev makefile helpers for pkg info
[pve-common.git] / README.dev
CommitLineData
a4a9a328 1= Setup PVE Development Environment =
e143e9d8 2
bb9d3865 30. Read https://pve.proxmox.com/wiki/Developer_Documentation
2c2b3b55
TL
41. Install Debian 9 'stretch' (you can also start from a PVE installation and
5 skip step 2 - 5, 7 - 11)
bb9d3865
MB
62. Configure the network interface(s)
73. Change the IP address of your hostname for proper name resolution
8 in /etc/hosts
9 Using 127.0.1.1 will not work, so change it to an IP address from your
10 local network!
a4a9a328 11
bb9d3865
MB
124: Check that the Debian repositories are set properly.
13 See https://wiki.debian.org/SourcesList for more information.
a4a9a328 14
bb9d3865 155. Optional: Install openssh-server and connect via ssh to the host.
a4a9a328 16
bb9d3865
MB
17 run: apt-get update && apt-get install openssh-server
18 Connect via ssh to host and switch user to root
a4a9a328 19
bb9d3865 206. Configure 'pvetest' repository in /etc/apt/sources.list.d/:
8bc53243 21
bb9d3865
MB
22 run: echo "deb http://download.proxmox.com/debian stretch pvetest" > /etc/apt/sources.list.d/pve-development.list
23
247. Add the repository key:
25
26 run: wget -O- "http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg" | apt-key add -
27
288. run: apt-get update && apt-get dist-upgrade
299. run: apt-get install proxmox-ve
3010. run: mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
31
3211. You should now have a working Proxmox VE installation.
33 Open a browser: https://<host_IP_address>:8006 e.g. https://10.0.0.90:8006
e143e9d8 34
a4a9a328
DM
35
36= Install build prerequisites for development environment =
47e4eb11 37
fb6134fe
TL
38NOTE: this is a huge list intended to be able to build (almost) all packages,
39from the UI/API components to backend components to our Linux Kernel.
40If you only want to hack on specific topics you won't need most of those.
41We try to have a complete list of build dependencies in each source
1149dc7b 42repositories 'debian/control' file. If you run `make deb` dpkg-buildpackage will
8010ddfd 43stop and tell you if you miss some required packages.
bb9d3865 44
fb6134fe
TL
4512. For installing the most important, always needed, ones run:
46
47apt-get install build-essential git git-email debhelper pve-doc-generator
48
49Additionally, for quickly installing (almost) all build dependencies run:
50
51apt-get install autotools-dev autogen dh-autoreconf dkms doxygen check pkg-config \
48e957b9
MR
52groff quilt dpatch automake autoconf libtool lintian libdevel-cycle-perl \
53libjson-perl libcommon-sense-perl liblinux-inotify2-perl libio-stringy-perl \
8bc53243
DM
54libstring-shellquote-perl dh-systemd rpm2cpio libsqlite3-dev sqlite3 \
55libglib2.0-dev librrd-dev librrds-perl rrdcached libdigest-hmac-perl \
56libxml-parser-perl gdb libcrypt-openssl-random-perl \
57libcrypt-openssl-rsa-perl libnet-ldap-perl libauthen-pam-perl \
58libjson-xs-perl libterm-readline-gnu-perl oathtool libmime-base32-perl \
59liboath0 libpci-dev texi2html libsdl1.2-dev libgnutls28-dev \
60libspice-protocol-dev xfslibs-dev libnuma-dev libaio-dev \
1cfd43f6 61pve-libspice-server-dev libusbredirparser-dev glusterfs-common \
8bc53243
DM
62libusb-1.0-0-dev librbd-dev libpopt-dev iproute bridge-utils numactl \
63glusterfs-common ceph-common python-ceph libgoogle-perftools4 \
64libfile-chdir-perl lvm2 glusterfs-client liblockfile-simple-perl \
37640d62 65libsystemd-dev libreadline-gplv2-dev libio-multiplex-perl \
8bc53243
DM
66libnetfilter-log-dev libipset3 ipset socat libsasl2-dev libogg-dev \
67python-pyparsing libfilesys-df-perl libcrypt-ssleay-perl \
68libfile-readbackwards-perl libanyevent-perl libanyevent-http-perl \
692160c1 69unzip liblocale-po-perl libfile-sync-perl cstream \
8bc53243 70lzop dtach apt-transport-https hdparm gdisk parted ttf-dejavu-core \
37640d62 71liblzma-dev dosfstools mtools libxen-dev libfuse-dev corosync-dev \
3ffb1395 72libcpg-dev libquorum-dev libcmap-dev libuuid-perl \
37640d62 73libqb-dev libapparmor-dev docbook2x libcap-dev dh-apparmor \
fe949d0e 74graphviz libseccomp-dev libglib-perl libgtk3-perl libnss3-dev libdlm-dev \
bb9d3865 75libudev-dev asciidoc-dblatex source-highlight libiscsi-dev libiscsi7 \
5d87f1cc 76librsvg2-bin libarchive-dev libgpgme-dev libcurl4-gnutls-dev \
cc74c62d 77libtest-mockmodule-perl libjemalloc-dev libjpeg-dev
bb9d3865 78
e143e9d8 79
a4a9a328
DM
80= Compile PVE packages from Source =
81
bb9d3865
MB
8213: Download and install git repositories as Proxmox modules:
83
84 run: mkdir /root/proxmox && cd /root/proxmox
85
86 run: git clone git://git.proxmox.com/git/pve-common.git
87
88 'pve-common.git' is some kind of starting repository and needed for some
89 other repositories as dependency.
90 Install this to get an idea of how the installation process is working.
91
92 See https://git.proxmox.com/ for all available repositories.
93
9414: Most packages can be installed with 'make dinstall' command.
95 run: cd pve-common && make dinstall
96
9715: Reboot the system.
9816. Learn to use the quilt patch scripts.
9917. Happy coding!
e143e9d8
DM
100
101
a4a9a328 102= REST vs. SOAP =
e143e9d8
DM
103
104We decided to change our SOAP API (1.X) and use a REST like API. The
105concept is described in [1] (Resource Oriented Architecture
106(ROA)). The main advantage is that we are able to remove a lot of code
107(the whole SOAP stack) to reduce software complexity.
108
109We also moved away from server side content generation. Instead we use
110the ExtJS Rich Internet Application Framework
111(http://www.sencha.com).
112
113That framework, like any other AJAX toolkit, can talk directly to the
114REST API using JSON. So we were able to remove the server side
115template toolkit completely.
116
a4a9a328 117= JSON and JSON Schema =
e143e9d8
DM
118
119We use JSON as data format, because it is simple and parse-able by any
120web browser.
121
122Additionally, we use JSON Schema [2] to formally describe our API. So
123we can automatically generate the whole API Documentation, and we can
124verify all parameters and return values.
125
60f4e8c7 126A great side effect was that we are able to use JSON Schema to
e143e9d8
DM
127produce command line argument parsers automatically. In fact, the REST
128API and the command line tools use the same code.
129
130Object linkage is done using the JSON Hyper Schema (links property).
131
132A small utility called 'pvesh' exposes the whole REST API on the command
133line.
134
135So here is a summary of the advantage:
136
137 - easy, human readable data format (native web browser format)
138 - automatic parameter verification (we can also verify return values)
139 - automatic generation of API documentation
140 - easy way to create command line tools (using same API).
141
a4a9a328 142= API Implementation (PVE::RESTHandler) =
e143e9d8
DM
143
144All classes exposing methods on the API use PVE::RESTHandler as base class.
145
146 use base qw(PVE::RESTHandler);
147
148To expose methods, one needs to call register_method():
149
150 __PACKAGE__->register_method ($schema);
151
152Where $schema is a PVE method schema as described in
153PVE::JSONSchema. It includes a description of parameters and return
154values, and a reference to the actual code
155
156__PACKAGE__->register_method ({
157 name => 'echo',
158 path => 'echo',
159 method => 'GET',
160 description => "simple return value of parameter 'text'",
161 parameters => {
162 additionalProperties => 0,
163 properties => {
164 text => {
165 type => 'string',
166 }
167 },
168 },
169 returns => {
170 type => 'string',
171 },
172 code => sub {
ef73f03b 173 my ($param) = @_;
e143e9d8
DM
174
175 return $param->{text};
176 }
177});
178
179The 'name' property is only used if you want to call the method
180directly from Perl. You can do that using:
181
182 print __PACKAGE__->echo({ text => "a test" });
183
184We use Perl's AUTOLOAD feature to implement this. Note: You need to
185pass parameters a HASH reference.
186
187There is a special helper method called cli_handler(). This is used by
188the CLIHandler Class for command line tools, where you want to pass
189arguments as array of strings. This uses Getopt::Long to parse parameters.
190
191There is a second way to map names to methods - using the 'path'
192property. And you can register subclasses. That way you can set up a
193filesystem like hierarchy to access methods.
194
195Here is an example:
196----------------------------
197package C1;
198
199__PACKAGE__->register_method ({
200 subclass => "C2",
201 path => 'sub2',
202});
203
204
205__PACKAGE__->register_method ({
206 name => 'list1',
207 path => 'index',
208 method => 'GET',
209 ...
210});
211
212package C2;
213
214__PACKAGE__->register_method ({
215 name => 'list2',
216 path => 'index',
217 method => 'GET',
218 ...
219});
220-------------------------------
221
222The utily method find_handler (in PVE::RESTHandler) can be use to do
223'path' related method lookups.
224
225C1->find_handler('GET', "/index") => C1::list1
226C1->find_handler('GET', "/sub2/index") => C2::list2
227
228The HTTP server use the URL (a path) to find the corresponding method.
229
230
a4a9a328
DM
231= References =
232
e143e9d8
DM
233[1] RESTful Web Services
234Web services for the real world
235
236By
237 Leonard Richardson, Sam Ruby
238Publisher:
239 O'Reilly Media
240Released:
241 May 2007
242
243[2] JSON Schema links: http://json-schema.org/