Skip to content

Commit

Permalink
scale deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Feb 29, 2024
1 parent 5dcdac6 commit 783fab5
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/aicli_parameters_scale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bmc_user: admin
bmc_password: password
hosts:
- name: ci-ai-node-0
bmc_url: http://192.168.122.1:9000/redfish/v1/Systems/local/ci-ai-node-3
- name: ci-ai-node-1
bmc_url: http://192.168.122.1:9000/redfish/v1/Systems/local/ci-ai-node-4
45 changes: 45 additions & 0 deletions ailib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,3 +1563,48 @@ def create_fake_host(self, name, cluster, secret_key, overrides={}):
new_host_params = models.HostCreateParams(**new_host_params)
self.client.api_client.default_headers['X-Secret-Key'] = secret_key
self.client.v2_register_host(infra_env_id=infra_env_id, new_host_params=new_host_params)

def scale_deployment(self, cluster, overrides, force=False, debug=False):
if cluster.endswith('-day2'):
self.create_cluster(cluster, overrides.copy(), force=force)
infraenv = f"{cluster}_infra-env"
minimal = overrides.get('minimal', False)
overrides['cluster'] = cluster
self.create_infra_env(infraenv, overrides)
del overrides['cluster']
else:
info_cluster = self.info_cluster(cluster)
if info_cluster.status != 'adding-hosts':
self.update_cluster(cluster, {'day2': True})
if not self.saas:
info("Waiting 240s for iso to be available")
sleep(240)
if 'iso_url' in overrides:
download_iso_path = overrides.get('download_iso_path')
if download_iso_path is None:
download_iso_path = '/var/www/html'
warning(f"Using {download_iso_path} to store iso")
else:
info(f"Using {download_iso_path} to store iso")
self.download_iso(cluster, download_iso_path)
else:
iso_url = self.info_iso(infraenv, overrides, minimal=minimal)
if 'hosts' not in overrides:
warning(f"Retrieve iso from {iso_url} and plug it to your nodes:")
else:
overrides['iso_url'] = iso_url
download_iso_cmd = overrides.get('download_iso_cmd')
if download_iso_cmd is not None:
call(download_iso_cmd, shell=True)
hosts_number = len(overrides.get('hosts', [0, 0]))
info(f"Setting hosts_number to {hosts_number}")
if 'hosts' not in overrides:
boot_overrides = overrides.copy()
boot_overrides['cluster'] = cluster
boot_result = boot_hosts(boot_overrides, debug=debug)
if boot_result != 0:
return {'result': 'failure', 'reason': 'Hit issue when booting hosts'}
self.wait_hosts(infraenv, hosts_number, filter_installed=True, require_inventory=True)
hosts = [h['requested_hostname'] for h in self.list_hosts() if h['status'] != 'installed']
self.start_hosts(hosts)
return {'result': 'success'}
24 changes: 24 additions & 0 deletions ailib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ def create_deployment(args):
ai.create_deployment(args.cluster, overrides, force=args.force, debug=args.debugredfish)


def scale_deployment(args):
info(f"Scaling deployment {args.cluster}")
overrides = handle_parameters(args.param, args.paramfile)
ai = AssistedClient(args.url, token=args.token, offlinetoken=args.offlinetoken, debug=args.debug,
ca=args.ca, cert=args.cert, key=args.key)
ai.scale_deployment(args.cluster, overrides, force=args.force, debug=args.debugredfish)


def create_manifests(args):
info(f"Uploading manifests for Cluster {args.cluster}")
directory = args.dir
Expand Down Expand Up @@ -1251,6 +1259,22 @@ def cli():
list_subparsers.add_parser('manifest', parents=[manifestslist_parser], description=manifestslist_desc,
help=manifestslist_desc, aliases=['manifests'])

scale_desc = 'scale Object'
scale_parser = subparsers.add_parser('scale', description=scale_desc, help=scale_desc)
scale_subparsers = scale_parser.add_subparsers(metavar='', dest='subcommand_scale')

deploymentscale_desc = 'Scale deployment'
deploymentscale_epilog = None
deploymentscale_parser = scale_subparsers.add_parser('deployment', description=deploymentscale_desc,
help=deploymentscale_desc, epilog=deploymentscale_epilog,
formatter_class=rawhelp)
deploymentscale_parser.add_argument('-d', '--debugredfish', action='store_true')
deploymentscale_parser.add_argument('-P', '--param', action='append', help=PARAMHELP, metavar='PARAM')
deploymentscale_parser.add_argument('--paramfile', '--pf', help='Parameters file', metavar='PARAMFILE',
action='append')
deploymentscale_parser.add_argument('cluster', metavar='CLUSTER')
deploymentscale_parser.set_defaults(func=scale_deployment)

start_desc = 'Start Object'
start_parser = subparsers.add_parser('start', description=start_desc, help=start_desc, aliases=['launch'])
start_subparsers = start_parser.add_subparsers(metavar='', dest='subcommand_start')
Expand Down

0 comments on commit 783fab5

Please sign in to comment.