Project

General

Profile

Migration » History » Version 1

Nicolas C, 2014-11-21 14:17

1 1 Nicolas C
h1. Migration
2
If you want to migrate between Tvheadend instances, one possible approach is to configure your new instance in advance, reading your muxes via http. Of course if you have a large number of muxes, just loading on by one could be tedious, so it's better to do it programmatically. Refer to the attached script.
3
4
This script has been tested on migrating a 3.4 server to a 3.9 server.
5
6
<pre>
7
#!/usr/bin/env python
8
import time
9
import urllib
10
import urllib2
11
import json
12
#Source IP of your TVHeadend Server
13
ipsrc='192.168.0.9'
14
#Target IP
15
ipdst='192.168.0.254'
16
#Old Network Name
17
onn='Astra28'
18
#New Network UUID
19
nnu='7cc8273901fadc4f5e8b65a4bca392fd'
20
url = 'http://'+ipsrc+':9981/api/mpegts/mux/grid?start=0&limit=400'
21
url=urllib2.urlopen(url)
22
json_string=url.read()
23
data = json.loads(json_string)
24
entries = data['entries']
25
if entries:
26
    for entry in entries:
27
        if entry['network']==onn:
28
            print "Creating MUX: ' + entry['name']
29
            conf = { 'enabled' : 'true',
30
                       'epg' : 0,
31
                       'scan_state' : 0,
32
                       'iptv_url' : 'http://'+ipsrc+':9981/stream/mux/' + entry['uuid'],
33
                       'iptv_interface' : 'eth0',
34
                       'iptv_atsc' : '',
35
                       'iptv_muxname' : entry['name'],
36
                       'iptv_sname' : '',
37
                       'charset' : '',
38
                       'pmt_06_ac3' : '',
39
                       'priority' : 0,
40
                       'spriority' : 0,
41
                   }
42
            data = { 'uuid' : nnu,
43
                     'conf' : json.JSONEncoder().encode(conf),
44
                   }
45
            posturl = 'http://'+ipdst+':9981/api/mpegts/network/mux_create'
46
            postdata = urllib.urlencode(data)
47
            req = urllib2.Request(posturl, postdata)
48
            response = urllib2.urlopen(req)
49
            the_page = response.read()
50
            print "Sleeping for 60 seconds to allow initial scan"
51
            time.sleep(60)
52
</pre>