Dummy Adaptor
Introduction
Dummy is used to quickly experience Octopus. The Dummy adaptor can simulate the interaction of limb and adaptor.
Registration Information
Versions | Register Name | Endpoint Socket | Available |
---|---|---|---|
v1alpha1 | adaptors.edge.cattle.io/dummy | dummy.sock | * |
Support Model
Kind | Group | Version | Available |
---|---|---|---|
DummySpecialDevice | devices.edge.cattle.io | v1alpha1 | * |
DummyProtocolDevice | devices.edge.cattle.io | v1alpha1 | * |
Support Platform
OS | Arch |
---|---|
linux | amd64 |
linux | arm |
linux | arm64 |
Usage
Authority
Grant permissions to Octopus as below:
Example
Specifies a
DummySpecialDevice
device link to connect a fake fan in living room.apiVersion: edge.cattle.io/v1alpha1kind: DeviceLinkmetadata:name: living-room-fanspec:adaptor:node: edge-workername: adaptors.edge.cattle.io/dummymodel:apiVersion: "devices.edge.cattle.io/v1alpha1"kind: "DummySpecialDevice"# uses Secret resourcesreferences:- name: "ca"secret:name: "living-room-fan-mqtt-ca"- name: "tls"secret:name: "living-room-fan-mqtt-tls"template:metadata:labels:device: living-room-fanspec:# integrates with MQTTextension:mqtt:client:server: tcps://test.mosquitto.org:8884tlsConfig:caFilePEMRef:name: caitem: ca.crtcertFilePEMRef:name: tlsitem: tls.crtkeyFilePEMRef:name: tlsitem: tls.keyserverName: test.mosquitto.orginsecureSkipVerify: truemessage:# uses dynamic topic with namespaced nametopic: "cattle.io/octopus/:namespace/:name"protocol:location: "living_room"gear: slow"on": trueSpecifies a
DummyProtocolDevice
device link to connect the chaos robot of localhost.apiVersion: edge.cattle.io/v1alpha1kind: DeviceLinkmetadata:name: localhost-robotspec:adaptor:node: edge-workername: adaptors.edge.cattle.io/dummymodel:apiVersion: "devices.edge.cattle.io/v1alpha1"kind: "DummyProtocolDevice"template:metadata:labels:device: localhost-robotspec:protocol:ip: "127.0.0.1"properties:name:type: stringdescription: "The name (unique identifier) of the robot."readOnly: truegender:type: objectdescription: "The gender of the robot."objectProperties:name:type: stringdescription: "The name of the gender."code:type: intdescription: "The code of the gender."friends:type: arraydescription: "The name list of the robot's friends."arrayProperties:type: stringdescription: "The name of the friend."power:type: floatdescription: "The power of the robot."
For more Dummy*Device
device link examples, please refer to the deploy/e2e directory.
DummySpecialDevice
The DummySpecialDevice
can be considered as a fake fan.
Parameter | Description | Schema | Required |
---|---|---|---|
metadata | metav1.ObjectMeta | false | |
spec | Defines the desired state of DummySpecialDevice . | DummySpecialDeviceSpec | true |
status | Defines the observed state of DummySpecialDevice . | DummySpecialDeviceStatus | false |
DummySpecialDeviceSpec
Parameter | Description | Schema | Required |
---|---|---|---|
extension | Specifies the extension of device. | DummyDeviceExtension | false |
protocol | Specifies the protocol for accessing the device. | DummySpecialDeviceProtocol | true |
on | Specifies if turn on the device. | bool | true |
gear | Specifies how fast the device should be, default to slow . | DummySpecialDeviceGear | false |
DummySpecialDeviceStatus
Parameter | Description | Schema | Required |
---|---|---|---|
gear | Reports the current gear of device. | DummySpecialDeviceGear | false |
rotatingSpeed | Reports the detail number of speed. | int32 | false |
DummySpecialDeviceProtocol
Parameter | Description | Schema | Required |
---|---|---|---|
location | Specifies the location of device. | string | true |
DummySpecialDeviceGear
DummySpecialDeviceGear defines how fast the dummy special device should be.
Parameter | Description | Schema |
---|---|---|
slow | Starts from 0 and increases every three seconds until 100. | string |
middle | Starts from 100 and increases every two seconds until 200. | string |
fast | Starts from 200 and increases every one second until 300. | string |
DummyProtocolDevice
The DummyProtocolDevice
can be considered as a chaos protocol robot, it will change its attribute values every two seconds.
Parameter | Description | Schema | Required |
---|---|---|---|
metadata | metav1.ObjectMeta | false | |
spec | Defines the desired state of DummyProtocolDevice . | DummyProtocolDeviceSpec | true |
status | Defines the observed state of DummyProtocolDevice . | DummyProtocolDeviceStatus | false |
DummyProtocolDeviceSpec
Parameter | Description | Schema | Required |
---|---|---|---|
extension | Specifies the extension of device. | DummyDeviceExtension | false |
protocol | Specifies the protocol for accessing the device. | DummyProtocolDeviceProtocol | true |
properties | Specifies the properties of device. | map[string]DummyProtocolDeviceProperty | false |
DummyProtocolDeviceStatus
Parameter | Description | Schema | Required |
---|---|---|---|
extension | Reports the extension of device. | DeviceExtensionStatus | false |
properties | Reports the observed value of the desired properties. | map[string]DummyProtocolDeviceStatusProperty | false |
DummyProtocolDeviceProtocol
Parameter | Description | Schema | Required |
---|---|---|---|
ip | Specifies where to connect the dummy protocol device. | string | true |
DummyProtocolDeviceProperty
DummyProtocolDeviceObjectOrArrayProperty
is the same asDummyProtocolDeviceProperty
. The existence ofDummyProtocolDeviceObjectOrArrayProperty
is to combat the object circular reference.
Parameter | Description | Schema | Required |
---|---|---|---|
type | Describes the type of property. | DummyProtocolDevicePropertyType | true |
description | Outlines the property. | string | false |
readOnly | Configures the property is readOnly or not. | bool | false |
arrayProperties | Describes item properties of the array type. | *DummyProtocolDeviceObjectOrArrayProperty | false |
objectProperties | Describes properties of the object type. | map[string]DummyProtocolDeviceObjectOrArrayProperty | false |
DummyProtocolDeviceStatusProperty
DummyProtocolDeviceStatusObjectOrArrayProperty
is the same asDummyProtocolDeviceStatusProperty
. The existence ofDummyProtocolDeviceStatusObjectOrArrayProperty
is to combat the object circular reference.
Parameter | Description | Schema | Required |
---|---|---|---|
type | Reports the type of property. | DummyProtocolDevicePropertyType | true |
intValue | Reports the value of int type. | *int | false |
stringValue | Reports the value of string type. | *string | false |
floatValue | Reports the value of float type. | *resource.Quantity, kubernetes-sigs/controller-tools/issues#245 | false |
booleanValue | Reports the value of bool type. | *bool | false |
arrayValue | Reports the value of array type. | []DummyProtocolDeviceStatusObjectOrArrayProperty | false |
objectValue | Reports the value of object type. | map[string]DummyProtocolDeviceStatusObjectOrArrayProperty | false |
DummyProtocolDevicePropertyType
DummyProtocolDevicePropertyType describes the type of property.
Parameter | Description | Schema |
---|---|---|
string | Property data type is string. | string |
int | Property data type is int. | string |
float | Property data type is float. | string |
boolean | Property data type is boolean. | string |
array | Property data type is array. | string |
object | Property data type is object. | string |
DummyDeviceExtension
Parameter | Description | Schema | Required |
---|---|---|---|
mqtt | Specifies the MQTT settings. | *v1alpha1.MQTTOptionsSpec | false |
Walkthrough
Create a DeviceLink to connect the DummySpecialDevice, which simulates a fan of living room.
kubectl apply -f https://raw.githubusercontent.com/cnrancher/octopus/master/adaptors/dummy/deploy/e2e/dl_specialdevice.yamlSynchronize the above-created fan's status to the remote MQTT broker server.
# create a Generic Secret to store the CA for connecting test.mosquitto.org.kubectl create secret generic living-room-fan-mqtt-ca --from-file=ca.crt=./test/integration/physical/testdata/mosquitto.org.crt# create a TLS Secret to store the TLS/SSL keypair for connecting test.mosquitto.org.kubectl create secret tls living-room-fan-mqtt-tls --key ./test/integration/physical/testdata/client-key.pem --cert ./test/integration/physical/testdata/client.crt# publish status to test.mosquitto.orgkubectl apply -f https://raw.githubusercontent.com/cnrancher/octopus/master/adaptors/dummy/deploy/e2e/dl_specialdevice_with_mqtt.yamlUse
mosquitto_sub
tool to watch the synchronized status.# get mqtt broker serverkubectl get dl living-room-fan -o jsonpath="{.spec.template.spec.extension.mqtt.client.server}"# get topic namekubectl get dl living-room-fan -o jsonpath="{.spec.template.spec.extension.mqtt.message.topic}"# use mosquitto_submosquitto_sub -h {the host of mqtt broker server} -p {the port of mqtt broker server} -t {the topic name}# mosquitto_sub -h test.mosquitto.org -p 1883 -t cattle.io/octopus/default/living-room-fanCreate a DeviceLink to connect the DummyProtocolDevice, which simulates an intelligent property-filled robot, it can fill the desired properties randomly in 2 seconds.
kubectl apply -f https://raw.githubusercontent.com/cnrancher/octopus/master/adaptors/dummy/deploy/e2e/dl_protocoldevice.yamlSynchronize the above-created robot's answers to the remote MQTT broker server.
# publish status to test.mosquitto.orgkubectl apply -f https://raw.githubusercontent.com/cnrancher/octopus/master/adaptors/dummy/deploy/e2e/dl_protocoldevice_with_mqtt.yamlUse
mosquitto_sub
tool to watch the synchronized answers.# get mqtt broker serverkubectl get dl localhost-robot -o jsonpath="{.spec.template.spec.extension.mqtt.client.server}"# get topic namekubectl get dl localhost-robot -o jsonpath="{.spec.template.spec.extension.mqtt.message.topic}"# get dl uidkubectl get dl localhost-robot -o jsonpath="{.metadata.uid}"# use mosquitto_submosquitto_sub -h {the host of mqtt broker server} -p {the port of mqtt broker server} -t {the topic name}# mosquitto_sub -h test.mosquitto.org -p 1883 -t cattle.io/octopus/835aea2e-5f80-4d14-88f5-40c4bda41aa3