1 <?php
2 /**
3 * Copyright 2012-2014 Rackspace US, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 namespace OpenCloud\Networking\Resource;
19
20 use OpenCloud\Common\Resource\PersistentResource;
21
22 /**
23 * A port represents a virtual switch port on a logical network switch, represented
24 * by {@see \OpenCloud\Networking\Resource\Network}. Virtual instances (such as
25 * servers created using the {@see \OpenCloud\Compute\Service}) attach their
26 * interfaces into ports. The port also defines the MAC address and the IP
27 * address(es) to be assigned to the interfaces plugged into them. When IP addresses
28 * are associated to a port, this also implies the port is associated with a {@see
29 * \OpenCloud\Networking\Resource\Subnet}, as the IP address is taken from the
30 * allocation pool for a specific subnet.
31 *
32 * @see http://docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html#Port
33 *
34 * @package OpenCloud\Networking\Resource
35 */
36 class Port extends PersistentResource
37 {
38 protected static $url_resource = 'ports';
39 protected static $json_name = 'port';
40
41 protected $id;
42 protected $name;
43 protected $adminStateUp;
44 protected $networkId;
45 protected $deviceId;
46 protected $deviceOwner;
47 protected $fixedIps;
48 protected $macAddress;
49 protected $securityGroups;
50 protected $status;
51 protected $tenantId;
52 protected $links;
53
54 protected $aliases = array(
55 'admin_state_up' => 'adminStateUp',
56 'network_id' => 'networkId',
57 'device_id' => 'deviceId',
58 'device_owner' => 'deviceOwner',
59 'fixed_ips' => 'fixedIps',
60 'mac_address' => 'macAddress',
61 'security_groups' => 'securityGroups',
62 'tenant_id' => 'tenantId',
63 'subnet_id' => 'subnetId',
64 'ip_address' => 'ipAddress'
65 );
66
67 protected $createKeys = array(
68 'name',
69 'adminStateUp',
70 'networkId',
71 'deviceId',
72 'deviceOwner',
73 'fixedIps',
74 'macAddress',
75 'securityGroups',
76 'tenantId'
77 );
78
79 protected $updateKeys = array(
80 'name',
81 'adminStateUp',
82 'deviceId',
83 'deviceOwner',
84 'fixedIps',
85 'securityGroups'
86 );
87
88 /**
89 * This method is inherited. The inherited method has protected scope
90 * but we are widening the scope to public so this method may be called
91 * from other classes such as {@see OpenCloud\Networking\Service}.
92 */
93 public function createJson()
94 {
95 return parent::createJson();
96 }
97 }
98