Search in sources :

Example 1 with OpenStackRule

use of com.att.cdp.openstack.model.OpenStackRule in project AJSC by att.

the class OpenStackComputeService method addACLRule.

/**
 * @see com.att.cdp.zones.ComputeService#addACLRule(java.lang.String, com.att.cdp.zones.model.Rule)
 */
@SuppressWarnings("nls")
@Override
public Rule addACLRule(String aclId, Rule rule) throws ZoneException {
    checkArg(aclId, "aclId");
    checkArg(rule, "rule");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        SecurityGroup group = nova.getClient().securityGroups().showSecurityGroup(aclId).execute();
        if (group != null) {
            com.woorea.openstack.nova.model.SecurityGroup.Rule createdRule = nova.getClient().securityGroups().createSecurityGroupRule(aclId, rule.getProtocol().toString(), rule.getFromPort(), rule.getToPort(), rule.getSourceIpRange()).execute();
            return new OpenStackRule(context, createdRule);
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackRule(com.att.cdp.openstack.model.OpenStackRule) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup)

Example 2 with OpenStackRule

use of com.att.cdp.openstack.model.OpenStackRule in project AJSC by att.

the class OpenStackComputeService method addACLRule.

/**
 * @see com.att.cdp.zones.ComputeService#addACLRule(java.lang.String,
 *      com.att.cdp.zones.model.Rule)
 */
@SuppressWarnings("nls")
@Override
public Rule addACLRule(String aclId, Rule rule) throws ZoneException {
    checkArg(aclId, "aclId");
    checkArg(rule, "rule");
    connect();
    Context context = getContext();
    trackRequest(new State(RequestState.SERVICE, "Compute"), new State(RequestState.SERVICE_URL, nova.getEndpoint()));
    try {
        SecurityGroup group = nova.getClient().securityGroups().showSecurityGroup(aclId).execute();
        if (group != null) {
            com.woorea.openstack.nova.model.SecurityGroup.Rule createdRule = nova.getClient().securityGroups().createSecurityGroupRule(aclId, rule.getProtocol().toString(), rule.getFromPort(), rule.getToPort(), rule.getSourceIpRange()).execute();
            return new OpenStackRule(context, createdRule);
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackRule(com.att.cdp.openstack.model.OpenStackRule) RequestState(com.att.cdp.zones.spi.RequestState) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)2 OpenStackRule (com.att.cdp.openstack.model.OpenStackRule)2 Context (com.att.cdp.zones.Context)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)2 SecurityGroup (com.woorea.openstack.nova.model.SecurityGroup)2 RequestState (com.att.cdp.zones.spi.RequestState)1