~anton-skriptsov/charms/trusty/cinder-nexentaedge/trunk

« back to all changes in this revision

Viewing changes to hooks/configurationSteps/nedeployInstall.py

  • Committer: anton.skriptsov at nexenta
  • Date: 2015-11-12 19:21:10 UTC
  • Revision ID: anton.skriptsov@nexenta.com-20151112192110-y49mpvnvf3pp3xk1
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#/usr/bin/env python
 
2
 
 
3
import os
 
4
import sys
 
5
import traceback
 
6
import subprocess
 
7
 
 
8
from settings import Settings
 
9
from baseConfigurationStep import BaseConfigurationStep
 
10
 
 
11
class NedeployInstall(BaseConfigurationStep):
 
12
    def __init__(self):
 
13
        pass
 
14
 
 
15
    def process(self, environment):
 
16
        node_public_ip  = environment['node_public_ip']
 
17
        node_type       = environment['node_type']
 
18
        replicast_eth   = environment['replicast_eth']
 
19
        nodocker        = environment['nodocker']
 
20
        profile         = environment['profile']
 
21
        exclude         = environment['exclude']
 
22
        reserved        = environment['reserved']
 
23
 
 
24
        print('[{}]'.format(self.__class__.__name__))
 
25
        print("\tnode_public_ip : {}".format(node_public_ip))
 
26
        print("\tnode_type      : {}".format(node_type))
 
27
        print("\treplicast_eth  : {}".format(replicast_eth))
 
28
        print("\tnodocker       : {}".format(nodocker))
 
29
        print("\tprofile        : {}".format(profile))
 
30
        print("\texclude        : {}".format(exclude))
 
31
        print("\treserved       : {}".format(reserved))
 
32
 
 
33
        try:
 
34
 
 
35
            neadmCmd = [Settings.NEDEPLOY_CMD, 'deploy', 'solo',  node_public_ip, 'nexenta:nexenta', '-i', replicast_eth]
 
36
 
 
37
            if node_type == 'mgmt':
 
38
                neadmCmd.append('-m')
 
39
            elif node_type == 'gateway':
 
40
                #ADD GATEWAY parameter to deploy solo cmd
 
41
                print("Gateway type selected!! ")
 
42
 
 
43
            #profile section 
 
44
            neadmCmd.append('-t')
 
45
            if profile.lower() == 'balanced':
 
46
                neadmCmd.append('balanced')
 
47
            elif profile.lower() == 'performance':
 
48
                neadmCmd.append('performance')
 
49
            else:
 
50
                neadmCmd.append('capacity')
 
51
 
 
52
            if nodocker and nodocker == True:
 
53
                neadmCmd.append('--nodocker')
 
54
           
 
55
            if exclude:
 
56
                neadmCmd.append('-x')
 
57
                neadmCmd.append(exclude)
 
58
        
 
59
            if reserved:
 
60
                neadmCmd.append('-X')
 
61
                neadmCmd.append(reserved)
 
62
 
 
63
            print("NEDEPLOY cmd is: {0}".format(' '.join(neadmCmd)))
 
64
            output = subprocess.check_output(neadmCmd)
 
65
 
 
66
        except Exception as ex:
 
67
            raise Exception('in {0}\nMessage:{1}\nTrace: {2}'.format(self.__class__.__name__, ex.message, traceback.format_exc()))