Add a security group rule to group <sgid>.
           Direction is either 'in' (ingress) or 'out' (egress).
           See modify() for other parameters.
552879
def add(self, sgid, other, proto_spec, direction="in"):
        """"""
        # returns bool
        # AuthorizeSecurityGroupIngress, AuthorizeSecurityGroupEgress
        if direction == "in":
            api = "AuthorizeSecurityGroupIngress"
        elif direction == "out":
            api = "AuthorizeSecurityGroupEgress"
        else:
            raise ValueError("direction must be one of ('in', 'out')")
        return self.modify(api, sgid, other, proto_spec)
1063203
def move_entry(self, entry = None, group = None):
        

        if entry is None or group is None or type(entry) is not v1Entry or \
            type(group) is not v1Group:
            raise KPError("Need an entry and a group.")
        elif entry not in self.entries:
            raise KPError("No entry found.")
        elif group in self.groups:
            entry.group.entries.remove(entry)
            group.entries.append(entry)
            entry.group_id = group.id_
            entry.group = group
            return True
        else:
            raise KPError("No group found.")
38735
public void changeGroup(String group, String file)
        throws IOException, ServerException {
        String arguments = group + " " + file;
        Command cmd = new Command("SITE CHGRP", arguments);
        try {
            controlChannel.execute(cmd);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(urce);
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        }
    }
924771
def remove(env, securitygroup_id, rule_id):
    """"""
    mgr = SoftLayer.NetworkManager(env.client)

    ret = mgr.remove_securitygroup_rule(securitygroup_id, rule_id)

    if not ret:
        raise exceptions.CLIAbort("Failed to remove security group rule")

    table = formatting.Table(REQUEST_BOOL_COLUMNS)
    table.add_row([ret['requestId']])

    env.fout(table)
258080
def change_channel_group(self, group):
        """"""
        assert self._probe is not None
        self._channels = _probe_channels(self._probe, group)
        self._positions = _probe_positions(self._probe, group)
1277465
private void onPublicKeysGroupAdded(int uid, ApiEncryptionKeyGroup keyGroup) {
        UserKeys userKeys = getCachedUserKeys(uid);
        if (userKeys == null) {
            return;
        }
        UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup);
        if (validatedKeysGroup != null) {
            UserKeys updatedUserKeys = userKeys.addUserKeyGroup(validatedKeysGroup);
            cacheUserKeys(updatedUserKeys);
            context().getEncryption().getEncryptedChatManager(uid)
                    .send(new EncryptedPeerActor.KeyGroupUpdated(userKeys));
        }
    }
485299
public void authorizeSecurityGroupRule(SecurityGroupRuleOperateRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getSecurityGroupId(), "securityGroupId should not be empty.");
        if (Strings.isNullOrEmpty(request.getClientToken())) {
            request.setClientToken(this.generateClientToken());
        }
        if (null == request.getRule()) {
            throw new IllegalArgumentException("request rule should not be null");
        }
        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, SECURITYGROUP_PREFIX,
                request.getSecurityGroupId());
        internalRequest.addParameter("authorizeRule", null);
        internalRequest.addParameter("clientToken", request.getClientToken());
        fillPayload(internalRequest, request);
        invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
345083
function(group)
	{
	    var bounds = {};
	    
	    var setBound = function(position)
		{
		    var left, top;
		    left = position[0];
		    top = position[1];
		    
		    if ((typeof bounds["left"] == "undefined") || bounds["left"] > left)
			bounds["left"] = left;
			
		    if ((typeof bounds["right"] == "undefined") || bounds["right"] < left)
			bounds["right"] = left;

		    if ((typeof bounds["top"] == "undefined") || bounds["top"] > top)
			bounds["top"] = top;

		    if ((typeof bounds["bottom"] == "undefined") || bounds["bottom"] < top)
			bounds["bottom"] = top;
		}
	    
	    if (lang.isObject(group.groupContainer))
	    {
		setBound(group.groupContainer.getConfig().position)
	    }
	    else
	    {
		for (var cI in group.containers)
		{
		    var c = group.containers[cI].container;
		    var config = c.getConfig();
		    
		    setBound(config.position);
		}
		
		for (var gI in group.groups)
		{
		    var g = group.groups[gI].group;
		    
		    setBound(WireIt.GroupUtils.workOutCenter(g));
		}
	    }
	    return [
		    ((bounds.right + bounds.left)/2),
		    ((bounds.top + bounds.bottom)/2)
		];
	}
418940
def _create_security_group(self, ingress):
        
        template_kwargs = {
            'app': self.app_name,
            'env': self.env,
            'region': self.region,
            'vpc': get_vpc_id(self.env, self.region),
            'description': self.properties['security_group']['description'],
            'ingress': ingress,
        }

        secgroup_json = get_template(
            template_file='infrastructure/securitygroup_data.json.j2', formats=self.generated, **template_kwargs)

        wait_for_task(secgroup_json)
        return True
1308290
def filter_existing_rules(self, rules, group):
        
        tmp = []
        for rule in rules:

            def eq(x):
                # returns True if this existing AWS rule matches the one we want to create
                assert isinstance(x, boto.ec2.securitygroup.IPPermissions)
                # these are simple catches that determine if we can rule out
                # the existing rule
                group_match = False
                if rule.group_name:
                    logger.debug("Checking for possible group name match %s", x.grants[0].group_id)

                if rule.group_name and x.grants[0].group_id \
                    and rule.group_name != self.get_group(x.grants[0].group_id).name:
                    logger.debug("Group name %s didn't match %s", rule.group_name, x.grants[0].name)
                    return False

                if x.ip_protocol != rule.protocol:
                    logger.debug("ruled out due to protocol: %s vs %s", x.ip_protocol, rule.protocol)
                    return False

                if int(x.from_port) != int(rule.from_port):
                    logger.debug("ruled out due to from_port: %s vs %s", int(x.from_port), int(rule.from_port))
                    return False

                if int(x.to_port) != (rule.to_port):
                    logger.debug("ruled out due to to_port: %s vs %s", int(x.to_port), int(rule.to_port))
                    return False

                # final checks - if one of these rules matches we already have a matching rule
                # and we return True
                if rule.address and not filter(lambda y: y.cidr_ip == rule.address, x.grants ):
                    logger.debug("%s not found in grants", rule.address)
                    return False

                logger.debug("%s %s ok", rule.address, rule.group_name)
                logger.debug("port_from: %s %s", rule.from_port, x.from_port)
                logger.debug("port_to: %s %s", rule.to_port, x.to_port)
                logger.debug("group: %s %s", rule.group_name, x.to_port)
                return True

            logger.debug("Applying rules for %s", group.name)
            filtered = filter(eq, group.rules)

            if not filtered:
                logger.debug(filtered)
                logger.debug("Applying rule %s against %s", rule, group.rules)
                tmp.append(rule)
        return tmp
650103
def parse_security_group(self, global_params, region, group):
        
        vpc_id = group['VpcId'] if 'VpcId' in group and group['VpcId'] else ec2_classic
        manage_dictionary(self.vpcs, vpc_id, VPCConfig(self.vpc_resource_types))
        security_group = {}
        security_group['name'] = group['GroupName']
        security_group['id'] = group['GroupId']
        security_group['description'] = group['Description']
        security_group['owner_id'] = group['OwnerId']
        security_group['rules'] = {'ingress': {}, 'egress': {}}
        security_group['rules']['ingress']['protocols'], security_group['rules']['ingress']['count'] = self.__parse_security_group_rules(group['IpPermissions'])
        security_group['rules']['egress']['protocols'], security_group['rules']['egress']['count'] = self.__parse_security_group_rules(group['IpPermissionsEgress'])
        self.vpcs[vpc_id].security_groups[group['GroupId']] = security_group
434872
public void move(String openId, int group) {
        String url = WxEndpoint.get("url.group.user.move");
        String json = String.format("{\"openid\":\"%s\",\"to_groupid\":%s}", openId, group);
        logger.debug("move user group: {}", json);
        wxClient.post(url, json);
    }
1333988
def cli(env, group_id, name, description):
    """"""
    mgr = SoftLayer.NetworkManager(env.client)
    data = {}
    if name:
        data['name'] = name
    if description:
        data['description'] = description

    if not mgr.edit_securitygroup(group_id, **data):
        raise exceptions.CLIAbort("Failed to edit security group")
133916
function buildBastionSecurityGroup(sourceIp = '0.0.0.0/0', { name = 'BastionSecurityGroup' } = {}) {
  return {
    [name]: {
      Type: 'AWS::EC2::SecurityGroup',
      Properties: {
        GroupDescription: 'Bastion Host',
        VpcId: {
          Ref: 'VPC',
        },
        SecurityGroupIngress: [
          {
            Description: 'Allow inbound SSH access to the bastion host',
            IpProtocol: 'tcp',
            FromPort: 22,
            ToPort: 22,
            CidrIp: sourceIp,
          },
          {
            Description: 'Allow inbound ICMP to the bastion host',
            IpProtocol: 'icmp',
            FromPort: -1,
            ToPort: -1,
            CidrIp: sourceIp,
          },
        ],
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'bastion',
                ],
              ],
            },
          },
        ],
      },
    },
  };
}
721986
def edit(env, securitygroup_id, rule_id, remote_ip, remote_group,
         direction, ethertype, port_max, port_min, protocol):
    """"""
    mgr = SoftLayer.NetworkManager(env.client)

    data = {}
    if remote_ip:
        data['remote_ip'] = remote_ip
    if remote_group:
        data['remote_group'] = remote_group
    if direction:
        data['direction'] = direction
    if ethertype:
        data['ethertype'] = ethertype
    if port_max is not None:
        data['port_max'] = port_max
    if port_min is not None:
        data['port_min'] = port_min
    if protocol:
        data['protocol'] = protocol

    ret = mgr.edit_securitygroup_rule(securitygroup_id, rule_id, **data)

    if not ret:
        raise exceptions.CLIAbort("Failed to edit security group rule")

    table = formatting.Table(REQUEST_BOOL_COLUMNS)
    table.add_row([ret['requestId']])

    env.fout(table)
265699
function buildNatSecurityGroup(subnets = [], { name = 'NatSecurityGroup' } = {}) {
  const SecurityGroupIngress = [];

  if (Array.isArray(subnets) && subnets.length > 0) {
    subnets.forEach((subnet, index) => {
      const position = index + 1;

      const http = {
        Description: `Allow inbound HTTP traffic from ${APP_SUBNET}Subnet${position}`,
        IpProtocol: 'tcp',
        FromPort: 80,
        ToPort: 80,
        CidrIp: subnet,
      };
      const https = {
        Description: `Allow inbound HTTPS traffic from ${APP_SUBNET}Subnet${position}`,
        IpProtocol: 'tcp',
        FromPort: 443,
        ToPort: 443,
        CidrIp: subnet,
      };
      SecurityGroupIngress.push(http, https);
    });
  }

  return {
    [name]: {
      Type: 'AWS::EC2::SecurityGroup',
      Properties: {
        GroupDescription: 'NAT Instance',
        VpcId: {
          Ref: 'VPC',
        },
        SecurityGroupEgress: [
          {
            Description: 'Allow outbound HTTP access to the Internet',
            IpProtocol: 'tcp',
            FromPort: 80,
            ToPort: 80,
            CidrIp: '0.0.0.0/0',
          },
          {
            Description: 'Allow outbound HTTPS access to the Internet',
            IpProtocol: 'tcp',
            FromPort: 443,
            ToPort: 443,
            CidrIp: '0.0.0.0/0',
          },
        ],
        SecurityGroupIngress,
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'nat',
                ],
              ],
            },
          },
        ],
      },
    },
  };
}
996004
public static void addSuccessAndErrorConditionsAndActions(final JpaRolloutGroup group,
            final RolloutGroupConditions conditions) {
        addSuccessAndErrorConditionsAndActions(group, conditions.getSuccessCondition(),
                conditions.getSuccessConditionExp(), conditions.getSuccessAction(), conditions.getSuccessActionExp(),
                conditions.getErrorCondition(), conditions.getErrorConditionExp(), conditions.getErrorAction(),
                conditions.getErrorActionExp());
    }