Skip to content

Commit 8ec011b

Browse files
committed
Add vendor attribute
Now has vendor as configurable attribute version increased to 1.1
1 parent 630642b commit 8ec011b

6 files changed

Lines changed: 30 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# MockResources
22
Mock resources for Demo, Development, Test, & Learning.
33
<ul>
4+
NOTE: IF you want to DECREASE the number of ports, you will have to delete them by hand. Easiest way is to delete all the sub resources then re-run the discovery.
45
<li>PDU Mock
56
<ul>
67
<li>Dynamic number of power sockets</li>
@@ -11,6 +12,7 @@ Mock resources for Demo, Development, Test, &amp; Learning.
1112
<li>Dynamic number of ports</li>
1213
<li>Dynamic number of power ports</li>
1314
<li>Dynamically changing model</li>
15+
<li>Dynamically changing vendor</li>
1416
</ul>
1517
</li>
1618
<li>Additional Mocks

mockresource/dist/Mockresource.zip

149 Bytes
Binary file not shown.

mockresource/shell-definition.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
33
metadata:
44
template_name: Mockresource
55
template_author: Tim.s@quali.com
6-
template_version: 1.0.0
6+
template_version: 1.1.0
77
template_icon: shell-icon.png
88

99
description: >
@@ -29,6 +29,10 @@ node_types:
2929
type: integer
3030
default: 1
3131
description: Enter the number of power ports to generate
32+
my_vendor:
33+
type: string
34+
default: CS Mock Resources
35+
description: Enter the Vendor name
3236
# my_property:
3337
# type: string # optional values: string, integer, float, boolean, cloudshell.datatypes.Password
3438
# default: fast
@@ -57,6 +61,9 @@ node_types:
5761
power_ports:
5862
type: integer
5963
default: 1
64+
my_vendor:
65+
type: string
66+
default: CS Mock Resources
6067
artifacts:
6168
icon:
6269
file: shell-icon.png

mockresource/src/data_model.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,21 @@ def power_ports(self, value='1'):
199199
"""
200200
self.attributes['Mockresource.power_ports'] = value
201201

202+
@property
203+
def my_vendor(self):
204+
"""
205+
:rtype: str
206+
"""
207+
return self.attributes['Mockresource.my_vendor'] if 'Mockresource.my_vendor' in self.attributes else None
208+
209+
@my_vendor.setter
210+
def my_vendor(self, value='CS Mock Resources'):
211+
"""
212+
Enter the Vendor name
213+
:type value: str
214+
"""
215+
self.attributes['Mockresource.my_vendor'] = value
216+
202217
@property
203218
def user(self):
204219
"""

mockresource/src/driver.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ def get_inventory(self, context):
5555
resource = Mockresource.create_from_context(context)
5656
resource.vendor = 'CS Mockual Resources'
5757
resource.model = resource.my_model
58+
resource.vendor = resource.my_vendor
5859

60+
#If the number of ports is decreased, this will NOT delete them
61+
# TODO: Handle decreasing number of ports
5962
length = str(len(str(resource.num_ports)))
6063
for port in range(1, int(resource.num_ports)+1):
6164
po = ResourcePort('Port ' + str(format(port, '0'+length)))
6265
resource.add_sub_resource(port, po)
6366

67+
# TODO: Handle decreasing number of ports
6468
length = str(len(str(resource.power_ports)))
6569
for port in range(1, int(resource.power_ports)+1):
6670
po = ResourcePort('Power Port ' + str(format(port, '0'+length)))

mockresource/src/drivermetadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Driver Description="Describe the purpose of your CloudShell shell" MainClass="driver.MockresourceDriver" Name="MockresourceDriver" Version="1.0.0">
1+
<Driver Description="Mock resource for Demo, Development, Test, &amp; Learning" MainClass="driver.MockresourceDriver" Name="MockresourceDriver" Version="1.1.0">
22
<Layout>
33
<Category Name="Hidden Commands">
44
<Command Description="" DisplayName="Orchestration Save" Name="orchestration_save" />

0 commit comments

Comments
 (0)