~openstack-charmers-next/charms/wily/keystone/trunk

« back to all changes in this revision

Viewing changes to charmhelpers/contrib/openstack/utils.py

  • Committer: Corey Bryant
  • Date: 2016-06-16 14:30:18 UTC
  • Revision ID: corey.bryant@canonical.com-20160616143018-ae3pxe0vtcz0p1ug
Add defaults for openstack-origin-git config option

openstack-origin-git currently only supports YAML that specifies
the git repositories to deploy from.

This adds support for default openstack-origin-git values. The
default values supported are: icehouse, kilo, liberty, mitaka,
and master.  For example: openstack-origin-git=master.

Change-Id: I03839dc0abfb7465578cbb4eedfdab5043d053e6

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    related_units,
52
52
    relation_ids,
53
53
    relation_set,
 
54
    service_name,
54
55
    status_set,
55
56
    hook_name
56
57
)
207
208
    ]),
208
209
}
209
210
 
 
211
GIT_DEFAULT_REPOS = {
 
212
    'requirements': 'git://github.com/openstack/requirements',
 
213
    'cinder': 'git://github.com/openstack/cinder',
 
214
    'glance': 'git://github.com/openstack/glance',
 
215
    'horizon': 'git://github.com/openstack/horizon',
 
216
    'keystone': 'git://github.com/openstack/keystone',
 
217
    'neutron': 'git://github.com/openstack/neutron',
 
218
    'neutron-fwaas': 'git://github.com/openstack/neutron-fwaas',
 
219
    'neutron-lbaas': 'git://github.com/openstack/neutron-lbaas',
 
220
    'neutron-vpnaas': 'git://github.com/openstack/neutron-vpnaas',
 
221
    'nova': 'git://github.com/openstack/nova',
 
222
}
 
223
 
 
224
GIT_DEFAULT_BRANCHES = {
 
225
    'icehouse': 'icehouse-eol',
 
226
    'kilo': 'stable/kilo',
 
227
    'liberty': 'stable/liberty',
 
228
    'mitaka': 'stable/mitaka',
 
229
    'master': 'master',
 
230
}
 
231
 
210
232
DEFAULT_LOOPBACK_SIZE = '5G'
211
233
 
212
234
 
703
725
requirements_dir = None
704
726
 
705
727
 
 
728
def git_default_repos(projects_yaml):
 
729
    """
 
730
    Returns default repos if a default openstack-origin-git value is specified.
 
731
    """
 
732
    service = service_name()
 
733
    core_project = service
 
734
 
 
735
    for default, branch in GIT_DEFAULT_BRANCHES.iteritems():
 
736
        if projects_yaml == default:
 
737
 
 
738
            # add the requirements repo first
 
739
            repo = {
 
740
                'name': 'requirements',
 
741
                'repository': GIT_DEFAULT_REPOS['requirements'],
 
742
                'branch': branch,
 
743
            }
 
744
            repos = [repo]
 
745
 
 
746
            # neutron-* and nova-* charms require some additional repos
 
747
            if service in ['neutron-api', 'neutron-gateway',
 
748
                           'neutron-openvswitch']:
 
749
                core_project = 'neutron'
 
750
                for project in ['neutron-fwaas', 'neutron-lbaas',
 
751
                                'neutron-vpnaas']:
 
752
                    repo = {
 
753
                        'name': project,
 
754
                        'repository': GIT_DEFAULT_REPOS[project],
 
755
                        'branch': branch,
 
756
                    }
 
757
                    repos.append(repo)
 
758
 
 
759
            elif service in ['nova-cloud-controller', 'nova-compute']:
 
760
                core_project = 'nova'
 
761
                repo = {
 
762
                    'name': 'neutron',
 
763
                    'repository': GIT_DEFAULT_REPOS['neutron'],
 
764
                    'branch': branch,
 
765
                }
 
766
                repos.append(repo)
 
767
            elif service == 'openstack-dashboard':
 
768
                core_project = 'horizon'
 
769
 
 
770
            # finally add the current service's core project repo
 
771
            repo = {
 
772
                'name': core_project,
 
773
                'repository': GIT_DEFAULT_REPOS[core_project],
 
774
                'branch': branch,
 
775
            }
 
776
            repos.append(repo)
 
777
 
 
778
            return yaml.dump(dict(repositories=repos))
 
779
 
 
780
    return projects_yaml
 
781
 
 
782
 
706
783
def _git_yaml_load(projects_yaml):
707
784
    """
708
785
    Load the specified yaml into a dictionary.