Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

99387 : support creating a govern node #265

Conversation

ericcournarie
Copy link
Contributor

add support for govern node creation

`
client = dataikuapi.FMClientAWS ("https://somewhere", "key", "secret")
client._session.verify = None

creator = client.new_virtual_network_creator ("MyNetwork")
creator.with_vpc ("vpc-xxx", "subnet-yyy")
netw = creator.create ()
netw.set_fleet_management (True, govern_server="Governor")
netw.save()

creator = client.new_instance_creator("MyGovernInstance", "ist-IJcznImxJFTI", "vn-xWfdn88cADov", "dss-11.0.2-default")
creator.with_dss_node_type(dataikuapi.fm.instances.FMNodeType.GOVERN).with_cloud_instance_type("m5a.2xlarge")
dss = creator.create ()
`

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #99387: Missing govern node type in FM client API.

Copy link
Contributor

@spicquenot spicquenot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough FM to verify the code that it will work.

However I have put a small remark about the compat with older version

@@ -37,14 +37,12 @@ def with_dss_node_type(self, dss_node_type):
"""
Set the DSS Node type of the instance to create

:param str dss_node_type: Optional , the type of the dss node to create. Supports "design", "automation ordeployer". Defaults to "design"
:param dss_node_type: Optional , the type of the dss node to create. Defaults to `DESIGN`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we want to be compatible with old usage, but with this change it will break (AttributeError: 'str' object has no attribute 'value')

If we do not want to break, either:

  • cover the two types with a check: isinstance(dss_node_type, FMNodeType)
  • just add a string govern instead
  • have the string value builder outside of this method

Quick note: maybe def with_dss_node_type(self, dss_node_type=FMNodeType.DESIGN): in the signature to make it "really" optional as a technical method or dss_node_type="design" for string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note: maybe def with_dss_node_type(self, dss_node_type=FMNodeType.DESIGN): in the signature to make it "really" optional as a technical method or dss_node_type="design" for string

the optional is not welcome in the doc , as the parameter is not optional .. it's the method call that is optional, as it has a default value of DESIGN if you do not use with_dss_node_type . there is another story about cleaning comments though ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we want to be compatible with old usage

not sure it is needed, as I doubt customers knows there was an API before .. maybe it's better to have clean script now . my 2 cents .. Fred will tell us its thoughts hopefully :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, indeed, in this case, I would put the defaults to design only in the other method that actually put the default to design and I would remove the word optional from here in the doc. Other it may be misleading for this particular method usage.

Noted, and ok pour waiting for the compatibility

)
self.data["dssNodeType"] = dss_node_type

self.data["dssNodeType"] = dss_node_type.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to complement the comment from @spicquenot , I'd maintain backwards compatibility by doing something like

if isinstance(dss_node_type, enum):
    self.data["dssNodeType"] = dss_node_type.value
else:
    self.data["dssNodeType"] = dss_node_type

(or something that is python2 AND python3 compatible)

the signature and comment change is fine IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BW compatibility added

@ericcournarie ericcournarie changed the base branch from release/11.0 to release/11.1 September 12, 2022 13:21
@ericcournarie ericcournarie merged commit 523e7ce into release/11.1 Sep 12, 2022
@ericcournarie ericcournarie deleted the feature/dss110-sc-99387-missing-govern-node-type-in-fm-client-api branch September 12, 2022 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants