Support network, subnet and FIP when creating cluster

Change-Id: Ia4f1ce4be215262fc89ceac30a2edb878ebd9937
Task: 36027
Story: 2006208
This commit is contained in:
Feilong Wang 2019-07-30 15:36:50 +12:00
parent d29d5cdec4
commit 5ad8b7dcf7
2 changed files with 43 additions and 0 deletions

View File

@ -116,6 +116,31 @@ class CreateCluster(command.Command):
metavar='<flavor>',
help=_('The nova flavor name or UUID to use when launching the '
'Cluster.'))
parser.add_argument(
'--fixed-network',
dest='fixed_network',
metavar='<fixed-network>',
help=_('The private Neutron network name to connect to this '
'Cluster template.'))
parser.add_argument(
'--fixed-subnet',
dest='fixed_subnet',
metavar='<fixed-subnet>',
help=_('The private Neutron subnet name to connect to Cluster.'))
parser.add_argument(
'--floating-ip-enabled',
dest='floating_ip_enabled',
default=[],
action='append_const',
const=True,
help=_('Indicates whether created Clusters should have a '
'floating ip.'))
parser.add_argument(
'--floating-ip-disabled',
dest='floating_ip_enabled',
action='append_const',
const=False,
help=_('Disables floating ip creation on the new Cluster'))
return parser
@ -133,6 +158,15 @@ class CreateCluster(command.Command):
'node_count': parsed_args.node_count,
}
if len(parsed_args.floating_ip_enabled) > 1:
raise exceptions.InvalidAttribute(
'--floating-ip-enabled and '
'--floating-ip-disabled are '
'mutually exclusive and '
'should be specified only once.')
elif len(parsed_args.floating_ip_enabled) == 1:
args['floating_ip_enabled'] = parsed_args.floating_ip_enabled[0]
if parsed_args.labels is not None:
args['labels'] = magnum_utils.handle_labels(parsed_args.labels)
@ -145,6 +179,12 @@ class CreateCluster(command.Command):
if parsed_args.flavor is not None:
args['flavor_id'] = parsed_args.flavor
if parsed_args.fixed_network is not None:
args["fixed_network"] = parsed_args.fixed_network
if parsed_args.fixed_subnet is not None:
args["fixed_subnet"] = parsed_args.fixed_subnet
cluster = mag_client.clusters.create(**args)
print("Request to create cluster %s accepted"
% cluster.uuid)

View File

@ -23,6 +23,9 @@ CREATION_ATTRIBUTES.append('docker_volume_size')
CREATION_ATTRIBUTES.append('labels')
CREATION_ATTRIBUTES.append('master_flavor_id')
CREATION_ATTRIBUTES.append('flavor_id')
CREATION_ATTRIBUTES.append('fixed_network')
CREATION_ATTRIBUTES.append('fixed_subnet')
CREATION_ATTRIBUTES.append('floating_ip_enabled')
class Cluster(baseunit.BaseTemplate):