Remove all usage of six library
Convert all code to not require six library and instead use python 3.x logic. Change-Id: I9d3193668769cd6499a8be8d8d19c16e046f4cc6
This commit is contained in:
parent
389da3e4cd
commit
a983902460
|
@ -15,7 +15,6 @@ import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from senlin.common import context
|
from senlin.common import context
|
||||||
from senlin.common import exception as exc
|
from senlin.common import exception as exc
|
||||||
|
@ -84,7 +83,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
ip_version=4)
|
ip_version=4)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceCreation(type='kubernetes',
|
raise exc.EResourceCreation(type='kubernetes',
|
||||||
message=six.text_type(ex),
|
message=str(ex),
|
||||||
resource_id=obj.id)
|
resource_id=obj.id)
|
||||||
pub_net = client.network_get(self.properties[self.PUBLIC_NETWORK])
|
pub_net = client.network_get(self.properties[self.PUBLIC_NETWORK])
|
||||||
try:
|
try:
|
||||||
|
@ -94,7 +93,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
fip = client.floatingip_create(floating_network_id=pub_net.id)
|
fip = client.floatingip_create(floating_network_id=pub_net.id)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceCreation(type='kubernetes',
|
raise exc.EResourceCreation(type='kubernetes',
|
||||||
message=six.text_type(ex),
|
message=str(ex),
|
||||||
resource_id=obj.id)
|
resource_id=obj.id)
|
||||||
|
|
||||||
ctx = context.get_service_context(user_id=obj.user,
|
ctx = context.get_service_context(user_id=obj.user,
|
||||||
|
@ -119,7 +118,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
client.floatingip_delete(fip_id)
|
client.floatingip_delete(fip_id)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='kubernetes', id=fip_id,
|
raise exc.EResourceDeletion(type='kubernetes', id=fip_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
router = obj.data.get(self.PRIVATE_ROUTER)
|
router = obj.data.get(self.PRIVATE_ROUTER)
|
||||||
subnet = obj.data.get(self.PRIVATE_SUBNET)
|
subnet = obj.data.get(self.PRIVATE_SUBNET)
|
||||||
|
@ -129,7 +128,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='kubernetes',
|
raise exc.EResourceDeletion(type='kubernetes',
|
||||||
id=subnet,
|
id=subnet,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
if router:
|
if router:
|
||||||
try:
|
try:
|
||||||
|
@ -138,7 +137,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='kubernetes',
|
raise exc.EResourceDeletion(type='kubernetes',
|
||||||
id=router,
|
id=router,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
net = obj.data.get(self.PRIVATE_NETWORK)
|
net = obj.data.get(self.PRIVATE_NETWORK)
|
||||||
if net:
|
if net:
|
||||||
|
@ -148,7 +147,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='kubernetes',
|
raise exc.EResourceDeletion(type='kubernetes',
|
||||||
id=net,
|
id=net,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _associate_floatingip(self, obj, server):
|
def _associate_floatingip(self, obj, server):
|
||||||
ctx = context.get_service_context(user_id=obj.user,
|
ctx = context.get_service_context(user_id=obj.user,
|
||||||
|
@ -165,7 +164,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
raise exc.EResourceOperation(op='floatingip',
|
raise exc.EResourceOperation(op='floatingip',
|
||||||
type='kubernetes',
|
type='kubernetes',
|
||||||
id=fip,
|
id=fip,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _disassociate_floatingip(self, obj, server):
|
def _disassociate_floatingip(self, obj, server):
|
||||||
ctx = context.get_service_context(user_id=obj.user,
|
ctx = context.get_service_context(user_id=obj.user,
|
||||||
|
@ -181,7 +180,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
raise exc.EResourceOperation(op='floatingip',
|
raise exc.EResourceOperation(op='floatingip',
|
||||||
type='kubernetes',
|
type='kubernetes',
|
||||||
id=fip,
|
id=fip,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _get_cluster_data(self, obj):
|
def _get_cluster_data(self, obj):
|
||||||
ctx = context.get_service_context(user_id=obj.user,
|
ctx = context.get_service_context(user_id=obj.user,
|
||||||
|
@ -211,7 +210,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
sg = client.security_group_create(name=self.name)
|
sg = client.security_group_create(name=self.name)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise exc.EResourceCreation(type='kubernetes',
|
raise exc.EResourceCreation(type='kubernetes',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
data = obj.data
|
data = obj.data
|
||||||
data[self.SECURITY_GROUP] = sg.id
|
data[self.SECURITY_GROUP] = sg.id
|
||||||
cluster_obj.Cluster.update(ctx, obj.id, {'data': data})
|
cluster_obj.Cluster.update(ctx, obj.id, {'data': data})
|
||||||
|
@ -241,7 +240,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
client.security_group_rule_create(sgid, port, protocol=p)
|
client.security_group_rule_create(sgid, port, protocol=p)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise exc.EResourceCreation(type='kubernetes',
|
raise exc.EResourceCreation(type='kubernetes',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _delete_security_group(self, obj):
|
def _delete_security_group(self, obj):
|
||||||
sgid = obj.data.get(self.SECURITY_GROUP)
|
sgid = obj.data.get(self.SECURITY_GROUP)
|
||||||
|
@ -252,7 +251,7 @@ class KubeBaseProfile(server.ServerProfile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='kubernetes',
|
raise exc.EResourceDeletion(type='kubernetes',
|
||||||
id=sgid,
|
id=sgid,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def do_validate(self, obj):
|
def do_validate(self, obj):
|
||||||
"""Validate if the spec has provided valid info for server creation.
|
"""Validate if the spec has provided valid info for server creation.
|
||||||
|
|
|
@ -15,7 +15,6 @@ import base64
|
||||||
import jinja2
|
import jinja2
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from kube import base
|
from kube import base
|
||||||
from senlin.common import consts
|
from senlin.common import consts
|
||||||
|
@ -241,7 +240,7 @@ class ServerProfile(base.KubeBaseProfile):
|
||||||
if server and server.id:
|
if server and server.id:
|
||||||
resource_id = server.id
|
resource_id = server.id
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex),
|
message=str(ex),
|
||||||
resource_id=resource_id)
|
resource_id=resource_id)
|
||||||
|
|
||||||
def do_delete(self, obj, **params):
|
def do_delete(self, obj, **params):
|
||||||
|
@ -277,4 +276,4 @@ class ServerProfile(base.KubeBaseProfile):
|
||||||
return True
|
return True
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='server', id=server_id,
|
raise exc.EResourceDeletion(type='server', id=server_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
|
@ -15,7 +15,6 @@ import base64
|
||||||
import jinja2
|
import jinja2
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from kube import base
|
from kube import base
|
||||||
from senlin.common import consts
|
from senlin.common import consts
|
||||||
|
@ -166,7 +165,7 @@ class ServerProfile(base.KubeBaseProfile):
|
||||||
cluster = cluster_obj.Cluster.find(ctx, master)
|
cluster = cluster_obj.Cluster.find(ctx, master)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise exc.EResourceCreation(type='kubernetes.worker',
|
raise exc.EResourceCreation(type='kubernetes.worker',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
for key in self.MASTER_CLUSTER_KEYS:
|
for key in self.MASTER_CLUSTER_KEYS:
|
||||||
if key not in cluster.data:
|
if key not in cluster.data:
|
||||||
raise exc.EResourceCreation(
|
raise exc.EResourceCreation(
|
||||||
|
@ -316,7 +315,7 @@ class ServerProfile(base.KubeBaseProfile):
|
||||||
if server and server.id:
|
if server and server.id:
|
||||||
resource_id = server.id
|
resource_id = server.id
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex),
|
message=str(ex),
|
||||||
resource_id=resource_id)
|
resource_id=resource_id)
|
||||||
|
|
||||||
def do_delete(self, obj, **params):
|
def do_delete(self, obj, **params):
|
||||||
|
@ -351,4 +350,4 @@ class ServerProfile(base.KubeBaseProfile):
|
||||||
return True
|
return True
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='server', id=server_id,
|
raise exc.EResourceDeletion(type='server', id=server_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
|
@ -17,7 +17,6 @@ import jinja2
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from senlin.common import constraints
|
from senlin.common import constraints
|
||||||
from senlin.common import consts
|
from senlin.common import consts
|
||||||
|
@ -343,7 +342,7 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
if reason == 'create':
|
if reason == 'create':
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -363,7 +362,7 @@ class ServerProfile(base.Profile):
|
||||||
try:
|
try:
|
||||||
flavor = self.compute(obj).flavor_find(name_or_id, False)
|
flavor = self.compute(obj).flavor_find(name_or_id, False)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
msg = six.text_type(ex)
|
msg = str(ex)
|
||||||
if reason is None: # reason is 'validate'
|
if reason is None: # reason is 'validate'
|
||||||
if ex.code == 404:
|
if ex.code == 404:
|
||||||
msg = _("The specified %(k)s '%(v)s' could not be found."
|
msg = _("The specified %(k)s '%(v)s' could not be found."
|
||||||
|
@ -392,10 +391,10 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
if reason == 'create':
|
if reason == 'create':
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
elif reason == 'update':
|
elif reason == 'update':
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
elif ex.code == 404:
|
elif ex.code == 404:
|
||||||
msg = _("The specified %(k)s '%(v)s' could not be found."
|
msg = _("The specified %(k)s '%(v)s' could not be found."
|
||||||
) % {'k': self.IMAGE, 'v': name_or_id}
|
) % {'k': self.IMAGE, 'v': name_or_id}
|
||||||
|
@ -409,10 +408,10 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
if reason == 'create':
|
if reason == 'create':
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
elif reason == 'update':
|
elif reason == 'update':
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
elif ex.code == 404:
|
elif ex.code == 404:
|
||||||
msg = _("The specified %(k)s '%(v)s' could not be found."
|
msg = _("The specified %(k)s '%(v)s' could not be found."
|
||||||
) % {'k': self.KEY_NAME, 'v': name_or_id}
|
) % {'k': self.KEY_NAME, 'v': name_or_id}
|
||||||
|
@ -476,7 +475,7 @@ class ServerProfile(base.Profile):
|
||||||
sg_obj = nc.security_group_find(sg)
|
sg_obj = nc.security_group_find(sg)
|
||||||
res.append(sg_obj.id)
|
res.append(sg_obj.id)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
return six.text_type(ex)
|
return str(ex)
|
||||||
|
|
||||||
result[self.PORT_SECURITY_GROUPS] = res
|
result[self.PORT_SECURITY_GROUPS] = res
|
||||||
return
|
return
|
||||||
|
@ -495,7 +494,7 @@ class ServerProfile(base.Profile):
|
||||||
net_obj = nc.network_get(net)
|
net_obj = nc.network_get(net)
|
||||||
result[self.NETWORK] = net_obj.id
|
result[self.NETWORK] = net_obj.id
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
return six.text_type(ex)
|
return str(ex)
|
||||||
|
|
||||||
def _check_port(self, nc, port, result):
|
def _check_port(self, nc, port, result):
|
||||||
"""Check the specified port.
|
"""Check the specified port.
|
||||||
|
@ -516,7 +515,7 @@ class ServerProfile(base.Profile):
|
||||||
result[self.PORT] = port_obj.id
|
result[self.PORT] = port_obj.id
|
||||||
return
|
return
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
return six.text_type(ex)
|
return str(ex)
|
||||||
|
|
||||||
def _check_floating_ip(self, nc, net_spec, result):
|
def _check_floating_ip(self, nc, net_spec, result):
|
||||||
"""Check floating IP and network, if specified.
|
"""Check floating IP and network, if specified.
|
||||||
|
@ -532,7 +531,7 @@ class ServerProfile(base.Profile):
|
||||||
net_obj = nc.network_get(net)
|
net_obj = nc.network_get(net)
|
||||||
result[self.FLOATING_NETWORK] = net_obj.id
|
result[self.FLOATING_NETWORK] = net_obj.id
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
return six.text_type(ex)
|
return str(ex)
|
||||||
|
|
||||||
flt_ip = net_spec.get(self.FLOATING_IP)
|
flt_ip = net_spec.get(self.FLOATING_IP)
|
||||||
if not flt_ip:
|
if not flt_ip:
|
||||||
|
@ -554,7 +553,7 @@ class ServerProfile(base.Profile):
|
||||||
result[self.FLOATING_IP] = flt_ip
|
result[self.FLOATING_IP] = flt_ip
|
||||||
return
|
return
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
return six.text_type(ex)
|
return str(ex)
|
||||||
|
|
||||||
def _validate_network(self, obj, net_spec, reason=None):
|
def _validate_network(self, obj, net_spec, reason=None):
|
||||||
|
|
||||||
|
@ -754,7 +753,7 @@ class ServerProfile(base.Profile):
|
||||||
metadata['cluster_node_id'] = obj.id
|
metadata['cluster_node_id'] = obj.id
|
||||||
if obj.cluster_id:
|
if obj.cluster_id:
|
||||||
metadata['cluster_id'] = obj.cluster_id
|
metadata['cluster_id'] = obj.cluster_id
|
||||||
metadata['cluster_node_index'] = six.text_type(obj.index)
|
metadata['cluster_node_index'] = str(obj.index)
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
@ -904,7 +903,7 @@ class ServerProfile(base.Profile):
|
||||||
if server and server.id:
|
if server and server.id:
|
||||||
resource_id = server.id
|
resource_id = server.id
|
||||||
raise exc.EResourceCreation(type='server',
|
raise exc.EResourceCreation(type='server',
|
||||||
message=six.text_type(ex),
|
message=str(ex),
|
||||||
resource_id=resource_id)
|
resource_id=resource_id)
|
||||||
|
|
||||||
def do_delete(self, obj, **params):
|
def do_delete(self, obj, **params):
|
||||||
|
@ -939,7 +938,7 @@ class ServerProfile(base.Profile):
|
||||||
return True
|
return True
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceDeletion(type='server', id=server_id,
|
raise exc.EResourceDeletion(type='server', id=server_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _check_server_name(self, obj, profile):
|
def _check_server_name(self, obj, profile):
|
||||||
"""Check if there is a new name to be assigned to the server.
|
"""Check if there is a new name to be assigned to the server.
|
||||||
|
@ -968,7 +967,7 @@ class ServerProfile(base.Profile):
|
||||||
self.compute(obj).server_update(obj.physical_id, name=new_name)
|
self.compute(obj).server_update(obj.physical_id, name=new_name)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _check_password(self, obj, new_profile):
|
def _check_password(self, obj, new_profile):
|
||||||
"""Check if the admin password has been changed in the new profile.
|
"""Check if the admin password has been changed in the new profile.
|
||||||
|
@ -999,7 +998,7 @@ class ServerProfile(base.Profile):
|
||||||
new_password)
|
new_password)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _update_metadata(self, obj, new_profile):
|
def _update_metadata(self, obj, new_profile):
|
||||||
"""Update the server metadata.
|
"""Update the server metadata.
|
||||||
|
@ -1020,7 +1019,7 @@ class ServerProfile(base.Profile):
|
||||||
self.compute(obj).server_metadata_update(obj.physical_id, new_meta)
|
self.compute(obj).server_metadata_update(obj.physical_id, new_meta)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _update_flavor(self, obj, new_profile):
|
def _update_flavor(self, obj, new_profile):
|
||||||
"""Update server flavor.
|
"""Update server flavor.
|
||||||
|
@ -1043,12 +1042,12 @@ class ServerProfile(base.Profile):
|
||||||
cc.server_resize(obj.physical_id, newflavor.id)
|
cc.server_resize(obj.physical_id, newflavor.id)
|
||||||
cc.wait_for_server(obj.physical_id, 'VERIFY_RESIZE')
|
cc.wait_for_server(obj.physical_id, 'VERIFY_RESIZE')
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
msg = six.text_type(ex)
|
msg = str(ex)
|
||||||
try:
|
try:
|
||||||
cc.server_resize_revert(obj.physical_id)
|
cc.server_resize_revert(obj.physical_id)
|
||||||
cc.wait_for_server(obj.physical_id, 'ACTIVE')
|
cc.wait_for_server(obj.physical_id, 'ACTIVE')
|
||||||
except exc.InternalError as ex1:
|
except exc.InternalError as ex1:
|
||||||
msg = six.text_type(ex1)
|
msg = str(ex1)
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=msg)
|
message=msg)
|
||||||
|
|
||||||
|
@ -1057,7 +1056,7 @@ class ServerProfile(base.Profile):
|
||||||
cc.wait_for_server(obj.physical_id, 'ACTIVE')
|
cc.wait_for_server(obj.physical_id, 'ACTIVE')
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _update_image(self, obj, new_profile, new_name, new_password):
|
def _update_image(self, obj, new_profile, new_name, new_password):
|
||||||
"""Update image used by server node.
|
"""Update image used by server node.
|
||||||
|
@ -1091,7 +1090,7 @@ class ServerProfile(base.Profile):
|
||||||
server = driver.server_get(obj.physical_id)
|
server = driver.server_get(obj.physical_id)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
# Still, this 'old_image_id' could be empty, but it doesn't matter
|
# Still, this 'old_image_id' could be empty, but it doesn't matter
|
||||||
# because the comparison below would fail if that is the case
|
# because the comparison below would fail if that is the case
|
||||||
old_image_id = server.image.get('id', None)
|
old_image_id = server.image.get('id', None)
|
||||||
|
@ -1105,7 +1104,7 @@ class ServerProfile(base.Profile):
|
||||||
driver.wait_for_server(obj.physical_id, 'ACTIVE')
|
driver.wait_for_server(obj.physical_id, 'ACTIVE')
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _update_network_add_port(self, obj, networks):
|
def _update_network_add_port(self, obj, networks):
|
||||||
|
@ -1122,7 +1121,7 @@ class ServerProfile(base.Profile):
|
||||||
server = cc.server_get(obj.physical_id)
|
server = cc.server_get(obj.physical_id)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
ports = self._create_ports_from_properties(
|
ports = self._create_ports_from_properties(
|
||||||
obj, networks, 'update')
|
obj, networks, 'update')
|
||||||
|
@ -1133,7 +1132,7 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server',
|
raise exc.EResourceUpdate(type='server',
|
||||||
id=obj.physical_id,
|
id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
def _find_port_by_net_spec(self, obj, net_spec, ports):
|
def _find_port_by_net_spec(self, obj, net_spec, ports):
|
||||||
"""Find existing ports match with specific network properties.
|
"""Find existing ports match with specific network properties.
|
||||||
|
@ -1207,7 +1206,7 @@ class ServerProfile(base.Profile):
|
||||||
ignore_missing=True)
|
ignore_missing=True)
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
raise exc.EResourceUpdate(type='server', id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
internal_ports.remove(port)
|
internal_ports.remove(port)
|
||||||
obj.data['internal_ports'] = internal_ports
|
obj.data['internal_ports'] = internal_ports
|
||||||
node_obj.Node.update(self.context, obj.id, {'data': obj.data})
|
node_obj.Node.update(self.context, obj.id, {'data': obj.data})
|
||||||
|
@ -1311,7 +1310,7 @@ class ServerProfile(base.Profile):
|
||||||
return {
|
return {
|
||||||
'Error': {
|
'Error': {
|
||||||
'code': ex.code,
|
'code': ex.code,
|
||||||
'message': six.text_type(ex)
|
'message': str(ex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1362,7 +1361,7 @@ class ServerProfile(base.Profile):
|
||||||
driver = self.compute(obj)
|
driver = self.compute(obj)
|
||||||
metadata = driver.server_metadata_get(obj.physical_id) or {}
|
metadata = driver.server_metadata_get(obj.physical_id) or {}
|
||||||
metadata['cluster_id'] = cluster_id
|
metadata['cluster_id'] = cluster_id
|
||||||
metadata['cluster_node_index'] = six.text_type(obj.index)
|
metadata['cluster_node_index'] = str(obj.index)
|
||||||
driver.server_metadata_update(obj.physical_id, metadata)
|
driver.server_metadata_update(obj.physical_id, metadata)
|
||||||
return super(ServerProfile, self).do_join(obj, cluster_id)
|
return super(ServerProfile, self).do_join(obj, cluster_id)
|
||||||
|
|
||||||
|
@ -1383,7 +1382,7 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceOperation(op='checking', type='server',
|
raise exc.EResourceOperation(op='checking', type='server',
|
||||||
id=obj.physical_id,
|
id=obj.physical_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
if (server is None or server.status != 'ACTIVE'):
|
if (server is None or server.status != 'ACTIVE'):
|
||||||
return False
|
return False
|
||||||
|
@ -1399,7 +1398,7 @@ class ServerProfile(base.Profile):
|
||||||
"""
|
"""
|
||||||
operation = options.get('operation', None)
|
operation = options.get('operation', None)
|
||||||
|
|
||||||
if operation and not isinstance(operation, six.string_types):
|
if operation and not isinstance(operation, str):
|
||||||
operation = operation[0]
|
operation = operation[0]
|
||||||
|
|
||||||
op_name = operation['name']
|
op_name = operation['name']
|
||||||
|
@ -1420,7 +1419,7 @@ class ServerProfile(base.Profile):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reboot_type = options.get(self.REBOOT_TYPE, self.REBOOT_SOFT)
|
reboot_type = options.get(self.REBOOT_TYPE, self.REBOOT_SOFT)
|
||||||
if (not isinstance(reboot_type, six.string_types) or
|
if (not isinstance(reboot_type, str) or
|
||||||
reboot_type not in self.REBOOT_TYPES):
|
reboot_type not in self.REBOOT_TYPES):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1439,7 +1438,7 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceOperation(op='rebuilding', type='server',
|
raise exc.EResourceOperation(op='rebuilding', type='server',
|
||||||
id=server_id,
|
id=server_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
|
|
||||||
if server is None or server.image is None:
|
if server is None or server.image is None:
|
||||||
return False
|
return False
|
||||||
|
@ -1454,7 +1453,7 @@ class ServerProfile(base.Profile):
|
||||||
except exc.InternalError as ex:
|
except exc.InternalError as ex:
|
||||||
raise exc.EResourceOperation(op='rebuilding', type='server',
|
raise exc.EResourceOperation(op='rebuilding', type='server',
|
||||||
id=server_id,
|
id=server_id,
|
||||||
message=six.text_type(ex))
|
message=str(ex))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_change_password(self, obj, **options):
|
def handle_change_password(self, obj, **options):
|
||||||
|
@ -1463,7 +1462,7 @@ class ServerProfile(base.Profile):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
password = options.get(self.ADMIN_PASSWORD, None)
|
password = options.get(self.ADMIN_PASSWORD, None)
|
||||||
if (password is None or not isinstance(password, six.string_types)):
|
if (password is None or not isinstance(password, str)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.compute(obj).server_change_password(obj.physical_id, password)
|
self.compute(obj).server_change_password(obj.physical_id, password)
|
||||||
|
|
|
@ -107,7 +107,6 @@ requests==2.14.2
|
||||||
requestsexceptions==1.4.0
|
requestsexceptions==1.4.0
|
||||||
rfc3986==1.1.0
|
rfc3986==1.1.0
|
||||||
Routes==2.3.1
|
Routes==2.3.1
|
||||||
six==1.10.0
|
|
||||||
smmap2==2.0.3
|
smmap2==2.0.3
|
||||||
sqlalchemy-migrate==0.11.0
|
sqlalchemy-migrate==0.11.0
|
||||||
SQLAlchemy==1.0.10
|
SQLAlchemy==1.0.10
|
||||||
|
|
Loading…
Reference in New Issue