def test_resource_actions(self): actions = [ action.Action("foo", "bar", None), action.Action("baz", "foobar", None), ] res = resource.Resource("title", [], "foo", "summary") res.actions = actions r = self.renderer.get_renderer(res) observed = r.render() self.assertResourceActions(res, actions, observed)
def test_actions(self): actions = [action.Action(None, None, None)] kind = self.obj(*self.args, actions=actions) for i in (self.args): self.assertEqual(i, getattr(kind, i)) self.assertEqual(actions, kind.actions)
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from ooi.occi.core import action from ooi.occi.core import attribute as attr from ooi.occi.core import kind from ooi.occi.core import mixin from ooi.occi.core import resource from ooi.occi import helpers up = action.Action(helpers.build_scheme('infrastructure/network/action'), "up", "up network instance") down = action.Action(helpers.build_scheme('infrastructure/network/action'), "down", "down network instance") class NetworkResource(resource.Resource): attributes = attr.AttributeCollection({ "occi.network.vlan": attr.MutableAttribute("occi.network.vlan", description="802.1q VLAN identifier", attr_type=attr.AttributeType.string_type), "occi.network.label": attr.MutableAttribute("occi.network.label", description="Tag based VLANs", attr_type=attr.AttributeType.string_type),
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from ooi.occi.core import action from ooi.occi.core import attribute as attr from ooi.occi.core import kind from ooi.occi.core import resource from ooi.occi import helpers start = action.Action(helpers.build_scheme('infrastructure/compute/action'), "start", "start compute instance") stop = action.Action(helpers.build_scheme('infrastructure/compute/action'), "stop", "stop compute instance") restart = action.Action(helpers.build_scheme('infrastructure/compute/action'), "restart", "restart compute instance") suspend = action.Action(helpers.build_scheme('infrastructure/compute/action'), "suspend", "suspend compute instance") class ComputeResource(resource.Resource): attributes = attr.AttributeCollection([ "occi.compute.architecture", "occi.compute.cores", "occi.compute.hostname", "occi.compute.speed", "occi.compute.memory",
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from ooi.occi.core import action from ooi.occi.core import attribute as attr from ooi.occi.core import kind from ooi.occi.core import resource from ooi.occi import helpers online = action.Action(helpers.build_scheme('infrastructure/storage/action'), "online", "online storage instance") offline = action.Action(helpers.build_scheme('infrastructure/storage/action'), "offline", "offline storage instance") backup = action.Action(helpers.build_scheme('infrastructure/storage/action'), "backup", "backup storage instance") snapshot = action.Action(helpers.build_scheme('infrastructure/storage/action'), "snapshot", "snapshot storage instance") resize = action.Action(helpers.build_scheme('infrastructure/storage/action'), "resize", "resize storage instance") class StorageResource(resource.Resource):