[
https://issues.apache.org/jira/browse/CLOUDSTACK-9337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15228606#comment-15228606
]
ASF GitHub Bot commented on CLOUDSTACK-9337:
--------------------------------------------
Github user alexandrelimassantana commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/1464#discussion_r58739597
--- Diff: tools/marvin/marvin/lib/vcenter.py ---
@@ -183,7 +192,157 @@ def get_clusters(self, dc, clus=None):
"""
pass
+ def create_datacenter(self, dcname=None, service_instance=None,
folder=None):
+ """
+ Creates a new datacenter with the given name.
+ Any % (percent) character used in this name parameter must be
escaped,
+ unless it is used to start an escape sequence. Clients may also
escape
+ any other characters in this name parameter.
+
+ An entity name must be a non-empty string of
+ less than 80 characters. The slash (/), backslash (\) and percent
(%)
+ will be escaped using the URL syntax. For example, %2F
+
+ This can raise the following exceptions:
+ vim.fault.DuplicateName
+ vim.fault.InvalidName
+ vmodl.fault.NotSupported
+ vmodl.fault.RuntimeFault
+ ValueError raised if the name len is > 79
+ https://github.com/vmware/pyvmomi/blob/master/docs/vim/Folder.rst
+
+ Required Privileges
+ Datacenter.Create
+
+ :param folder: Folder object to create DC in. If None it will
default to
+ rootFolder
+ :param dcname: Name for the new datacenter.
+ :param service_instance: ServiceInstance connection to a given
vCenter
+ :return:
+ """
+ if len(dcname) > 79:
+ raise ValueError("The name of the datacenter must be under "
+ "80 characters.")
+
+ if folder is None:
+ folder = self.service_instance.content.rootFolder
+
+ if folder is not None and isinstance(folder, vim.Folder):
+ dc_moref = folder.CreateDatacenter(name=dcname)
--- End diff --
got it. The code looks good, those were the only doubts I had. I would just
use a Semaphore in line 317, but sleep an pool is not that bad also.
The code seems fine, but tests are needed.
> [CI] Enhance vcenter library to add datacenter programmatically
> ---------------------------------------------------------------
>
> Key: CLOUDSTACK-9337
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9337
> Project: CloudStack
> Issue Type: Test
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Sanjeev N
> Assignee: Sanjeev N
>
> Enhance vcenter.py to create data centers in vCenter server automatically by
> reading the configuration from a json file.
> Added few methods to create data center, cluster and hosts in it.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)