Commit b3e4083f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #36133 from luomiao/photon-support-PR-v2

Automatic merge from submit-queue Support persistent volume usage for kubernetes running on Photon Controller platform **What this PR does / why we need it:** Enable the persistent volume usage for kubernetes running on Photon platform. Photon Controller: https://vmware.github.io/photon-controller/ _Only the first commit include the real code change. The following commits are for third-party vendor dependency and auto-generated code/docs updating._ Two components are added: pkg/cloudprovider/providers/photon: support Photon Controller as cloud provider pkg/volume/photon_pd: support Photon persistent disk as volume source for persistent volume Usage introduction: a. Photon Controller is supported as cloud provider. When choosing to use photon controller as a cloud provider, "--cloud-provider=photon --cloud-config=[path_to_config_file]" is required for kubelet/kube-controller-manager/kube-apiserver. The config file of Photon Controller should follow the following usage: ``` [Global] target = http://[photon_controller_endpoint_IP] ignoreCertificate = true tenant = [tenant_name] project = [project_name] overrideIP = true ``` b. Photon persistent disk is supported as volume source/persistent volume source. yaml usage: ``` volumes: - name: photon-storage-1 photonPersistentDisk: pdID: "643ed4e2-3fcc-482b-96d0-12ff6cab2a69" ``` pdID is the persistent disk ID from Photon Controller. c. Enable Photon Controller as volume provisioner. yaml usage: ``` kind: StorageClass apiVersion: storage.k8s.io/v1beta1 metadata: name: gold_sc provisioner: kubernetes.io/photon-pd parameters: flavor: persistent-disk-gold ``` The flavor "persistent-disk-gold" needs to be created by Photon platform admin before hand.
parents 4d3fd065 20b9fc69
...@@ -2289,6 +2289,16 @@ ...@@ -2289,6 +2289,16 @@
"Rev": "b5ee639d7aa4b8dbb48ab4f75dddc19f71b5c514" "Rev": "b5ee639d7aa4b8dbb48ab4f75dddc19f71b5c514"
}, },
{ {
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon",
"Comment": "PROMOTED-336",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
},
{
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon/lightwave",
"Comment": "PROMOTED-336",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
},
{
"ImportPath": "github.com/xanzy/go-cloudstack/cloudstack", "ImportPath": "github.com/xanzy/go-cloudstack/cloudstack",
"Comment": "v2.1.1-1-g1e2cbf6", "Comment": "v2.1.1-1-g1e2cbf6",
"Rev": "1e2cbf647e57fa90353612074fdfc42faf5073bf" "Rev": "1e2cbf647e57fa90353612074fdfc42faf5073bf"
......
...@@ -1452,6 +1452,10 @@ ...@@ -1452,6 +1452,10 @@
"azureDisk": { "azureDisk": {
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
},
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
} }
} }
}, },
...@@ -2085,6 +2089,23 @@ ...@@ -2085,6 +2089,23 @@
"id": "v1.AzureDataDiskCachingMode", "id": "v1.AzureDataDiskCachingMode",
"properties": {} "properties": {}
}, },
"v1.PhotonPersistentDiskVolumeSource": {
"id": "v1.PhotonPersistentDiskVolumeSource",
"description": "Represents a Photon Controller persistent disk resource.",
"required": [
"pdID"
],
"properties": {
"pdID": {
"type": "string",
"description": "ID that identifies Photon Controller persistent disk"
},
"fsType": {
"type": "string",
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified."
}
}
},
"v1.Container": { "v1.Container": {
"id": "v1.Container", "id": "v1.Container",
"description": "A single application container that you want to run within a pod.", "description": "A single application container that you want to run within a pod.",
......
...@@ -1452,6 +1452,10 @@ ...@@ -1452,6 +1452,10 @@
"azureDisk": { "azureDisk": {
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
},
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
} }
} }
}, },
...@@ -2085,6 +2089,23 @@ ...@@ -2085,6 +2089,23 @@
"id": "v1.AzureDataDiskCachingMode", "id": "v1.AzureDataDiskCachingMode",
"properties": {} "properties": {}
}, },
"v1.PhotonPersistentDiskVolumeSource": {
"id": "v1.PhotonPersistentDiskVolumeSource",
"description": "Represents a Photon Controller persistent disk resource.",
"required": [
"pdID"
],
"properties": {
"pdID": {
"type": "string",
"description": "ID that identifies Photon Controller persistent disk"
},
"fsType": {
"type": "string",
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified."
}
}
},
"v1.Container": { "v1.Container": {
"id": "v1.Container", "id": "v1.Container",
"description": "A single application container that you want to run within a pod.", "description": "A single application container that you want to run within a pod.",
......
...@@ -1457,6 +1457,10 @@ ...@@ -1457,6 +1457,10 @@
"azureDisk": { "azureDisk": {
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
},
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
} }
} }
}, },
...@@ -2090,6 +2094,23 @@ ...@@ -2090,6 +2094,23 @@
"id": "v1.AzureDataDiskCachingMode", "id": "v1.AzureDataDiskCachingMode",
"properties": {} "properties": {}
}, },
"v1.PhotonPersistentDiskVolumeSource": {
"id": "v1.PhotonPersistentDiskVolumeSource",
"description": "Represents a Photon Controller persistent disk resource.",
"required": [
"pdID"
],
"properties": {
"pdID": {
"type": "string",
"description": "ID that identifies Photon Controller persistent disk"
},
"fsType": {
"type": "string",
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified."
}
}
},
"v1.Container": { "v1.Container": {
"id": "v1.Container", "id": "v1.Container",
"description": "A single application container that you want to run within a pod.", "description": "A single application container that you want to run within a pod.",
......
...@@ -8224,6 +8224,10 @@ ...@@ -8224,6 +8224,10 @@
"azureDisk": { "azureDisk": {
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
},
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
} }
} }
}, },
...@@ -8857,6 +8861,23 @@ ...@@ -8857,6 +8861,23 @@
"id": "v1.AzureDataDiskCachingMode", "id": "v1.AzureDataDiskCachingMode",
"properties": {} "properties": {}
}, },
"v1.PhotonPersistentDiskVolumeSource": {
"id": "v1.PhotonPersistentDiskVolumeSource",
"description": "Represents a Photon Controller persistent disk resource.",
"required": [
"pdID"
],
"properties": {
"pdID": {
"type": "string",
"description": "ID that identifies Photon Controller persistent disk"
},
"fsType": {
"type": "string",
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified."
}
}
},
"v1.Container": { "v1.Container": {
"id": "v1.Container", "id": "v1.Container",
"description": "A single application container that you want to run within a pod.", "description": "A single application container that you want to run within a pod.",
......
...@@ -17654,6 +17654,10 @@ ...@@ -17654,6 +17654,10 @@
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
}, },
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
},
"accessModes": { "accessModes": {
"type": "array", "type": "array",
"items": { "items": {
...@@ -18104,6 +18108,23 @@ ...@@ -18104,6 +18108,23 @@
"id": "v1.AzureDataDiskCachingMode", "id": "v1.AzureDataDiskCachingMode",
"properties": {} "properties": {}
}, },
"v1.PhotonPersistentDiskVolumeSource": {
"id": "v1.PhotonPersistentDiskVolumeSource",
"description": "Represents a Photon Controller persistent disk resource.",
"required": [
"pdID"
],
"properties": {
"pdID": {
"type": "string",
"description": "ID that identifies Photon Controller persistent disk"
},
"fsType": {
"type": "string",
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified."
}
}
},
"v1.PersistentVolumeStatus": { "v1.PersistentVolumeStatus": {
"id": "v1.PersistentVolumeStatus", "id": "v1.PersistentVolumeStatus",
"description": "PersistentVolumeStatus is the current status of a persistent volume.", "description": "PersistentVolumeStatus is the current status of a persistent volume.",
...@@ -18362,6 +18383,10 @@ ...@@ -18362,6 +18383,10 @@
"azureDisk": { "azureDisk": {
"$ref": "v1.AzureDiskVolumeSource", "$ref": "v1.AzureDiskVolumeSource",
"description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod."
},
"photonPersistentDisk": {
"$ref": "v1.PhotonPersistentDiskVolumeSource",
"description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine"
} }
} }
}, },
......
...@@ -38,6 +38,7 @@ go_library( ...@@ -38,6 +38,7 @@ go_library(
"//pkg/cloudprovider/providers/azure:go_default_library", "//pkg/cloudprovider/providers/azure:go_default_library",
"//pkg/cloudprovider/providers/gce:go_default_library", "//pkg/cloudprovider/providers/gce:go_default_library",
"//pkg/cloudprovider/providers/openstack:go_default_library", "//pkg/cloudprovider/providers/openstack:go_default_library",
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/cloudprovider/providers/vsphere:go_default_library", "//pkg/cloudprovider/providers/vsphere:go_default_library",
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//pkg/controller/certificates:go_default_library", "//pkg/controller/certificates:go_default_library",
...@@ -83,6 +84,7 @@ go_library( ...@@ -83,6 +84,7 @@ go_library(
"//pkg/volume/glusterfs:go_default_library", "//pkg/volume/glusterfs:go_default_library",
"//pkg/volume/host_path:go_default_library", "//pkg/volume/host_path:go_default_library",
"//pkg/volume/nfs:go_default_library", "//pkg/volume/nfs:go_default_library",
"//pkg/volume/photon_pd:go_default_library",
"//pkg/volume/quobyte:go_default_library", "//pkg/volume/quobyte:go_default_library",
"//pkg/volume/rbd:go_default_library", "//pkg/volume/rbd:go_default_library",
"//pkg/volume/vsphere_volume:go_default_library", "//pkg/volume/vsphere_volume:go_default_library",
......
...@@ -34,6 +34,7 @@ import ( ...@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure" "k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce" "k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/pkg/cloudprovider/providers/openstack" "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack"
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere"
utilconfig "k8s.io/kubernetes/pkg/util/config" utilconfig "k8s.io/kubernetes/pkg/util/config"
"k8s.io/kubernetes/pkg/util/io" "k8s.io/kubernetes/pkg/util/io"
...@@ -47,6 +48,7 @@ import ( ...@@ -47,6 +48,7 @@ import (
"k8s.io/kubernetes/pkg/volume/glusterfs" "k8s.io/kubernetes/pkg/volume/glusterfs"
"k8s.io/kubernetes/pkg/volume/host_path" "k8s.io/kubernetes/pkg/volume/host_path"
"k8s.io/kubernetes/pkg/volume/nfs" "k8s.io/kubernetes/pkg/volume/nfs"
"k8s.io/kubernetes/pkg/volume/photon_pd"
"k8s.io/kubernetes/pkg/volume/quobyte" "k8s.io/kubernetes/pkg/volume/quobyte"
"k8s.io/kubernetes/pkg/volume/rbd" "k8s.io/kubernetes/pkg/volume/rbd"
"k8s.io/kubernetes/pkg/volume/vsphere_volume" "k8s.io/kubernetes/pkg/volume/vsphere_volume"
...@@ -67,6 +69,7 @@ func ProbeAttachableVolumePlugins(config componentconfig.VolumeConfiguration) [] ...@@ -67,6 +69,7 @@ func ProbeAttachableVolumePlugins(config componentconfig.VolumeConfiguration) []
allPlugins = append(allPlugins, flexvolume.ProbeVolumePlugins(config.FlexVolumePluginDir)...) allPlugins = append(allPlugins, flexvolume.ProbeVolumePlugins(config.FlexVolumePluginDir)...)
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...)
return allPlugins return allPlugins
} }
...@@ -124,6 +127,8 @@ func ProbeControllerVolumePlugins(cloud cloudprovider.Interface, config componen ...@@ -124,6 +127,8 @@ func ProbeControllerVolumePlugins(cloud cloudprovider.Interface, config componen
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
case azure.CloudProviderName == cloud.ProviderName(): case azure.CloudProviderName == cloud.ProviderName():
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
case photon.ProviderName == cloud.ProviderName():
allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...)
} }
} }
...@@ -154,6 +159,8 @@ func NewAlphaVolumeProvisioner(cloud cloudprovider.Interface, config componentco ...@@ -154,6 +159,8 @@ func NewAlphaVolumeProvisioner(cloud cloudprovider.Interface, config componentco
return getProvisionablePluginFromVolumePlugins(vsphere_volume.ProbeVolumePlugins()) return getProvisionablePluginFromVolumePlugins(vsphere_volume.ProbeVolumePlugins())
case cloud != nil && azure.CloudProviderName == cloud.ProviderName(): case cloud != nil && azure.CloudProviderName == cloud.ProviderName():
return getProvisionablePluginFromVolumePlugins(azure_dd.ProbeVolumePlugins()) return getProvisionablePluginFromVolumePlugins(azure_dd.ProbeVolumePlugins())
case cloud != nil && photon.ProviderName == cloud.ProviderName():
return getProvisionablePluginFromVolumePlugins(photon_pd.ProbeVolumePlugins())
} }
return nil, nil return nil, nil
} }
......
...@@ -93,6 +93,7 @@ go_library( ...@@ -93,6 +93,7 @@ go_library(
"//pkg/volume/host_path:go_default_library", "//pkg/volume/host_path:go_default_library",
"//pkg/volume/iscsi:go_default_library", "//pkg/volume/iscsi:go_default_library",
"//pkg/volume/nfs:go_default_library", "//pkg/volume/nfs:go_default_library",
"//pkg/volume/photon_pd:go_default_library",
"//pkg/volume/quobyte:go_default_library", "//pkg/volume/quobyte:go_default_library",
"//pkg/volume/rbd:go_default_library", "//pkg/volume/rbd:go_default_library",
"//pkg/volume/secret:go_default_library", "//pkg/volume/secret:go_default_library",
......
...@@ -45,6 +45,7 @@ import ( ...@@ -45,6 +45,7 @@ import (
"k8s.io/kubernetes/pkg/volume/host_path" "k8s.io/kubernetes/pkg/volume/host_path"
"k8s.io/kubernetes/pkg/volume/iscsi" "k8s.io/kubernetes/pkg/volume/iscsi"
"k8s.io/kubernetes/pkg/volume/nfs" "k8s.io/kubernetes/pkg/volume/nfs"
"k8s.io/kubernetes/pkg/volume/photon_pd"
"k8s.io/kubernetes/pkg/volume/quobyte" "k8s.io/kubernetes/pkg/volume/quobyte"
"k8s.io/kubernetes/pkg/volume/rbd" "k8s.io/kubernetes/pkg/volume/rbd"
"k8s.io/kubernetes/pkg/volume/secret" "k8s.io/kubernetes/pkg/volume/secret"
...@@ -86,6 +87,7 @@ func ProbeVolumePlugins(pluginDir string) []volume.VolumePlugin { ...@@ -86,6 +87,7 @@ func ProbeVolumePlugins(pluginDir string) []volume.VolumePlugin {
allPlugins = append(allPlugins, configmap.ProbeVolumePlugins()...) allPlugins = append(allPlugins, configmap.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...)
return allPlugins return allPlugins
} }
......
...@@ -383,6 +383,47 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -383,6 +383,47 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<h2 id="_definitions">Definitions</h2> <h2 id="_definitions">Definitions</h2>
<div class="sectionbody"> <div class="sectionbody">
<div class="sect2"> <div class="sect2">
<h3 id="_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</h3>
<div class="paragraph">
<p>Represents a Photon Controller persistent disk resource.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pdID</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ID that identifies Photon Controller persistent disk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fsType</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_versioned_event">versioned.Event</h3> <h3 id="_versioned_event">versioned.Event</h3>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
...@@ -3388,6 +3429,13 @@ The StatefulSet guarantees that a given network identity will always map to the ...@@ -3388,6 +3429,13 @@ The StatefulSet guarantees that a given network identity will always map to the
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">photonPersistentDisk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -4396,7 +4444,7 @@ The StatefulSet guarantees that a given network identity will always map to the ...@@ -4396,7 +4444,7 @@ The StatefulSet guarantees that a given network identity will always map to the
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2016-11-03 15:09:35 UTC Last updated 2016-11-06 03:50:37 UTC
</div> </div>
</div> </div>
</body> </body>
......
...@@ -383,6 +383,47 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -383,6 +383,47 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<h2 id="_definitions">Definitions</h2> <h2 id="_definitions">Definitions</h2>
<div class="sectionbody"> <div class="sectionbody">
<div class="sect2"> <div class="sect2">
<h3 id="_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</h3>
<div class="paragraph">
<p>Represents a Photon Controller persistent disk resource.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pdID</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ID that identifies Photon Controller persistent disk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fsType</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_versioned_event">versioned.Event</h3> <h3 id="_versioned_event">versioned.Event</h3>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
...@@ -3375,6 +3416,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i ...@@ -3375,6 +3416,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">photonPersistentDisk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -4328,7 +4376,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i ...@@ -4328,7 +4376,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2016-11-03 15:10:02 UTC Last updated 2016-11-05 07:45:07 UTC
</div> </div>
</div> </div>
</body> </body>
......
...@@ -3188,6 +3188,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i ...@@ -3188,6 +3188,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">photonPersistentDisk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -4258,6 +4265,47 @@ Populated by the system when a graceful deletion is requested. Read-only. More i ...@@ -4258,6 +4265,47 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</h3>
<div class="paragraph">
<p>Represents a Photon Controller persistent disk resource.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pdID</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ID that identifies Photon Controller persistent disk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fsType</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1beta1_networkpolicy">v1beta1.NetworkPolicy</h3> <h3 id="_v1beta1_networkpolicy">v1beta1.NetworkPolicy</h3>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
...@@ -5157,7 +5205,10 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -5157,7 +5205,10 @@ Both these may change in the future. Incoming requests are matched against the h
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_v1beta1_cputargetutilization">v1beta1.CPUTargetUtilization</h3> <h3 id="_v1_loadbalancerstatus">v1.LoadBalancerStatus</h3>
<div class="paragraph">
<p>LoadBalancerStatus represents the status of a load-balancer.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
<col style="width:20%;"> <col style="width:20%;">
...@@ -5177,10 +5228,10 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -5177,10 +5228,10 @@ Both these may change in the future. Incoming requests are matched against the h
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">targetPercentage</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">ingress</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">fraction of the requested CPU that should be utilized/used, e.g. 70 means that 70% of the requested CPU should be in use.</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_loadbalanceringress">v1.LoadBalancerIngress</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
</tbody> </tbody>
...@@ -5188,10 +5239,7 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -5188,10 +5239,7 @@ Both these may change in the future. Incoming requests are matched against the h
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_v1_loadbalancerstatus">v1.LoadBalancerStatus</h3> <h3 id="_v1beta1_cputargetutilization">v1beta1.CPUTargetUtilization</h3>
<div class="paragraph">
<p>LoadBalancerStatus represents the status of a load-balancer.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
<col style="width:20%;"> <col style="width:20%;">
...@@ -5211,10 +5259,10 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -5211,10 +5259,10 @@ Both these may change in the future. Incoming requests are matched against the h
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ingress</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">targetPercentage</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">fraction of the requested CPU that should be utilized/used, e.g. 70 means that 70% of the requested CPU should be in use.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_loadbalanceringress">v1.LoadBalancerIngress</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
</tbody> </tbody>
...@@ -6770,7 +6818,7 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -6770,7 +6818,7 @@ Both these may change in the future. Incoming requests are matched against the h
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2016-11-07 11:40:35 UTC Last updated 2016-11-08 08:09:17 UTC
</div> </div>
</div> </div>
</body> </body>
......
...@@ -3914,6 +3914,13 @@ The resulting set of endpoints can be viewed as:<br> ...@@ -3914,6 +3914,13 @@ The resulting set of endpoints can be viewed as:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_azurediskvolumesource">v1.AzureDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">photonPersistentDisk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -5301,6 +5308,47 @@ The resulting set of endpoints can be viewed as:<br> ...@@ -5301,6 +5308,47 @@ The resulting set of endpoints can be viewed as:<br>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</h3>
<div class="paragraph">
<p>Represents a Photon Controller persistent disk resource.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pdID</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ID that identifies Photon Controller persistent disk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fsType</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_versioned_event">versioned.Event</h3> <h3 id="_versioned_event">versioned.Event</h3>
<table class="tableblock frame-all grid-all" style="width:100%; "> <table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup> <colgroup>
...@@ -6226,6 +6274,13 @@ The resulting set of endpoints can be viewed as:<br> ...@@ -6226,6 +6274,13 @@ The resulting set of endpoints can be viewed as:<br>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr> <tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">photonPersistentDisk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_photonpersistentdiskvolumesource">v1.PhotonPersistentDiskVolumeSource</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">accessModes</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">accessModes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">AccessModes contains all ways the volume can be mounted. More info: <a href="http://kubernetes.io/docs/user-guide/persistent-volumes#access-modes">http://kubernetes.io/docs/user-guide/persistent-volumes#access-modes</a></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">AccessModes contains all ways the volume can be mounted. More info: <a href="http://kubernetes.io/docs/user-guide/persistent-volumes#access-modes">http://kubernetes.io/docs/user-guide/persistent-volumes#access-modes</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
...@@ -8558,7 +8613,7 @@ The resulting set of endpoints can be viewed as:<br> ...@@ -8558,7 +8613,7 @@ The resulting set of endpoints can be viewed as:<br>
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2016-11-04 19:49:05 UTC Last updated 2016-11-06 03:50:31 UTC
</div> </div>
</div> </div>
</body> </body>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -289,6 +289,8 @@ type VolumeSource struct { ...@@ -289,6 +289,8 @@ type VolumeSource struct {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty"` AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty"`
// PhotonPersistentDisk represents a Photon Controller persistent disk attached and mounted on kubelets host machine
PhotonPersistentDisk *PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty"`
} }
// Similar to VolumeSource but meant for the administrator who creates PVs. // Similar to VolumeSource but meant for the administrator who creates PVs.
...@@ -349,6 +351,8 @@ type PersistentVolumeSource struct { ...@@ -349,6 +351,8 @@ type PersistentVolumeSource struct {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty"` AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty"`
// PhotonPersistentDisk represents a Photon Controller persistent disk attached and mounted on kubelets host machine
PhotonPersistentDisk *PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty"`
} }
type PersistentVolumeClaimVolumeSource struct { type PersistentVolumeClaimVolumeSource struct {
...@@ -936,6 +940,16 @@ type VsphereVirtualDiskVolumeSource struct { ...@@ -936,6 +940,16 @@ type VsphereVirtualDiskVolumeSource struct {
FSType string `json:"fsType,omitempty"` FSType string `json:"fsType,omitempty"`
} }
// Represents a Photon Controller persistent disk resource.
type PhotonPersistentDiskVolumeSource struct {
// ID that identifies Photon Controller persistent disk
PdID string `json:"pdID"`
// Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
FSType string `json:"fsType,omitempty"`
}
type AzureDataDiskCachingMode string type AzureDataDiskCachingMode string
const ( const (
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2033,6 +2033,9 @@ message PersistentVolumeSource { ...@@ -2033,6 +2033,9 @@ message PersistentVolumeSource {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
optional AzureDiskVolumeSource azureDisk = 16; optional AzureDiskVolumeSource azureDisk = 16;
// PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
optional PhotonPersistentDiskVolumeSource photonPersistentDisk = 17;
} }
// PersistentVolumeSpec is the specification of a persistent volume. // PersistentVolumeSpec is the specification of a persistent volume.
...@@ -2082,6 +2085,17 @@ message PersistentVolumeStatus { ...@@ -2082,6 +2085,17 @@ message PersistentVolumeStatus {
optional string reason = 3; optional string reason = 3;
} }
// Represents a Photon Controller persistent disk resource.
message PhotonPersistentDiskVolumeSource {
// ID that identifies Photon Controller persistent disk
optional string pdID = 1;
// Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
optional string fsType = 2;
}
// Pod is a collection of containers that can run on a host. This resource is created // Pod is a collection of containers that can run on a host. This resource is created
// by clients and scheduled onto hosts. // by clients and scheduled onto hosts.
message Pod { message Pod {
...@@ -3541,6 +3555,9 @@ message VolumeSource { ...@@ -3541,6 +3555,9 @@ message VolumeSource {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
optional AzureDiskVolumeSource azureDisk = 22; optional AzureDiskVolumeSource azureDisk = 22;
// PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
optional PhotonPersistentDiskVolumeSource photonPersistentDisk = 23;
} }
// Represents a vSphere volume resource. // Represents a vSphere volume resource.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -322,6 +322,8 @@ type VolumeSource struct { ...@@ -322,6 +322,8 @@ type VolumeSource struct {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty" protobuf:"bytes,22,opt,name=azureDisk"` AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty" protobuf:"bytes,22,opt,name=azureDisk"`
// PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
PhotonPersistentDisk *PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty" protobuf:"bytes,23,opt,name=photonPersistentDisk"`
} }
// PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace. // PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace.
...@@ -405,6 +407,8 @@ type PersistentVolumeSource struct { ...@@ -405,6 +407,8 @@ type PersistentVolumeSource struct {
// AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. // AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
// +optional // +optional
AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty" protobuf:"bytes,16,opt,name=azureDisk"` AzureDisk *AzureDiskVolumeSource `json:"azureDisk,omitempty" protobuf:"bytes,16,opt,name=azureDisk"`
// PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
PhotonPersistentDisk *PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty" protobuf:"bytes,17,opt,name=photonPersistentDisk"`
} }
// +genclient=true // +genclient=true
...@@ -1023,6 +1027,17 @@ type VsphereVirtualDiskVolumeSource struct { ...@@ -1023,6 +1027,17 @@ type VsphereVirtualDiskVolumeSource struct {
// +optional // +optional
FSType string `json:"fsType,omitempty" protobuf:"bytes,2,opt,name=fsType"` FSType string `json:"fsType,omitempty" protobuf:"bytes,2,opt,name=fsType"`
} }
// Represents a Photon Controller persistent disk resource.
type PhotonPersistentDiskVolumeSource struct {
// ID that identifies Photon Controller persistent disk
PdID string `json:"pdID" protobuf:"bytes,1,opt,name=pdID"`
// Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
FSType string `json:"fsType,omitempty" protobuf:"bytes,2,opt,name=fsType"`
}
type AzureDataDiskCachingMode string type AzureDataDiskCachingMode string
const ( const (
......
...@@ -1098,6 +1098,7 @@ var map_PersistentVolumeSource = map[string]string{ ...@@ -1098,6 +1098,7 @@ var map_PersistentVolumeSource = map[string]string{
"vsphereVolume": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", "vsphereVolume": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine",
"quobyte": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", "quobyte": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime",
"azureDisk": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", "azureDisk": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.",
"photonPersistentDisk": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine",
} }
func (PersistentVolumeSource) SwaggerDoc() map[string]string { func (PersistentVolumeSource) SwaggerDoc() map[string]string {
...@@ -1127,6 +1128,16 @@ func (PersistentVolumeStatus) SwaggerDoc() map[string]string { ...@@ -1127,6 +1128,16 @@ func (PersistentVolumeStatus) SwaggerDoc() map[string]string {
return map_PersistentVolumeStatus return map_PersistentVolumeStatus
} }
var map_PhotonPersistentDiskVolumeSource = map[string]string{
"": "Represents a Photon Controller persistent disk resource.",
"pdID": "ID that identifies Photon Controller persistent disk",
"fsType": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.",
}
func (PhotonPersistentDiskVolumeSource) SwaggerDoc() map[string]string {
return map_PhotonPersistentDiskVolumeSource
}
var map_Pod = map[string]string{ var map_Pod = map[string]string{
"": "Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.", "": "Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.",
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata", "metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
...@@ -1787,18 +1798,19 @@ var map_VolumeSource = map[string]string{ ...@@ -1787,18 +1798,19 @@ var map_VolumeSource = map[string]string{
"iscsi": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: http://releases.k8s.io/HEAD/examples/volumes/iscsi/README.md", "iscsi": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: http://releases.k8s.io/HEAD/examples/volumes/iscsi/README.md",
"glusterfs": "Glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: http://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md", "glusterfs": "Glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: http://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md",
"persistentVolumeClaim": "PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims", "persistentVolumeClaim": "PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims",
"rbd": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: http://releases.k8s.io/HEAD/examples/volumes/rbd/README.md", "rbd": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: http://releases.k8s.io/HEAD/examples/volumes/rbd/README.md",
"flexVolume": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", "flexVolume": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.",
"cinder": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: http://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", "cinder": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: http://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md",
"cephfs": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime", "cephfs": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime",
"flocker": "Flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running", "flocker": "Flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running",
"downwardAPI": "DownwardAPI represents downward API about the pod that should populate this volume", "downwardAPI": "DownwardAPI represents downward API about the pod that should populate this volume",
"fc": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", "fc": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.",
"azureFile": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", "azureFile": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.",
"configMap": "ConfigMap represents a configMap that should populate this volume", "configMap": "ConfigMap represents a configMap that should populate this volume",
"vsphereVolume": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", "vsphereVolume": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine",
"quobyte": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", "quobyte": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime",
"azureDisk": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", "azureDisk": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.",
"photonPersistentDisk": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine",
} }
func (VolumeSource) SwaggerDoc() map[string]string { func (VolumeSource) SwaggerDoc() map[string]string {
......
...@@ -229,6 +229,8 @@ func RegisterConversions(scheme *runtime.Scheme) error { ...@@ -229,6 +229,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
Convert_api_PersistentVolumeSpec_To_v1_PersistentVolumeSpec, Convert_api_PersistentVolumeSpec_To_v1_PersistentVolumeSpec,
Convert_v1_PersistentVolumeStatus_To_api_PersistentVolumeStatus, Convert_v1_PersistentVolumeStatus_To_api_PersistentVolumeStatus,
Convert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus, Convert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus,
Convert_v1_PhotonPersistentDiskVolumeSource_To_api_PhotonPersistentDiskVolumeSource,
Convert_api_PhotonPersistentDiskVolumeSource_To_v1_PhotonPersistentDiskVolumeSource,
Convert_v1_Pod_To_api_Pod, Convert_v1_Pod_To_api_Pod,
Convert_api_Pod_To_v1_Pod, Convert_api_Pod_To_v1_Pod,
Convert_v1_PodAffinity_To_api_PodAffinity, Convert_v1_PodAffinity_To_api_PodAffinity,
...@@ -2649,6 +2651,7 @@ func autoConvert_v1_PersistentVolumeSource_To_api_PersistentVolumeSource(in *Per ...@@ -2649,6 +2651,7 @@ func autoConvert_v1_PersistentVolumeSource_To_api_PersistentVolumeSource(in *Per
out.VsphereVolume = (*api.VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume)) out.VsphereVolume = (*api.VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume))
out.Quobyte = (*api.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte)) out.Quobyte = (*api.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte))
out.AzureDisk = (*api.AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk)) out.AzureDisk = (*api.AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk))
out.PhotonPersistentDisk = (*api.PhotonPersistentDiskVolumeSource)(unsafe.Pointer(in.PhotonPersistentDisk))
return nil return nil
} }
...@@ -2673,6 +2676,7 @@ func autoConvert_api_PersistentVolumeSource_To_v1_PersistentVolumeSource(in *api ...@@ -2673,6 +2676,7 @@ func autoConvert_api_PersistentVolumeSource_To_v1_PersistentVolumeSource(in *api
out.AzureFile = (*AzureFileVolumeSource)(unsafe.Pointer(in.AzureFile)) out.AzureFile = (*AzureFileVolumeSource)(unsafe.Pointer(in.AzureFile))
out.VsphereVolume = (*VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume)) out.VsphereVolume = (*VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume))
out.AzureDisk = (*AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk)) out.AzureDisk = (*AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk))
out.PhotonPersistentDisk = (*PhotonPersistentDiskVolumeSource)(unsafe.Pointer(in.PhotonPersistentDisk))
return nil return nil
} }
...@@ -2732,6 +2736,26 @@ func Convert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus(in *api.Per ...@@ -2732,6 +2736,26 @@ func Convert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus(in *api.Per
return autoConvert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus(in, out, s) return autoConvert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus(in, out, s)
} }
func autoConvert_v1_PhotonPersistentDiskVolumeSource_To_api_PhotonPersistentDiskVolumeSource(in *PhotonPersistentDiskVolumeSource, out *api.PhotonPersistentDiskVolumeSource, s conversion.Scope) error {
out.PdID = in.PdID
out.FSType = in.FSType
return nil
}
func Convert_v1_PhotonPersistentDiskVolumeSource_To_api_PhotonPersistentDiskVolumeSource(in *PhotonPersistentDiskVolumeSource, out *api.PhotonPersistentDiskVolumeSource, s conversion.Scope) error {
return autoConvert_v1_PhotonPersistentDiskVolumeSource_To_api_PhotonPersistentDiskVolumeSource(in, out, s)
}
func autoConvert_api_PhotonPersistentDiskVolumeSource_To_v1_PhotonPersistentDiskVolumeSource(in *api.PhotonPersistentDiskVolumeSource, out *PhotonPersistentDiskVolumeSource, s conversion.Scope) error {
out.PdID = in.PdID
out.FSType = in.FSType
return nil
}
func Convert_api_PhotonPersistentDiskVolumeSource_To_v1_PhotonPersistentDiskVolumeSource(in *api.PhotonPersistentDiskVolumeSource, out *PhotonPersistentDiskVolumeSource, s conversion.Scope) error {
return autoConvert_api_PhotonPersistentDiskVolumeSource_To_v1_PhotonPersistentDiskVolumeSource(in, out, s)
}
func autoConvert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error { func autoConvert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error {
if err := Convert_v1_ObjectMeta_To_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { if err := Convert_v1_ObjectMeta_To_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
return err return err
...@@ -4266,6 +4290,7 @@ func autoConvert_v1_VolumeSource_To_api_VolumeSource(in *VolumeSource, out *api. ...@@ -4266,6 +4290,7 @@ func autoConvert_v1_VolumeSource_To_api_VolumeSource(in *VolumeSource, out *api.
out.VsphereVolume = (*api.VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume)) out.VsphereVolume = (*api.VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume))
out.Quobyte = (*api.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte)) out.Quobyte = (*api.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte))
out.AzureDisk = (*api.AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk)) out.AzureDisk = (*api.AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk))
out.PhotonPersistentDisk = (*api.PhotonPersistentDiskVolumeSource)(unsafe.Pointer(in.PhotonPersistentDisk))
return nil return nil
} }
...@@ -4296,6 +4321,7 @@ func autoConvert_api_VolumeSource_To_v1_VolumeSource(in *api.VolumeSource, out * ...@@ -4296,6 +4321,7 @@ func autoConvert_api_VolumeSource_To_v1_VolumeSource(in *api.VolumeSource, out *
out.ConfigMap = (*ConfigMapVolumeSource)(unsafe.Pointer(in.ConfigMap)) out.ConfigMap = (*ConfigMapVolumeSource)(unsafe.Pointer(in.ConfigMap))
out.VsphereVolume = (*VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume)) out.VsphereVolume = (*VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume))
out.AzureDisk = (*AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk)) out.AzureDisk = (*AzureDiskVolumeSource)(unsafe.Pointer(in.AzureDisk))
out.PhotonPersistentDisk = (*PhotonPersistentDiskVolumeSource)(unsafe.Pointer(in.PhotonPersistentDisk))
return nil return nil
} }
......
...@@ -132,6 +132,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { ...@@ -132,6 +132,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeSource, InType: reflect.TypeOf(&PersistentVolumeSource{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeSource, InType: reflect.TypeOf(&PersistentVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeSpec, InType: reflect.TypeOf(&PersistentVolumeSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeSpec, InType: reflect.TypeOf(&PersistentVolumeSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeStatus, InType: reflect.TypeOf(&PersistentVolumeStatus{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PersistentVolumeStatus, InType: reflect.TypeOf(&PersistentVolumeStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PhotonPersistentDiskVolumeSource, InType: reflect.TypeOf(&PhotonPersistentDiskVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_Pod, InType: reflect.TypeOf(&Pod{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_Pod, InType: reflect.TypeOf(&Pod{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PodAffinity, InType: reflect.TypeOf(&PodAffinity{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PodAffinity, InType: reflect.TypeOf(&PodAffinity{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PodAffinityTerm, InType: reflect.TypeOf(&PodAffinityTerm{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_PodAffinityTerm, InType: reflect.TypeOf(&PodAffinityTerm{})},
...@@ -2231,6 +2232,13 @@ func DeepCopy_v1_PersistentVolumeSource(in interface{}, out interface{}, c *conv ...@@ -2231,6 +2232,13 @@ func DeepCopy_v1_PersistentVolumeSource(in interface{}, out interface{}, c *conv
} else { } else {
out.AzureDisk = nil out.AzureDisk = nil
} }
if in.PhotonPersistentDisk != nil {
in, out := &in.PhotonPersistentDisk, &out.PhotonPersistentDisk
*out = new(PhotonPersistentDiskVolumeSource)
**out = **in
} else {
out.PhotonPersistentDisk = nil
}
return nil return nil
} }
} }
...@@ -2283,6 +2291,16 @@ func DeepCopy_v1_PersistentVolumeStatus(in interface{}, out interface{}, c *conv ...@@ -2283,6 +2291,16 @@ func DeepCopy_v1_PersistentVolumeStatus(in interface{}, out interface{}, c *conv
} }
} }
func DeepCopy_v1_PhotonPersistentDiskVolumeSource(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*PhotonPersistentDiskVolumeSource)
out := out.(*PhotonPersistentDiskVolumeSource)
out.PdID = in.PdID
out.FSType = in.FSType
return nil
}
}
func DeepCopy_v1_Pod(in interface{}, out interface{}, c *conversion.Cloner) error { func DeepCopy_v1_Pod(in interface{}, out interface{}, c *conversion.Cloner) error {
{ {
in := in.(*Pod) in := in.(*Pod)
...@@ -3706,6 +3724,13 @@ func DeepCopy_v1_VolumeSource(in interface{}, out interface{}, c *conversion.Clo ...@@ -3706,6 +3724,13 @@ func DeepCopy_v1_VolumeSource(in interface{}, out interface{}, c *conversion.Clo
} else { } else {
out.AzureDisk = nil out.AzureDisk = nil
} }
if in.PhotonPersistentDisk != nil {
in, out := &in.PhotonPersistentDisk, &out.PhotonPersistentDisk
*out = new(PhotonPersistentDiskVolumeSource)
**out = **in
} else {
out.PhotonPersistentDisk = nil
}
return nil return nil
} }
} }
......
...@@ -665,6 +665,14 @@ func validateVolumeSource(source *api.VolumeSource, fldPath *field.Path) field.E ...@@ -665,6 +665,14 @@ func validateVolumeSource(source *api.VolumeSource, fldPath *field.Path) field.E
allErrs = append(allErrs, validateVsphereVolumeSource(source.VsphereVolume, fldPath.Child("vsphereVolume"))...) allErrs = append(allErrs, validateVsphereVolumeSource(source.VsphereVolume, fldPath.Child("vsphereVolume"))...)
} }
} }
if source.PhotonPersistentDisk != nil {
if numVolumes > 0 {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("photonPersistentDisk"), "may not specify more than 1 volume type"))
} else {
numVolumes++
allErrs = append(allErrs, validatePhotonPersistentDiskVolumeSource(source.PhotonPersistentDisk, fldPath.Child("photonPersistentDisk"))...)
}
}
if source.AzureDisk != nil { if source.AzureDisk != nil {
numVolumes++ numVolumes++
allErrs = append(allErrs, validateAzureDisk(source.AzureDisk, fldPath.Child("azureDisk"))...) allErrs = append(allErrs, validateAzureDisk(source.AzureDisk, fldPath.Child("azureDisk"))...)
...@@ -1008,6 +1016,14 @@ func validateVsphereVolumeSource(cd *api.VsphereVirtualDiskVolumeSource, fldPath ...@@ -1008,6 +1016,14 @@ func validateVsphereVolumeSource(cd *api.VsphereVirtualDiskVolumeSource, fldPath
return allErrs return allErrs
} }
func validatePhotonPersistentDiskVolumeSource(cd *api.PhotonPersistentDiskVolumeSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(cd.PdID) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("pdID"), ""))
}
return allErrs
}
// ValidatePersistentVolumeName checks that a name is appropriate for a // ValidatePersistentVolumeName checks that a name is appropriate for a
// PersistentVolumeName object. // PersistentVolumeName object.
var ValidatePersistentVolumeName = NameIsDNSSubdomain var ValidatePersistentVolumeName = NameIsDNSSubdomain
...@@ -1159,6 +1175,14 @@ func ValidatePersistentVolume(pv *api.PersistentVolume) field.ErrorList { ...@@ -1159,6 +1175,14 @@ func ValidatePersistentVolume(pv *api.PersistentVolume) field.ErrorList {
allErrs = append(allErrs, validateVsphereVolumeSource(pv.Spec.VsphereVolume, specPath.Child("vsphereVolume"))...) allErrs = append(allErrs, validateVsphereVolumeSource(pv.Spec.VsphereVolume, specPath.Child("vsphereVolume"))...)
} }
} }
if pv.Spec.PhotonPersistentDisk != nil {
if numVolumes > 0 {
allErrs = append(allErrs, field.Forbidden(specPath.Child("photonPersistentDisk"), "may not specify more than 1 volume type"))
} else {
numVolumes++
allErrs = append(allErrs, validatePhotonPersistentDiskVolumeSource(pv.Spec.PhotonPersistentDisk, specPath.Child("photonPersistentDisk"))...)
}
}
if pv.Spec.AzureDisk != nil { if pv.Spec.AzureDisk != nil {
numVolumes++ numVolumes++
allErrs = append(allErrs, validateAzureDisk(pv.Spec.AzureDisk, specPath.Child("azureDisk"))...) allErrs = append(allErrs, validateAzureDisk(pv.Spec.AzureDisk, specPath.Child("azureDisk"))...)
......
...@@ -136,6 +136,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { ...@@ -136,6 +136,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeSource, InType: reflect.TypeOf(&PersistentVolumeSource{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeSource, InType: reflect.TypeOf(&PersistentVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeSpec, InType: reflect.TypeOf(&PersistentVolumeSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeSpec, InType: reflect.TypeOf(&PersistentVolumeSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeStatus, InType: reflect.TypeOf(&PersistentVolumeStatus{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PersistentVolumeStatus, InType: reflect.TypeOf(&PersistentVolumeStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PhotonPersistentDiskVolumeSource, InType: reflect.TypeOf(&PhotonPersistentDiskVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_Pod, InType: reflect.TypeOf(&Pod{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_Pod, InType: reflect.TypeOf(&Pod{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PodAffinity, InType: reflect.TypeOf(&PodAffinity{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PodAffinity, InType: reflect.TypeOf(&PodAffinity{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PodAffinityTerm, InType: reflect.TypeOf(&PodAffinityTerm{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_PodAffinityTerm, InType: reflect.TypeOf(&PodAffinityTerm{})},
...@@ -2290,6 +2291,13 @@ func DeepCopy_api_PersistentVolumeSource(in interface{}, out interface{}, c *con ...@@ -2290,6 +2291,13 @@ func DeepCopy_api_PersistentVolumeSource(in interface{}, out interface{}, c *con
} else { } else {
out.AzureDisk = nil out.AzureDisk = nil
} }
if in.PhotonPersistentDisk != nil {
in, out := &in.PhotonPersistentDisk, &out.PhotonPersistentDisk
*out = new(PhotonPersistentDiskVolumeSource)
**out = **in
} else {
out.PhotonPersistentDisk = nil
}
return nil return nil
} }
} }
...@@ -2342,6 +2350,16 @@ func DeepCopy_api_PersistentVolumeStatus(in interface{}, out interface{}, c *con ...@@ -2342,6 +2350,16 @@ func DeepCopy_api_PersistentVolumeStatus(in interface{}, out interface{}, c *con
} }
} }
func DeepCopy_api_PhotonPersistentDiskVolumeSource(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*PhotonPersistentDiskVolumeSource)
out := out.(*PhotonPersistentDiskVolumeSource)
out.PdID = in.PdID
out.FSType = in.FSType
return nil
}
}
func DeepCopy_api_Pod(in interface{}, out interface{}, c *conversion.Cloner) error { func DeepCopy_api_Pod(in interface{}, out interface{}, c *conversion.Cloner) error {
{ {
in := in.(*Pod) in := in.(*Pod)
...@@ -3752,6 +3770,13 @@ func DeepCopy_api_VolumeSource(in interface{}, out interface{}, c *conversion.Cl ...@@ -3752,6 +3770,13 @@ func DeepCopy_api_VolumeSource(in interface{}, out interface{}, c *conversion.Cl
} else { } else {
out.AzureDisk = nil out.AzureDisk = nil
} }
if in.PhotonPersistentDisk != nil {
in, out := &in.PhotonPersistentDisk, &out.PhotonPersistentDisk
*out = new(PhotonPersistentDiskVolumeSource)
**out = **in
} else {
out.PhotonPersistentDisk = nil
}
return nil return nil
} }
} }
......
...@@ -898,6 +898,7 @@ var ( ...@@ -898,6 +898,7 @@ var (
VsphereVolume FSType = "vsphereVolume" VsphereVolume FSType = "vsphereVolume"
Quobyte FSType = "quobyte" Quobyte FSType = "quobyte"
AzureDisk FSType = "azureDisk" AzureDisk FSType = "azureDisk"
PhotonPersistentDisk FSType = "photonPersistentDisk"
All FSType = "*" All FSType = "*"
) )
......
...@@ -22,6 +22,7 @@ go_library( ...@@ -22,6 +22,7 @@ go_library(
"//pkg/cloudprovider/providers/mesos:go_default_library", "//pkg/cloudprovider/providers/mesos:go_default_library",
"//pkg/cloudprovider/providers/openstack:go_default_library", "//pkg/cloudprovider/providers/openstack:go_default_library",
"//pkg/cloudprovider/providers/ovirt:go_default_library", "//pkg/cloudprovider/providers/ovirt:go_default_library",
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/cloudprovider/providers/rackspace:go_default_library", "//pkg/cloudprovider/providers/rackspace:go_default_library",
"//pkg/cloudprovider/providers/vsphere:go_default_library", "//pkg/cloudprovider/providers/vsphere:go_default_library",
], ],
......
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
"go_test",
"cgo_library",
)
go_library(
name = "go_default_library",
srcs = ["photon.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/types:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/vmware/photon-controller-go-sdk/photon",
"//vendor:gopkg.in/gcfg.v1",
],
)
go_test(
name = "go_default_test",
srcs = ["photon_test.go"],
library = "go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/cloudprovider:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/rand:go_default_library",
],
)
maintainers:
- luomiao
- kerneltime
- abrarshivani
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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.
*/
package photon
import (
"log"
"os"
"strconv"
"strings"
"testing"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/rand"
)
func configFromEnv() (TestVM string, TestFlavor string, cfg PCConfig, ok bool) {
var IgnoreCertificate bool
var OverrideIP bool
var err error
cfg.Global.CloudTarget = os.Getenv("PHOTON_TARGET")
cfg.Global.Tenant = os.Getenv("PHOTON_TENANT")
cfg.Global.Project = os.Getenv("PHOTON_PROJECT")
if os.Getenv("PHOTON_IGNORE_CERTIFICATE") != "" {
IgnoreCertificate, err = strconv.ParseBool(os.Getenv("PHOTON_IGNORE_CERTIFICATE"))
} else {
IgnoreCertificate = false
}
if err != nil {
log.Fatal(err)
}
cfg.Global.IgnoreCertificate = IgnoreCertificate
if os.Getenv("PHOTON_OVERRIDE_IP") != "" {
OverrideIP, err = strconv.ParseBool(os.Getenv("PHOTON_OVERRIDE_IP"))
} else {
OverrideIP = false
}
if err != nil {
log.Fatal(err)
}
cfg.Global.OverrideIP = OverrideIP
TestVM = os.Getenv("PHOTON_TEST_VM")
if os.Getenv("PHOTON_TEST_FLAVOR") != "" {
TestFlavor = os.Getenv("PHOTON_TEST_FLAVOR")
} else {
TestFlavor = ""
}
if err != nil {
log.Fatal(err)
}
ok = (cfg.Global.CloudTarget != "" &&
cfg.Global.Tenant != "" &&
cfg.Global.Project != "" &&
TestVM != "")
return
}
func TestReadConfig(t *testing.T) {
_, err := readConfig(nil)
if err == nil {
t.Errorf("Should fail when no config is provided: %s", err)
}
cfg, err := readConfig(strings.NewReader(`
[Global]
target = 0.0.0.0
ignoreCertificate = true
tenant = tenant
project = project
overrideIP = false
`))
if err != nil {
t.Fatalf("Should succeed when a valid config is provided: %s", err)
}
if cfg.Global.CloudTarget != "0.0.0.0" {
t.Errorf("incorrect photon target ip: %s", cfg.Global.CloudTarget)
}
if cfg.Global.Tenant != "tenant" {
t.Errorf("incorrect tenant: %s", cfg.Global.Tenant)
}
if cfg.Global.Project != "project" {
t.Errorf("incorrect project: %s", cfg.Global.Project)
}
}
func TestNewPCCloud(t *testing.T) {
_, _, cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
_, err := newPCCloud(cfg)
if err != nil {
t.Fatalf("Failed to create new Photon client: %s", err)
}
}
func TestInstances(t *testing.T) {
testVM, _, cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
NodeName := types.NodeName(testVM)
pc, err := newPCCloud(cfg)
if err != nil {
t.Fatalf("Failed to create new Photon client: %s", err)
}
i, ok := pc.Instances()
if !ok {
t.Fatalf("Instances() returned false")
}
externalId, err := i.ExternalID(NodeName)
if err != nil {
t.Fatalf("Instances.ExternalID(%s) failed: %s", testVM, err)
}
t.Logf("Found ExternalID(%s) = %s\n", testVM, externalId)
nonExistingVM := types.NodeName(rand.String(15))
externalId, err = i.ExternalID(nonExistingVM)
if err == cloudprovider.InstanceNotFound {
t.Logf("VM %s was not found as expected\n", nonExistingVM)
} else if err == nil {
t.Fatalf("Instances.ExternalID did not fail as expected, VM %s was found", nonExistingVM)
} else {
t.Fatalf("Instances.ExternalID did not fail as expected, err: %v", err)
}
instanceId, err := i.InstanceID(NodeName)
if err != nil {
t.Fatalf("Instances.InstanceID(%s) failed: %s", testVM, err)
}
t.Logf("Found InstanceID(%s) = %s\n", testVM, instanceId)
instanceId, err = i.InstanceID(nonExistingVM)
if err == cloudprovider.InstanceNotFound {
t.Logf("VM %s was not found as expected\n", nonExistingVM)
} else if err == nil {
t.Fatalf("Instances.InstanceID did not fail as expected, VM %s was found", nonExistingVM)
} else {
t.Fatalf("Instances.InstanceID did not fail as expected, err: %v", err)
}
addrs, err := i.NodeAddresses(NodeName)
if err != nil {
t.Fatalf("Instances.NodeAddresses(%s) failed: %s", testVM, err)
}
t.Logf("Found NodeAddresses(%s) = %s\n", testVM, addrs)
}
func TestVolumes(t *testing.T) {
testVM, testFlavor, cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
pc, err := newPCCloud(cfg)
if err != nil {
t.Fatalf("Failed to create new Photon client: %s", err)
}
NodeName := types.NodeName(testVM)
volumeOptions := &VolumeOptions{
CapacityGB: 2,
Tags: nil,
Name: "kubernetes-test-volume-" + rand.String(10),
Flavor: testFlavor}
pdID, err := pc.CreateDisk(volumeOptions)
if err != nil {
t.Fatalf("Cannot create a Photon persistent disk: %v", err)
}
err = pc.AttachDisk(pdID, NodeName)
if err != nil {
t.Fatalf("Cannot attach persistent disk(%s) to VM(%s): %v", pdID, testVM, err)
}
_, err = pc.DiskIsAttached(pdID, NodeName)
if err != nil {
t.Fatalf("Cannot attach persistent disk(%s) to VM(%s): %v", pdID, testVM, err)
}
err = pc.DetachDisk(pdID, NodeName)
if err != nil {
t.Fatalf("Cannot detach persisten disk(%s) from VM(%s): %v", pdID, testVM, err)
}
err = pc.DeleteDisk(pdID)
if err != nil {
t.Fatalf("Cannot delete persisten disk(%s): %v", pdID, err)
}
}
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/mesos" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/mesos"
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack"
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt"
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/rackspace" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/rackspace"
_ "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere"
) )
...@@ -10556,11 +10556,18 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{ ...@@ -10556,11 +10556,18 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{
Ref: spec.MustCreateRef("#/definitions/v1.AzureDiskVolumeSource"), Ref: spec.MustCreateRef("#/definitions/v1.AzureDiskVolumeSource"),
}, },
}, },
"photonPersistentDisk": {
SchemaProps: spec.SchemaProps{
Description: "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine",
Ref: spec.MustCreateRef("#/definitions/v1.PhotonPersistentDiskVolumeSource"),
},
},
}, },
Required: []string{"photonPersistentDisk"},
}, },
}, },
Dependencies: []string{ Dependencies: []string{
"v1.AWSElasticBlockStoreVolumeSource", "v1.AzureDiskVolumeSource", "v1.AzureFileVolumeSource", "v1.CephFSVolumeSource", "v1.CinderVolumeSource", "v1.FCVolumeSource", "v1.FlexVolumeSource", "v1.FlockerVolumeSource", "v1.GCEPersistentDiskVolumeSource", "v1.GlusterfsVolumeSource", "v1.HostPathVolumeSource", "v1.ISCSIVolumeSource", "v1.NFSVolumeSource", "v1.QuobyteVolumeSource", "v1.RBDVolumeSource", "v1.VsphereVirtualDiskVolumeSource"}, "v1.AWSElasticBlockStoreVolumeSource", "v1.AzureDiskVolumeSource", "v1.AzureFileVolumeSource", "v1.CephFSVolumeSource", "v1.CinderVolumeSource", "v1.FCVolumeSource", "v1.FlexVolumeSource", "v1.FlockerVolumeSource", "v1.GCEPersistentDiskVolumeSource", "v1.GlusterfsVolumeSource", "v1.HostPathVolumeSource", "v1.ISCSIVolumeSource", "v1.NFSVolumeSource", "v1.PhotonPersistentDiskVolumeSource", "v1.QuobyteVolumeSource", "v1.RBDVolumeSource", "v1.VsphereVirtualDiskVolumeSource"},
}, },
"v1.PersistentVolumeSpec": { "v1.PersistentVolumeSpec": {
Schema: spec.Schema{ Schema: spec.Schema{
...@@ -10644,6 +10651,31 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{ ...@@ -10644,6 +10651,31 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{
}, },
Dependencies: []string{}, Dependencies: []string{},
}, },
"v1.PhotonPersistentDiskVolumeSource": {
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Represents a Photon Controller persistent disk resource.",
Properties: map[string]spec.Schema{
"pdID": {
SchemaProps: spec.SchemaProps{
Description: "ID that identifies Photon Controller persistent disk",
Type: []string{"string"},
Format: "",
},
},
"fsType": {
SchemaProps: spec.SchemaProps{
Description: "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"pdID", "fsType"},
},
},
Dependencies: []string{},
},
"v1.Pod": { "v1.Pod": {
Schema: spec.Schema{ Schema: spec.Schema{
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
...@@ -13145,11 +13177,18 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{ ...@@ -13145,11 +13177,18 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{
Ref: spec.MustCreateRef("#/definitions/v1.AzureDiskVolumeSource"), Ref: spec.MustCreateRef("#/definitions/v1.AzureDiskVolumeSource"),
}, },
}, },
"photonPersistentDisk": {
SchemaProps: spec.SchemaProps{
Description: "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine",
Ref: spec.MustCreateRef("#/definitions/v1.PhotonPersistentDiskVolumeSource"),
},
},
}, },
Required: []string{"photonPersistentDisk"},
}, },
}, },
Dependencies: []string{ Dependencies: []string{
"v1.AWSElasticBlockStoreVolumeSource", "v1.AzureDiskVolumeSource", "v1.AzureFileVolumeSource", "v1.CephFSVolumeSource", "v1.CinderVolumeSource", "v1.ConfigMapVolumeSource", "v1.DownwardAPIVolumeSource", "v1.EmptyDirVolumeSource", "v1.FCVolumeSource", "v1.FlexVolumeSource", "v1.FlockerVolumeSource", "v1.GCEPersistentDiskVolumeSource", "v1.GitRepoVolumeSource", "v1.GlusterfsVolumeSource", "v1.HostPathVolumeSource", "v1.ISCSIVolumeSource", "v1.NFSVolumeSource", "v1.PersistentVolumeClaimVolumeSource", "v1.QuobyteVolumeSource", "v1.RBDVolumeSource", "v1.SecretVolumeSource", "v1.VsphereVirtualDiskVolumeSource"}, "v1.AWSElasticBlockStoreVolumeSource", "v1.AzureDiskVolumeSource", "v1.AzureFileVolumeSource", "v1.CephFSVolumeSource", "v1.CinderVolumeSource", "v1.ConfigMapVolumeSource", "v1.DownwardAPIVolumeSource", "v1.EmptyDirVolumeSource", "v1.FCVolumeSource", "v1.FlexVolumeSource", "v1.FlockerVolumeSource", "v1.GCEPersistentDiskVolumeSource", "v1.GitRepoVolumeSource", "v1.GlusterfsVolumeSource", "v1.HostPathVolumeSource", "v1.ISCSIVolumeSource", "v1.NFSVolumeSource", "v1.PersistentVolumeClaimVolumeSource", "v1.PhotonPersistentDiskVolumeSource", "v1.QuobyteVolumeSource", "v1.RBDVolumeSource", "v1.SecretVolumeSource", "v1.VsphereVirtualDiskVolumeSource"},
}, },
"v1.VsphereVirtualDiskVolumeSource": { "v1.VsphereVirtualDiskVolumeSource": {
Schema: spec.Schema{ Schema: spec.Schema{
......
...@@ -572,6 +572,8 @@ func describeVolumes(volumes []api.Volume, out io.Writer, space string) { ...@@ -572,6 +572,8 @@ func describeVolumes(volumes []api.Volume, out io.Writer, space string) {
printVsphereVolumeSource(volume.VolumeSource.VsphereVolume, out) printVsphereVolumeSource(volume.VolumeSource.VsphereVolume, out)
case volume.VolumeSource.Cinder != nil: case volume.VolumeSource.Cinder != nil:
printCinderVolumeSource(volume.VolumeSource.Cinder, out) printCinderVolumeSource(volume.VolumeSource.Cinder, out)
case volume.VolumeSource.PhotonPersistentDisk != nil:
printPhotonPersistentDiskVolumeSource(volume.VolumeSource.PhotonPersistentDisk, out)
default: default:
fmt.Fprintf(out, " <unknown>\n") fmt.Fprintf(out, " <unknown>\n")
} }
...@@ -706,6 +708,14 @@ func printVsphereVolumeSource(vsphere *api.VsphereVirtualDiskVolumeSource, out i ...@@ -706,6 +708,14 @@ func printVsphereVolumeSource(vsphere *api.VsphereVirtualDiskVolumeSource, out i
" FSType:\t%v\n", " FSType:\t%v\n",
vsphere.VolumePath, vsphere.FSType) vsphere.VolumePath, vsphere.FSType)
} }
func printPhotonPersistentDiskVolumeSource(photon *api.PhotonPersistentDiskVolumeSource, out io.Writer) {
fmt.Fprintf(out, " Type:\tPhotonPersistentDisk (a Persistent Disk resource in photon platform)\n"+
" PdID:\t%v\n"+
" FSType:\t%v\n",
photon.PdID, photon.FSType)
}
func printCinderVolumeSource(cinder *api.CinderVolumeSource, out io.Writer) { func printCinderVolumeSource(cinder *api.CinderVolumeSource, out io.Writer) {
fmt.Fprintf(out, " Type:\tCinder (a Persistent Disk resource in OpenStack)\n"+ fmt.Fprintf(out, " Type:\tCinder (a Persistent Disk resource in OpenStack)\n"+
" VolumeID:\t%v\n"+ " VolumeID:\t%v\n"+
...@@ -772,6 +782,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string, describerSe ...@@ -772,6 +782,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string, describerSe
printCinderVolumeSource(pv.Spec.Cinder, out) printCinderVolumeSource(pv.Spec.Cinder, out)
case pv.Spec.AzureDisk != nil: case pv.Spec.AzureDisk != nil:
printAzureDiskVolumeSource(pv.Spec.AzureDisk, out) printAzureDiskVolumeSource(pv.Spec.AzureDisk, out)
case pv.Spec.PhotonPersistentDisk != nil:
printPhotonPersistentDiskVolumeSource(pv.Spec.PhotonPersistentDisk, out)
} }
if events != nil { if events != nil {
......
...@@ -60,7 +60,8 @@ func GetAllFSTypesAsSet() sets.String { ...@@ -60,7 +60,8 @@ func GetAllFSTypesAsSet() sets.String {
string(extensions.ConfigMap), string(extensions.ConfigMap),
string(extensions.VsphereVolume), string(extensions.VsphereVolume),
string(extensions.Quobyte), string(extensions.Quobyte),
string(extensions.AzureDisk)) string(extensions.AzureDisk),
string(extensions.PhotonPersistentDisk))
return fstypes return fstypes
} }
...@@ -111,6 +112,8 @@ func GetVolumeFSType(v api.Volume) (extensions.FSType, error) { ...@@ -111,6 +112,8 @@ func GetVolumeFSType(v api.Volume) (extensions.FSType, error) {
return extensions.Quobyte, nil return extensions.Quobyte, nil
case v.AzureDisk != nil: case v.AzureDisk != nil:
return extensions.AzureDisk, nil return extensions.AzureDisk, nil
case v.PhotonPersistentDisk != nil:
return extensions.PhotonPersistentDisk, nil
} }
return "", fmt.Errorf("unknown volume type for volume: %#v", v) return "", fmt.Errorf("unknown volume type for volume: %#v", v)
......
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
"go_test",
"cgo_library",
)
go_library(
name = "go_default_library",
srcs = [
"attacher.go",
"photon_pd.go",
"photon_util.go",
],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/resource:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/exec:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor:github.com/golang/glog",
],
)
go_test(
name = "go_default_test",
srcs = [
"attacher_test.go",
"photon_pd_test.go",
],
library = "go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/util/testing:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/testing:go_default_library",
"//vendor:github.com/golang/glog",
],
)
maintainers:
- luomiao
- kerneltime
- abrarshivani
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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.
*/
package photon_pd
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
)
type photonPersistentDiskAttacher struct {
host volume.VolumeHost
photonDisks photon.Disks
}
var _ volume.Attacher = &photonPersistentDiskAttacher{}
var _ volume.AttachableVolumePlugin = &photonPersistentDiskPlugin{}
func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error) {
photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider())
if err != nil {
glog.Errorf("Photon Controller attacher: NewAttacher failed to get cloud provider")
return nil, err
}
return &photonPersistentDiskAttacher{
host: plugin.host,
photonDisks: photonCloud,
}, nil
}
// Attaches the volume specified by the given spec to the given host.
// On success, returns the device path where the device was attached on the
// node.
// Callers are responsible for retryinging on failure.
// Callers are responsible for thread safety between concurrent attach and
// detach operations.
func (attacher *photonPersistentDiskAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string, error) {
hostName := string(nodeName)
volumeSource, _, err := getVolumeSource(spec)
if err != nil {
glog.Errorf("Photon Controller attacher: Attach failed to get volume source")
return "", err
}
glog.V(4).Infof("Photon Controller: Attach disk called for host %s", hostName)
// TODO: if disk is already attached?
err = attacher.photonDisks.AttachDisk(volumeSource.PdID, nodeName)
if err != nil {
glog.Errorf("Error attaching volume %q: %+v", volumeSource.PdID, err)
return "", err
}
PdidWithNoHypens := strings.Replace(volumeSource.PdID, "-", "", -1)
return path.Join(diskByIDPath, diskPhotonPrefix+PdidWithNoHypens), nil
}
func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName types.NodeName) (map[*volume.Spec]bool, error) {
volumesAttachedCheck := make(map[*volume.Spec]bool)
volumeSpecMap := make(map[string]*volume.Spec)
pdIDList := []string{}
for _, spec := range specs {
volumeSource, _, err := getVolumeSource(spec)
if err != nil {
glog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err)
continue
}
pdIDList = append(pdIDList, volumeSource.PdID)
volumesAttachedCheck[spec] = true
volumeSpecMap[volumeSource.PdID] = spec
}
attachedResult, err := attacher.photonDisks.DisksAreAttached(pdIDList, nodeName)
if err != nil {
glog.Errorf(
"Error checking if volumes (%v) are attached to current node (%q). err=%v",
pdIDList, nodeName, err)
return volumesAttachedCheck, err
}
for pdID, attached := range attachedResult {
if !attached {
spec := volumeSpecMap[pdID]
volumesAttachedCheck[spec] = false
glog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", pdID, spec.Name())
}
}
return volumesAttachedCheck, nil
}
func (attacher *photonPersistentDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath string, timeout time.Duration) (string, error) {
volumeSource, _, err := getVolumeSource(spec)
if err != nil {
glog.Errorf("Photon Controller attacher: WaitForAttach failed to get volume source")
return "", err
}
if devicePath == "" {
return "", fmt.Errorf("WaitForAttach failed for PD %s: devicePath is empty.", volumeSource.PdID)
}
// scan scsi path to discover the new disk
scsiHostScan()
ticker := time.NewTicker(checkSleepDuration)
defer ticker.Stop()
timer := time.NewTimer(timeout)
defer timer.Stop()
for {
select {
case <-ticker.C:
glog.V(4).Infof("Checking PD %s is attached", volumeSource.PdID)
checkPath, err := verifyDevicePath(devicePath)
if err != nil {
// Log error, if any, and continue checking periodically. See issue #11321
glog.Warningf("Photon Controller attacher: WaitForAttach with devicePath %s Checking PD %s Error verify path", devicePath, volumeSource.PdID)
} else if checkPath != "" {
// A device path has successfully been created for the VMDK
glog.V(4).Infof("Successfully found attached PD %s.", volumeSource.PdID)
// map path with spec.Name()
volName := spec.Name()
realPath, _ := filepath.EvalSymlinks(devicePath)
deviceName := path.Base(realPath)
volNameToDeviceName[volName] = deviceName
return devicePath, nil
}
case <-timer.C:
return "", fmt.Errorf("Could not find attached PD %s. Timeout waiting for mount paths to be created.", volumeSource.PdID)
}
}
}
// GetDeviceMountPath returns a path where the device should
// point which should be bind mounted for individual volumes.
func (attacher *photonPersistentDiskAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) {
volumeSource, _, err := getVolumeSource(spec)
if err != nil {
glog.Errorf("Photon Controller attacher: GetDeviceMountPath failed to get volume source")
return "", err
}
return makeGlobalPDPath(attacher.host, volumeSource.PdID), nil
}
// GetMountDeviceRefs finds all other references to the device referenced
// by deviceMountPath; returns a list of paths.
func (plugin *photonPersistentDiskPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) {
mounter := plugin.host.GetMounter()
return mount.GetMountRefs(mounter, deviceMountPath)
}
// MountDevice mounts device to global mount point.
func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string) error {
mounter := attacher.host.GetMounter()
notMnt, err := mounter.IsLikelyNotMountPoint(deviceMountPath)
if err != nil {
if os.IsNotExist(err) {
if err := os.MkdirAll(deviceMountPath, 0750); err != nil {
glog.Errorf("Failed to create directory at %#v. err: %s", deviceMountPath, err)
return err
}
notMnt = true
} else {
return err
}
}
volumeSource, _, err := getVolumeSource(spec)
if err != nil {
glog.Errorf("Photon Controller attacher: MountDevice failed to get volume source. err: %s", err)
return err
}
options := []string{}
if notMnt {
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Runner: exec.New()}
err = diskMounter.FormatAndMount(devicePath, deviceMountPath, volumeSource.FSType, options)
if err != nil {
os.Remove(deviceMountPath)
return err
}
glog.V(4).Infof("formatting spec %v devicePath %v deviceMountPath %v fs %v with options %+v", spec.Name(), devicePath, deviceMountPath, volumeSource.FSType, options)
}
return nil
}
type photonPersistentDiskDetacher struct {
mounter mount.Interface
photonDisks photon.Disks
}
var _ volume.Detacher = &photonPersistentDiskDetacher{}
func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error) {
photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider())
if err != nil {
glog.Errorf("Photon Controller attacher: NewDetacher failed to get cloud provider. err: %s", err)
return nil, err
}
return &photonPersistentDiskDetacher{
mounter: plugin.host.GetMounter(),
photonDisks: photonCloud,
}, nil
}
// Detach the given device from the given host.
func (detacher *photonPersistentDiskDetacher) Detach(deviceMountPath string, nodeName types.NodeName) error {
hostName := string(nodeName)
pdID := deviceMountPath
attached, err := detacher.photonDisks.DiskIsAttached(pdID, nodeName)
if err != nil {
// Log error and continue with detach
glog.Errorf(
"Error checking if persistent disk (%q) is already attached to current node (%q). Will continue and try detach anyway. err=%v",
pdID, hostName, err)
}
if err == nil && !attached {
// Volume is already detached from node.
glog.V(4).Infof("detach operation was successful. persistent disk %q is already detached from node %q.", pdID, hostName)
return nil
}
if err := detacher.photonDisks.DetachDisk(pdID, nodeName); err != nil {
glog.Errorf("Error detaching volume %q: %v", pdID, err)
return err
}
return nil
}
func (detacher *photonPersistentDiskDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
ticker := time.NewTicker(checkSleepDuration)
defer ticker.Stop()
timer := time.NewTimer(timeout)
defer timer.Stop()
for {
select {
case <-ticker.C:
glog.V(4).Infof("Checking device %q is detached.", devicePath)
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
return fmt.Errorf("Error checking if device path exists: %v", err)
} else if !pathExists {
return nil
}
case <-timer.C:
return fmt.Errorf("Timeout reached; Device %v is still attached", devicePath)
}
}
}
func (detacher *photonPersistentDiskDetacher) UnmountDevice(deviceMountPath string) error {
return volumeutil.UnmountPath(deviceMountPath, detacher.mounter)
}
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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.
*/
package photon_pd
import (
"fmt"
"os"
"path"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/mount"
utiltesting "k8s.io/kubernetes/pkg/util/testing"
"k8s.io/kubernetes/pkg/volume"
volumetest "k8s.io/kubernetes/pkg/volume/testing"
)
func TestCanSupport(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("photonpdTest")
if err != nil {
t.Fatalf("can't make a temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if plug.GetPluginName() != "kubernetes.io/photon-pd" {
t.Errorf("Wrong name: %s", plug.GetPluginName())
}
if !plug.CanSupport(&volume.Spec{Volume: &api.Volume{VolumeSource: api.VolumeSource{PhotonPersistentDisk: &api.PhotonPersistentDiskVolumeSource{}}}}) {
t.Errorf("Expected true")
}
if !plug.CanSupport(&volume.Spec{PersistentVolume: &api.PersistentVolume{Spec: api.PersistentVolumeSpec{PersistentVolumeSource: api.PersistentVolumeSource{PhotonPersistentDisk: &api.PhotonPersistentDiskVolumeSource{}}}}}) {
t.Errorf("Expected true")
}
}
func TestGetAccessModes(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("photonpdTest")
if err != nil {
t.Fatalf("can't make a temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))
plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/photon-pd")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if !contains(plug.GetAccessModes(), api.ReadWriteOnce) {
t.Errorf("Expected to support AccessModeTypes: %s", api.ReadWriteOnce)
}
if contains(plug.GetAccessModes(), api.ReadOnlyMany) {
t.Errorf("Expected not to support AccessModeTypes: %s", api.ReadOnlyMany)
}
}
func contains(modes []api.PersistentVolumeAccessMode, mode api.PersistentVolumeAccessMode) bool {
for _, m := range modes {
if m == mode {
return true
}
}
return false
}
type fakePDManager struct {
}
func (fake *fakePDManager) CreateVolume(c *photonPersistentDiskProvisioner) (pdID string, volumeSizeGB int, err error) {
return "test-photon-pd-id", 10, nil
}
func (fake *fakePDManager) DeleteVolume(cd *photonPersistentDiskDeleter) error {
if cd.pdID != "test-photon-pd-id" {
return fmt.Errorf("Deleter got unexpected volume name: %s", cd.pdID)
}
return nil
}
func TestPlugin(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("photonpdTest")
if err != nil {
t.Fatalf("can't make a temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
spec := &api.Volume{
Name: "vol1",
VolumeSource: api.VolumeSource{
PhotonPersistentDisk: &api.PhotonPersistentDiskVolumeSource{
PdID: "pdid",
FSType: "ext4",
},
},
}
fakeManager := &fakePDManager{}
fakeMounter := &mount.FakeMounter{}
mounter, err := plug.(*photonPersistentDiskPlugin).newMounterInternal(volume.NewSpecFromVolume(spec), types.UID("poduid"), fakeManager, fakeMounter)
if err != nil {
t.Errorf("Failed to make a new Mounter: %v", err)
}
if mounter == nil {
t.Errorf("Got a nil Mounter")
}
volPath := path.Join(tmpDir, "pods/poduid/volumes/kubernetes.io~photon-pd/vol1")
path := mounter.GetPath()
if path != volPath {
t.Errorf("Got unexpected path: %s", path)
}
if err := mounter.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
t.Errorf("SetUp() failed, volume path not created: %s", path)
} else {
t.Errorf("SetUp() failed: %v", err)
}
}
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
t.Errorf("SetUp() failed, volume path not created: %s", path)
} else {
t.Errorf("SetUp() failed: %v", err)
}
}
fakeManager = &fakePDManager{}
unmounter, err := plug.(*photonPersistentDiskPlugin).newUnmounterInternal("vol1", types.UID("poduid"), fakeManager, fakeMounter)
if err != nil {
t.Errorf("Failed to make a new Unmounter: %v", err)
}
if unmounter == nil {
t.Errorf("Got a nil Unmounter")
}
if err := unmounter.TearDown(); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err == nil {
t.Errorf("TearDown() failed, volume path still exists: %s", path)
} else if !os.IsNotExist(err) {
t.Errorf("SetUp() failed: %v", err)
}
// Test Provisioner
options := volume.VolumeOptions{
PVC: volumetest.CreateTestPVC("10Gi", []api.PersistentVolumeAccessMode{api.ReadWriteOnce}),
PersistentVolumeReclaimPolicy: api.PersistentVolumeReclaimDelete,
}
provisioner, err := plug.(*photonPersistentDiskPlugin).newProvisionerInternal(options, &fakePDManager{})
persistentSpec, err := provisioner.Provision()
if err != nil {
t.Errorf("Provision() failed: %v", err)
}
if persistentSpec.Spec.PersistentVolumeSource.PhotonPersistentDisk.PdID != "test-photon-pd-id" {
t.Errorf("Provision() returned unexpected persistent disk ID: %s", persistentSpec.Spec.PersistentVolumeSource.PhotonPersistentDisk.PdID)
}
cap := persistentSpec.Spec.Capacity[api.ResourceStorage]
size := cap.Value()
if size != 10*1024*1024*1024 {
t.Errorf("Provision() returned unexpected volume size: %v", size)
}
// Test Deleter
volSpec := &volume.Spec{
PersistentVolume: persistentSpec,
}
deleter, err := plug.(*photonPersistentDiskPlugin).newDeleterInternal(volSpec, &fakePDManager{})
err = deleter.Delete()
if err != nil {
t.Errorf("Deleter() failed: %v", err)
}
}
func TestMounterAndUnmounterTypeAssert(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("photonpdTest")
if err != nil {
t.Fatalf("can't make a temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
spec := &api.Volume{
Name: "vol1",
VolumeSource: api.VolumeSource{
PhotonPersistentDisk: &api.PhotonPersistentDiskVolumeSource{
PdID: "pdid",
FSType: "ext4",
},
},
}
mounter, err := plug.(*photonPersistentDiskPlugin).newMounterInternal(volume.NewSpecFromVolume(spec), types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{})
if _, ok := mounter.(volume.Unmounter); ok {
t.Errorf("Volume Mounter can be type-assert to Unmounter")
}
unmounter, err := plug.(*photonPersistentDiskPlugin).newUnmounterInternal("vol1", types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{})
if _, ok := unmounter.(volume.Mounter); ok {
t.Errorf("Volume Unmounter can be type-assert to Mounter")
}
}
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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.
*/
package photon_pd
import (
"errors"
"fmt"
"io/ioutil"
"strings"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
"k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
)
const (
maxRetries = 10
checkSleepDuration = time.Second
diskByIDPath = "/dev/disk/by-id/"
diskPhotonPrefix = "wwn-0x"
)
var ErrProbeVolume = errors.New("Error scanning attached volumes")
// volNameToDeviceName is a mapping between spec.Name from detacher
// and the device name inside scsi path. Once pvscsi controller is
// supported, this won't be needed.
var volNameToDeviceName = make(map[string]string)
type PhotonDiskUtil struct{}
func removeFromScsiSubsystem(volName string) {
// TODO: if using pvscsi controller, this won't be needed
deviceName := volNameToDeviceName[volName]
fileName := "/sys/block/" + deviceName + "/device/delete"
data := []byte("1")
ioutil.WriteFile(fileName, data, 0666)
}
func scsiHostScan() {
// TODO: if using pvscsi controller, this won't be needed
scsi_path := "/sys/class/scsi_host/"
if dirs, err := ioutil.ReadDir(scsi_path); err == nil {
for _, f := range dirs {
name := scsi_path + f.Name() + "/scan"
data := []byte("- - -")
ioutil.WriteFile(name, data, 0666)
glog.Errorf("scsiHostScan scan for %s", name)
}
}
}
func verifyDevicePath(path string) (string, error) {
if pathExists, err := volumeutil.PathExists(path); err != nil {
return "", fmt.Errorf("Error checking if path exists: %v", err)
} else if pathExists {
return path, nil
}
glog.V(4).Infof("verifyDevicePath: path not exists yet")
return "", nil
}
// CreateVolume creates a PhotonController persistent disk.
func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pdID string, capacityGB int, err error) {
cloud, err := getCloudProvider(p.plugin.host.GetCloudProvider())
if err != nil {
glog.Errorf("Photon Controller Util: CreateVolume failed to get cloud provider. Error [%v]", err)
return "", 0, err
}
capacity := p.options.PVC.Spec.Resources.Requests[api.ResourceName(api.ResourceStorage)]
volSizeBytes := capacity.Value()
// PhotonController works with GB, convert to GB with rounding up
volSizeGB := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024))
name := volume.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 255)
volumeOptions := &photon.VolumeOptions{
CapacityGB: volSizeGB,
Tags: *p.options.CloudTags,
Name: name,
}
for parameter, value := range p.options.Parameters {
switch strings.ToLower(parameter) {
case "flavor":
volumeOptions.Flavor = value
default:
glog.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName())
return "", 0, fmt.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName())
}
}
pdID, err = cloud.CreateDisk(volumeOptions)
if err != nil {
glog.Errorf("Photon Controller Util: failed to CreateDisk. Error [%v]", err)
return "", 0, err
}
glog.V(4).Infof("Successfully created Photon Controller persistent disk %s", name)
return pdID, volSizeGB, nil
}
// DeleteVolume deletes a vSphere volume.
func (util *PhotonDiskUtil) DeleteVolume(pd *photonPersistentDiskDeleter) error {
cloud, err := getCloudProvider(pd.plugin.host.GetCloudProvider())
if err != nil {
glog.Errorf("Photon Controller Util: DeleteVolume failed to get cloud provider. Error [%v]", err)
return err
}
if err = cloud.DeleteDisk(pd.pdID); err != nil {
glog.Errorf("Photon Controller Util: failed to DeleteDisk for pdID %s. Error [%v]", pd.pdID, err)
return err
}
glog.V(4).Infof("Successfully deleted PhotonController persistent disk %s", pd.pdID)
return nil
}
func getCloudProvider(cloud cloudprovider.Interface) (*photon.PCCloud, error) {
if cloud == nil {
glog.Errorf("Photon Controller Util: Cloud provider not initialized properly")
return nil, fmt.Errorf("Photon Controller Util: Cloud provider not initialized properly")
}
pcc := cloud.(*photon.PCCloud)
if pcc == nil {
glog.Errorf("Invalid cloud provider: expected Photon Controller")
return nil, fmt.Errorf("Invalid cloud provider: expected Photon Controller")
}
return pcc, nil
}
...@@ -574,6 +574,7 @@ k8s.io/kubernetes/pkg/cloudprovider/providers/gce,yifan-gu,1 ...@@ -574,6 +574,7 @@ k8s.io/kubernetes/pkg/cloudprovider/providers/gce,yifan-gu,1
k8s.io/kubernetes/pkg/cloudprovider/providers/mesos,mml,1 k8s.io/kubernetes/pkg/cloudprovider/providers/mesos,mml,1
k8s.io/kubernetes/pkg/cloudprovider/providers/openstack,Q-Lee,1 k8s.io/kubernetes/pkg/cloudprovider/providers/openstack,Q-Lee,1
k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt,girishkalele,1 k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt,girishkalele,1
k8s.io/kubernetes/pkg/cloudprovider/providers/photon,luomiao,0
k8s.io/kubernetes/pkg/cloudprovider/providers/rackspace,caesarxuchao,1 k8s.io/kubernetes/pkg/cloudprovider/providers/rackspace,caesarxuchao,1
k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere,apelisse,1 k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere,apelisse,1
k8s.io/kubernetes/pkg/controller,mikedanese,1 k8s.io/kubernetes/pkg/controller,mikedanese,1
...@@ -846,6 +847,7 @@ k8s.io/kubernetes/pkg/volume/glusterfs,timstclair,1 ...@@ -846,6 +847,7 @@ k8s.io/kubernetes/pkg/volume/glusterfs,timstclair,1
k8s.io/kubernetes/pkg/volume/host_path,jbeda,1 k8s.io/kubernetes/pkg/volume/host_path,jbeda,1
k8s.io/kubernetes/pkg/volume/iscsi,cjcullen,1 k8s.io/kubernetes/pkg/volume/iscsi,cjcullen,1
k8s.io/kubernetes/pkg/volume/nfs,justinsb,1 k8s.io/kubernetes/pkg/volume/nfs,justinsb,1
k8s.io/kubernetes/pkg/volume/photon_pd,luomiao,0
k8s.io/kubernetes/pkg/volume/quobyte,yujuhong,1 k8s.io/kubernetes/pkg/volume/quobyte,yujuhong,1
k8s.io/kubernetes/pkg/volume/rbd,piosz,1 k8s.io/kubernetes/pkg/volume/rbd,piosz,1
k8s.io/kubernetes/pkg/volume/secret,rmmh,1 k8s.io/kubernetes/pkg/volume/secret,rmmh,1
......
...@@ -11494,3 +11494,41 @@ go_library( ...@@ -11494,3 +11494,41 @@ go_library(
"//pkg/api/v1:go_default_library", "//pkg/api/v1:go_default_library",
], ],
) )
go_library(
name = "github.com/vmware/photon-controller-go-sdk/photon",
srcs = [
"github.com/vmware/photon-controller-go-sdk/photon/apitypes.go",
"github.com/vmware/photon-controller-go-sdk/photon/auth.go",
"github.com/vmware/photon-controller-go-sdk/photon/availabilityzones.go",
"github.com/vmware/photon-controller-go-sdk/photon/client.go",
"github.com/vmware/photon-controller-go-sdk/photon/clusters.go",
"github.com/vmware/photon-controller-go-sdk/photon/deployments.go",
"github.com/vmware/photon-controller-go-sdk/photon/disks.go",
"github.com/vmware/photon-controller-go-sdk/photon/flavors.go",
"github.com/vmware/photon-controller-go-sdk/photon/hosts.go",
"github.com/vmware/photon-controller-go-sdk/photon/images.go",
"github.com/vmware/photon-controller-go-sdk/photon/info.go",
"github.com/vmware/photon-controller-go-sdk/photon/networks.go",
"github.com/vmware/photon-controller-go-sdk/photon/projects.go",
"github.com/vmware/photon-controller-go-sdk/photon/resourcetickets.go",
"github.com/vmware/photon-controller-go-sdk/photon/restclient.go",
"github.com/vmware/photon-controller-go-sdk/photon/status.go",
"github.com/vmware/photon-controller-go-sdk/photon/tasks.go",
"github.com/vmware/photon-controller-go-sdk/photon/tenants.go",
"github.com/vmware/photon-controller-go-sdk/photon/util.go",
"github.com/vmware/photon-controller-go-sdk/photon/virtualnetworks.go",
"github.com/vmware/photon-controller-go-sdk/photon/vms.go",
],
tags = ["automanaged"],
deps = ["//vendor:github.com/vmware/photon-controller-go-sdk/photon/lightwave"],
)
go_library(
name = "github.com/vmware/photon-controller-go-sdk/photon/lightwave",
srcs = [
"github.com/vmware/photon-controller-go-sdk/photon/lightwave/jwttoken.go",
"github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient.go",
],
tags = ["automanaged"],
)
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
"fmt"
"github.com/vmware/photon-controller-go-sdk/photon/lightwave"
)
// Contains functionality for auth API.
type AuthAPI struct {
client *Client
}
const authUrl string = "/auth"
// Gets authentication info.
func (api *AuthAPI) Get() (info *AuthInfo, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+authUrl, "")
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
info = &AuthInfo{}
err = json.NewDecoder(res.Body).Decode(info)
return
}
// Gets Tokens from username/password.
func (api *AuthAPI) GetTokensByPassword(username string, password string) (tokenOptions *TokenOptions, err error) {
oidcClient, err := api.buildOIDCClient()
if err != nil {
return
}
tokenResponse, err := oidcClient.GetTokenByPasswordGrant(username, password)
if err != nil {
return
}
return api.toTokenOptions(tokenResponse), nil
}
// Gets tokens from refresh token.
func (api *AuthAPI) GetTokensByRefreshToken(refreshtoken string) (tokenOptions *TokenOptions, err error) {
oidcClient, err := api.buildOIDCClient()
if err != nil {
return
}
tokenResponse, err := oidcClient.GetTokenByRefreshTokenGrant(refreshtoken)
if err != nil {
return
}
return api.toTokenOptions(tokenResponse), nil
}
func (api *AuthAPI) getAuthEndpoint() (endpoint string, err error) {
authInfo, err := api.client.Auth.Get()
if err != nil {
return
}
if !authInfo.Enabled {
return "", SdkError{Message: "Authentication not enabled on this endpoint"}
}
if authInfo.Port == 0 {
authInfo.Port = 443
}
return fmt.Sprintf("https://%s:%d", authInfo.Endpoint, authInfo.Port), nil
}
func (api *AuthAPI) buildOIDCClient() (client *lightwave.OIDCClient, err error) {
authEndPoint, err := api.getAuthEndpoint()
if err != nil {
return
}
return lightwave.NewOIDCClient(
authEndPoint,
api.buildOIDCClientOptions(&api.client.options),
api.client.restClient.logger), nil
}
const tokenScope string = "openid offline_access rs_esxcloud at_groups"
func (api *AuthAPI) buildOIDCClientOptions(options *ClientOptions) *lightwave.OIDCClientOptions {
return &lightwave.OIDCClientOptions{
IgnoreCertificate: api.client.options.IgnoreCertificate,
RootCAs: api.client.options.RootCAs,
TokenScope: tokenScope,
}
}
func (api *AuthAPI) toTokenOptions(response *lightwave.OIDCTokenResponse) *TokenOptions {
return &TokenOptions{
AccessToken: response.AccessToken,
ExpiresIn: response.ExpiresIn,
RefreshToken: response.RefreshToken,
IdToken: response.IdToken,
TokenType: response.TokenType,
}
}
// Parse the given token details.
func (api *AuthAPI) parseTokenDetails(token string) (jwtToken *lightwave.JWTToken, err error) {
jwtToken = lightwave.ParseTokenDetails(token)
return jwtToken, nil
}
// Parse the given token raw details.
func (api *AuthAPI) parseRawTokenDetails(token string) (jwtToken []string, err error) {
jwtToken, err = lightwave.ParseRawTokenDetails(token)
return jwtToken, err
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for availability zones API.
type AvailabilityZonesAPI struct {
client *Client
}
var availabilityzoneUrl string = "/availabilityzones"
// Creates availability zone.
func (api *AvailabilityZonesAPI) Create(availabilityzoneSpec *AvailabilityZoneCreateSpec) (task *Task, err error) {
body, err := json.Marshal(availabilityzoneSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+availabilityzoneUrl,
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets availability zone with the specified ID.
func (api *AvailabilityZonesAPI) Get(id string) (availabilityzone *AvailabilityZone, err error) {
res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
availabilityzone = &AvailabilityZone{}
err = json.NewDecoder(res.Body).Decode(availabilityzone)
return
}
// Returns all availability zones on an photon instance.
func (api *AvailabilityZonesAPI) GetAll() (result *AvailabilityZones, err error) {
uri := api.client.Endpoint + availabilityzoneUrl
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &AvailabilityZones{}
err = json.Unmarshal(res, result)
return
}
// Deletes the availability zone with specified ID.
func (api *AvailabilityZonesAPI) Delete(id string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+availabilityzoneUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets all tasks with the specified availability zone ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *AvailabilityZonesAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + availabilityzoneUrl + "/" + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
func (api *AvailabilityZonesAPI) getEntityUrl(id string) (url string) {
return api.client.Endpoint + availabilityzoneUrl + "/" + id
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
)
// Represents stateless context needed to call photon APIs.
type Client struct {
options ClientOptions
restClient *restClient
logger *log.Logger
Endpoint string
Status *StatusAPI
Tenants *TenantsAPI
Tasks *TasksAPI
Projects *ProjectsAPI
Flavors *FlavorsAPI
Images *ImagesAPI
Disks *DisksAPI
VMs *VmAPI
Hosts *HostsAPI
Deployments *DeploymentsAPI
ResourceTickets *ResourceTicketsAPI
Subnets *SubnetsAPI
VirtualSubnets *VirtualSubnetsAPI
Clusters *ClustersAPI
Auth *AuthAPI
AvailabilityZones *AvailabilityZonesAPI
Info *InfoAPI
}
// Represents Tokens
type TokenOptions struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token,omitempty"`
IdToken string `json:"id_token"`
TokenType string `json:"token_type"`
}
// Options for Client
type ClientOptions struct {
// When using the Tasks.Wait APIs, defines the duration of how long
// the SDK should continue to poll the server. Default is 30 minutes.
// TasksAPI.WaitTimeout() can be used to specify timeout on
// individual calls.
TaskPollTimeout time.Duration
// Whether or not to ignore any TLS errors when talking to photon,
// false by default.
IgnoreCertificate bool
// List of root CA's to use for server validation
// nil by default.
RootCAs *x509.CertPool
// For tasks APIs, defines the delay between each polling attempt.
// Default is 100 milliseconds.
TaskPollDelay time.Duration
// For tasks APIs, defines the number of retries to make in the event
// of an error. Default is 3.
TaskRetryCount int
// Tokens for user authentication. Default is empty.
TokenOptions *TokenOptions
}
// Creates a new photon client with specified options. If options
// is nil, default options will be used.
func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c *Client) {
defaultOptions := &ClientOptions{
TaskPollTimeout: 30 * time.Minute,
TaskPollDelay: 100 * time.Millisecond,
TaskRetryCount: 3,
TokenOptions: &TokenOptions{},
IgnoreCertificate: false,
RootCAs: nil,
}
if options != nil {
if options.TaskPollTimeout != 0 {
defaultOptions.TaskPollTimeout = options.TaskPollTimeout
}
if options.TaskPollDelay != 0 {
defaultOptions.TaskPollDelay = options.TaskPollDelay
}
if options.TaskRetryCount != 0 {
defaultOptions.TaskRetryCount = options.TaskRetryCount
}
if options.TokenOptions != nil {
defaultOptions.TokenOptions = options.TokenOptions
}
if options.RootCAs != nil {
defaultOptions.RootCAs = options.RootCAs
}
defaultOptions.IgnoreCertificate = options.IgnoreCertificate
}
if logger == nil {
logger = createPassThroughLogger()
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: defaultOptions.IgnoreCertificate,
RootCAs: defaultOptions.RootCAs},
}
endpoint = strings.TrimRight(endpoint, "/")
restClient := &restClient{
httpClient: &http.Client{Transport: tr},
logger: logger,
}
c = &Client{Endpoint: endpoint, restClient: restClient, logger: logger}
// Ensure a copy of options is made, rather than using a pointer
// which may change out from underneath if misused by the caller.
c.options = *defaultOptions
c.Status = &StatusAPI{c}
c.Tenants = &TenantsAPI{c}
c.Tasks = &TasksAPI{c}
c.Projects = &ProjectsAPI{c}
c.Flavors = &FlavorsAPI{c}
c.Images = &ImagesAPI{c}
c.Disks = &DisksAPI{c}
c.VMs = &VmAPI{c}
c.Hosts = &HostsAPI{c}
c.Deployments = &DeploymentsAPI{c}
c.ResourceTickets = &ResourceTicketsAPI{c}
c.Subnets = &SubnetsAPI{c}
c.VirtualSubnets = &VirtualSubnetsAPI{c}
c.Clusters = &ClustersAPI{c}
c.Auth = &AuthAPI{c}
c.AvailabilityZones = &AvailabilityZonesAPI{c}
c.Info = &InfoAPI{c}
return
}
// Creates a new photon client with specified options and http.Client.
// Useful for functional testing where http calls must be mocked out.
// If options is nil, default options will be used.
func NewTestClient(endpoint string, options *ClientOptions, httpClient *http.Client) (c *Client) {
c = NewClient(endpoint, options, nil)
c.restClient.httpClient = httpClient
return
}
func createPassThroughLogger() (l *log.Logger) {
// ioutil.Discard makes all logging operation be a no-op.
return log.New(ioutil.Discard, "", log.LstdFlags)
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for clusters API.
type ClustersAPI struct {
client *Client
}
var clusterUrl string = "/clusters/"
const ExtendedPropertyDNS string = "dns"
const ExtendedPropertyGateway string = "gateway"
const ExtendedPropertyNetMask string = "netmask"
const ExtendedPropertyMasterIP string = "master_ip"
const ExtendedPropertyContainerNetwork string = "container_network"
const ExtendedPropertyZookeeperIP1 string = "zookeeper_ip1"
const ExtendedPropertyZookeeperIP2 string = "zookeeper_ip2"
const ExtendedPropertyZookeeperIP3 string = "zookeeper_ip3"
const ExtendedPropertyETCDIP1 string = "etcd_ip1"
const ExtendedPropertyETCDIP2 string = "etcd_ip2"
const ExtendedPropertyETCDIP3 string = "etcd_ip3"
const ExtendedPropertySSHKey string = "ssh_key"
const ExtendedPropertyRegistryCACert string = "registry_ca_cert"
const ExtendedPropertyAdminPassword string = "admin_password"
// Deletes a cluster with specified ID.
func (api *ClustersAPI) Delete(id string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+clusterUrl+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets a cluster with the specified ID.
func (api *ClustersAPI) Get(id string) (cluster *Cluster, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+clusterUrl+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
var result Cluster
err = json.NewDecoder(res.Body).Decode(&result)
return &result, nil
}
// Gets vms for cluster with the specified ID.
func (api *ClustersAPI) GetVMs(id string) (result *VMs, err error) {
uri := api.client.Endpoint + clusterUrl + id + "/vms"
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &VMs{}
err = json.Unmarshal(res, result)
return
}
// Resize a cluster to specified count.
func (api *ClustersAPI) Resize(id string, resize *ClusterResizeOperation) (task *Task, err error) {
body, err := json.Marshal(resize)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+clusterUrl+id+"/resize",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Start a background process to recreate failed VMs in a cluster with the specified ID.
func (api *ClustersAPI) TriggerMaintenance(id string) (task *Task, err error) {
body := []byte{}
res, err := api.client.restClient.Post(
api.client.Endpoint+clusterUrl+id+"/trigger_maintenance",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for deployments API.
type DeploymentsAPI struct {
client *Client
}
var deploymentUrl string = "/deployments"
// Creates a deployment
func (api *DeploymentsAPI) Create(deploymentSpec *DeploymentCreateSpec) (task *Task, err error) {
body, err := json.Marshal(deploymentSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+deploymentUrl,
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Deletes a deployment with specified ID.
func (api *DeploymentsAPI) Delete(id string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.getEntityUrl(id), api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Deploys a deployment with specified ID.
func (api *DeploymentsAPI) Deploy(id string, config *DeploymentDeployOperation) (task *Task, err error) {
body, err := json.Marshal(config)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/deploy",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Destroys a deployment with specified ID.
func (api *DeploymentsAPI) Destroy(id string) (task *Task, err error) {
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/destroy",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Returns all deployments.
func (api *DeploymentsAPI) GetAll() (result *Deployments, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+deploymentUrl, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
result = &Deployments{}
err = json.NewDecoder(res.Body).Decode(result)
return
}
// Gets a deployment with the specified ID.
func (api *DeploymentsAPI) Get(id string) (deployment *Deployment, err error) {
res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
var result Deployment
err = json.NewDecoder(res.Body).Decode(&result)
return &result, nil
}
// Gets all hosts with the specified deployment ID.
func (api *DeploymentsAPI) GetHosts(id string) (result *Hosts, err error) {
uri := api.getEntityUrl(id) + "/hosts"
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &Hosts{}
err = json.Unmarshal(res, result)
return
}
// Gets all the vms with the specified deployment ID.
func (api *DeploymentsAPI) GetVms(id string) (result *VMs, err error) {
uri := api.getEntityUrl(id) + "/vms"
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &VMs{}
err = json.Unmarshal(res, result)
return
}
// Initialize deployment migration from source to destination
func (api *DeploymentsAPI) InitializeDeploymentMigration(sourceAddress *InitializeMigrationOperation, id string) (task *Task, err error) {
body, err := json.Marshal(sourceAddress)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/initialize_migration",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Finalize deployment migration from source to destination
func (api *DeploymentsAPI) FinalizeDeploymentMigration(sourceAddress *FinalizeMigrationOperation, id string) (task *Task, err error) {
body, err := json.Marshal(sourceAddress)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/finalize_migration",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
func (api *DeploymentsAPI) SetSecurityGroups(id string, securityGroups *SecurityGroupsSpec) (*Task, error) {
return setSecurityGroups(api.client, api.getEntityUrl(id), securityGroups)
}
// Update image datastores of a deployment.
func (api *DeploymentsAPI) SetImageDatastores(id string, imageDatastores *ImageDatastores) (task *Task, err error) {
body, err := json.Marshal(imageDatastores)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/set_image_datastores",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Pause system with specified deployment ID.
func (api *DeploymentsAPI) PauseSystem(id string) (task *Task, err error) {
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/pause_system",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Pause background tasks of system with specified deployment ID.
func (api *DeploymentsAPI) PauseBackgroundTasks(id string) (task *Task, err error) {
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/pause_background_tasks",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Pause background tasks of system with specified deployment ID.
func (api *DeploymentsAPI) ResumeSystem(id string) (task *Task, err error) {
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/resume_system",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Enable cluster type with specified deployment ID.
func (api *DeploymentsAPI) EnableClusterType(id string, clusterConfigSpec *ClusterConfigurationSpec) (task *Task, err error) {
body, err := json.Marshal(clusterConfigSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/enable_cluster_type",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Disable cluster type with specified deployment ID.
func (api *DeploymentsAPI) DisableClusterType(id string, clusterConfigSpec *ClusterConfigurationSpec) (task *Task, err error) {
body, err := json.Marshal(clusterConfigSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.getEntityUrl(id)+"/disable_cluster_type",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
func (api *DeploymentsAPI) getEntityUrl(id string) (url string) {
return api.client.Endpoint + deploymentUrl + "/" + id
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
)
// Contains functionality for disks API.
type DisksAPI struct {
client *Client
}
var diskUrl string = "/disks/"
// Gets a PersistentDisk for the disk with specified ID.
func (api *DisksAPI) Get(diskID string) (disk *PersistentDisk, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
disk = &PersistentDisk{}
err = json.NewDecoder(res.Body).Decode(disk)
return
}
// Deletes a disk with the specified ID.
func (api *DisksAPI) Delete(diskID string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets all tasks with the specified disk ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *DisksAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + diskUrl + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for flavors API.
type FlavorsAPI struct {
client *Client
}
// Options used for find/get APIs
type FlavorGetOptions struct {
Name string `urlParam:"name"`
Kind string `urlParam:"kind"`
}
var flavorUrl string = "/flavors"
// Creates a flavor.
func (api *FlavorsAPI) Create(spec *FlavorCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+flavorUrl,
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets details of flavor with specified ID.
func (api *FlavorsAPI) Get(flavorID string) (flavor *Flavor, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+flavorUrl+"/"+flavorID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
flavor = &Flavor{}
err = json.NewDecoder(res.Body).Decode(flavor)
return
}
// Gets flavors using options to filter results. Returns all flavors if options is nil.
func (api *FlavorsAPI) GetAll(options *FlavorGetOptions) (flavors *FlavorList, err error) {
uri := api.client.Endpoint + flavorUrl
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
flavors = &FlavorList{}
err = json.Unmarshal(res, flavors)
return
}
// Deletes flavor with specified ID.
func (api *FlavorsAPI) Delete(flavorID string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+flavorUrl+"/"+flavorID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets all tasks with the specified flavor ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *FlavorsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + flavorUrl + "/" + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for hosts API.
type HostsAPI struct {
client *Client
}
var hostUrl string = "/hosts"
// Creates a host.
func (api *HostsAPI) Create(hostSpec *HostCreateSpec, deploymentId string) (task *Task, err error) {
body, err := json.Marshal(hostSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+deploymentUrl+"/"+deploymentId+hostUrl,
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Deletes a host with specified ID.
func (api *HostsAPI) Delete(id string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+hostUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Returns all hosts
func (api *HostsAPI) GetAll() (result *Hosts, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
result = &Hosts{}
err = json.NewDecoder(res.Body).Decode(result)
return
}
// Gets a host with the specified ID.
func (api *HostsAPI) Get(id string) (host *Host, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
var result Host
err = json.NewDecoder(res.Body).Decode(&result)
return &result, nil
}
// Sets host's availability zone.
func (api *HostsAPI) SetAvailabilityZone(id string, availabilityZone *HostSetAvailabilityZoneOperation) (task *Task, err error) {
body, err := json.Marshal(availabilityZone)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+hostUrl+"/"+id+"/set_availability_zone",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets all tasks with the specified host ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *HostsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + hostUrl + "/" + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Gets all the vms with the specified deployment ID.
func (api *HostsAPI) GetVMs(id string) (result *VMs, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl+"/"+id+"/vms", api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
result = &VMs{}
err = json.NewDecoder(res.Body).Decode(result)
return
}
// Suspend the host with the specified id
func (api *HostsAPI) Suspend(id string) (task *Task, err error) {
body := []byte{}
res, err := api.client.restClient.Post(
api.client.Endpoint+hostUrl+"/"+id+"/suspend",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Resume the host with the specified id
func (api *HostsAPI) Resume(id string) (task *Task, err error) {
body := []byte{}
res, err := api.client.restClient.Post(
api.client.Endpoint+hostUrl+"/"+id+"/resume",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Host with the specified id enter maintenance mode
func (api *HostsAPI) EnterMaintenanceMode(id string) (task *Task, err error) {
body := []byte{}
res, err := api.client.restClient.Post(
api.client.Endpoint+hostUrl+"/"+id+"/enter_maintenance",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Host with the specified id exit maintenance mode
func (api *HostsAPI) ExitMaintenanceMode(id string) (task *Task, err error) {
body := []byte{}
res, err := api.client.restClient.Post(
api.client.Endpoint+hostUrl+"/"+id+"/exit_maintenance",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
"io"
)
// Contains functionality for images API.
type ImagesAPI struct {
client *Client
}
// Options for GetImage API.
type ImageGetOptions struct {
Name string `urlParam:"name"`
}
var imageUrl string = "/images"
// Uploads a new image, reading from the specified image path.
// If options is nil, default options are used.
func (api *ImagesAPI) CreateFromFile(imagePath string, options *ImageCreateOptions) (task *Task, err error) {
params := imageCreateOptionsToMap(options)
res, err := api.client.restClient.MultipartUploadFile(api.client.Endpoint+imageUrl, imagePath, params, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
result, err := getTask(getError(res))
return result, err
}
// Uploads a new image, reading from the specified io.Reader.
// Name is a descriptive name of the image, it is used in the filename field of the Content-Disposition header,
// and does not need to be unique.
// If options is nil, default options are used.
func (api *ImagesAPI) Create(reader io.Reader, name string, options *ImageCreateOptions) (task *Task, err error) {
params := imageCreateOptionsToMap(options)
res, err := api.client.restClient.MultipartUpload(api.client.Endpoint+imageUrl, reader, name, params, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
result, err := getTask(getError(res))
return result, err
}
// Gets all images on this photon instance.
func (api *ImagesAPI) GetAll(options *ImageGetOptions) (images *Images, err error) {
uri := api.client.Endpoint + imageUrl
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
images = &Images{}
err = json.Unmarshal(res, images)
return
}
// Gets details of image with the specified ID.
func (api *ImagesAPI) Get(imageID string) (image *Image, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+imageUrl+"/"+imageID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
var result Image
err = json.NewDecoder(res.Body).Decode(&result)
return &result, nil
}
// Deletes image with the specified ID.
func (api *ImagesAPI) Delete(imageID string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+imageUrl+"/"+imageID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
result, err := getTask(getError(res))
return result, err
}
// Gets all tasks with the specified image ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *ImagesAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + imageUrl + "/" + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
func imageCreateOptionsToMap(opts *ImageCreateOptions) map[string]string {
if opts == nil {
return nil
}
return map[string]string{
"ImageReplication": opts.ReplicationType,
}
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
)
type InfoAPI struct {
client *Client
}
var infoUrl = "/info"
// Get info
func (api *InfoAPI) Get() (info *Info, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+infoUrl, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
info = new(Info)
err = json.NewDecoder(res.Body).Decode(info)
return
}
package lightwave
import (
"encoding/base64"
"encoding/json"
"strings"
)
type JWTToken struct {
TokenId string `json:"jti"`
Algorithm string `json:"alg"`
Subject string `json:"sub"`
Audience []string `json:"aud"`
Groups []string `json:"groups"`
Issuer string `json:"iss"`
IssuedAt int64 `json:"iat"`
Expires int64 `json:"exp"`
Scope string `json:"scope"`
TokenType string `json:"token_type"`
TokenClass string `json:"token_class"`
Tenant string `json:"tenant"`
// It's possible to have more fields depending on how Lightwave defines the token.
// This covers all the fields we currently have.
}
// A JSON web token is a set of Base64 encoded strings separated by a period (.)
// When decoded, it will either be JSON text or a signature
// Here we decode the strings into a single token structure. We do not parse the signature.
func ParseTokenDetails(token string) (jwtToken *JWTToken) {
jwtToken = &JWTToken{}
chunks := strings.Split(token, ".")
for _, chunk := range chunks {
json_string, err := base64.RawURLEncoding.DecodeString(chunk)
if err == nil {
// Ignore errors. We expect that the signature is not JSON,
// so unmarshalling it will fail. That's fine. We'll extract
// all the data we can.
_ = json.Unmarshal(json_string, &jwtToken)
}
}
return jwtToken
}
// A JSON web token is a set of Base64 encoded strings separated by a period (.)
// When decoded, it will either be JSON text or a signature
// Here we parse the full JSON text. We do not parse the signature.
func ParseRawTokenDetails(token string) (jwtToken []string, err error) {
chunks := strings.Split(token, ".")
for _, chunk := range chunks {
jsonString, err := base64.RawURLEncoding.DecodeString(chunk)
if err == nil {
jwtToken = append(jwtToken, string(jsonString))
}
}
return jwtToken, err
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package lightwave
import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
const tokenScope string = "openid offline_access"
type OIDCClient struct {
httpClient *http.Client
logger *log.Logger
Endpoint string
Options *OIDCClientOptions
}
type OIDCClientOptions struct {
// Whether or not to ignore any TLS errors when talking to photon,
// false by default.
IgnoreCertificate bool
// List of root CA's to use for server validation
// nil by default.
RootCAs *x509.CertPool
// The scope values to use when requesting tokens
TokenScope string
}
func NewOIDCClient(endpoint string, options *OIDCClientOptions, logger *log.Logger) (c *OIDCClient) {
if logger == nil {
logger = log.New(ioutil.Discard, "", log.LstdFlags)
}
options = buildOptions(options)
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: options.IgnoreCertificate,
RootCAs: options.RootCAs},
}
c = &OIDCClient{
httpClient: &http.Client{Transport: tr},
logger: logger,
Endpoint: strings.TrimRight(endpoint, "/"),
Options: options,
}
return
}
func buildOptions(options *OIDCClientOptions) (result *OIDCClientOptions) {
result = &OIDCClientOptions{
TokenScope: tokenScope,
}
if options == nil {
return
}
result.IgnoreCertificate = options.IgnoreCertificate
if options.RootCAs != nil {
result.RootCAs = options.RootCAs
}
if options.TokenScope != "" {
result.TokenScope = options.TokenScope
}
return
}
func (client *OIDCClient) buildUrl(path string) (url string) {
return fmt.Sprintf("%s%s", client.Endpoint, path)
}
// Cert download helper
const certDownloadPath string = "/afd/vecs/ssl"
type lightWaveCert struct {
Value string `json:"encoded"`
}
func (client *OIDCClient) GetRootCerts() (certList []*x509.Certificate, err error) {
// turn TLS verification off for
originalTr := client.httpClient.Transport
defer client.setTransport(originalTr)
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
client.setTransport(tr)
// get the certs
resp, err := client.httpClient.Get(client.buildUrl(certDownloadPath))
if err != nil {
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
err = fmt.Errorf("Unexpected error retrieving auth server certs: %v %s", resp.StatusCode, resp.Status)
return
}
// parse the certs
certsData := &[]lightWaveCert{}
err = json.NewDecoder(resp.Body).Decode(certsData)
if err != nil {
return
}
certList = make([]*x509.Certificate, len(*certsData))
for idx, cert := range *certsData {
block, _ := pem.Decode([]byte(cert.Value))
if block == nil {
err = fmt.Errorf("Unexpected response format: %v", certsData)
return nil, err
}
decodedCert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, err
}
certList[idx] = decodedCert
}
return
}
func (client *OIDCClient) setTransport(tr http.RoundTripper) {
client.httpClient.Transport = tr
}
// Toke request helpers
const tokenPath string = "/openidconnect/token"
const passwordGrantFormatString = "grant_type=password&username=%s&password=%s&scope=%s"
const refreshTokenGrantFormatString = "grant_type=refresh_token&refresh_token=%s"
type OIDCTokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token,omitempty"`
IdToken string `json:"id_token"`
TokenType string `json:"token_type"`
}
func (client *OIDCClient) GetTokenByPasswordGrant(username string, password string) (tokens *OIDCTokenResponse, err error) {
body := fmt.Sprintf(passwordGrantFormatString, username, password, client.Options.TokenScope)
return client.getToken(body)
}
func (client *OIDCClient) GetTokenByRefreshTokenGrant(refreshToken string) (tokens *OIDCTokenResponse, err error) {
body := fmt.Sprintf(refreshTokenGrantFormatString, refreshToken)
return client.getToken(body)
}
func (client *OIDCClient) getToken(body string) (tokens *OIDCTokenResponse, err error) {
request, err := http.NewRequest("POST", client.buildUrl(tokenPath), strings.NewReader(body))
if err != nil {
return nil, err
}
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.httpClient.Do(request)
if err != nil {
return nil, err
}
defer resp.Body.Close()
err = client.checkResponse(resp)
if err != nil {
return nil, err
}
tokens = &OIDCTokenResponse{}
err = json.NewDecoder(resp.Body).Decode(tokens)
if err != nil {
return nil, err
}
return
}
type OIDCError struct {
Code string `json:"error"`
Message string `json:"error_description"`
}
func (e OIDCError) Error() string {
return fmt.Sprintf("%v: %v", e.Code, e.Message)
}
func (client *OIDCClient) checkResponse(response *http.Response) (err error) {
if response.StatusCode/100 == 2 {
return
}
respBody, readErr := ioutil.ReadAll(response.Body)
if err != nil {
return fmt.Errorf(
"Status: %v, Body: %v [%v]", response.Status, string(respBody[:]), readErr)
}
var oidcErr OIDCError
err = json.Unmarshal(respBody, &oidcErr)
if err != nil {
return fmt.Errorf(
"Status: %v, Body: %v [%v]", response.Status, string(respBody[:]), readErr)
}
return oidcErr
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for networks API.
type SubnetsAPI struct {
client *Client
}
// Options used for GetAll API
type SubnetGetOptions struct {
Name string `urlParam:"name"`
}
var subnetUrl string = "/subnets"
// Creates a network.
func (api *SubnetsAPI) Create(networkSpec *SubnetCreateSpec) (task *Task, err error) {
body, err := json.Marshal(networkSpec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+subnetUrl,
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Deletes a network with specified ID.
func (api *SubnetsAPI) Delete(id string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+subnetUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets a network with the specified ID.
func (api *SubnetsAPI) Get(id string) (network *Subnet, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+subnetUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
var result Subnet
err = json.NewDecoder(res.Body).Decode(&result)
return &result, nil
}
// Returns all networks
func (api *SubnetsAPI) GetAll(options *SubnetGetOptions) (result *Subnets, err error) {
uri := api.client.Endpoint + subnetUrl
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
result = &Subnets{}
err = json.Unmarshal(res, result)
return
}
// Sets default network.
func (api *SubnetsAPI) SetDefault(id string) (task *Task, err error) {
res, err := api.client.restClient.Post(
api.client.Endpoint+subnetUrl+"/"+id+"/set_default",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"bytes"
"encoding/json"
)
// Contains functionality for projects API.
type ProjectsAPI struct {
client *Client
}
// Options for GetDisks API.
type DiskGetOptions struct {
Name string `urlParam:"name"`
}
// Options for GetDisks API.
type VmGetOptions struct {
Name string `urlParam:"name"`
}
var projectUrl string = "/projects/"
// Deletes the project with specified ID. Any VMs, disks, etc., owned by the project must be deleted first.
func (api *ProjectsAPI) Delete(projectID string) (task *Task, err error) {
res, err := api.client.restClient.Delete(api.client.Endpoint+projectUrl+projectID, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Creates a disk on the specified project.
func (api *ProjectsAPI) CreateDisk(projectID string, spec *DiskCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+projectUrl+projectID+"/disks",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets disks for project with the specified ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *ProjectsAPI) GetDisks(projectID string, options *DiskGetOptions) (result *DiskList, err error) {
uri := api.client.Endpoint + projectUrl + projectID + "/disks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &DiskList{}
err = json.Unmarshal(res, result)
return
}
// Creates a VM on the specified project.
func (api *ProjectsAPI) CreateVM(projectID string, spec *VmCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+projectUrl+projectID+"/vms",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets all tasks with the specified project ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *ProjectsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + projectUrl + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Gets vms for project with the specified ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *ProjectsAPI) GetVMs(projectID string, options *VmGetOptions) (result *VMs, err error) {
uri := api.client.Endpoint + projectUrl + projectID + "/vms"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &VMs{}
err = json.Unmarshal(res, result)
return
}
// Creates a cluster on the specified project.
func (api *ProjectsAPI) CreateCluster(projectID string, spec *ClusterCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := api.client.restClient.Post(
api.client.Endpoint+projectUrl+projectID+"/clusters",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
// Gets clusters for project with the specified ID
func (api *ProjectsAPI) GetClusters(projectID string) (result *Clusters, err error) {
uri := api.client.Endpoint + projectUrl + projectID + "/clusters"
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &Clusters{}
err = json.Unmarshal(res, result)
return
}
// Gets the project with a specified ID.
func (api *ProjectsAPI) Get(id string) (project *ProjectCompact, err error) {
res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
project = &ProjectCompact{}
err = json.NewDecoder(res.Body).Decode(project)
return
}
// Set security groups for this project, overwriting any existing ones.
func (api *ProjectsAPI) SetSecurityGroups(projectID string, securityGroups *SecurityGroupsSpec) (*Task, error) {
return setSecurityGroups(api.client, api.getEntityUrl(projectID), securityGroups)
}
func (api *ProjectsAPI) getEntityUrl(id string) string {
return api.client.Endpoint + projectUrl + id
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
)
// Contains functionality for hosts API.
type ResourceTicketsAPI struct {
client *Client
}
var resourceTicketUrl string = "/resource-tickets/"
// Gets all tasks with the specified resource ticket ID, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *ResourceTicketsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + resourceTicketUrl + id + "/tasks"
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Gets the resource ticket with a specified ID.
func (api *ResourceTicketsAPI) Get(id string) (resourceTicket *ResourceTicket, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+resourceTicketUrl+"/"+id,
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
resourceTicket = &ResourceTicket{}
err = json.NewDecoder(res.Body).Decode(resourceTicket)
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"crypto/rand"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)
type restClient struct {
httpClient *http.Client
logger *log.Logger
}
type request struct {
Method string
URL string
ContentType string
Body io.Reader
Token string
}
type page struct {
Items []interface{} `json:"items"`
NextPageLink string `json:"nextPageLink"`
PreviousPageLink string `json:"previousPageLink"`
}
type documentList struct {
Items []interface{}
}
const appJson string = "application/json"
// From https://golang.org/src/mime/multipart/writer.go
var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
func (client *restClient) AppendSlice(origSlice []interface{}, dataToAppend []interface{}) []interface{} {
origLen := len(origSlice)
newLen := origLen + len(dataToAppend)
if newLen > cap(origSlice) {
newSlice := make([]interface{}, (newLen+1)*2)
copy(newSlice, origSlice)
origSlice = newSlice
}
origSlice = origSlice[0:newLen]
copy(origSlice[origLen:newLen], dataToAppend)
return origSlice
}
func (client *restClient) Get(url string, token string) (res *http.Response, err error) {
req := request{"GET", url, "", nil, token}
res, err = client.Do(&req)
return
}
func (client *restClient) GetList(endpoint string, url string, token string) (result []byte, err error) {
req := request{"GET", url, "", nil, token}
res, err := client.Do(&req)
if err != nil {
return
}
res, err = getError(res)
if err != nil {
return
}
decoder := json.NewDecoder(res.Body)
decoder.UseNumber()
page := &page{}
err = decoder.Decode(page)
if err != nil {
return
}
documentList := &documentList{}
documentList.Items = client.AppendSlice(documentList.Items, page.Items)
for page.NextPageLink != "" {
req = request{"GET", endpoint + page.NextPageLink, "", nil, token}
res, err = client.Do(&req)
if err != nil {
return
}
res, err = getError(res)
if err != nil {
return
}
decoder = json.NewDecoder(res.Body)
decoder.UseNumber()
page.NextPageLink = ""
page.PreviousPageLink = ""
err = decoder.Decode(page)
if err != nil {
return
}
documentList.Items = client.AppendSlice(documentList.Items, page.Items)
}
result, err = json.Marshal(documentList)
return
}
func (client *restClient) Post(url string, contentType string, body io.Reader, token string) (res *http.Response, err error) {
if contentType == "" {
contentType = appJson
}
req := request{"POST", url, contentType, body, token}
res, err = client.Do(&req)
return
}
func (client *restClient) Delete(url string, token string) (res *http.Response, err error) {
req := request{"DELETE", url, "", nil, token}
res, err = client.Do(&req)
return
}
func (client *restClient) Do(req *request) (res *http.Response, err error) {
r, err := http.NewRequest(req.Method, req.URL, req.Body)
if err != nil {
client.logger.Printf("An error occured creating request %s on %s. Error: %s", req.Method, req.URL, err)
return
}
if req.ContentType != "" {
r.Header.Add("Content-Type", req.ContentType)
}
if req.Token != "" {
r.Header.Add("Authorization", "Bearer "+req.Token)
}
res, err = client.httpClient.Do(r)
if err != nil {
client.logger.Printf("An error occured when calling %s on %s. Error: %s", req.Method, req.URL, err)
return
}
client.logger.Printf("[%s] %s - %s %s", res.Header.Get("request-id"), res.Status, req.Method, req.URL)
return
}
func (client *restClient) MultipartUploadFile(url, filePath string, params map[string]string, token string) (res *http.Response, err error) {
file, err := os.Open(filePath)
if err != nil {
return
}
defer file.Close()
return client.MultipartUpload(url, file, filepath.Base(filePath), params, token)
}
func (client *restClient) MultipartUpload(url string, reader io.Reader, filename string, params map[string]string, token string) (res *http.Response, err error) {
// The mime/multipart package does not support streaming multipart data from disk,
// at least not without complicated, problematic goroutines that simultaneously read/write into a buffer.
// A much easier approach is to just construct the multipart request by hand, using io.MultiPart to
// concatenate the parts of the request together into a single io.Reader.
boundary := client.randomBoundary()
parts := []io.Reader{}
// Create a part for each key, val pair in params
for k, v := range params {
parts = append(parts, client.createFieldPart(k, v, boundary))
}
start := fmt.Sprintf("\r\n--%s\r\n", boundary)
start += fmt.Sprintf("Content-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n", quoteEscaper.Replace(filename))
start += fmt.Sprintf("Content-Type: application/octet-stream\r\n\r\n")
end := fmt.Sprintf("\r\n--%s--", boundary)
// The request will consist of a reader to begin the request, a reader which points
// to the file data on disk, and a reader containing the closing boundary of the request.
parts = append(parts, strings.NewReader(start), reader, strings.NewReader(end))
contentType := fmt.Sprintf("multipart/form-data; boundary=%s", boundary)
res, err = client.Do(&request{"POST", url, contentType, io.MultiReader(parts...), token})
return
}
// From https://golang.org/src/mime/multipart/writer.go
func (client *restClient) randomBoundary() string {
var buf [30]byte
_, err := io.ReadFull(rand.Reader, buf[:])
if err != nil {
panic(err)
}
return fmt.Sprintf("%x", buf[:])
}
// Creates a reader that encapsulates a single multipart form part
func (client *restClient) createFieldPart(fieldname, value, boundary string) io.Reader {
str := fmt.Sprintf("\r\n--%s\r\n", boundary)
str += fmt.Sprintf("Content-Disposition: form-data; name=\"%s\"\r\n\r\n", quoteEscaper.Replace(fieldname))
str += value
return strings.NewReader(str)
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
)
// Contains functionality for status API.
type StatusAPI struct {
client *Client
}
var statusUrl string = "/status"
// Returns the status of an photon endpoint.
func (api *StatusAPI) Get() (status *Status, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+statusUrl, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
status = &Status{}
err = json.NewDecoder(res.Body).Decode(status)
return
}
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"encoding/json"
"time"
)
// Contains functionality for tasks API.
type TasksAPI struct {
client *Client
}
var taskUrl string = "/tasks"
// Gets a task by ID.
func (api *TasksAPI) Get(id string) (task *Task, err error) {
res, err := api.client.restClient.Get(api.client.Endpoint+taskUrl+"/"+id, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
result, err := getTask(getError(res))
return result, err
}
// Gets all tasks, using options to filter the results.
// If options is nil, no filtering will occur.
func (api *TasksAPI) GetAll(options *TaskGetOptions) (result *TaskList, err error) {
uri := api.client.Endpoint + taskUrl
if options != nil {
uri += getQueryString(options)
}
res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
result = &TaskList{}
err = json.Unmarshal(res, result)
return
}
// Waits for a task to complete by polling the tasks API until a task returns with
// the state COMPLETED or ERROR. Will wait no longer than the duration specified by timeout.
func (api *TasksAPI) WaitTimeout(id string, timeout time.Duration) (task *Task, err error) {
start := time.Now()
numErrors := 0
maxErrors := api.client.options.TaskRetryCount
for time.Since(start) < timeout {
task, err = api.Get(id)
if err != nil {
switch err.(type) {
// If an ApiError comes back, something is wrong, return the error to the caller
case ApiError:
return
// For other errors, retry before giving up
default:
numErrors++
if numErrors > maxErrors {
return
}
}
} else {
// Reset the error count any time a successful call is made
numErrors = 0
if task.State == "COMPLETED" {
return
}
if task.State == "ERROR" {
err = TaskError{task.ID, getFailedStep(task)}
return
}
}
time.Sleep(api.client.options.TaskPollDelay)
}
err = TaskTimeoutError{id}
return
}
// Waits for a task to complete by polling the tasks API until a task returns with
// the state COMPLETED or ERROR.
func (api *TasksAPI) Wait(id string) (task *Task, err error) {
return api.WaitTimeout(id, api.client.options.TaskPollTimeout)
}
// Gets the failed step in the task to get error details for failed task.
func getFailedStep(task *Task) (step Step) {
var errorStep Step
for _, s := range task.Steps {
if s.State == "ERROR" {
errorStep = s
break
}
}
return errorStep
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment