~anton-skriptsov/charms/trusty/nedge-swift-gw/trunk

« back to all changes in this revision

Viewing changes to charms/trusty/nedge-swift-gw/hooks/configurationSteps/neadmClusterCreation.py

  • Committer: anton.skriptsov at nexenta
  • Date: 2015-11-12 18:35:03 UTC
  • Revision ID: anton.skriptsov@nexenta.com-20151112183503-z674ufwk2prmljvq
removeĀ files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#/usbr/in/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 NeadmClusterCreation(BaseConfigurationStep):
12
 
    def __init__(self):
13
 
      pass
14
 
 
15
 
    def process(self, environment):
16
 
 
17
 
      nedge_cluster_name = environment['nedge_cluster_name']
18
 
      nedge_tenant_name  = environment['nedge_tenant_name']
19
 
      nedge_bucket_name  = environment['nedge_bucket_name']
20
 
 
21
 
      print('[{}]'.format(self.__class__.__name__))
22
 
      print('\tnedge_cluster_name : {}'.format(nedge_cluster_name))
23
 
      print('\tnedge_tenant_name : {}'.format(nedge_tenant_name))
24
 
      print('\tnedge_bucket_name : {}'.format(nedge_bucket_name))
25
 
 
26
 
      try:
27
 
        tenant_name = "{0}/{1}".format(nedge_cluster_name, nedge_tenant_name)
28
 
        bucket_name = "{0}/{1}/{2}".format(nedge_cluster_name, nedge_tenant_name, nedge_bucket_name)
29
 
 
30
 
        cluster_cmd = [Settings.NEADM_CMD, 'cluster', 'create', nedge_cluster_name]
31
 
        tenant_cmd  = [Settings.NEADM_CMD, 'tenant',  'create', tenant_name]
32
 
        bucket_cmd  = [Settings.NEADM_CMD, 'bucket',  'create', bucket_name]
33
 
 
34
 
        print("\tNEADM cluster creation cmd is {0}".format(' '.join(cluster_cmd)))
35
 
        subprocess.check_call(cluster_cmd)
36
 
        
37
 
        print("\tNEADM tenant creation cmd is {0}".format(' '.join(tenant_cmd)))
38
 
        subprocess.check_call(tenant_cmd)
39
 
 
40
 
        print("\tNEADM bucket creation cmd is {0}".format(' '.join(bucket_cmd)))
41
 
        subprocess.check_call(bucket_cmd)
42
 
 
43
 
      except Exception as ex:
44
 
        raise Exception('in {0}\nMessage:{1}\nTrace: {2}'.format(self.__class__.__name__, ex.message, traceback.format_exc()))
45