Adding the maas deployment script. This will deploy the maas in a
[joid.git] / ci / deploy.py
1 #!/usr/bin/env python
2 """
3 MAAS Deployment Tool
4 """
5 import copy
6 import itertools
7 import json
8 import logging
9 import os
10 import sys
11 import time
12 import yaml
13
14 from maas_deployer.vmaas.util import CONF as cfg
15
16 from maas_deployer.vmaas import (
17     vm,
18     util,
19     template,
20 )
21
22
23 # Setup logging before imports
24 logging.basicConfig(
25     filename='maas_deployer.log',
26     level=logging.DEBUG,
27     format=('%(asctime)s %(levelname)s '
28             '(%(funcName)s) %(message)s'))
29
30 log = logging.getLogger('vmaas.main')
31 handler = logging.StreamHandler()
32 formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
33 handler.setFormatter(formatter)
34 log.addHandler(handler)
35
36 def main():
37
38     maasipaddress = str(sys.argv); 
39
40     script = """
41         sudo apt-get install git -y 
42         git clone https://gerrit.opnfv.org/gerrit/joid
43         juju init -y
44         cp /home/juju/.juju/environments.yaml ~/.juju/
45         cd joid/ci/
46         ./deploy.sh 
47         """ 
48     try:
49         util.exec_script_remote('ubuntu', maasipaddress[1], script)
50     except:
51         # Remove console handler to avoid displaying the exception twice
52         log.removeHandler(handler)
53         log.exception("MAAS deployment failed.")
54         raise
55
56 if __name__ == '__main__':
57     main()