'Creates OsContract for createServerGroup.
To verify the operation, we just check that the spinnaker security group
for the given application was created.'

def create_a_security_group(self):

    rules = [{'fromPort': 80, 'toPort': 80, 'prevcidr': '0.0.0.0/0', 'cidr': '0.0.0.0/0', 'ruleType': 'TCP', 'remoteSecurityGroupId': '', 'icmpType': (-1), 'icmpCode': (-1)}, {'fromPort': 10, 'toPort': 65530, 'prevcidr': '', 'cidr': '', 'ruleType': 'UDP', 'remoteSecurityGroupId': 'SELF', 'icmpType': (-1), 'icmpCode': (-1)}, {'fromPort': 1, 'toPort': 65535, 'prevcidr': '', 'cidr': '', 'ruleType': 'ICMP', 'remoteSecurityGroupId': 'SELF', 'icmpType': 12, 'icmpCode': 9}]
    job = [{'provider': 'openstack', 'region': self.bindings['OS_REGION_NAME'], 'stack': self.TEST_STACK, 'description': 'Test    -    create    security    group    for    {app}'.format(app=self.TEST_APP), 'detail': '', 'account': self.bindings['SPINNAKER_OS_ACCOUNT'], 'rules': rules, 'name': self.TEST_SECURITY_GROUP, 'securityGroupName': self.TEST_SECURITY_GROUP, 'cloudProvider': 'openstack', 'type': 'upsertSecurityGroup', 'user': self.bindings['TEST_OS_USERNAME']}]
    builder = os.OsContractBuilder(self.os_observer)
    builder.new_clause_builder('Security    Group    Created', retryable_for_secs=30).show_resource('security    group', self.TEST_SECURITY_GROUP).contains_pred_list([jp.DICT_MATCHES({'name': jp.STR_SUBSTR(self.TEST_SECURITY_GROUP), 'rules': (jp.STR_SUBSTR("protocol='tcp'") and jp.STR_SUBSTR("port_range_min='80'") and jp.STR_SUBSTR("port_range_max='80'"))}), jp.DICT_MATCHES({'rules': (jp.STR_SUBSTR("protocol='udp'") and jp.STR_SUBSTR("port_range_min='10'") and jp.STR_SUBSTR("port_range_max='65530'"))}), jp.DICT_MATCHES({'rules': (jp.STR_SUBSTR("protocol='icmp'") and jp.STR_SUBSTR("port_range_min='12'") and jp.STR_SUBSTR("port_range_max='9'"))})])
    payload = self.agent.make_json_payload_from_kwargs(job=job, description='    Test    -    create    security    group    for    {app}'.format(app=self.TEST_APP), application=self.TEST_APP)
    return st.OperationContract(self.new_post_operation(title='create_security_group', data=payload, path='applications/{app}/tasks'.format(app=self.TEST_APP)), contract=builder.build())
