예제 #1
0
 def __get_state(self, state):
     if state == 'Active':
         return color.green(state)
     elif state == 'Inactive':
         return color.red(state)
     else:
         return state
예제 #2
0
파일: rds.py 프로젝트: okamos/bush
 def __get_state(self, state):
     if state == 'available':
         return color.green(state)
     if state == 'deleting' or state == 'failed' or state == 'storage-full':
         return color.red(state)
     if state == 'creating' or state == 'modirying' or state == 'rebooting':
         return color.yellow(state)
     else:
         return state
예제 #3
0
 def __get_state_with_image(self, image):
     state = image.state
     if state == 'available':
         return color.green(state)
     elif state == 'pending':
         return color.yellow(state)
     elif state == 'failed':
         return color.red(state)
     else:
         return state
예제 #4
0
 def __get_state(self, instance):
     code = instance.state['Code']
     state = instance.state['Name']
     # ref http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceState.html
     if code == 16:
         return color.green(state)
     elif code == 48 or code == 80:
         return color.red(state)
     elif code == 0 or code == 32 or code == 64:
         return color.yellow(state)
     else:
         return state
예제 #5
0
파일: session.py 프로젝트: okamos/bush
def create_session(options):
    # Bush looks for credentials this order.
    #   1. Environment variables
    #   2. AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
    #   3. ~/.aws/credentials with profile
    #   4. ~/.aws/credentials with default profile
    access_key = os.environ.get('AWS_ACCESS_KEY_ID') or options.access_key
    secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY') or options.secret_key
    params = {}
    if options.region:
        params['region_name'] = options.region

    if access_key and secret_key:
        params['aws_access_key_id'] = access_key
        params['aws_secret_access_key'] = secret_key

    if options.profile:
        params['profile_name'] = options.profile

    try:
        return session.Session(**params)
    except botocore.exceptions.ProfileNotFound as error:
        print(color.red(error))
        sys.exit(2)