@@ -891,159 +891,6 @@ def version(self):
891
891
print (migration .db_version (database = 'api' ))
892
892
893
893
894
- class CellCommands (object ):
895
- """Commands for managing cells v1 functionality."""
896
-
897
- # TODO(stephenfin): Remove this when cells v1 is removed
898
- description = ('DEPRECATED: The cell commands, which configure cells v1 '
899
- 'functionality, are deprecated as Cells v1 itself has '
900
- 'been deprecated. They will be removed in an upcoming '
901
- 'release.' )
902
-
903
- @staticmethod
904
- def _parse_server_string (server_str ):
905
- """Parses the given server_string and returns a tuple of host and port.
906
- If it's not a combination of host part and port, the port element is an
907
- empty string. If the input is invalid expression, return a tuple of two
908
- empty strings.
909
- """
910
- try :
911
- # First of all, exclude pure IPv6 address (w/o port).
912
- if netaddr .valid_ipv6 (server_str ):
913
- return (server_str , '' )
914
-
915
- # Next, check if this is IPv6 address with a port number
916
- # combination.
917
- if server_str .find ("]:" ) != - 1 :
918
- (address , port ) = server_str .replace ('[' , '' , 1 ).split (']:' )
919
- return (address , port )
920
-
921
- # Third, check if this is a combination of an address and a port
922
- if server_str .find (':' ) == - 1 :
923
- return (server_str , '' )
924
-
925
- # This must be a combination of an address and a port
926
- (address , port ) = server_str .split (':' )
927
- return (address , port )
928
-
929
- except (ValueError , netaddr .AddrFormatError ):
930
- print ('Invalid server_string: %s' % server_str )
931
- return ('' , '' )
932
-
933
- def _create_transport_hosts (self , username , password ,
934
- broker_hosts = None , hostname = None , port = None ):
935
- """Returns a list of oslo.messaging.TransportHost objects."""
936
- transport_hosts = []
937
- # Either broker-hosts or hostname should be set
938
- if broker_hosts :
939
- hosts = broker_hosts .split (',' )
940
- for host in hosts :
941
- host = host .strip ()
942
- broker_hostname , broker_port = self ._parse_server_string (host )
943
- if not broker_port :
944
- msg = _ ('Invalid broker_hosts value: %s. It should be'
945
- ' in hostname:port format' ) % host
946
- raise ValueError (msg )
947
- try :
948
- broker_port = int (broker_port )
949
- except ValueError :
950
- msg = _ ('Invalid port value: %s. It should be '
951
- 'an integer' ) % broker_port
952
- raise ValueError (msg )
953
- transport_hosts .append (
954
- messaging .TransportHost (
955
- hostname = broker_hostname ,
956
- port = broker_port ,
957
- username = username ,
958
- password = password ))
959
- else :
960
- try :
961
- port = int (port )
962
- except ValueError :
963
- msg = _ ("Invalid port value: %s. Should be an integer" ) % port
964
- raise ValueError (msg )
965
- transport_hosts .append (
966
- messaging .TransportHost (
967
- hostname = hostname ,
968
- port = port ,
969
- username = username ,
970
- password = password ))
971
- return transport_hosts
972
-
973
- @args ('--name' , metavar = '<name>' , help = 'Name for the new cell' )
974
- @args ('--cell_type' , metavar = '<parent|api|child|compute>' ,
975
- help = 'Whether the cell is parent/api or child/compute' )
976
- @args ('--username' , metavar = '<username>' ,
977
- help = 'Username for the message broker in this cell' )
978
- @args ('--password' , metavar = '<password>' ,
979
- help = 'Password for the message broker in this cell' )
980
- @args ('--broker_hosts' , metavar = '<broker_hosts>' ,
981
- help = 'Comma separated list of message brokers in this cell. '
982
- 'Each Broker is specified as hostname:port with both '
983
- 'mandatory. This option overrides the --hostname '
984
- 'and --port options (if provided). ' )
985
- @args ('--hostname' , metavar = '<hostname>' ,
986
- help = 'Address of the message broker in this cell' )
987
- @args ('--port' , metavar = '<number>' ,
988
- help = 'Port number of the message broker in this cell' )
989
- @args ('--virtual_host' , metavar = '<virtual_host>' ,
990
- help = 'The virtual host of the message broker in this cell' )
991
- @args ('--woffset' , metavar = '<float>' )
992
- @args ('--wscale' , metavar = '<float>' )
993
- def create (self , name , cell_type = 'child' , username = None , broker_hosts = None ,
994
- password = None , hostname = None , port = None , virtual_host = None ,
995
- woffset = None , wscale = None ):
996
-
997
- if cell_type not in ['parent' , 'child' , 'api' , 'compute' ]:
998
- print ("Error: cell type must be 'parent'/'api' or "
999
- "'child'/'compute'" )
1000
- return 2
1001
-
1002
- # Set up the transport URL
1003
- transport_hosts = self ._create_transport_hosts (
1004
- username , password ,
1005
- broker_hosts , hostname ,
1006
- port )
1007
- transport_url = rpc .get_transport_url ()
1008
- transport_url .hosts .extend (transport_hosts )
1009
- transport_url .virtual_host = virtual_host
1010
-
1011
- is_parent = False
1012
- if cell_type in ['api' , 'parent' ]:
1013
- is_parent = True
1014
- values = {'name' : name ,
1015
- 'is_parent' : is_parent ,
1016
- 'transport_url' : urlparse .unquote (str (transport_url )),
1017
- 'weight_offset' : float (woffset ),
1018
- 'weight_scale' : float (wscale )}
1019
- ctxt = context .get_admin_context ()
1020
- db .cell_create (ctxt , values )
1021
-
1022
- @args ('--cell_name' , metavar = '<cell_name>' ,
1023
- help = 'Name of the cell to delete' )
1024
- def delete (self , cell_name ):
1025
- ctxt = context .get_admin_context ()
1026
- db .cell_delete (ctxt , cell_name )
1027
-
1028
- def list (self ):
1029
- ctxt = context .get_admin_context ()
1030
- cells = db .cell_get_all (ctxt )
1031
- fmt = "%3s %-10s %-6s %-10s %-15s %-5s %-10s"
1032
- print (fmt % ('Id' , 'Name' , 'Type' , 'Username' , 'Hostname' ,
1033
- 'Port' , 'VHost' ))
1034
- print (fmt % ('-' * 3 , '-' * 10 , '-' * 6 , '-' * 10 , '-' * 15 ,
1035
- '-' * 5 , '-' * 10 ))
1036
- for cell in cells :
1037
- url = rpc .get_transport_url (cell .transport_url )
1038
- host = url .hosts [0 ] if url .hosts else messaging .TransportHost ()
1039
- print (fmt % (cell .id , cell .name ,
1040
- 'parent' if cell .is_parent else 'child' ,
1041
- host .username , host .hostname ,
1042
- host .port , url .virtual_host ))
1043
- print (fmt % ('-' * 3 , '-' * 10 , '-' * 6 , '-' * 10 , '-' * 15 ,
1044
- '-' * 5 , '-' * 10 ))
1045
-
1046
-
1047
894
class CellV2Commands (object ):
1048
895
"""Commands for managing cells v2."""
1049
896
@@ -1085,14 +932,10 @@ def simple_cell_setup(self, transport_url=None):
1085
932
"""Simple cellsv2 setup.
1086
933
1087
934
This simplified command is for use by existing non-cells users to
1088
- configure the default environment. If you are using CellsV1, this
1089
- will not work for you. Returns 0 if setup is completed (or has
1090
- already been done), 1 if no hosts are reporting (and this cannot
1091
- be mapped) and 2 if run in a CellsV1 environment.
935
+ configure the default environment. Returns 0 if setup is completed (or
936
+ has already been done) and 1 if no hosts are reporting (and this cannot
937
+ be mapped).
1092
938
"""
1093
- if CONF .cells .enable :
1094
- print ('CellsV1 users cannot use this simplified setup command' )
1095
- return 2
1096
939
transport_url = self ._validate_transport_url (transport_url )
1097
940
if not transport_url :
1098
941
return 1
@@ -2332,7 +2175,6 @@ def sync_aggregates(self, verbose=False):
2332
2175
2333
2176
CATEGORIES = {
2334
2177
'api_db' : ApiDbCommands ,
2335
- 'cell' : CellCommands ,
2336
2178
'cell_v2' : CellV2Commands ,
2337
2179
'db' : DbCommands ,
2338
2180
'floating' : FloatingIpCommands ,
0 commit comments