def post(self, request): """Create a network :param admin_state_up (optional): The administrative state of the network, which is up (true) or down (false). :param name (optional): The network name. A request body is optional: If you include it, it can specify this optional attribute. :param net_profile_id (optional): network profile id :param shared (optional): Indicates whether this network is shared across all tenants. By default, only administrative users can change this value. :param tenant_id (optional): Admin-only. The UUID of the tenant that will own the network. This tenant can be different from the tenant that makes the create network request. However, only administrative users can specify a tenant ID other than their own. You cannot change this value through authorization policies. :return: JSON representation of a Network """ if not api.neutron.is_port_profiles_supported(): request.DATA.pop("net_profile_id", None) new_network = api.neutron.network_create(request, **request.DATA) rest_utils.ensure_tenant_name(request, [new_network]) new_network_dict = new_network.to_dict() if hasattr(new_network, 'tenant_name'): new_network_dict.update({'tenant_name': new_network.tenant_name}) new_network_dict.update({'domain_id': new_network.domain_id}) rest_utils.ensure_domain_name(request, [new_network_dict]) return rest_utils.CreatedResponse( '/api/neutron/networks/%s' % new_network.id, new_network_dict)
def post(self, request): if not hasattr(request, 'DATA'): request.DATA = request.POST data = request.FILES['image_file'] result = self.getFile(request, data) return rest_utils.CreatedResponse("/api/uus/upgrade/", result)
def patch(self, request, ipsecsiteconnection_id): new_ipsecsiteconnection = api.vpn.ipsecsiteconnection_update( request, ipsecsiteconnection_id, **request.DATA) return rest_utils.CreatedResponse( '/api/vpn/ipsecsiteconnection/%s' % utils_http.urlquote(new_ipsecsiteconnection.id), new_ipsecsiteconnection.to_dict())
def post(self, request): """Create a Subnet for a given Network :param name (optional): The subnet name. :param network_id: The ID of the attached network. :param tenant_id (optional): The ID of the tenant who owns the network. Only administrative users can specify a tenant ID other than their own. :param allocation_pools (optional): The start and end addresses for the allocation pools. :param gateway_ip (optional): The gateway IP address. :param ip_version: The IP version, which is 4 or 6. :param cidr: The CIDR. :param id (optional): The ID of the subnet. :param enable_dhcp (optional): Set to true if DHCP is enabled and false if DHCP is disabled. :return: JSON representation of a Subnet """ new_subnet = api.neutron.subnet_create(request, **request.DATA) new_network_dict = new_subnet.to_dict() rest_utils.ensure_neutron_parent_network_name(request, [new_network_dict]) return rest_utils.CreatedResponse( '/api/neutron/subnets/%s' % new_subnet.id, new_network_dict)
def post(self, request): kwargs = request.DATA policy_id = kwargs.pop('policy_id') rule = api.neutron.bandwidth_limit_rule_create(request, policy_id, **kwargs) return rest_utils.CreatedResponse( '/api/neutron/bandwidthlimitrules/%s' % rule.id, rule.to_dict())
def patch(self, request, policy_id): kwargs = request.DATA new_policy = api.neutron.qos_policy_update(request, policy_id, **kwargs) return rest_utils.CreatedResponse( '/api/neutron/router/%s' % utils_http.urlquote(new_policy.name), new_policy.to_dict())
def post(self, request, volume_id): keys = tuple(request.DATA) if 'backup_id' and 'volume_id' in keys: if request.DATA['volume_id'] == 'Choose No': restore = api.cinder.volume_backup_restore_default( request, backup_id=request.DATA['backup_id'], ) else: restore = api.cinder.volume_backup_restore( request, volume_id=request.DATA['volume_id'], backup_id=request.DATA['backup_id'], ) result_dict = {'backup_id' : restore.backup_id, 'volume_id' : restore.volume_id, 'volume_name' : restore.volume_name } return {'items': result_dict} else: if(request.DATA['backup_type']==u'full'): increment = False new_backup = api.cinder.volume_backup_create( request, volume_id=request.DATA['volume']['id'], name=request.DATA.get('name'), incremental=increment, description=request.DATA.get('description', None), ) return rest_utils.CreatedResponse( '/api/cinder/volumebackup/%s' % new_backup.id, new_backup.to_dict() ) else: increment = True new_backup = api.cinder.volume_backup_incre_create( request, volume_id=request.DATA['volume']['id'], name=request.DATA.get('name'), incremental=increment, description=request.DATA.get('description', None), ) return rest_utils.CreatedResponse( '/api/cinder/volumebackup/%s' % new_backup.id, new_backup.to_dict() )
def patch(self, request, port_id): kwargs = request.DATA new = api.neutron.port_update(request, port_id, **kwargs) port_dict = new.to_dict() rest_utils.ensure_floatingip_instance_for_port(request, [port_dict]) rest_utils.ensure_fixed_ip_for_ports(request, [port_dict]) return rest_utils.CreatedResponse( '/api/neutron/ports/%s' % utils_http.urlquote(new.name), port_dict)
def post(self, request, router_id): new_router_port = api.neutron.router_add_interface( request, router_id, subnet_id=request.DATA.get('subnet_id'), port_id=request.DATA.get('port_id')) return rest_utils.CreatedResponse( '/api/neutron/router/%s' % utils_http.urlquote(new_router_port.get('id')), new_router_port)
def post(self, request): kwargs = request.DATA policy_param = {'name': kwargs.get('name')} new_qos_policy = api.neutron.create_qos_policy(request, **policy_param) rule_param = {'max_kbps': kwargs.get('max_kbps')} api.neutron.bandwidth_limit_rule_create(request, new_qos_policy.id, **rule_param) return rest_utils.CreatedResponse( '/api/neutron/qospolicyandrules/%s' % new_qos_policy.id, new_qos_policy.to_dict())
def post(self, request): """Create a role. Create a role using the "name" (string) parameter supplied in the POST application/json object. This method returns the new role object on success. """ new_role = api.keystone.role_create(request, request.DATA['name']) return rest_utils.CreatedResponse( '/api/keystone/roles/%s' % new_role.id, new_role.to_dict())
def post(self, request, volume_id): new_volume_snapshot = api.cinder.volume_snapshot_create( request, volume_id=volume_id, name=request.DATA.get('name'), description=request.DATA.get('description', None), force=request.DATA.get('force', False), ) return rest_utils.CreatedResponse( '/api/cinder/volumesnapshot/%s' % new_volume_snapshot.id, new_volume_snapshot.to_dict() )
def post(self, request, volume_id): response = api.cinder.volume_upload_to_image( request, volume_id=volume_id, image_name=request.DATA['name'], container_format='bare', disk_format='raw', force='True') new_volume_image = response[1]['os-volume_upload_image'] return rest_utils.CreatedResponse( '/api/cinder/volumetoimage/%s' % new_volume_image['id'], new_volume_image )
def post(self, request): body = request.DATA unit = meter_unit.get(body.get('threshold_rule').get('meter_name')) if unit == 'MB/s': body['threshold_rule']['threshold'] = body[ 'threshold_rule']['threshold'] * 1024 * 1024 new_alarm = api.ceilometer.alarm_create(request, ceilometer_usage=None, **body) _dic = new_alarm.to_dict() _dic.update({'create_time': format_time(_dic.get('timestamp'))}) return rest_utils.CreatedResponse( '/api/ceilometer/alarms/%s' % utils_http.urlquote(new_alarm.id), _dic )
def post(self, request): """Create notify list, update current user""" user_id = request.user.id admin = request.user.is_superuser user = api.keystone.user_get(request, user_id, admin) dic = user.to_dict() notify_list = dic.get('notify_list') if notify_list == None: notify_list = [] notify_list.append(request.DATA) data = {'notify_list': notify_list} data.update({'project': request.user.tenant_id}) api.keystone.user_update(request, user, admin, **data) return rest_utils.CreatedResponse('/api/keystone/notifylist/', request.DATA)
def post(self, request): """Create IKEPolicy :param request: request context :param name: name for IKEPolicy :param description: description for IKEPolicy :param auth_algorithm: authorization algorithm for IKEPolicy :param encryption_algorithm: encryption algorithm for IKEPolicy :param ike_version: IKE version for IKEPolicy :param lifetime: Lifetime Units and Value for IKEPolicy :param pfs: Perfect Forward Secrecy for IKEPolicy :param phase1_negotiation_mode: IKE Phase1 negotiation mode for IKEPolicy """ new_ikepolicy = api.vpn.ikepolicy_create(request, **request.DATA) return rest_utils.CreatedResponse( '/api/vpn/ikepolicy/%s' % new_ikepolicy.id, new_ikepolicy.to_dict())
def post(self, request): """Create IPSecPolicy :param request: request context :param name: name for IPSecPolicy :param description: description for IPSecPolicy :param auth_algorithm: authorization algorithm for IPSecPolicy :param encapsulation_mode: encapsulation mode for IPSecPolicy :param encryption_algorithm: encryption algorithm for IPSecPolicy :param lifetime: Lifetime Units and Value for IPSecPolicy :param pfs: Perfect Forward Secrecy for IPSecPolicy :param transform_protocol: Transform Protocol for IPSecPolicy """ new_ipsecpolicy = api.vpn.ipsecpolicy_create(request, **request.DATA) return rest_utils.CreatedResponse( '/api/vpn/ipsecpolicies/%s' % new_ipsecpolicy.id, new_ipsecpolicy.to_dict())
def patch(self, request, policy_id): """Add a single firewall rule to policy by id. This method returns HTTP 204 (no content) on success. """ if id == 'default': return http.HttpResponseNotFound('default') policy = api.fwaas.policy_get(request, policy_id) rules = policy.firewall_rules rule_id = request.DATA.get('rule') rules.append(rule_id) body = {'firewall_rules': rules} new = api.fwaas.policy_update(request, policy_id, **body) return rest_utils.CreatedResponse( '/api/network/firewallpolicyrule/%s' % utils_http.urlquote(new.name), new.to_dict())
def post(self, request): """Create a firewall. Create a firewall using the parameters supplied in the POST application/json object. The parameters are: :param name: name for firewall :param description: description for firewall :param firewall_policy_id: policy id used by firewall :param shared: boolean (default false) :param admin_state_up: boolean (default true) This returns the new firewall object on success. """ new = api.fwaas.firewall_create(request, **request.DATA) return rest_utils.CreatedResponse( '/api/network/firewalls/%s' % utils_http.urlquote(new.name), new.to_dict())
def post(self, request, retrieve_all=None): """ Create a router. :param name: (optional) name of the router created :return: JSON representation of a Router """ filter, kargs = rest_utils.parse_filters_kwargs(request) if api.keystone.is_dedicated_context(request): filter['domain_id'] = request.user.user_domain_id filter['dedicated'] = True if ('unit' in filter): del filter['unit'] new_router = api.neutron.router_create(request, **filter) return rest_utils.CreatedResponse( '/api/neutron/router/%s' % new_router.id, new_router.to_dict())
def post(self, request): new_volume = api.cinder.volume_create( request, size=request.DATA.get('size'), name=request.DATA.get('name'), description=request.DATA.get('description'), volume_type=request.DATA.get('volume_type'), snapshot_id=request.DATA.get('snapshot_id', None), multiattach=request.DATA.get('multiattach', False), metadata=request.DATA.get('metadata', None), image_id=request.DATA.get('image_id', None), availability_zone=request.DATA.get('availability_zone', None), source_volid=request.DATA.get('source_volid', None), ) return rest_utils.CreatedResponse( '/api/cinder/volume/%s' % new_volume.id, new_volume.to_dict() )
def post(self, request): """Create a firewall. Create a firewall policy using the parameters supplied in the POST application/json object. The parameters are: :param request: request context :param name: name for policy :param description: description for policy :param firewall_rules: ordered list of rules in policy :param shared: boolean (default false) :param audited: boolean (default false) This returns the new firewall policy object on success. """ new = api.fwaas.policy_create(request, **request.DATA) return rest_utils.CreatedResponse( '/api/network/firewallpolicies/%s' % utils_http.urlquote(new.name), new.to_dict())
def post(self, request): """Perform some action on the collection of domains. This action creates a domain using parameters supplied in the POST application/json object. The "name" (string) parameter is required, others are optional: "description" (string) and "enabled" (boolean, defaults to true). This method returns the new domain object on success. """ new_domain = api.keystone.domain_create( request, request.DATA['name'], id=request.DATA.get('id', None), description=request.DATA.get('description', None), enabled=request.DATA.get('enabled', False), ) api.keystone.dedicated_tenant_init(request, new_domain.id) return rest_utils.CreatedResponse( '/api/keystone/domains/%s' % new_domain.id, new_domain.to_dict())
def post(self, request): """Create a project (tenant). Create a project using parameters supplied in the POST application/json object. The "name" (string) parameter is required, others are optional: "description" (string), "domain_id" (string) and "enabled" (boolean, defaults to true). Additional, undefined parameters may also be provided, but you'll have to look deep into keystone to figure out what they might be. This method returns the new project object on success. """ kwargs = _tenant_kwargs_from_DATA(request.DATA) if not kwargs['name']: raise rest_utils.AjaxError(400, '"name" is required') new_project = api.keystone.tenant_create(request, kwargs.pop('name'), **kwargs) return rest_utils.CreatedResponse( '/api/keystone/projects/%s' % new_project.id, new_project.to_dict())
def post(self, request): """Create a image. This action returns the new image object on success. """ if not hasattr(request, 'DATA'): request.DATA = request.POST meta = self.ensureMeta(request) new_image = api.glance.image_create(request, **meta) # add tenant_name before return rest_utils.ensure_tenant_name(request, [new_image], tenant_id_str='owner') new_image_dict = new_image.to_dict() new_image_dict['tenant_name'] = new_image.tenant_name return rest_utils.CreatedResponse( '/api/keystone/users/%s' % new_image.id, new_image_dict)
def post(self, request): """ Create a port on a specified network. :param network_id: network id a subnet is created on :param device_id: (optional) device id attached to the port :param tenant_id: (optional) tenant id of the port created :param name: (optional) name of the port created :return: JSON representation of a Port """ kwargs = request.DATA network_id = kwargs.pop('network_id') new_port = api.neutron.port_create(request, network_id, **kwargs) new_port_dict = new_port.to_dict() rest_utils.ensure_floatingip_instance_for_port(request, [new_port_dict]) rest_utils.ensure_fixed_ip_for_ports(request, [new_port_dict]) return rest_utils.CreatedResponse( '/api/neutron/ports/%s' % new_port.id, new_port.to_dict())
def post(self, request): """Create a firewall rule. Create a firewall rule using the parameters supplied in the POST application/json object. The parameters are: :param name: name for rule :param description: description for rule :param protocol: protocol for rule :param action: action for rule :param source_ip_address: source IP address or subnet :param source_port: integer in [1, 65535] or range in a:b :param destination_ip_address: destination IP address or subnet :param destination_port: integer in [1, 65535] or range in a:b :param shared: boolean (default false) :param enabled: boolean (default true) This returns the new firewall rule object on success. """ new = api.fwaas.rule_create(request, **request.DATA) return rest_utils.CreatedResponse( '/api/network/firewallrules/%s' % utils_http.urlquote(new.name), new.to_dict())
def patch(self, request, firewall_id): new = api.fwaas.firewall_update(request, firewall_id, **request.DATA) return rest_utils.CreatedResponse( '/api/network/firewall/%s' % utils_http.urlquote(new.name), new.to_dict())
def patch(self, request, router_id): new = api.neutron.router_update(request, router_id, **request.DATA) return rest_utils.CreatedResponse( '/api/neutron/router/%s' % utils_http.urlquote(new.name), new.to_dict())
def post(self, request): kwargs = request.DATA policy = api.neutron.create_qos_policy(request, **kwargs) return rest_utils.CreatedResponse( '/api/neutron/qospolicys/%s' % policy.id, policy.to_dict())