Migrate to python3 only charm
Change-Id: Ia4bcf570d40083625358fdd4fea14202ff3d89af
This commit is contained in:
parent
a070870967
commit
834cde35ec
|
@ -1,4 +1,3 @@
|
||||||
- project:
|
- project:
|
||||||
templates:
|
templates:
|
||||||
- python-charm-jobs
|
- python35-charm-jobs
|
||||||
- openstack-python35-jobs-nonvoting
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Copyright 2016 Canonical Ltd
|
# Copyright 2016 Canonical Ltd
|
||||||
#
|
#
|
||||||
|
@ -17,13 +17,23 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append('hooks/')
|
_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
|
||||||
|
_root = os.path.abspath(os.path.join(_path, '..'))
|
||||||
|
|
||||||
|
|
||||||
|
def _add_path(path):
|
||||||
|
if path not in sys.path:
|
||||||
|
sys.path.insert(1, path)
|
||||||
|
|
||||||
|
_add_path(_hooks)
|
||||||
|
_add_path(_root)
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import action_fail
|
from charmhelpers.core.hookenv import action_fail
|
||||||
from cinder_utils import (
|
from cinder_utils import (
|
||||||
pause_unit_helper,
|
pause_unit_helper,
|
||||||
resume_unit_helper,
|
|
||||||
register_configs,
|
register_configs,
|
||||||
|
resume_unit_helper,
|
||||||
)
|
)
|
||||||
import cinder_manage
|
import cinder_manage
|
||||||
|
|
||||||
|
@ -57,7 +67,7 @@ def main(args):
|
||||||
try:
|
try:
|
||||||
action = ACTIONS[action_name]
|
action = ACTIONS[action_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return "Action %s undefined" % action_name
|
return "Action {} undefined".format(action_name)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
action(args)
|
action(args)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Copyright 2016 Canonical Ltd
|
# Copyright 2016 Canonical Ltd
|
||||||
#
|
#
|
||||||
|
@ -14,21 +14,33 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import subprocess
|
|
||||||
|
|
||||||
sys.path.append('hooks/')
|
|
||||||
|
_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
|
||||||
|
_root = os.path.abspath(os.path.join(_path, '..'))
|
||||||
|
|
||||||
|
|
||||||
|
def _add_path(path):
|
||||||
|
if path not in sys.path:
|
||||||
|
sys.path.insert(1, path)
|
||||||
|
|
||||||
|
_add_path(_hooks)
|
||||||
|
_add_path(_root)
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
os_release,
|
|
||||||
CompareOpenStackReleases,
|
CompareOpenStackReleases,
|
||||||
|
os_release,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
action_set,
|
|
||||||
action_fail,
|
action_fail,
|
||||||
action_get,
|
action_get,
|
||||||
|
action_set,
|
||||||
log,
|
log,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,14 +62,42 @@ class CinderService():
|
||||||
|
|
||||||
|
|
||||||
def cinder_manage_remove(binary, hostname):
|
def cinder_manage_remove(binary, hostname):
|
||||||
return subprocess.check_call(["cinder-manage", "service", "remove", binary,
|
"""Call cinder-manage service remove <binary> <hostname>
|
||||||
hostname])
|
|
||||||
|
:param binary: The binary (executable) for the service to remove
|
||||||
|
:type binary: str
|
||||||
|
:param hostname: The host name associated with the binary
|
||||||
|
:type hostname: str
|
||||||
|
:returns: 0 if the cinder-manage service command succeeds
|
||||||
|
:rtype: int
|
||||||
|
:raises: subprocess.CalledProcessError if the call fails
|
||||||
|
"""
|
||||||
|
return (subprocess
|
||||||
|
.check_call(["cinder-manage",
|
||||||
|
"service",
|
||||||
|
"remove",
|
||||||
|
binary,
|
||||||
|
hostname]))
|
||||||
|
|
||||||
|
|
||||||
def cinder_manage_volume_update_host(currenthost, newhost):
|
def cinder_manage_volume_update_host(currenthost, newhost):
|
||||||
return subprocess.check_call(["cinder-manage", "volume", "update_host",
|
"""Call cinder-manage volume update_host --currenthost <current-host> \\
|
||||||
"--currenthost", currenthost,
|
--newhost <newhost>
|
||||||
"--newhost", newhost])
|
|
||||||
|
:param currenthost: the hostname to update to newhost
|
||||||
|
:type currenthost: str
|
||||||
|
:param newhost: the new name to update the host to
|
||||||
|
:type newhost: str
|
||||||
|
:returns: 0 if the cinder-manage volume command succeeds
|
||||||
|
:rtype: int
|
||||||
|
:raises: subprocess.CalledProcessError if the call fails
|
||||||
|
"""
|
||||||
|
return (subprocess
|
||||||
|
.check_call(["cinder-manage",
|
||||||
|
"volume",
|
||||||
|
"update_host",
|
||||||
|
"--currenthost", currenthost,
|
||||||
|
"--newhost", newhost]))
|
||||||
|
|
||||||
|
|
||||||
def cinder_manage_service_list():
|
def cinder_manage_service_list():
|
||||||
|
@ -83,15 +123,16 @@ def remove_services(args):
|
||||||
removed_services = []
|
removed_services = []
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
log("Removing binary:%s, hostname:%s" % (service.binary, service.host))
|
log("Removing binary:{}, hostname:{}"
|
||||||
|
.format(service.binary, service.host))
|
||||||
try:
|
try:
|
||||||
if CompareOpenStackReleases(os_release("cinder")) >= "liberty":
|
if CompareOpenStackReleases(os_release("cinder")) >= "liberty":
|
||||||
cinder_manage_remove(service.binary, service.host)
|
cinder_manage_remove(service.binary, service.host)
|
||||||
else:
|
else:
|
||||||
action_fail("Cannot remove service: %s" % service.host)
|
action_fail("Cannot remove service: {}".format(service.host))
|
||||||
except:
|
except:
|
||||||
action_set({'traceback': traceback.format_exc()})
|
action_set({'traceback': traceback.format_exc()})
|
||||||
action_fail("Cannot remove service: %s" % service.host)
|
action_fail("Cannot remove service: {}".format(service.host))
|
||||||
else:
|
else:
|
||||||
removed_services.append(service.host)
|
removed_services.append(service.host)
|
||||||
|
|
||||||
|
@ -108,10 +149,8 @@ def _rename_volume_host(currenthost, newhost):
|
||||||
action_set({'traceback': traceback.format_exc()})
|
action_set({'traceback': traceback.format_exc()})
|
||||||
action_fail("Cannot update host {}".format(currenthost))
|
action_fail("Cannot update host {}".format(currenthost))
|
||||||
else:
|
else:
|
||||||
action_fail(
|
action_fail("Cannot update host attribute from {}, {} not found"
|
||||||
"Cannot update host attribute from {}, {} not found".format(
|
.format(currenthost, currenthost))
|
||||||
currenthost,
|
|
||||||
currenthost))
|
|
||||||
|
|
||||||
|
|
||||||
def rename_volume_host(args):
|
def rename_volume_host(args):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Copyright 2016 Canonical Ltd
|
# Copyright 2016 Canonical Ltd
|
||||||
#
|
#
|
||||||
|
@ -14,10 +14,22 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
sys.path.append('hooks/')
|
|
||||||
|
_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
|
||||||
|
_root = os.path.abspath(os.path.join(_path, '..'))
|
||||||
|
|
||||||
|
|
||||||
|
def _add_path(path):
|
||||||
|
if path not in sys.path:
|
||||||
|
sys.path.insert(1, path)
|
||||||
|
|
||||||
|
_add_path(_hooks)
|
||||||
|
_add_path(_root)
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
do_action_openstack_upgrade,
|
do_action_openstack_upgrade,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
repo: https://github.com/juju/charm-helpers
|
repo: https://github.com/juju/charm-helpers
|
||||||
destination: hooks/charmhelpers
|
destination: charmhelpers
|
||||||
include:
|
include:
|
||||||
- core
|
- core
|
||||||
- osplatform
|
- osplatform
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue