Пример #1
0
    def get_previous_thumbprint(self, components=None):
        """
        Returns a dictionary representing the previous configuration state.

        Thumbprint is of the form:

            {
                component_name1: {key: value},
                component_name2: {key: value},
                ...
            }

        """
        components = str_to_component_list(components)
        tp_fn = self.manifest_filename
        if self.file_exists(tp_fn):
            fd = six.BytesIO()
            get(tp_fn, fd)
            tp_text = fd.getvalue()
            manifest_data = {}
            raw_data = yaml.load(tp_text, Loader=yaml.Loader)  # SafeLoader can't load native tuples
            for k, v in raw_data.items():
                manifest_key = assert_valid_satchel(k)
                service_name = clean_service_name(k)
                if components and service_name not in components:
                    continue
                manifest_data[manifest_key] = v
            return manifest_data
Пример #2
0
    def get_previous_thumbprint(self, components=None):
        """
        Returns a dictionary representing the previous configuration state.

        Thumbprint is of the form:

            {
                component_name1: {key: value},
                component_name2: {key: value},
                ...
            }

        """
        components = str_to_component_list(components)
        tp_fn = self.manifest_filename
        tp_text = None
        if self.file_exists(tp_fn):
            fd = StringIO()
            get(tp_fn, fd)
            tp_text = fd.getvalue()
            manifest_data = {}
            raw_data = yaml.load(tp_text)
            for k, v in raw_data.items():
                manifest_key = assert_valid_satchel(k)
                service_name = clean_service_name(k)
                if components and service_name not in components:
                    continue
                manifest_data[manifest_key] = v
            return manifest_data
Пример #3
0
    def get_current_thumbprint(self, components=None):
        """
        Returns a dictionary representing the current configuration state.

        Thumbprint is of the form:

            {
                component_name1: {key: value},
                component_name2: {key: value},
                ...
            }

        """
        components = str_to_component_list(components)
        if self.verbose:
            print('deploy.get_current_thumbprint.components:', components)
        manifest_data = {} # {component:data}
        for component_name, func in sorted(manifest_recorder.items()):
            self.vprint('Checking thumbprint for component %s...' % component_name)
            manifest_key = assert_valid_satchel(component_name)
            service_name = clean_service_name(component_name)
            if service_name not in self.genv.services:
                self.vprint('Skipping unused component:', component_name)
                continue
            elif components and service_name not in components:
                self.vprint('Skipping non-matching component:', component_name)
                continue
            try:
                self.vprint('Retrieving manifest for %s...' % component_name)
                manifest_data[manifest_key] = func()
                if self.verbose:
                    pprint(manifest_data[manifest_key], indent=4)
            except exceptions.AbortDeployment as e:
                raise
        return manifest_data
Пример #4
0
def get_last(name):
    from burlap.deploy import get_last_thumbprint
    name = common.assert_valid_satchel(name)
    last_thumbprint = get_last_thumbprint()
#     print('get_last:', last_thumbprint.get(name))
#     raw_input('enter')
    if last_thumbprint:
        if name in last_thumbprint:
            return last_thumbprint.get(name, {})
Пример #5
0
def get_last(name):
    from burlap.deploy import get_last_thumbprint
    name = common.assert_valid_satchel(name)
    last_thumbprint = get_last_thumbprint()
    #     print('get_last:', last_thumbprint.get(name))
    #     raw_input('enter')
    if last_thumbprint:
        if name in last_thumbprint:
            return last_thumbprint.get(name, {})
Пример #6
0
def explain(name, **kwargs):
    #common.set_verbose(1)
    kwargs = kwargs or {}
    name = common.assert_valid_satchel(name)
    kwargs['only_components'] = [name]
    kwargs['local_verbose'] = 1
    diffs = dict(iter_thumbprint_differences(**kwargs))
    last, current = diffs.get(name, (None, None))
    if last is None and current is None:
        print('There are no differences.')
Пример #7
0
def explain(name, **kwargs):
    #common.set_verbose(1)
    kwargs = kwargs or {}
    name = common.assert_valid_satchel(name)
    kwargs['only_components'] = [name]
    kwargs['local_verbose'] = 1
    diffs = dict(iter_thumbprint_differences(**kwargs))
    last, current = diffs.get(name, (None, None))
    if last is None and current is None:
        print('There are no differences.')
Пример #8
0
 def get_last(self, name):
     from burlap.deploy import deploy as deploy_satchel
     name = common.assert_valid_satchel(name)
     last_thumbprint = deploy_satchel.get_previous_thumbprint()
     #print('manifest.name:', name)
     #print('manifest.last_thumbprint:')
     #pprint(last_thumbprint, indent=4)
     if last_thumbprint:
         if name in last_thumbprint:
             return last_thumbprint.get(name, type(self.genv)())
     return type(self.genv)()
Пример #9
0
    def get_current_thumbprint(self, components=None):
        """
        Returns a dictionary representing the current configuration state.

        Thumbprint is of the form:

            {
                component_name1: {key: value},
                component_name2: {key: value},
                ...
            }

        """
        components = str_to_component_list(components)
        if self.verbose:
            print('deploy.get_current_thumbprint.components:', components)
        manifest_data = {}  # {component:data}
        for component_name, func in sorted(manifest_recorder.iteritems()):
            self.vprint('Checking thumbprint for component %s...' %
                        component_name)
            manifest_key = assert_valid_satchel(component_name)
            service_name = clean_service_name(component_name)
            if service_name not in self.genv.services:
                self.vprint('Skipping unused component:', component_name)
                continue
            elif components and service_name not in components:
                self.vprint('Skipping non-matching component:', component_name)
                continue
            try:
                self.vprint('Retrieving manifest for %s...' % component_name)
                manifest_data[manifest_key] = func()
                if self.verbose:
                    pprint(manifest_data[manifest_key], indent=4)
            except exceptions.AbortDeployment as e:
                raise
        return manifest_data