Create resource group if it does not exist.
163183
def _create_resource_group(self, region, resource_group_name):
        
        resource_group_config = {'location': region}

        try:
            self.resource.resource_groups.create_or_update(
                resource_group_name, resource_group_config
            )
        except Exception as error:
            raise AzureCloudException(
                'Unable to create resource group: {0}.'.format(error)
            )
1364283
def create_resource(self, parent_id=""):
        
        resource_name = self.trigger_settings.get('resource', '')
        resource_name = resource_name.replace('/', '')
        if not self.resource_id:
            created_resource = self.client.create_resource(
                restApiId=self.api_id, parentId=parent_id, pathPart=resource_name)
            self.resource_id = created_resource['id']
            self.log.info("Successfully created resource")
        else:
            self.log.info("Resource already exists. To update resource please delete existing resource: %s",
                          resource_name)
914526
def create(self, create_missing=None):
        
        return HostGroup(
            self._server_config,
            id=self.create_json(create_missing)['id'],
        ).read()
436844
def create_group(self, group_name, path='/'):
        
        params = {'GroupName' : group_name,
                  'Path' : path}
        return self.get_response('CreateGroup', params)
919595
def _maybe_create_resources(logging_task: Task = None):
  """"""

  def log(*args):
    if logging_task:
      logging_task.log(*args)
    else:
      util.log(*args)

  def should_create_resources():
    """Check if gateway, keypair, vpc exist."""
    prefix = u.get_prefix()
    if u.get_keypair_name() not in u.get_keypair_dict():
      log(f"Missing {u.get_keypair_name()} keypair, creating resources")
      return True
    vpcs = u.get_vpc_dict()
    if prefix not in vpcs:
      log(f"Missing {prefix} vpc, creating resources")
      return True
    vpc = vpcs[prefix]
    gateways = u.get_gateway_dict(vpc)
    if prefix not in gateways:
      log(f"Missing {prefix} gateway, creating resources")
      return True
    return False

  try:
    # this locking is approximate, still possible for threads to slip through
    if os.path.exists(AWS_LOCK_FN):
      pid, ts, lock_taskname = open(AWS_LOCK_FN).read().split('-')
      ts = int(ts)
      log(f"waiting for aws resource creation, another resource initiation was "
          f"initiated {int(time.time()-ts)} seconds ago by "
          f"{lock_taskname}, delete lock file "
          f"{AWS_LOCK_FN} if this is an error")
      while True:
        if os.path.exists(AWS_LOCK_FN):
          log(f"waiting for lock file {AWS_LOCK_FN} to get deleted "
              f"initiated {int(time.time()-ts)} seconds ago by ")
          time.sleep(2)
          continue
        else:
          break
      return

    with open(AWS_LOCK_FN, 'w') as f:
      f.write(
        f'{os.getpid()}-{int(time.time())}-{logging_task.name if logging_task else ""}')

    if not should_create_resources():
      util.log("Resources already created, no-op")
      os.remove(AWS_LOCK_FN)
      return

    create_lib.create_resources()
  finally:
    if os.path.exists(AWS_LOCK_FN):
      os.remove(AWS_LOCK_FN)
214789
def empty_group(group_id, scenario_id, **kwargs):
    
    user_id = int(kwargs.get('user_id'))
    #check the scenario exists
    _get_scenario(scenario_id, user_id)

    rgi = db.DBSession.query(ResourceGroupItem).\
            filter(ResourceGroupItem.group_id==group_id).\
            filter(ResourceGroupItem.scenario_id==scenario_id).all()
    rgi.delete()
790601
def _restore_group(self, group_id):
        """"""
        meta = self.TaskSetModel._default_manager.restore_taskset(group_id)
        if meta:
            return meta.to_dict()
441281
def contains_group(store, path=None):
    """"""
    path = normalize_storage_path(path)
    prefix = _path_to_prefix(path)
    key = prefix + group_meta_key
    return key in store
1232257
def add_resourcegroup(group, network_id,**kwargs):
    
    group_i                   = ResourceGroup()
    group_i.name              = group.name
    group_i.description       = group.description
    group_i.status            = group.status
    group_i.network_id        = network_id
    db.DBSession.add(group_i)
    db.DBSession.flush()
    return group_i
640498
def provider_group_factory():
    """"""
    for provider in all_providers():
        p = get_notifier(provider)
        provider_name = p.name
        help = f"Options for '{provider_name}'"
        group = click.Group(name=provider_name, help=help)

        # Notify command
        notify = partial(_notify, p=p)
        group.add_command(schema_to_command(p, "notify", notify, add_message=True))

        # Resources command
        resources_callback = partial(_resources, p=p)
        resources_cmd = click.Command(
            "resources",
            callback=resources_callback,
            help="Show provider resources list",
        )
        group.add_command(resources_cmd)

        pretty_opt = click.Option(
            ["--pretty/--not-pretty"], help="Output a pretty version of the JSON"
        )

        # Add any provider resources
        for resource in p.resources:
            rsc = getattr(p, resource)
            rsrc_callback = partial(_resource, rsc)
            rsrc_command = schema_to_command(
                rsc, resource, rsrc_callback, add_message=False
            )
            rsrc_command.params.append(pretty_opt)
            group.add_command(rsrc_command)

        for name, description in CORE_COMMANDS.items():
            callback = func_factory(p, name)
            params = [pretty_opt]
            command = click.Command(
                name,
                callback=callback,
                help=description.format(provider_name),
                params=params,
            )
            group.add_command(command)

        notifiers_cli.add_command(group)
708814
def check_if_exists(self):
        """"""
        if self.req is None:
            return False
        try:
            self.satisfied_by = pkg_resources.get_distribution(self.req)
        except pkg_resources.DistributionNotFound:
            return False
        except pkg_resources.VersionConflict:
            self.conflicts_with = pkg_resources.get_distribution(self.req.project_name)
        return True
592873
def add_resourcegroupitems(scenario_id, items, scenario=None, **kwargs):

    
    user_id = int(kwargs.get('user_id'))

    if scenario is None:
        scenario = _get_scenario(scenario_id, user_id)

    _check_network_ownership(scenario.network_id, user_id)

    newitems = []
    for group_item in items:
        group_item_i = _add_resourcegroupitem(group_item, scenario.id)
        newitems.append(group_item_i)

    db.DBSession.flush()

    return newitems
876953
def groups_create(self, name, **kwargs):
        """"""
        return self.__call_api_post('groups.create', name=name, kwargs=kwargs)
189475
def add_group(network_id, group,**kwargs):
    

    user_id = kwargs.get('user_id')
    try:
        net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
        net_i.check_write_permission(user_id=user_id)
    except NoResultFound:
        raise ResourceNotFoundError("Network %s not found"%(network_id))

    res_grp_i = net_i.add_group(group.name, group.description, group.status)

    hdb.add_resource_attributes(res_grp_i, group.attributes)

    db.DBSession.flush()
    if group.types is not None and len(group.types) > 0:
        res_types = []
        res_attrs = []
        res_scenarios = {}
        for typesummary in group.types:
            ra, rt, rs = template.set_resource_type(res_grp_i,
                                        typesummary.id,
                                         **kwargs)
            res_types.append(rt)
            res_attrs.extend(ra)
            res_scenarios.update(rs)#rs is a dict
        if len(res_types) > 0:
            db.DBSession.bulk_insert_mappings(ResourceType, res_types)
        if len(res_attrs) > 0:
            db.DBSession.bulk_insert_mappings(ResourceAttr, res_attrs)

            new_res_attrs = db.DBSession.query(ResourceAttr).order_by(ResourceAttr.id.desc()).limit(len(res_attrs)).all()
            all_rs = []
            for ra in new_res_attrs:
                ra_id = ra.id
                if ra.attr_id in res_scenarios:
                    rs_list = res_scenarios[ra.attr_id]
                    for rs in rs_list:
                        rs_list[rs]['resource_attr_id'] = ra_id
                        all_rs.append(rs_list[rs])

            if len(all_rs) > 0:
                db.DBSession.bulk_insert_mappings(ResourceScenario, all_rs)


    db.DBSession.refresh(res_grp_i)

    return res_grp_i
837286
def create_secgroups(self):
        """"""
        utils.banner("Creating Security Group")
        sgobj = securitygroup.SpinnakerSecurityGroup(
            app=self.app, env=self.env, region=self.region, prop_path=self.json_path)
        sgobj.create_security_group()
731288
def secgroup_create(self, name, description):
        '''
        
        '''
        nt_ks = self.compute_conn
        nt_ks.security_groups.create(name, description)
        ret = {'name': name, 'description': description}
        return ret
91944
function ResourceGroupVersion(resource, group, version) {
  this.resource = resource;
  this.group    = group;
  this.version  = version;
  return this;
}