def do_command(self): env_name = self.app.pargs.environment_name modules = self.app.pargs.modules if modules and len(modules) > 0: self.compose_multiple_apps() return group = self.app.pargs.env_group_suffix cname = self.app.pargs.cname tier = self.app.pargs.tier itype = self.app.pargs.instance_type platform = self.app.pargs.platform single = self.app.pargs.single iprofile = self.app.pargs.instance_profile service_role = self.app.pargs.service_role label = self.app.pargs.version branch_default = self.app.pargs.branch_default key_name = self.app.pargs.keyname sample = self.app.pargs.sample nohang = self.app.pargs.nohang tags = self.app.pargs.tags envvars = self.app.pargs.envvars scale = self.app.pargs.scale timeout = self.app.pargs.timeout cfg = self.app.pargs.cfg elb_type = self.app.pargs.elb_type source = self.app.pargs.source process = self.app.pargs.process enable_spot = self.app.pargs.enable_spot spot_max_price = self.app.pargs.spot_max_price instance_types = self.app.pargs.instance_types on_demand_base_capacity = self.app.pargs.on_demand_base_capacity on_demand_above_base_capacity = self.app.pargs.on_demand_above_base_capacity max_instances = self.app.pargs.max_instances min_instances = self.app.pargs.min_instances interactive = False if env_name else True provided_env_name = env_name if sample and label: raise InvalidOptionsError(strings['create.sampleandlabel']) if single and scale: raise InvalidOptionsError(strings['create.singleandsize']) if (max_instances or min_instances) and scale: raise InvalidOptionsError(strings['create.scaleandminmax']) if (max_instances or min_instances) and single: raise InvalidOptionsError(strings['create.singleandminmax']) if single and elb_type: raise InvalidOptionsError(strings['create.single_and_elb_type']) if cname and tier and Tier.looks_like_worker_tier(tier): raise InvalidOptionsError(strings['worker.cname']) if cname and not elasticbeanstalk.is_cname_available(cname): raise AlreadyExistsError(strings['cname.unavailable'].replace( '{cname}', cname)) if tier and Tier.looks_like_worker_tier(tier): if self.app.pargs.vpc_elbpublic or self.app.pargs.vpc_elbsubnets or self.app.pargs.vpc_publicip: raise InvalidOptionsError( strings['create.worker_and_incompatible_vpc_arguments']) if (not tier or Tier.looks_like_webserver_tier(tier)) and single: if self.app.pargs.vpc_elbpublic or self.app.pargs.vpc_elbsubnets: raise InvalidOptionsError( strings['create.single_and_elbpublic_or_elb_subnet']) if (spot_max_price or on_demand_base_capacity or on_demand_above_base_capacity) and not enable_spot: raise InvalidOptionsError(strings['create.missing_enable_spot']) if instance_types is "": raise InvalidOptionsError( strings['spot.instance_types_validation']) if itype and instance_types: raise InvalidOptionsError(strings['create.itype_and_instances']) platform = _determine_platform(platform, iprofile) app_name = self.get_app_name() tags = tagops.get_and_validate_tags(tags) envvars = get_and_validate_envars(envvars) process_app_version = fileoperations.env_yaml_exists() or process template_name = get_template_name(app_name, cfg) tier = get_environment_tier(tier) env_name = provided_env_name or get_environment_name(app_name, group) cname = cname or get_environment_cname(env_name, provided_env_name, tier) key_name = key_name or commonops.get_default_keyname() elb_type = elb_type or get_elb_type_from_customer( interactive, single, tier) enable_spot = enable_spot or spotops.get_spot_request_from_customer( interactive) instance_types = instance_types or spotops.get_spot_instance_types_from_customer( interactive, enable_spot) database = self.form_database_object() vpc = self.form_vpc_object(tier, single) if not timeout and database: timeout = 15 env_request = CreateEnvironmentRequest( app_name=app_name, env_name=env_name, group_name=group, cname=cname, template_name=template_name, platform=platform, tier=tier, instance_type=itype, version_label=label, instance_profile=iprofile, service_role=service_role, single_instance=single, key_name=key_name, sample_application=sample, tags=tags, scale=scale, database=database, vpc=vpc, elb_type=elb_type, enable_spot=enable_spot, instance_types=instance_types, spot_max_price=spot_max_price, on_demand_base_capacity=on_demand_base_capacity, on_demand_above_base_capacity=on_demand_above_base_capacity, min_instances=min_instances, max_instances=max_instances) env_request.option_settings += envvars createops.make_new_env(env_request, branch_default=branch_default, process_app_version=process_app_version, nohang=nohang, interactive=interactive, timeout=timeout, source=source)
def do_command(self): # save command line args env_name = self.app.pargs.environment_name modules = self.app.pargs.modules if modules and len(modules) > 0: self.compose_multiple_apps() return group = self.app.pargs.env_group_suffix cname = self.app.pargs.cname tier = self.app.pargs.tier itype = self.app.pargs.instance_type solution_string = self.app.pargs.platform or solution_stack_ops.get_default_solution_stack( ) single = self.app.pargs.single iprofile = self.app.pargs.instance_profile service_role = self.app.pargs.service_role label = self.app.pargs.version branch_default = self.app.pargs.branch_default key_name = self.app.pargs.keyname sample = self.app.pargs.sample nohang = self.app.pargs.nohang tags = self.app.pargs.tags envvars = self.app.pargs.envvars scale = self.app.pargs.scale timeout = self.app.pargs.timeout cfg = self.app.pargs.cfg elb_type = self.app.pargs.elb_type source = self.app.pargs.source process = self.app.pargs.process region = self.app.pargs.region interactive = False if env_name else True provided_env_name = env_name if sample and label: raise InvalidOptionsError(strings['create.sampleandlabel']) if single and scale: raise InvalidOptionsError(strings['create.singleandsize']) if single and elb_type: raise InvalidOptionsError(strings['create.single_and_elb_type']) if cname and tier and Tier.looks_like_worker_tier(tier): raise InvalidOptionsError(strings['worker.cname']) if cname and not elasticbeanstalk.is_cname_available(cname): raise AlreadyExistsError(strings['cname.unavailable'].replace( '{cname}', cname)) if tier and Tier.looks_like_worker_tier(tier): if self.app.pargs.vpc_elbpublic or self.app.pargs.vpc_elbsubnets or self.app.pargs.vpc_publicip: raise InvalidOptionsError( strings['create.worker_and_incompatible_vpc_arguments']) if (not tier or Tier.looks_like_webserver_tier(tier)) and single: if self.app.pargs.vpc_elbpublic or self.app.pargs.vpc_elbsubnets: raise InvalidOptionsError( strings['create.single_and_elbpublic_or_elb_subnet']) app_name = self.get_app_name() tags = createops.get_and_validate_tags(tags) envvars = get_and_validate_envars(envvars) process_app_version = fileoperations.env_yaml_exists() or process platform = get_platform(solution_string, iprofile) template_name = get_template_name(app_name, cfg) tier = get_environment_tier(tier) env_name = provided_env_name or get_environment_name(app_name, group) cname = cname or get_environment_cname(env_name, provided_env_name, tier) key_name = key_name or commonops.get_default_keyname() elb_type = elb_type or get_elb_type_from_customer( interactive, single, region, tier) database = self.form_database_object() vpc = self.form_vpc_object(tier, single) # avoid prematurely timing out in the CLI when an environment is launched with a RDS DB if not timeout and database: timeout = 15 env_request = CreateEnvironmentRequest(app_name=app_name, env_name=env_name, group_name=group, cname=cname, template_name=template_name, platform=platform, tier=tier, instance_type=itype, version_label=label, instance_profile=iprofile, service_role=service_role, single_instance=single, key_name=key_name, sample_application=sample, tags=tags, scale=scale, database=database, vpc=vpc, elb_type=elb_type) env_request.option_settings += envvars createops.make_new_env(env_request, branch_default=branch_default, process_app_version=process_app_version, nohang=nohang, interactive=interactive, timeout=timeout, source=source)