Print out the change_set to console.
    This needs to run create_change_set first.

    :param awsclient:
    :param change_set_name:
    :param stack_name:
13331
def describe_change_set(awsclient, change_set_name, stack_name):
    
    client = awsclient.get_client('cloudformation')

    status = None
    while status not in ['CREATE_COMPLETE', 'FAILED']:
        response = client.describe_change_set(
            ChangeSetName=change_set_name,
            StackName=stack_name)
        status = response['Status']
        # print('##### %s' % status)
        if status == 'FAILED':
            print(response['StatusReason'])
        elif status == 'CREATE_COMPLETE':
            for change in response['Changes']:
                print(json2table(change['ResourceChange']))
651040
def set_present(name, set_type, family='ipv4', **kwargs):
    '''
    
    '''

    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    set_check = __salt__['ipset.check_set'](name)
    if set_check is True:
        ret['result'] = True
        ret['comment'] = ('ipset set {0} already exists for {1}'
                          .format(name, family))
        return ret

    if __opts__['test']:
        ret['comment'] = 'ipset set {0} would be added for {1}'.format(
            name,
            family)
        return ret
    command = __salt__['ipset.new_set'](name, set_type, family, **kwargs)
    if command is True:
        ret['changes'] = {'locale': name}
        ret['result'] = True
        ret['comment'] = ('ipset set {0} created successfully for {1}'
                          .format(name, family))
        return ret
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to create set {0} for {2}: {1}'.format(
            name,
            command.strip(),
            family
        )
        return ret
692677
def create_changeset(comment = nil, tags = {})
      tags.merge!(:comment => comment) { |key, v1, v2| v1 }
      changeset = Changeset.new(:tags => tags)
      changeset_id = put("/changeset/create", :body => changeset.to_xml).to_i
      find_changeset(changeset_id) unless changeset_id == 0
    end
602955
def annotate_from_changeset(self, changeset):
        
        if self.annotate_from_changeset_func:
            return self.annotate_from_changeset_func(changeset)
        else:
            return ''.join((changeset.id, '\n'))
375256
def do_stack(self,args):
        """"""
        parser = CommandArgumentParser("stack")
        parser.add_argument(dest='stack',help='stack index or name');
        args = vars(parser.parse_args(args))

        print "loading stack {}".format(args['stack'])
        try:
            index = int(args['stack'])            
            stackSummary = self.wrappedStack['resourcesByTypeIndex']['AWS::CloudFormation::Stack'][index]
        except ValueError:
            stackSummary = self.wrappedStack['resourcesByTypeName']['AWS::CloudFormation::Stack'][args['stack']]

        self.stackResource(stackSummary.stack_name,stackSummary.logical_id)
162509
def print_stack_events(self):
        '''
        
        '''
        first_token = '7be7981bd6287dd8112305e8f3822a6f'
        keep_going = True
        next_token = first_token
        current_request_token = None
        rows = []
        try:
            while keep_going and next_token:
                if next_token == first_token:
                    response = self._cf_client.describe_stack_events(
                        StackName=self._stack_name
                    )
                else:
                    response = self._cf_client.describe_stack_events(
                        StackName=self._stack_name,
                        NextToken=next_token
                    )

                next_token = response.get('NextToken', None)
                for event in response['StackEvents']:
                    row = []
                    event_time = event.get('Timestamp')
                    request_token = event.get('ClientRequestToken', 'unknown')
                    if current_request_token is None:
                        current_request_token = request_token
                    elif current_request_token != request_token:
                        keep_going = False
                        break

                    row.append(event_time.strftime('%x %X'))
                    row.append(event.get('LogicalResourceId'))
                    row.append(event.get('ResourceStatus'))
                    row.append(event.get('ResourceStatusReason', ''))
                    rows.append(row)

            if len(rows) > 0:
                print('\nEvents for the current upsert:')
                print(tabulate(rows, headers=['Time', 'Logical ID', 'Status', 'Message']))
                return True
            else:
                print('\nNo stack events found\n')
        except Exception as wtf:
            print(wtf)

        return False
941140
def do_set(self, args: argparse.Namespace) -> None:
        """"""

        # Check if param was passed in
        if not args.param:
            return self.show(args)
        param = utils.norm_fold(args.param.strip())

        # Check if value was passed in
        if not args.value:
            return self.show(args, param)
        value = args.value

        # Check if param points to just one settable
        if param not in self.settable:
            hits = [p for p in self.settable if p.startswith(param)]
            if len(hits) == 1:
                param = hits[0]
            else:
                return self.show(args, param)

        # Update the settable's value
        current_value = getattr(self, param)
        value = utils.cast(current_value, value)
        setattr(self, param, value)

        self.poutput('{} - was: {}\nnow: {}\n'.format(param, current_value, value))

        # See if we need to call a change hook for this settable
        if current_value != value:
            onchange_hook = getattr(self, '_onchange_{}'.format(param), None)
            if onchange_hook is not None:
                onchange_hook(old=current_value, new=value)
1199185
def _set_update(self):
        
        try:
            self._updateStack = False
            stack_name = self._config.get('environment', {}).get('stack_name', None)
            response = self._cloudFormation.describe_stacks(StackName=stack_name)
            stack = response['Stacks'][0]
            if stack['StackStatus'] == 'ROLLBACK_COMPLETE':
                logging.info('stack is in ROLLBACK_COMPLETE status and should be deleted')
                del_stack_resp = self._cloudFormation.delete_stack(StackName=stack_name)
                logging.info('delete started for stack: {}'.format(stack_name))
                logging.debug('delete_stack returned: {}'.format(json.dumps(del_stack_resp, indent=4)))
                stack_delete = self.poll_stack()
                if not stack_delete:
                    return False

            if stack['StackStatus'] in ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_ROLLBACK_COMPLETE']:
                self._updateStack = True
        except:
            self._updateStack = False

        logging.info('update_stack: ' + str(self._updateStack))
        return True
214575
def sset_loop(args):
    '''  '''
    # Ensure that the requested action is a valid fiss_cmd
    fiss_func = __cmd_to_func(args.action)
    if not fiss_func:
        eprint("invalid FISS cmd '" + args.action + "'")
        return 1

    # First get the sample set names
    r = fapi.get_entities(args.project, args.workspace, "sample_set")
    fapi._check_response_code(r, 200)

    sample_sets = [entity['name'] for entity in r.json()]

    args.entity_type = "sample_set"
    for sset in sample_sets:
        print('\n# {0}::{1}/{2} {3}'.format(args.project, args.workspace, sset,
                                            args.action))
        args.entity = sset
        # Note how this code is similar to how args.func is called in
        # main so it may make sense to try to a common method for both
        try:
            result = fiss_func(args)
        except Exception as e:
            status = __pretty_print_fc_exception(e)
            if not args.keep_going:
                return status
        printToCLI(result)

    return 0
1138565
def _notify_change(self):
        
        d = self.declaration
        self._notify_count -= 1
        if self._notify_count == 0:
            #: Tell the UI we made changes
            self.adapter.notifyDataSetChanged(now=True)
            self.get_context().timed_call(
                500, self._queue_pending_calls)
180858
def main():
    
    parser = parser_setup()
    options = parser.parse_args()

    debug = bool(options.debug > 0)
    debugall = bool(options.debug > 1)

    awsc.init()
    debg.init(debug, debugall)
    print(C_NORM)

    options.func(options)

    sys.exit()
349614
def update_stack(params)
      unless stack_exists?(@stack_name)
        puts "Cannot update a stack because the #{@stack_name} does not exists."
        return
      end
      exist_unless_updatable(stack_status(@stack_name))

      message = "Updating #{@stack_name} stack"
      error = nil
      if @options[:noop]
        message = "NOOP #{message}"
      else
        diff.run if @options[:diff]
        preview.run if @options[:preview]
        are_you_sure?(:update)

        if @options[:change_set] # defaults to this
          message << " via change set: #{preview.change_set_name}"
          change_set_update
        else
          standard_update(params)
        end
      end
      puts message unless @options[:mute] || error
    end
552621
def handle_stack_error(e)
      case e.message
      when /is in ROLLBACK_COMPLETE state and can not be updated/
        puts "The #{@stack_name} stack is in #{"ROLLBACK_COMPLETE".color(:red)} and cannot be updated. Deleted the stack and try again."
        region = `aws configure get region`.strip rescue 'us-east-1'
        url = "https://console.aws.amazon.com/cloudformation/home?region=#{region}"
        puts "Here's the CloudFormation console url: #{url}"
        exit 1
      when /No updates are to be performed/
        puts "There are no updates to be performed. Exiting.".color(:yellow)
        exit 1
      else
        raise
      end
    end
89490
def _update_stage(awsclient, api_id, stage_name, method_settings):
    
    # settings docs in response: https://botocore.readthedocs.io/en/latest/reference/services/apigateway.html#APIGateway.Client.update_stage
    client_api = awsclient.get_client('apigateway')
    operations = _convert_method_settings_into_operations(method_settings)
    if operations:
        print('update method settings for stage')
        _sleep()
        response = client_api.update_stage(
            restApiId=api_id,
            stageName=stage_name,
            patchOperations=operations)
715233
def do_changed(self, subcmd, opts, component):
        

        releases = get_released_versions(component)
        latest = releases[0]

        filter_dir = components.comp_names[component].path

        latest_tag = '-'.join(latest)
        data = get_changed_since_tag(latest_tag, filter_dir)

        if len(data) > 0:
            print(data)
563356
def changeset
      @changeset ||= git_diff.map do |diff_file|
        file_diff = FileDiff.new(diff_file)
        file_diff unless FormattingChecker.pure_formatting?(file_diff)
      end.compact
    end
444948
def rename_set(set=None, new_set=None, family='ipv4'):
    '''
    
    '''

    if not set:
        return 'Error: Set needs to be specified'

    if not new_set:
        return 'Error: New name for set needs to be specified'

    settype = _find_set_type(set)
    if not settype:
        return 'Error: Set does not exist'

    settype = _find_set_type(new_set)
    if settype:
        return 'Error: New Set already exists'

    cmd = '{0} rename {1} {2}'.format(_ipset_cmd(), set, new_set)
    out = __salt__['cmd.run'](cmd, python_shell=False)

    if not out:
        out = True
    return out