Resync charmhelpers for licensing change
The charm-helpers project have re-licensed to Apache 2.0 inline with the agreed licensing approach to intefaces, layers and charms generally. Resync helpers to bring charmhelpers inline with charm codebase. Change-Id: I1cf9e7d748536f5e34abaf29dd635413b30ecb1f
This commit is contained in:
parent
1166ba580e
commit
baf633e1d0
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Bootstrap charm-helpers, installing its dependencies if necessary using
|
# Bootstrap charm-helpers, installing its dependencies if necessary using
|
||||||
# only standard libraries.
|
# only standard libraries.
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2012 Canonical Ltd.
|
# Copyright 2012 Canonical Ltd.
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2012 Canonical Ltd.
|
# Copyright 2012 Canonical Ltd.
|
||||||
|
@ -41,10 +39,11 @@ from charmhelpers.core.hookenv import (
|
||||||
relation_get,
|
relation_get,
|
||||||
config as config_get,
|
config as config_get,
|
||||||
INFO,
|
INFO,
|
||||||
ERROR,
|
DEBUG,
|
||||||
WARNING,
|
WARNING,
|
||||||
unit_get,
|
unit_get,
|
||||||
is_leader as juju_is_leader
|
is_leader as juju_is_leader,
|
||||||
|
status_set,
|
||||||
)
|
)
|
||||||
from charmhelpers.core.decorators import (
|
from charmhelpers.core.decorators import (
|
||||||
retry_on_exception,
|
retry_on_exception,
|
||||||
|
@ -60,6 +59,10 @@ class HAIncompleteConfig(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class HAIncorrectConfig(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CRMResourceNotFound(Exception):
|
class CRMResourceNotFound(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -274,27 +277,71 @@ def get_hacluster_config(exclude_keys=None):
|
||||||
Obtains all relevant configuration from charm configuration required
|
Obtains all relevant configuration from charm configuration required
|
||||||
for initiating a relation to hacluster:
|
for initiating a relation to hacluster:
|
||||||
|
|
||||||
ha-bindiface, ha-mcastport, vip
|
ha-bindiface, ha-mcastport, vip, os-internal-hostname,
|
||||||
|
os-admin-hostname, os-public-hostname, os-access-hostname
|
||||||
|
|
||||||
param: exclude_keys: list of setting key(s) to be excluded.
|
param: exclude_keys: list of setting key(s) to be excluded.
|
||||||
returns: dict: A dict containing settings keyed by setting name.
|
returns: dict: A dict containing settings keyed by setting name.
|
||||||
raises: HAIncompleteConfig if settings are missing.
|
raises: HAIncompleteConfig if settings are missing or incorrect.
|
||||||
'''
|
'''
|
||||||
settings = ['ha-bindiface', 'ha-mcastport', 'vip']
|
settings = ['ha-bindiface', 'ha-mcastport', 'vip', 'os-internal-hostname',
|
||||||
|
'os-admin-hostname', 'os-public-hostname', 'os-access-hostname']
|
||||||
conf = {}
|
conf = {}
|
||||||
for setting in settings:
|
for setting in settings:
|
||||||
if exclude_keys and setting in exclude_keys:
|
if exclude_keys and setting in exclude_keys:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
conf[setting] = config_get(setting)
|
conf[setting] = config_get(setting)
|
||||||
missing = []
|
|
||||||
[missing.append(s) for s, v in six.iteritems(conf) if v is None]
|
if not valid_hacluster_config():
|
||||||
if missing:
|
raise HAIncorrectConfig('Insufficient or incorrect config data to '
|
||||||
log('Insufficient config data to configure hacluster.', level=ERROR)
|
'configure hacluster.')
|
||||||
raise HAIncompleteConfig
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
def valid_hacluster_config():
|
||||||
|
'''
|
||||||
|
Check that either vip or dns-ha is set. If dns-ha then one of os-*-hostname
|
||||||
|
must be set.
|
||||||
|
|
||||||
|
Note: ha-bindiface and ha-macastport both have defaults and will always
|
||||||
|
be set. We only care that either vip or dns-ha is set.
|
||||||
|
|
||||||
|
:returns: boolean: valid config returns true.
|
||||||
|
raises: HAIncompatibileConfig if settings conflict.
|
||||||
|
raises: HAIncompleteConfig if settings are missing.
|
||||||
|
'''
|
||||||
|
vip = config_get('vip')
|
||||||
|
dns = config_get('dns-ha')
|
||||||
|
if not(bool(vip) ^ bool(dns)):
|
||||||
|
msg = ('HA: Either vip or dns-ha must be set but not both in order to '
|
||||||
|
'use high availability')
|
||||||
|
status_set('blocked', msg)
|
||||||
|
raise HAIncorrectConfig(msg)
|
||||||
|
|
||||||
|
# If dns-ha then one of os-*-hostname must be set
|
||||||
|
if dns:
|
||||||
|
dns_settings = ['os-internal-hostname', 'os-admin-hostname',
|
||||||
|
'os-public-hostname', 'os-access-hostname']
|
||||||
|
# At this point it is unknown if one or all of the possible
|
||||||
|
# network spaces are in HA. Validate at least one is set which is
|
||||||
|
# the minimum required.
|
||||||
|
for setting in dns_settings:
|
||||||
|
if config_get(setting):
|
||||||
|
log('DNS HA: At least one hostname is set {}: {}'
|
||||||
|
''.format(setting, config_get(setting)),
|
||||||
|
level=DEBUG)
|
||||||
|
return True
|
||||||
|
|
||||||
|
msg = ('DNS HA: At least one os-*-hostname(s) must be set to use '
|
||||||
|
'DNS HA')
|
||||||
|
status_set('blocked', msg)
|
||||||
|
raise HAIncompleteConfig(msg)
|
||||||
|
|
||||||
|
log('VIP HA: VIP is set {}'.format(vip), level=DEBUG)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def canonical_url(configs, vip_setting='vip'):
|
def canonical_url(configs, vip_setting='vip'):
|
||||||
'''
|
'''
|
||||||
Returns the correct HTTP URL to this host given the state of HTTPS
|
Returns the correct HTTP URL to this host given the state of HTTPS
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
''' Helper for managing alternatives for file conflict resolution '''
|
''' Helper for managing alternatives for file conflict resolution '''
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
@ -43,9 +41,6 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||||
self.openstack = openstack
|
self.openstack = openstack
|
||||||
self.source = source
|
self.source = source
|
||||||
self.stable = stable
|
self.stable = stable
|
||||||
# Note(coreycb): this needs to be changed when new next branches come
|
|
||||||
# out.
|
|
||||||
self.current_next = "trusty"
|
|
||||||
|
|
||||||
def get_logger(self, name="deployment-logger", level=logging.DEBUG):
|
def get_logger(self, name="deployment-logger", level=logging.DEBUG):
|
||||||
"""Get a logger object that will log to stdout."""
|
"""Get a logger object that will log to stdout."""
|
||||||
|
@ -72,38 +67,34 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||||
|
|
||||||
self.log.info('OpenStackAmuletDeployment: determine branch locations')
|
self.log.info('OpenStackAmuletDeployment: determine branch locations')
|
||||||
|
|
||||||
# Charms outside the lp:~openstack-charmers namespace
|
# Charms outside the ~openstack-charmers
|
||||||
base_charms = ['mysql', 'mongodb', 'nrpe']
|
base_charms = {
|
||||||
|
'mysql': ['precise', 'trusty'],
|
||||||
# Force these charms to current series even when using an older series.
|
'mongodb': ['precise', 'trusty'],
|
||||||
# ie. Use trusty/nrpe even when series is precise, as the P charm
|
'nrpe': ['precise', 'trusty'],
|
||||||
# does not possess the necessary external master config and hooks.
|
}
|
||||||
force_series_current = ['nrpe']
|
|
||||||
|
|
||||||
if self.series in ['precise', 'trusty']:
|
|
||||||
base_series = self.series
|
|
||||||
else:
|
|
||||||
base_series = self.current_next
|
|
||||||
|
|
||||||
for svc in other_services:
|
for svc in other_services:
|
||||||
if svc['name'] in force_series_current:
|
|
||||||
base_series = self.current_next
|
|
||||||
# If a location has been explicitly set, use it
|
# If a location has been explicitly set, use it
|
||||||
if svc.get('location'):
|
if svc.get('location'):
|
||||||
continue
|
continue
|
||||||
if self.stable:
|
if svc['name'] in base_charms:
|
||||||
temp = 'lp:charms/{}/{}'
|
# NOTE: not all charms have support for all series we
|
||||||
svc['location'] = temp.format(base_series,
|
# want/need to test against, so fix to most recent
|
||||||
svc['name'])
|
# that each base charm supports
|
||||||
|
target_series = self.series
|
||||||
|
if self.series not in base_charms[svc['name']]:
|
||||||
|
target_series = base_charms[svc['name']][-1]
|
||||||
|
svc['location'] = 'cs:{}/{}'.format(target_series,
|
||||||
|
svc['name'])
|
||||||
|
elif self.stable:
|
||||||
|
svc['location'] = 'cs:{}/{}'.format(self.series,
|
||||||
|
svc['name'])
|
||||||
else:
|
else:
|
||||||
if svc['name'] in base_charms:
|
svc['location'] = 'cs:~openstack-charmers-next/{}/{}'.format(
|
||||||
temp = 'lp:charms/{}/{}'
|
self.series,
|
||||||
svc['location'] = temp.format(base_series,
|
svc['name']
|
||||||
svc['name'])
|
)
|
||||||
else:
|
|
||||||
temp = 'lp:~openstack-charmers/charms/{}/{}/next'
|
|
||||||
svc['location'] = temp.format(self.current_next,
|
|
||||||
svc['name'])
|
|
||||||
|
|
||||||
return other_services
|
return other_services
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import amulet
|
import amulet
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
|
@ -1438,7 +1436,7 @@ class AppArmorContext(OSContextGenerator):
|
||||||
:return ctxt: Dictionary of the apparmor profile or None
|
:return ctxt: Dictionary of the apparmor profile or None
|
||||||
"""
|
"""
|
||||||
if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
|
if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
|
||||||
ctxt = {'aa-profile-mode': config('aa-profile-mode')}
|
ctxt = {'aa_profile_mode': config('aa-profile-mode')}
|
||||||
else:
|
else:
|
||||||
ctxt = None
|
ctxt = None
|
||||||
return ctxt
|
return ctxt
|
||||||
|
@ -1482,10 +1480,10 @@ class AppArmorContext(OSContextGenerator):
|
||||||
log("Not enabling apparmor Profile")
|
log("Not enabling apparmor Profile")
|
||||||
return
|
return
|
||||||
self.install_aa_utils()
|
self.install_aa_utils()
|
||||||
cmd = ['aa-{}'.format(self.ctxt['aa-profile-mode'])]
|
cmd = ['aa-{}'.format(self.ctxt['aa_profile_mode'])]
|
||||||
cmd.append(self.ctxt['aa-profile'])
|
cmd.append(self.ctxt['aa_profile'])
|
||||||
log("Setting up the apparmor profile for {} in {} mode."
|
log("Setting up the apparmor profile for {} in {} mode."
|
||||||
"".format(self.ctxt['aa-profile'], self.ctxt['aa-profile-mode']))
|
"".format(self.ctxt['aa_profile'], self.ctxt['aa_profile_mode']))
|
||||||
try:
|
try:
|
||||||
check_call(cmd)
|
check_call(cmd)
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
|
@ -1494,12 +1492,12 @@ class AppArmorContext(OSContextGenerator):
|
||||||
# apparmor is yet unaware of the profile and aa-disable aa-profile
|
# apparmor is yet unaware of the profile and aa-disable aa-profile
|
||||||
# fails. If aa-disable learns to read profile files first this can
|
# fails. If aa-disable learns to read profile files first this can
|
||||||
# be removed.
|
# be removed.
|
||||||
if self.ctxt['aa-profile-mode'] == 'disable':
|
if self.ctxt['aa_profile_mode'] == 'disable':
|
||||||
log("Manually disabling the apparmor profile for {}."
|
log("Manually disabling the apparmor profile for {}."
|
||||||
"".format(self.ctxt['aa-profile']))
|
"".format(self.ctxt['aa_profile']))
|
||||||
self.manually_disable_aa_profile()
|
self.manually_disable_aa_profile()
|
||||||
return
|
return
|
||||||
status_set('blocked', "Apparmor profile {} failed to be set to {}."
|
status_set('blocked', "Apparmor profile {} failed to be set to {}."
|
||||||
"".format(self.ctxt['aa-profile'],
|
"".format(self.ctxt['aa_profile'],
|
||||||
self.ctxt['aa-profile-mode']))
|
self.ctxt['aa_profile_mode']))
|
||||||
raise e
|
raise e
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# Copyright 2016 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
class OSContextError(Exception):
|
class OSContextError(Exception):
|
||||||
"""Raised when an error occurs during context generation.
|
"""Raised when an error occurs during context generation.
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# dummy __init__.py to fool syncer into thinking this is a syncable python
|
# dummy __init__.py to fool syncer into thinking this is a syncable python
|
||||||
# module
|
# module
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Copyright 2016 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
|
@ -0,0 +1,128 @@
|
||||||
|
# Copyright 2014-2016 Canonical Limited.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2016 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# Openstack Charmers <
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Helpers for high availability.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from charmhelpers.core.hookenv import (
|
||||||
|
log,
|
||||||
|
relation_set,
|
||||||
|
charm_name,
|
||||||
|
config,
|
||||||
|
status_set,
|
||||||
|
DEBUG,
|
||||||
|
)
|
||||||
|
|
||||||
|
from charmhelpers.core.host import (
|
||||||
|
lsb_release
|
||||||
|
)
|
||||||
|
|
||||||
|
from charmhelpers.contrib.openstack.ip import (
|
||||||
|
resolve_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DNSHAException(Exception):
|
||||||
|
"""Raised when an error occurs setting up DNS HA
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def update_dns_ha_resource_params(resources, resource_params,
|
||||||
|
relation_id=None,
|
||||||
|
crm_ocf='ocf:maas:dns'):
|
||||||
|
""" Check for os-*-hostname settings and update resource dictionaries for
|
||||||
|
the HA relation.
|
||||||
|
|
||||||
|
@param resources: Pointer to dictionary of resources.
|
||||||
|
Usually instantiated in ha_joined().
|
||||||
|
@param resource_params: Pointer to dictionary of resource parameters.
|
||||||
|
Usually instantiated in ha_joined()
|
||||||
|
@param relation_id: Relation ID of the ha relation
|
||||||
|
@param crm_ocf: Corosync Open Cluster Framework resource agent to use for
|
||||||
|
DNS HA
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Validate the charm environment for DNS HA
|
||||||
|
assert_charm_supports_dns_ha()
|
||||||
|
|
||||||
|
settings = ['os-admin-hostname', 'os-internal-hostname',
|
||||||
|
'os-public-hostname', 'os-access-hostname']
|
||||||
|
|
||||||
|
# Check which DNS settings are set and update dictionaries
|
||||||
|
hostname_group = []
|
||||||
|
for setting in settings:
|
||||||
|
hostname = config(setting)
|
||||||
|
if hostname is None:
|
||||||
|
log('DNS HA: Hostname setting {} is None. Ignoring.'
|
||||||
|
''.format(setting),
|
||||||
|
DEBUG)
|
||||||
|
continue
|
||||||
|
m = re.search('os-(.+?)-hostname', setting)
|
||||||
|
if m:
|
||||||
|
networkspace = m.group(1)
|
||||||
|
else:
|
||||||
|
msg = ('Unexpected DNS hostname setting: {}. '
|
||||||
|
'Cannot determine network space name'
|
||||||
|
''.format(setting))
|
||||||
|
status_set('blocked', msg)
|
||||||
|
raise DNSHAException(msg)
|
||||||
|
|
||||||
|
hostname_key = 'res_{}_{}_hostname'.format(charm_name(), networkspace)
|
||||||
|
if hostname_key in hostname_group:
|
||||||
|
log('DNS HA: Resource {}: {} already exists in '
|
||||||
|
'hostname group - skipping'.format(hostname_key, hostname),
|
||||||
|
DEBUG)
|
||||||
|
continue
|
||||||
|
|
||||||
|
hostname_group.append(hostname_key)
|
||||||
|
resources[hostname_key] = crm_ocf
|
||||||
|
resource_params[hostname_key] = (
|
||||||
|
'params fqdn="{}" ip_address="{}" '
|
||||||
|
''.format(hostname, resolve_address(endpoint_type=networkspace,
|
||||||
|
override=False)))
|
||||||
|
|
||||||
|
if len(hostname_group) >= 1:
|
||||||
|
log('DNS HA: Hostname group is set with {} as members. '
|
||||||
|
'Informing the ha relation'.format(' '.join(hostname_group)),
|
||||||
|
DEBUG)
|
||||||
|
relation_set(relation_id=relation_id, groups={
|
||||||
|
'grp_{}_hostnames'.format(charm_name()): ' '.join(hostname_group)})
|
||||||
|
else:
|
||||||
|
msg = 'DNS HA: Hostname group has no members.'
|
||||||
|
status_set('blocked', msg)
|
||||||
|
raise DNSHAException(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def assert_charm_supports_dns_ha():
|
||||||
|
"""Validate prerequisites for DNS HA
|
||||||
|
The MAAS client is only available on Xenial or greater
|
||||||
|
"""
|
||||||
|
if lsb_release().get('DISTRIB_RELEASE') < '16.04':
|
||||||
|
msg = ('DNS HA is only supported on 16.04 and greater '
|
||||||
|
'versions of Ubuntu.')
|
||||||
|
status_set('blocked', msg)
|
||||||
|
raise DNSHAException(msg)
|
||||||
|
return True
|
|
@ -1,19 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
config,
|
config,
|
||||||
|
@ -109,7 +106,7 @@ def _get_address_override(endpoint_type=PUBLIC):
|
||||||
return addr_override.format(service_name=service_name())
|
return addr_override.format(service_name=service_name())
|
||||||
|
|
||||||
|
|
||||||
def resolve_address(endpoint_type=PUBLIC):
|
def resolve_address(endpoint_type=PUBLIC, override=True):
|
||||||
"""Return unit address depending on net config.
|
"""Return unit address depending on net config.
|
||||||
|
|
||||||
If unit is clustered with vip(s) and has net splits defined, return vip on
|
If unit is clustered with vip(s) and has net splits defined, return vip on
|
||||||
|
@ -119,10 +116,13 @@ def resolve_address(endpoint_type=PUBLIC):
|
||||||
split if one is configured, or a Juju 2.0 extra-binding has been used.
|
split if one is configured, or a Juju 2.0 extra-binding has been used.
|
||||||
|
|
||||||
:param endpoint_type: Network endpoing type
|
:param endpoint_type: Network endpoing type
|
||||||
|
:param override: Accept hostname overrides or not
|
||||||
"""
|
"""
|
||||||
resolved_address = _get_address_override(endpoint_type)
|
resolved_address = None
|
||||||
if resolved_address:
|
if override:
|
||||||
return resolved_address
|
resolved_address = _get_address_override(endpoint_type)
|
||||||
|
if resolved_address:
|
||||||
|
return resolved_address
|
||||||
|
|
||||||
vips = config('vip')
|
vips = config('vip')
|
||||||
if vips:
|
if vips:
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Various utilies for dealing with Neutron and the renaming from Quantum.
|
# Various utilies for dealing with Neutron and the renaming from Quantum.
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# dummy __init__.py to fool syncer into thinking this is a syncable python
|
# dummy __init__.py to fool syncer into thinking this is a syncable python
|
||||||
# module
|
# module
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Common python helper functions used for OpenStack charms.
|
# Common python helper functions used for OpenStack charms.
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -51,6 +49,7 @@ from charmhelpers.core.hookenv import (
|
||||||
related_units,
|
related_units,
|
||||||
relation_ids,
|
relation_ids,
|
||||||
relation_set,
|
relation_set,
|
||||||
|
service_name,
|
||||||
status_set,
|
status_set,
|
||||||
hook_name
|
hook_name
|
||||||
)
|
)
|
||||||
|
@ -207,6 +206,26 @@ PACKAGE_CODENAMES = {
|
||||||
]),
|
]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIT_DEFAULT_REPOS = {
|
||||||
|
'requirements': 'git://github.com/openstack/requirements',
|
||||||
|
'cinder': 'git://github.com/openstack/cinder',
|
||||||
|
'glance': 'git://github.com/openstack/glance',
|
||||||
|
'horizon': 'git://github.com/openstack/horizon',
|
||||||
|
'keystone': 'git://github.com/openstack/keystone',
|
||||||
|
'neutron': 'git://github.com/openstack/neutron',
|
||||||
|
'neutron-fwaas': 'git://github.com/openstack/neutron-fwaas',
|
||||||
|
'neutron-lbaas': 'git://github.com/openstack/neutron-lbaas',
|
||||||
|
'neutron-vpnaas': 'git://github.com/openstack/neutron-vpnaas',
|
||||||
|
'nova': 'git://github.com/openstack/nova',
|
||||||
|
}
|
||||||
|
|
||||||
|
GIT_DEFAULT_BRANCHES = {
|
||||||
|
'kilo': 'stable/kilo',
|
||||||
|
'liberty': 'stable/liberty',
|
||||||
|
'mitaka': 'stable/mitaka',
|
||||||
|
'master': 'master',
|
||||||
|
}
|
||||||
|
|
||||||
DEFAULT_LOOPBACK_SIZE = '5G'
|
DEFAULT_LOOPBACK_SIZE = '5G'
|
||||||
|
|
||||||
|
|
||||||
|
@ -703,6 +722,67 @@ def git_install_requested():
|
||||||
requirements_dir = None
|
requirements_dir = None
|
||||||
|
|
||||||
|
|
||||||
|
def git_default_repos(projects_yaml):
|
||||||
|
"""
|
||||||
|
Returns default repos if a default openstack-origin-git value is specified.
|
||||||
|
"""
|
||||||
|
service = service_name()
|
||||||
|
core_project = service
|
||||||
|
|
||||||
|
for default, branch in GIT_DEFAULT_BRANCHES.iteritems():
|
||||||
|
if projects_yaml == default:
|
||||||
|
|
||||||
|
# add the requirements repo first
|
||||||
|
repo = {
|
||||||
|
'name': 'requirements',
|
||||||
|
'repository': GIT_DEFAULT_REPOS['requirements'],
|
||||||
|
'branch': branch,
|
||||||
|
}
|
||||||
|
repos = [repo]
|
||||||
|
|
||||||
|
# NOTE(coreycb): This is a temp work-around until the requirements
|
||||||
|
# repo moves from stable/kilo branch to kilo-eol tag. The core
|
||||||
|
# repos have already done this.
|
||||||
|
if default == 'kilo':
|
||||||
|
branch = 'kilo-eol'
|
||||||
|
|
||||||
|
# neutron-* and nova-* charms require some additional repos
|
||||||
|
if service in ['neutron-api', 'neutron-gateway',
|
||||||
|
'neutron-openvswitch']:
|
||||||
|
core_project = 'neutron'
|
||||||
|
for project in ['neutron-fwaas', 'neutron-lbaas',
|
||||||
|
'neutron-vpnaas', 'nova']:
|
||||||
|
repo = {
|
||||||
|
'name': project,
|
||||||
|
'repository': GIT_DEFAULT_REPOS[project],
|
||||||
|
'branch': branch,
|
||||||
|
}
|
||||||
|
repos.append(repo)
|
||||||
|
|
||||||
|
elif service in ['nova-cloud-controller', 'nova-compute']:
|
||||||
|
core_project = 'nova'
|
||||||
|
repo = {
|
||||||
|
'name': 'neutron',
|
||||||
|
'repository': GIT_DEFAULT_REPOS['neutron'],
|
||||||
|
'branch': branch,
|
||||||
|
}
|
||||||
|
repos.append(repo)
|
||||||
|
elif service == 'openstack-dashboard':
|
||||||
|
core_project = 'horizon'
|
||||||
|
|
||||||
|
# finally add the current service's core project repo
|
||||||
|
repo = {
|
||||||
|
'name': core_project,
|
||||||
|
'repository': GIT_DEFAULT_REPOS[core_project],
|
||||||
|
'branch': branch,
|
||||||
|
}
|
||||||
|
repos.append(repo)
|
||||||
|
|
||||||
|
return yaml.dump(dict(repositories=repos))
|
||||||
|
|
||||||
|
return projects_yaml
|
||||||
|
|
||||||
|
|
||||||
def _git_yaml_load(projects_yaml):
|
def _git_yaml_load(projects_yaml):
|
||||||
"""
|
"""
|
||||||
Load the specified yaml into a dictionary.
|
Load the specified yaml into a dictionary.
|
||||||
|
@ -760,6 +840,7 @@ def git_clone_and_install(projects_yaml, core_project):
|
||||||
pip_install(p, upgrade=True, proxy=http_proxy,
|
pip_install(p, upgrade=True, proxy=http_proxy,
|
||||||
venv=os.path.join(parent_dir, 'venv'))
|
venv=os.path.join(parent_dir, 'venv'))
|
||||||
|
|
||||||
|
constraints = None
|
||||||
for p in projects['repositories']:
|
for p in projects['repositories']:
|
||||||
repo = p['repository']
|
repo = p['repository']
|
||||||
branch = p['branch']
|
branch = p['branch']
|
||||||
|
@ -771,10 +852,15 @@ def git_clone_and_install(projects_yaml, core_project):
|
||||||
parent_dir, http_proxy,
|
parent_dir, http_proxy,
|
||||||
update_requirements=False)
|
update_requirements=False)
|
||||||
requirements_dir = repo_dir
|
requirements_dir = repo_dir
|
||||||
|
constraints = os.path.join(repo_dir, "upper-constraints.txt")
|
||||||
|
# upper-constraints didn't exist until after icehouse
|
||||||
|
if not os.path.isfile(constraints):
|
||||||
|
constraints = None
|
||||||
else:
|
else:
|
||||||
repo_dir = _git_clone_and_install_single(repo, branch, depth,
|
repo_dir = _git_clone_and_install_single(repo, branch, depth,
|
||||||
parent_dir, http_proxy,
|
parent_dir, http_proxy,
|
||||||
update_requirements=True)
|
update_requirements=True,
|
||||||
|
constraints=constraints)
|
||||||
|
|
||||||
os.environ = old_environ
|
os.environ = old_environ
|
||||||
|
|
||||||
|
@ -806,7 +892,7 @@ def _git_ensure_key_exists(key, keys):
|
||||||
|
|
||||||
|
|
||||||
def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
|
def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
|
||||||
update_requirements):
|
update_requirements, constraints=None):
|
||||||
"""
|
"""
|
||||||
Clone and install a single git repository.
|
Clone and install a single git repository.
|
||||||
"""
|
"""
|
||||||
|
@ -829,9 +915,10 @@ def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
|
||||||
|
|
||||||
juju_log('Installing git repo from dir: {}'.format(repo_dir))
|
juju_log('Installing git repo from dir: {}'.format(repo_dir))
|
||||||
if http_proxy:
|
if http_proxy:
|
||||||
pip_install(repo_dir, proxy=http_proxy, venv=venv)
|
pip_install(repo_dir, proxy=http_proxy, venv=venv,
|
||||||
|
constraints=constraints)
|
||||||
else:
|
else:
|
||||||
pip_install(repo_dir, venv=venv)
|
pip_install(repo_dir, venv=venv, constraints=constraints)
|
||||||
|
|
||||||
return repo_dir
|
return repo_dir
|
||||||
|
|
||||||
|
@ -911,6 +998,7 @@ def git_generate_systemd_init_files(templates_dir):
|
||||||
script generation, which is used by the OpenStack packages.
|
script generation, which is used by the OpenStack packages.
|
||||||
"""
|
"""
|
||||||
for f in os.listdir(templates_dir):
|
for f in os.listdir(templates_dir):
|
||||||
|
# Create the init script and systemd unit file from the template
|
||||||
if f.endswith(".init.in"):
|
if f.endswith(".init.in"):
|
||||||
init_in_file = f
|
init_in_file = f
|
||||||
init_file = f[:-8]
|
init_file = f[:-8]
|
||||||
|
@ -936,10 +1024,47 @@ def git_generate_systemd_init_files(templates_dir):
|
||||||
os.remove(init_dest)
|
os.remove(init_dest)
|
||||||
if os.path.exists(service_dest):
|
if os.path.exists(service_dest):
|
||||||
os.remove(service_dest)
|
os.remove(service_dest)
|
||||||
shutil.move(init_source, init_dest)
|
shutil.copyfile(init_source, init_dest)
|
||||||
shutil.move(service_source, service_dest)
|
shutil.copyfile(service_source, service_dest)
|
||||||
os.chmod(init_dest, 0o755)
|
os.chmod(init_dest, 0o755)
|
||||||
|
|
||||||
|
for f in os.listdir(templates_dir):
|
||||||
|
# If there's a service.in file, use it instead of the generated one
|
||||||
|
if f.endswith(".service.in"):
|
||||||
|
service_in_file = f
|
||||||
|
service_file = f[:-3]
|
||||||
|
|
||||||
|
service_in_source = os.path.join(templates_dir, service_in_file)
|
||||||
|
service_source = os.path.join(templates_dir, service_file)
|
||||||
|
service_dest = os.path.join('/lib/systemd/system', service_file)
|
||||||
|
|
||||||
|
shutil.copyfile(service_in_source, service_source)
|
||||||
|
|
||||||
|
if os.path.exists(service_dest):
|
||||||
|
os.remove(service_dest)
|
||||||
|
shutil.copyfile(service_source, service_dest)
|
||||||
|
|
||||||
|
for f in os.listdir(templates_dir):
|
||||||
|
# Generate the systemd unit if there's no existing .service.in
|
||||||
|
if f.endswith(".init.in"):
|
||||||
|
init_in_file = f
|
||||||
|
init_file = f[:-8]
|
||||||
|
service_in_file = "{}.service.in".format(init_file)
|
||||||
|
service_file = "{}.service".format(init_file)
|
||||||
|
|
||||||
|
init_in_source = os.path.join(templates_dir, init_in_file)
|
||||||
|
service_in_source = os.path.join(templates_dir, service_in_file)
|
||||||
|
service_source = os.path.join(templates_dir, service_file)
|
||||||
|
service_dest = os.path.join('/lib/systemd/system', service_file)
|
||||||
|
|
||||||
|
if not os.path.exists(service_in_source):
|
||||||
|
cmd = ['pkgos-gen-systemd-unit', init_in_source]
|
||||||
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
if os.path.exists(service_dest):
|
||||||
|
os.remove(service_dest)
|
||||||
|
shutil.copyfile(service_source, service_dest)
|
||||||
|
|
||||||
|
|
||||||
def os_workload_status(configs, required_interfaces, charm_func=None):
|
def os_workload_status(configs, required_interfaces, charm_func=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -80,7 +78,8 @@ def pip_install_requirements(requirements, constraints=None, **options):
|
||||||
pip_execute(command)
|
pip_execute(command)
|
||||||
|
|
||||||
|
|
||||||
def pip_install(package, fatal=False, upgrade=False, venv=None, **options):
|
def pip_install(package, fatal=False, upgrade=False, venv=None,
|
||||||
|
constraints=None, **options):
|
||||||
"""Install a python package"""
|
"""Install a python package"""
|
||||||
if venv:
|
if venv:
|
||||||
venv_python = os.path.join(venv, 'bin/pip')
|
venv_python = os.path.join(venv, 'bin/pip')
|
||||||
|
@ -95,6 +94,9 @@ def pip_install(package, fatal=False, upgrade=False, venv=None, **options):
|
||||||
if upgrade:
|
if upgrade:
|
||||||
command.append('--upgrade')
|
command.append('--upgrade')
|
||||||
|
|
||||||
|
if constraints:
|
||||||
|
command.extend(['-c', constraints])
|
||||||
|
|
||||||
if isinstance(package, list):
|
if isinstance(package, list):
|
||||||
command.extend(package)
|
command.extend(package)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2012 Canonical Ltd.
|
# Copyright 2012 Canonical Ltd.
|
||||||
|
@ -1231,7 +1229,7 @@ class CephConfContext(object):
|
||||||
|
|
||||||
permitted = self.permitted_sections
|
permitted = self.permitted_sections
|
||||||
if permitted:
|
if permitted:
|
||||||
diff = set(conf.keys()).symmetric_difference(set(permitted))
|
diff = set(conf.keys()).difference(set(permitted))
|
||||||
if diff:
|
if diff:
|
||||||
log("Config-flags contains invalid keys '%s' - they will be "
|
log("Config-flags contains invalid keys '%s' - they will be "
|
||||||
"ignored" % (', '.join(diff)), level=WARNING)
|
"ignored" % (', '.join(diff)), level=WARNING)
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from subprocess import (
|
from subprocess import (
|
||||||
CalledProcessError,
|
CalledProcessError,
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2014 Canonical Ltd.
|
# Copyright 2014 Canonical Ltd.
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
__author__ = 'Jorge Niedbalski <niedbalski@ubuntu.com>'
|
__author__ = 'Jorge Niedbalski <niedbalski@ubuntu.com>'
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
"Interactions with the Juju environment"
|
"Interactions with the Juju environment"
|
||||||
# Copyright 2013 Canonical Ltd.
|
# Copyright 2013 Canonical Ltd.
|
||||||
|
@ -1006,4 +1004,4 @@ def network_get_primary_address(binding):
|
||||||
:raise: NotImplementedError if run on Juju < 2.0
|
:raise: NotImplementedError if run on Juju < 2.0
|
||||||
'''
|
'''
|
||||||
cmd = ['network-get', '--primary-address', binding]
|
cmd = ['network-get', '--primary-address', binding]
|
||||||
return subprocess.check_output(cmd).strip()
|
return subprocess.check_output(cmd).decode('UTF-8').strip()
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
"""Tools for working with the host system"""
|
"""Tools for working with the host system"""
|
||||||
# Copyright 2012 Canonical Ltd.
|
# Copyright 2012 Canonical Ltd.
|
||||||
|
@ -176,7 +174,7 @@ def init_is_systemd():
|
||||||
|
|
||||||
|
|
||||||
def adduser(username, password=None, shell='/bin/bash', system_user=False,
|
def adduser(username, password=None, shell='/bin/bash', system_user=False,
|
||||||
primary_group=None, secondary_groups=None):
|
primary_group=None, secondary_groups=None, uid=None):
|
||||||
"""Add a user to the system.
|
"""Add a user to the system.
|
||||||
|
|
||||||
Will log but otherwise succeed if the user already exists.
|
Will log but otherwise succeed if the user already exists.
|
||||||
|
@ -187,15 +185,21 @@ def adduser(username, password=None, shell='/bin/bash', system_user=False,
|
||||||
:param bool system_user: Whether to create a login or system user
|
:param bool system_user: Whether to create a login or system user
|
||||||
:param str primary_group: Primary group for user; defaults to username
|
:param str primary_group: Primary group for user; defaults to username
|
||||||
:param list secondary_groups: Optional list of additional groups
|
:param list secondary_groups: Optional list of additional groups
|
||||||
|
:param int uid: UID for user being created
|
||||||
|
|
||||||
:returns: The password database entry struct, as returned by `pwd.getpwnam`
|
:returns: The password database entry struct, as returned by `pwd.getpwnam`
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
user_info = pwd.getpwnam(username)
|
user_info = pwd.getpwnam(username)
|
||||||
log('user {0} already exists!'.format(username))
|
log('user {0} already exists!'.format(username))
|
||||||
|
if uid:
|
||||||
|
user_info = pwd.getpwuid(int(uid))
|
||||||
|
log('user with uid {0} already exists!'.format(uid))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log('creating user {0}'.format(username))
|
log('creating user {0}'.format(username))
|
||||||
cmd = ['useradd']
|
cmd = ['useradd']
|
||||||
|
if uid:
|
||||||
|
cmd.extend(['--uid', str(uid)])
|
||||||
if system_user or password is None:
|
if system_user or password is None:
|
||||||
cmd.append('--system')
|
cmd.append('--system')
|
||||||
else:
|
else:
|
||||||
|
@ -230,14 +234,58 @@ def user_exists(username):
|
||||||
return user_exists
|
return user_exists
|
||||||
|
|
||||||
|
|
||||||
def add_group(group_name, system_group=False):
|
def uid_exists(uid):
|
||||||
"""Add a group to the system"""
|
"""Check if a uid exists"""
|
||||||
|
try:
|
||||||
|
pwd.getpwuid(uid)
|
||||||
|
uid_exists = True
|
||||||
|
except KeyError:
|
||||||
|
uid_exists = False
|
||||||
|
return uid_exists
|
||||||
|
|
||||||
|
|
||||||
|
def group_exists(groupname):
|
||||||
|
"""Check if a group exists"""
|
||||||
|
try:
|
||||||
|
grp.getgrnam(groupname)
|
||||||
|
group_exists = True
|
||||||
|
except KeyError:
|
||||||
|
group_exists = False
|
||||||
|
return group_exists
|
||||||
|
|
||||||
|
|
||||||
|
def gid_exists(gid):
|
||||||
|
"""Check if a gid exists"""
|
||||||
|
try:
|
||||||
|
grp.getgrgid(gid)
|
||||||
|
gid_exists = True
|
||||||
|
except KeyError:
|
||||||
|
gid_exists = False
|
||||||
|
return gid_exists
|
||||||
|
|
||||||
|
|
||||||
|
def add_group(group_name, system_group=False, gid=None):
|
||||||
|
"""Add a group to the system
|
||||||
|
|
||||||
|
Will log but otherwise succeed if the group already exists.
|
||||||
|
|
||||||
|
:param str group_name: group to create
|
||||||
|
:param bool system_group: Create system group
|
||||||
|
:param int gid: GID for user being created
|
||||||
|
|
||||||
|
:returns: The password database entry struct, as returned by `grp.getgrnam`
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
group_info = grp.getgrnam(group_name)
|
group_info = grp.getgrnam(group_name)
|
||||||
log('group {0} already exists!'.format(group_name))
|
log('group {0} already exists!'.format(group_name))
|
||||||
|
if gid:
|
||||||
|
group_info = grp.getgrgid(gid)
|
||||||
|
log('group with gid {0} already exists!'.format(gid))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log('creating group {0}'.format(group_name))
|
log('creating group {0}'.format(group_name))
|
||||||
cmd = ['addgroup']
|
cmd = ['addgroup']
|
||||||
|
if gid:
|
||||||
|
cmd.extend(['--gid', str(gid)])
|
||||||
if system_group:
|
if system_group:
|
||||||
cmd.append('--system')
|
cmd.append('--system')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2,19 +2,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from charmhelpers.core import fstab
|
from charmhelpers.core import fstab
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
|
__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from .base import * # NOQA
|
from .base import * # NOQA
|
||||||
from .helpers import * # NOQA
|
from .helpers import * # NOQA
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,17 @@
|
||||||
#
|
#
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# Authors:
|
# Authors:
|
||||||
# Kapil Thangavelu <kapil.foss@gmail.com>
|
# Kapil Thangavelu <kapil.foss@gmail.com>
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
@ -398,16 +396,13 @@ def install_remote(source, *args, **kwargs):
|
||||||
# We ONLY check for True here because can_handle may return a string
|
# We ONLY check for True here because can_handle may return a string
|
||||||
# explaining why it can't handle a given source.
|
# explaining why it can't handle a given source.
|
||||||
handlers = [h for h in plugins() if h.can_handle(source) is True]
|
handlers = [h for h in plugins() if h.can_handle(source) is True]
|
||||||
installed_to = None
|
|
||||||
for handler in handlers:
|
for handler in handlers:
|
||||||
try:
|
try:
|
||||||
installed_to = handler.install(source, *args, **kwargs)
|
return handler.install(source, *args, **kwargs)
|
||||||
except UnhandledSource as e:
|
except UnhandledSource as e:
|
||||||
log('Install source attempt unsuccessful: {}'.format(e),
|
log('Install source attempt unsuccessful: {}'.format(e),
|
||||||
level='WARNING')
|
level='WARNING')
|
||||||
if not installed_to:
|
raise UnhandledSource("No handler found for source {}".format(source))
|
||||||
raise UnhandledSource("No handler found for source {}".format(source))
|
|
||||||
return installed_to
|
|
||||||
|
|
||||||
|
|
||||||
def install_from_config(config_var_name):
|
def install_from_config(config_var_name):
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
@ -42,15 +40,23 @@ class BzrUrlFetchHandler(BaseFetchHandler):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def branch(self, source, dest):
|
def branch(self, source, dest, revno=None):
|
||||||
if not self.can_handle(source):
|
if not self.can_handle(source):
|
||||||
raise UnhandledSource("Cannot handle {}".format(source))
|
raise UnhandledSource("Cannot handle {}".format(source))
|
||||||
|
cmd_opts = []
|
||||||
|
if revno:
|
||||||
|
cmd_opts += ['-r', str(revno)]
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
check_call(['bzr', 'pull', '--overwrite', '-d', dest, source])
|
cmd = ['bzr', 'pull']
|
||||||
|
cmd += cmd_opts
|
||||||
|
cmd += ['--overwrite', '-d', dest, source]
|
||||||
else:
|
else:
|
||||||
check_call(['bzr', 'branch', source, dest])
|
cmd = ['bzr', 'branch']
|
||||||
|
cmd += cmd_opts
|
||||||
|
cmd += [source, dest]
|
||||||
|
check_call(cmd)
|
||||||
|
|
||||||
def install(self, source, dest=None):
|
def install(self, source, dest=None, revno=None):
|
||||||
url_parts = self.parse_url(source)
|
url_parts = self.parse_url(source)
|
||||||
branch_name = url_parts.path.strip("/").split("/")[-1]
|
branch_name = url_parts.path.strip("/").split("/")[-1]
|
||||||
if dest:
|
if dest:
|
||||||
|
@ -59,10 +65,11 @@ class BzrUrlFetchHandler(BaseFetchHandler):
|
||||||
dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
|
dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
|
||||||
branch_name)
|
branch_name)
|
||||||
|
|
||||||
if not os.path.exists(dest_dir):
|
if dest and not os.path.exists(dest):
|
||||||
mkdir(dest_dir, perms=0o755)
|
mkdir(dest, perms=0o755)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.branch(source, dest_dir)
|
self.branch(source, dest_dir, revno)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise UnhandledSource(e.strerror)
|
raise UnhandledSource(e.strerror)
|
||||||
return dest_dir
|
return dest_dir
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from subprocess import check_call, CalledProcessError
|
from subprocess import check_call, CalledProcessError
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
"Tools for working with files injected into a charm just before deployment."
|
"Tools for working with files injected into a charm just before deployment."
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Bootstrap charm-helpers, installing its dependencies if necessary using
|
# Bootstrap charm-helpers, installing its dependencies if necessary using
|
||||||
# only standard libraries.
|
# only standard libraries.
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import amulet
|
import amulet
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
@ -43,9 +41,6 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||||
self.openstack = openstack
|
self.openstack = openstack
|
||||||
self.source = source
|
self.source = source
|
||||||
self.stable = stable
|
self.stable = stable
|
||||||
# Note(coreycb): this needs to be changed when new next branches come
|
|
||||||
# out.
|
|
||||||
self.current_next = "trusty"
|
|
||||||
|
|
||||||
def get_logger(self, name="deployment-logger", level=logging.DEBUG):
|
def get_logger(self, name="deployment-logger", level=logging.DEBUG):
|
||||||
"""Get a logger object that will log to stdout."""
|
"""Get a logger object that will log to stdout."""
|
||||||
|
@ -72,38 +67,34 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||||
|
|
||||||
self.log.info('OpenStackAmuletDeployment: determine branch locations')
|
self.log.info('OpenStackAmuletDeployment: determine branch locations')
|
||||||
|
|
||||||
# Charms outside the lp:~openstack-charmers namespace
|
# Charms outside the ~openstack-charmers
|
||||||
base_charms = ['mysql', 'mongodb', 'nrpe']
|
base_charms = {
|
||||||
|
'mysql': ['precise', 'trusty'],
|
||||||
# Force these charms to current series even when using an older series.
|
'mongodb': ['precise', 'trusty'],
|
||||||
# ie. Use trusty/nrpe even when series is precise, as the P charm
|
'nrpe': ['precise', 'trusty'],
|
||||||
# does not possess the necessary external master config and hooks.
|
}
|
||||||
force_series_current = ['nrpe']
|
|
||||||
|
|
||||||
if self.series in ['precise', 'trusty']:
|
|
||||||
base_series = self.series
|
|
||||||
else:
|
|
||||||
base_series = self.current_next
|
|
||||||
|
|
||||||
for svc in other_services:
|
for svc in other_services:
|
||||||
if svc['name'] in force_series_current:
|
|
||||||
base_series = self.current_next
|
|
||||||
# If a location has been explicitly set, use it
|
# If a location has been explicitly set, use it
|
||||||
if svc.get('location'):
|
if svc.get('location'):
|
||||||
continue
|
continue
|
||||||
if self.stable:
|
if svc['name'] in base_charms:
|
||||||
temp = 'lp:charms/{}/{}'
|
# NOTE: not all charms have support for all series we
|
||||||
svc['location'] = temp.format(base_series,
|
# want/need to test against, so fix to most recent
|
||||||
svc['name'])
|
# that each base charm supports
|
||||||
|
target_series = self.series
|
||||||
|
if self.series not in base_charms[svc['name']]:
|
||||||
|
target_series = base_charms[svc['name']][-1]
|
||||||
|
svc['location'] = 'cs:{}/{}'.format(target_series,
|
||||||
|
svc['name'])
|
||||||
|
elif self.stable:
|
||||||
|
svc['location'] = 'cs:{}/{}'.format(self.series,
|
||||||
|
svc['name'])
|
||||||
else:
|
else:
|
||||||
if svc['name'] in base_charms:
|
svc['location'] = 'cs:~openstack-charmers-next/{}/{}'.format(
|
||||||
temp = 'lp:charms/{}/{}'
|
self.series,
|
||||||
svc['location'] = temp.format(base_series,
|
svc['name']
|
||||||
svc['name'])
|
)
|
||||||
else:
|
|
||||||
temp = 'lp:~openstack-charmers/charms/{}/{}/next'
|
|
||||||
svc['location'] = temp.format(self.current_next,
|
|
||||||
svc['name'])
|
|
||||||
|
|
||||||
return other_services
|
return other_services
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
# Copyright 2014-2015 Canonical Limited.
|
# Copyright 2014-2015 Canonical Limited.
|
||||||
#
|
#
|
||||||
# This file is part of charm-helpers.
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# charm-helpers is free software: you can redistribute it and/or modify
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
#
|
||||||
# charm-helpers is distributed in the hope that it will be useful,
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# GNU Lesser General Public License for more details.
|
# See the License for the specific language governing permissions and
|
||||||
#
|
# limitations under the License.
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
|
||||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import amulet
|
import amulet
|
||||||
import json
|
import json
|
||||||
|
|
Loading…
Reference in New Issue