Пример #1
0
def _parse_security_group_request(args=None):
    if args is None:
        args = {}

    helpers.require_atleast_one_parameter(["GroupName", "GroupId"])

    if helpers.contains_parameter("GroupName"):
        args["securityGroupName"] = helpers.get("GroupName")
        args["name"] = helpers.get("GroupName")
    elif helpers.contains_parameter("GroupId"):
        args["securityGroupId"] = helpers.get("GroupId")
        args["id"] = helpers.get("GroupId")

    helpers.require_parameters(["IpProtocol"])

    args["protocol"] = helpers.get("IpProtocol")

    helpers.require_parameters(["FromPort", "ToPort"])

    if args["protocol"] in ["icmp"]:
        args["icmptype"] = helpers.get("FromPort")
        args["icmpcode"] = helpers.get("ToPort")
    else:
        args["startport"] = helpers.get("FromPort")
        args["endport"] = helpers.get("ToPort")

    if helpers.get("CidrIp") is None:
        args["cidrlist"] = "0.0.0.0/0"
    else:
        args["cidrlist"] = helpers.get("CidrIp")

    return args
Пример #2
0
def _parse_security_group_request(args=None):
    if args is None:
        args = {}

    helpers.require_atleast_one_parameter(['GroupName', 'GroupId'])

    if helpers.contains_parameter('GroupName'):
        args['securityGroupName'] = helpers.get('GroupName')
        args['name'] = helpers.get('GroupName')
    elif helpers.contains_parameter('GroupId'):
        args['securityGroupId'] = helpers.get('GroupId')
        args['id'] = helpers.get('GroupId')

    helpers.require_parameters(['IpProtocol'])

    args['protocol'] = helpers.get('IpProtocol')

    helpers.require_parameters(['FromPort', 'ToPort'])

    if args['protocol'] in ['icmp']:
        args['icmptype'] = helpers.get('FromPort')
        args['icmpcode'] = helpers.get('ToPort')
    else:
        args['startport'] = helpers.get('FromPort')
        args['endport'] = helpers.get('ToPort')

    if helpers.get('CidrIp') is None:
        args['cidrlist'] = '0.0.0.0/0'
    else:
        args['cidrlist'] = helpers.get('CidrIp')

    return args
Пример #3
0
def _delete_security_group_request():
    args = {}

    helpers.require_atleast_one_parameter(["GroupName", "GroupId"])

    if helpers.contains_parameter("GroupName"):
        args["name"] = helpers.get("GroupName")

    elif helpers.contains_parameter("GroupId"):
        args["id"] = helpers.get("GroupId")

    args["command"] = "deleteSecurityGroup"

    response = requester.make_request(args)

    return response
Пример #4
0
def _delete_security_group_request():
    args = {}

    helpers.require_atleast_one_parameter(['GroupName', 'GroupId'])

    if helpers.contains_parameter('GroupName'):
        args['name'] = helpers.get('GroupName')

    elif helpers.contains_parameter('GroupId'):
        args['id'] = helpers.get('GroupId')

    args['command'] = 'deleteSecurityGroup'

    response = requester.make_request(args)

    return response
Пример #5
0
def _delete_security_group_request():
    """
    Request to delete a security group.

    @return: Response.
    """
    args = {}

    helpers.require_atleast_one_parameter(['GroupName', 'GroupId'])

    if helpers.contains_parameter('GroupName'):
        args['name'] = helpers.get('GroupName')

    elif helpers.contains_parameter('GroupId'):
        args['id'] = helpers.get('GroupId')

    args['command'] = 'deleteSecurityGroup'

    response = requester.make_request(args)

    return response
Пример #6
0
def _parse_security_group_request(args=None):
    """
    Parse the request parameters into a Cloudstack request payload.

    @param args: Arguments to include in the request.
    @return: Request payload.
    """
    if args is None:
        args = {}

    helpers.require_atleast_one_parameter(['GroupName', 'GroupId'])

    if helpers.contains_parameter('GroupName'):
        args['securityGroupName'] = helpers.get('GroupName')
        args['name'] = helpers.get('GroupName')
    elif helpers.contains_parameter('GroupId'):
        args['securityGroupId'] = helpers.get('GroupId')
        args['id'] = helpers.get('GroupId')

    helpers.require_parameters(['IpProtocol'])

    args['protocol'] = helpers.get('IpProtocol')

    helpers.require_parameters(['FromPort', 'ToPort'])

    if args['protocol'] in ['icmp']:
        args['icmptype'] = helpers.get('FromPort')
        args['icmpcode'] = helpers.get('ToPort')
    else:
        args['startport'] = helpers.get('FromPort')
        args['endport'] = helpers.get('ToPort')

    if helpers.get('CidrIp') is None:
        args['cidrlist'] = '0.0.0.0/0'
    else:
        args['cidrlist'] = helpers.get('CidrIp')

    return args
Пример #7
0
def _parse_security_group_request(args=None):
    """
    Parse the request parameters into a Cloudstack request payload.

    @param args: Arguments to include in the request.
    @return: Request payload.
    """
    if args is None:
        args = {}

    helpers.require_atleast_one_parameter(['GroupName', 'GroupId'])

    if helpers.contains_parameter('GroupName'):
        args['securityGroupName'] = helpers.get('GroupName')
        args['name'] = helpers.get('GroupName')
    elif helpers.contains_parameter('GroupId'):
        args['securityGroupId'] = helpers.get('GroupId')
        args['id'] = helpers.get('GroupId')

    helpers.require_parameters(['IpProtocol'])

    args['protocol'] = helpers.get('IpProtocol')

    helpers.require_parameters(['FromPort', 'ToPort'])

    if args['protocol'] in ['icmp']:
        args['icmptype'] = helpers.get('FromPort')
        args['icmpcode'] = helpers.get('ToPort')
    else:
        args['startport'] = helpers.get('FromPort')
        args['endport'] = helpers.get('ToPort')

    if helpers.get('CidrIp') is None:
        args['cidrlist'] = '0.0.0.0/0'
    else:
        args['cidrlist'] = helpers.get('CidrIp')

    return args
Пример #8
0
def create_volume():
    helpers.require_atleast_one_parameter(["SnapshotId", "Size"])
    response = _create_volume_request()
    return _create_volume_response(response)
Пример #9
0
def create_volume():
    helpers.require_atleast_one_parameter(['SnapshotId', 'Size'])
    response = _create_volume_request()
    return _create_volume_response(response)